@prisma-next/sql-builder 0.11.0-dev.6 → 0.11.0-dev.61
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/{db-Tp8O0y-a.d.mts → db-CkP-ZJTr.d.mts} +4 -3
- package/dist/db-CkP-ZJTr.d.mts.map +1 -0
- package/dist/exports/types.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/runtime/index.d.mts +5 -4
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +28 -27
- package/dist/runtime/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/expression.ts +4 -1
- package/src/runtime/builder-base.ts +11 -6
- package/src/runtime/functions.ts +11 -6
- package/src/runtime/joined-tables-impl.ts +1 -1
- package/src/runtime/mutation-impl.ts +6 -4
- package/src/runtime/query-impl.ts +5 -2
- package/src/runtime/sql.ts +4 -1
- package/src/runtime/table-proxy-impl.ts +2 -1
- package/src/types/table-proxy.ts +2 -2
- package/dist/db-Tp8O0y-a.d.mts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyFromSource, SelectAst } from "@prisma-next/sql-relational-core/ast";
|
|
2
|
-
import { CodecExpression, CodecTypesBase, Expression as Expression$1, ScopeField, TraitExpression } from "@prisma-next/sql-relational-core/expression";
|
|
2
|
+
import { CodecExpression, CodecTypesBase, Expression as Expression$1, RawSqlTag, ScopeField, TraitExpression } from "@prisma-next/sql-relational-core/expression";
|
|
3
3
|
import { AnnotationValue, OperationKind, ValidAnnotations } from "@prisma-next/framework-components/runtime";
|
|
4
4
|
import { ExtractCodecTypes, ExtractFieldInputTypes, ExtractFieldOutputTypes, ExtractQueryOperationTypes, QueryOperationTypesBase, StorageTable, StorageTable as StorageTable$1 } from "@prisma-next/sql-contract/types";
|
|
5
5
|
import { SqlQueryPlan } from "@prisma-next/sql-relational-core/plan";
|
|
@@ -119,6 +119,7 @@ type BuiltinFunctions<CT extends Record<string, {
|
|
|
119
119
|
nullable: boolean;
|
|
120
120
|
}>, values: Array<CodecExpression<CodecId, boolean, CT>>): Expression$1<BooleanCodecType>;
|
|
121
121
|
};
|
|
122
|
+
readonly raw: RawSqlTag;
|
|
122
123
|
};
|
|
123
124
|
type Functions<QC extends QueryContext> = BuiltinFunctions<QC['codecTypes']> & DeriveExtFunctions<QC['queryOperationTypes']>;
|
|
124
125
|
type CountField = {
|
|
@@ -334,7 +335,7 @@ type ContractToQC<C extends TableProxyContract, Name extends string = string> =
|
|
|
334
335
|
readonly resolvedColumnOutputTypes: ResolvedColumnTypes<C, Name, ExtractFieldOutputTypes<C>>;
|
|
335
336
|
};
|
|
336
337
|
interface TableProxy<C extends TableProxyContract, Name extends string & keyof UnboundTables<C>, Alias extends string = Name, AvailableScope extends Scope = DefaultScope<Name, UnboundTables<C>[Name]>, QC extends QueryContext = ContractToQC<C, Name>> extends JoinSource<StorageTableToScopeTable<UnboundTables<C>[Name]>, Alias>, WithSelect<QC, AvailableScope, EmptyRow>, WithJoin<QC, AvailableScope, C['capabilities']> {
|
|
337
|
-
as<NewAlias extends string>(newAlias: NewAlias): TableProxy<C, Name, NewAlias, RebindScope<AvailableScope, Alias, NewAlias
|
|
338
|
+
as<NewAlias extends string>(newAlias: NewAlias): TableProxy<C, Name, NewAlias, RebindScope<AvailableScope, Alias, NewAlias>, QC>;
|
|
338
339
|
insert(rows: ReadonlyArray<ResolvedInsertValues<C, UnboundTables<C>[Name], Name, QC['codecTypes'], ExtractFieldInputTypes<C>>>): InsertQuery<QC, AvailableScope, EmptyRow>;
|
|
339
340
|
update(set: ResolvedUpdateValues<C, UnboundTables<C>[Name], Name, QC['codecTypes'], ExtractFieldInputTypes<C>>): UpdateQuery<QC, AvailableScope, EmptyRow>;
|
|
340
341
|
update(callback: (fields: FieldProxy<AvailableScope>, fns: Functions<QC>) => ResolvedUpdateExpressions<UnboundTables<C>[Name]>): UpdateQuery<QC, AvailableScope, EmptyRow>;
|
|
@@ -357,4 +358,4 @@ type TableInAnyNamespace<C extends TableProxyContract, Name extends string> = {
|
|
|
357
358
|
type Db<C extends TableProxyContract> = { [Name in TableNamesAcrossNamespaces<C>]: TableProxy<C, Name> };
|
|
358
359
|
//#endregion
|
|
359
360
|
export { Scope as _, GroupedQuery as a, UpdateQuery as c, BooleanCodecType as d, Expression$1 as f, QueryContext as g, GatedMethod as h, SelectQuery as i, ResolveRow as l, Functions as m, TableProxyContract as n, DeleteQuery as o, FieldProxy as p, TableProxy as r, InsertQuery as s, Db as t, AggregateFunctions as u, ScopeField as v, Subquery as y };
|
|
360
|
-
//# sourceMappingURL=db-
|
|
361
|
+
//# sourceMappingURL=db-CkP-ZJTr.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-CkP-ZJTr.d.mts","names":[],"sources":["../src/scope.ts","../src/expression.ts","../src/resolve.ts","../src/types/mutation-query.ts","../src/types/joined-tables.ts","../src/types/grouped-query.ts","../src/types/select-query.ts","../src/types/shared.ts","../src/types/table-proxy.ts","../src/types/db.ts"],"mappings":";;;;;;;KASY,WAAA,mCAA8C,YAAA,SAAqB,QAAA,GAC3E,MAAA;AAAA,cAGiB,cAAA;AAAA,cACA,cAAA;AAAA,KAET,MAAA,oBAA0B,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KAChC,QAAA,GAAW,MAAM,QAAQ,UAAA;AAAA,KAEzB,UAAA,GAAa,MAAM,SAAS,UAAA;AAAA,KAE5B,KAAA;EACV,QAAA,EAAU,UAAA;EACV,UAAA,EAAY,MAAA,SAAe,UAAA;AAAA;AAAA,KAGjB,UAAA,aAAuB,UAAA;EAAA,UACvB,cAAA;IACR,QAAA,EAAU,GAAA;IACV,UAAA,EAAY,MAAA,CAAO,KAAA,EAAO,GAAA;EAAA;EAG5B,iBAAA,IAAqB,KAAA;EACrB,QAAA,IAAY,aAAA;AAAA;AAAA,KAGF,YAAA,oCAAgD,cAAA;EAC1D,QAAA,EAAU,wBAAA,CAAyB,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SAGrD,YAAA,EAAc,gBAAA;AAAA;AAAA,KAKb,aAAA,WAAwB,kBAAA,wBAChB,0BAAA,CAA2B,CAAA,IAAK,mBAAA,CAAoB,CAAA,EAAG,IAAA;AAAA,KAGtE,0BAAA,WAAqC,kBAAA,qBACzB,CAAA,kCAAmC,CAAA,0BAA2B,IAAA,6BAEvE,CAAA;AAAA,KAEH,mBAAA,WAA8B,kBAAA,0CAClB,CAAA,4BAA6B,IAAA,eAAmB,CAAA,0BAA2B,IAAA,cACtF,CAAA,0BAA2B,IAAA,YAAgB,IAAA,kBAEzC,CAAA;AAAA,KAEI,EAAA,WAAa,kBAAA,eACd,0BAAA,CAA2B,CAAA,IAAK,UAAA,CAAW,CAAA,EAAG,IAAA"}
|
package/dist/exports/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as Scope, a as GroupedQuery, c as UpdateQuery, d as BooleanCodecType, f as Expression, g as QueryContext, h as GatedMethod, i as SelectQuery, l as ResolveRow, m as Functions, n as TableProxyContract, o as DeleteQuery, r as TableProxy, s as InsertQuery, t as Db, u as AggregateFunctions, v as ScopeField, y as Subquery } from "../db-
|
|
1
|
+
import { _ as Scope, a as GroupedQuery, c as UpdateQuery, d as BooleanCodecType, f as Expression, g as QueryContext, h as GatedMethod, i as SelectQuery, l as ResolveRow, m as Functions, n as TableProxyContract, o as DeleteQuery, r as TableProxy, s as InsertQuery, t as Db, u as AggregateFunctions, v as ScopeField, y as Subquery } from "../db-CkP-ZJTr.mjs";
|
|
2
2
|
export { type AggregateFunctions, type BooleanCodecType, type Db, type DeleteQuery, type Expression, type Functions, type GatedMethod, type GroupedQuery, type InsertQuery, type QueryContext, type ResolveRow, type Scope, type ScopeField, type SelectQuery, type Subquery, type TableProxy, type TableProxyContract, type UpdateQuery };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as Scope, a as GroupedQuery, c as UpdateQuery, f as Expression, g as QueryContext, h as GatedMethod, i as SelectQuery, l as ResolveRow, m as Functions, o as DeleteQuery, r as TableProxy, s as InsertQuery, t as Db, u as AggregateFunctions, v as ScopeField, y as Subquery } from "./db-
|
|
1
|
+
import { _ as Scope, a as GroupedQuery, c as UpdateQuery, f as Expression, g as QueryContext, h as GatedMethod, i as SelectQuery, l as ResolveRow, m as Functions, o as DeleteQuery, r as TableProxy, s as InsertQuery, t as Db, u as AggregateFunctions, v as ScopeField, y as Subquery } from "./db-CkP-ZJTr.mjs";
|
|
2
2
|
export { type AggregateFunctions, type Db, type DeleteQuery, type Expression, type Functions, type GatedMethod, type GroupedQuery, type InsertQuery, type QueryContext, type ResolveRow, type Scope, type ScopeField, type SelectQuery, type Subquery, type TableProxy, type UpdateQuery };
|
package/dist/runtime/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as Scope, g as QueryContext, m as Functions, n as TableProxyContract, p as FieldProxy, t as Db, u as AggregateFunctions, v as ScopeField } from "../db-
|
|
1
|
+
import { _ as Scope, g as QueryContext, m as Functions, n as TableProxyContract, p as FieldProxy, t as Db, u as AggregateFunctions, v as ScopeField } from "../db-CkP-ZJTr.mjs";
|
|
2
2
|
import { AnyExpression } from "@prisma-next/sql-relational-core/ast";
|
|
3
|
-
import { Expression } from "@prisma-next/sql-relational-core/expression";
|
|
3
|
+
import { Expression, RawCodecInferer } from "@prisma-next/sql-relational-core/expression";
|
|
4
4
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
5
5
|
import { CodecRef } from "@prisma-next/framework-components/codec";
|
|
6
6
|
import { SqlOperationEntry } from "@prisma-next/sql-operations";
|
|
@@ -25,12 +25,13 @@ declare class ExpressionImpl<T extends ScopeField = ScopeField> implements Expre
|
|
|
25
25
|
declare function createFieldProxy<S extends Scope>(scope: S): FieldProxy<S>;
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region src/runtime/functions.d.ts
|
|
28
|
-
declare function createFunctions<QC extends QueryContext>(operations: Readonly<Record<string, SqlOperationEntry
|
|
29
|
-
declare function createAggregateFunctions<QC extends QueryContext>(operations: Readonly<Record<string, SqlOperationEntry
|
|
28
|
+
declare function createFunctions<QC extends QueryContext>(operations: Readonly<Record<string, SqlOperationEntry>>, rawCodecInferer: RawCodecInferer): Functions<QC>;
|
|
29
|
+
declare function createAggregateFunctions<QC extends QueryContext>(operations: Readonly<Record<string, SqlOperationEntry>>, rawCodecInferer: RawCodecInferer): AggregateFunctions<QC>;
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/runtime/sql.d.ts
|
|
32
32
|
interface SqlOptions<C extends Contract<SqlStorage> & TableProxyContract> {
|
|
33
33
|
readonly context: ExecutionContext<C>;
|
|
34
|
+
readonly rawCodecInferer: RawCodecInferer;
|
|
34
35
|
}
|
|
35
36
|
declare function sql<C extends Contract<SqlStorage> & TableProxyContract>(options: SqlOptions<C>): Db<C>;
|
|
36
37
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/runtime/expression-impl.ts","../../src/runtime/field-proxy.ts","../../src/runtime/functions.ts","../../src/runtime/sql.ts"],"mappings":";;;;;;;;;;;;;;;cAUa,cAAA,WAAyB,UAAA,GAAa,UAAA,aAAuB,UAAA,CAAW,CAAA;EAAA,iBAClE,GAAA;EAAA,SACR,UAAA,EAAY,CAAA;EAAA,SACZ,KAAA,EAAO,QAAA;cAEJ,GAAA,EAAK,aAAA,EAAe,UAAA,EAAY,CAAA,EAAG,KAAA,GAAQ,QAAA;EAMvD,QAAA,CAAA,GAAY,aAAA;AAAA;;;iBChBE,gBAAA,WAA2B,KAAA,CAAA,CAAO,KAAA,EAAO,CAAA,GAAI,UAAA,CAAW,CAAA;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/runtime/expression-impl.ts","../../src/runtime/field-proxy.ts","../../src/runtime/functions.ts","../../src/runtime/sql.ts"],"mappings":";;;;;;;;;;;;;;;cAUa,cAAA,WAAyB,UAAA,GAAa,UAAA,aAAuB,UAAA,CAAW,CAAA;EAAA,iBAClE,GAAA;EAAA,SACR,UAAA,EAAY,CAAA;EAAA,SACZ,KAAA,EAAO,QAAA;cAEJ,GAAA,EAAK,aAAA,EAAe,UAAA,EAAY,CAAA,EAAG,KAAA,GAAQ,QAAA;EAMvD,QAAA,CAAA,GAAY,aAAA;AAAA;;;iBChBE,gBAAA,WAA2B,KAAA,CAAA,CAAO,KAAA,EAAO,CAAA,GAAI,UAAA,CAAW,CAAA;;;iBCgLxD,eAAA,YAA2B,YAAA,CAAA,CACzC,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,iBAAA,IACpC,eAAA,EAAiB,eAAA,GAChB,SAAA,CAAU,EAAA;AAAA,iBAgBG,wBAAA,YAAoC,YAAA,CAAA,CAClD,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,iBAAA,IACpC,eAAA,EAAiB,eAAA,GAChB,kBAAA,CAAmB,EAAA;;;UCnML,UAAA,WAAqB,QAAA,CAAS,UAAA,IAAc,kBAAA;EAAA,SAClD,OAAA,EAAS,gBAAA,CAAiB,CAAA;EAAA,SAC1B,eAAA,EAAiB,eAAA;AAAA;AAAA,iBAkBZ,GAAA,WAAc,QAAA,CAAS,UAAA,IAAc,kBAAA,CAAA,CACnD,OAAA,EAAS,UAAA,CAAW,CAAA,IACnB,EAAA,CAAG,CAAA"}
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AggregateExpr, AndExpr, BinaryExpr, ColumnRef, DeleteAst, DerivedTableSource, ExistsExpr, IdentifierRef, InsertAst, JoinAst, ListExpression, LiteralExpr, NullCheckExpr, OrExpr, OrderByItem, ParamRef, ProjectionItem, SelectAst, SubqueryExpr, TableSource, UpdateAst, collectOrderedParamRefs } from "@prisma-next/sql-relational-core/ast";
|
|
2
|
-
import { codecOf, toExpr } from "@prisma-next/sql-relational-core/expression";
|
|
2
|
+
import { codecOf, createRawSql, toExpr } from "@prisma-next/sql-relational-core/expression";
|
|
3
3
|
import { codecRefForStorageColumn } from "@prisma-next/sql-relational-core/codec-descriptor-registry";
|
|
4
4
|
import { assertAnnotationsApplicable } from "@prisma-next/framework-components/runtime";
|
|
5
5
|
//#region src/runtime/expression-impl.ts
|
|
@@ -107,7 +107,7 @@ function numericAgg(fn, expr) {
|
|
|
107
107
|
nullable: true
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
function createBuiltinFunctions() {
|
|
110
|
+
function createBuiltinFunctions(rawCodecInferer) {
|
|
111
111
|
return {
|
|
112
112
|
eq: (a, b) => eq(a, b),
|
|
113
113
|
ne: (a, b) => ne(a, b),
|
|
@@ -120,7 +120,8 @@ function createBuiltinFunctions() {
|
|
|
120
120
|
exists: (subquery) => boolExpr(ExistsExpr.exists(subquery.buildAst())),
|
|
121
121
|
notExists: (subquery) => boolExpr(ExistsExpr.notExists(subquery.buildAst())),
|
|
122
122
|
in: (expr, valuesOrSubquery) => inOrNotIn(expr, valuesOrSubquery, "in"),
|
|
123
|
-
notIn: (expr, valuesOrSubquery) => inOrNotIn(expr, valuesOrSubquery, "notIn")
|
|
123
|
+
notIn: (expr, valuesOrSubquery) => inOrNotIn(expr, valuesOrSubquery, "notIn"),
|
|
124
|
+
raw: createRawSql(rawCodecInferer)
|
|
124
125
|
};
|
|
125
126
|
}
|
|
126
127
|
function createAggregateOnlyFunctions() {
|
|
@@ -138,17 +139,16 @@ function createAggregateOnlyFunctions() {
|
|
|
138
139
|
max: (expr) => numericAgg("max", expr)
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
|
-
function createFunctions(operations) {
|
|
142
|
-
const builtins = createBuiltinFunctions();
|
|
142
|
+
function createFunctions(operations, rawCodecInferer) {
|
|
143
|
+
const builtins = createBuiltinFunctions(rawCodecInferer);
|
|
143
144
|
return new Proxy({}, { get(_target, prop) {
|
|
144
|
-
|
|
145
|
-
if (builtin) return builtin;
|
|
145
|
+
if (Object.hasOwn(builtins, prop)) return builtins[prop];
|
|
146
146
|
const op = operations[prop];
|
|
147
147
|
if (op) return op.impl;
|
|
148
148
|
} });
|
|
149
149
|
}
|
|
150
|
-
function createAggregateFunctions(operations) {
|
|
151
|
-
const baseFns = createFunctions(operations);
|
|
150
|
+
function createAggregateFunctions(operations, rawCodecInferer) {
|
|
151
|
+
const baseFns = createFunctions(operations, rawCodecInferer);
|
|
152
152
|
const aggregates = createAggregateOnlyFunctions();
|
|
153
153
|
return new Proxy({}, { get(_target, prop) {
|
|
154
154
|
const agg = aggregates[prop];
|
|
@@ -157,7 +157,7 @@ function createAggregateFunctions(operations) {
|
|
|
157
157
|
} });
|
|
158
158
|
}
|
|
159
159
|
//#endregion
|
|
160
|
-
//#region ../../../1-framework/0-foundation/utils/dist/defined-
|
|
160
|
+
//#region ../../../1-framework/0-foundation/utils/dist/defined-BnXRnErx.mjs
|
|
161
161
|
/**
|
|
162
162
|
* Returns an object with the key/value if value is defined, otherwise an empty object.
|
|
163
163
|
*
|
|
@@ -348,7 +348,7 @@ function resolveSelectArgs(args, scope, ctx) {
|
|
|
348
348
|
if (typeof args[0] === "string" && typeof args[1] === "function") {
|
|
349
349
|
const alias = args[0];
|
|
350
350
|
const exprFn = args[1];
|
|
351
|
-
const fns = createAggregateFunctions(ctx.queryOperationTypes);
|
|
351
|
+
const fns = createAggregateFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);
|
|
352
352
|
const result = exprFn(createFieldProxy(scope), fns);
|
|
353
353
|
const field = result.returnType;
|
|
354
354
|
projections.push(ProjectionItem.of(alias, result.buildAst(), field.codec));
|
|
@@ -360,7 +360,7 @@ function resolveSelectArgs(args, scope, ctx) {
|
|
|
360
360
|
}
|
|
361
361
|
if (typeof args[0] === "function") {
|
|
362
362
|
const callbackFn = args[0];
|
|
363
|
-
const fns = createAggregateFunctions(ctx.queryOperationTypes);
|
|
363
|
+
const fns = createAggregateFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);
|
|
364
364
|
const record = callbackFn(createFieldProxy(scope), fns);
|
|
365
365
|
for (const [key, expr] of Object.entries(record)) {
|
|
366
366
|
const field = expr.returnType;
|
|
@@ -383,7 +383,7 @@ function resolveOrderBy(arg, options, scope, rowFields, ctx, useAggregateFns) {
|
|
|
383
383
|
}
|
|
384
384
|
if (typeof arg === "function") {
|
|
385
385
|
const combined = orderByScopeOf(scope, rowFields);
|
|
386
|
-
const fns = useAggregateFns ? createAggregateFunctions(ctx.queryOperationTypes) : createFunctions(ctx.queryOperationTypes);
|
|
386
|
+
const fns = useAggregateFns ? createAggregateFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer) : createFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);
|
|
387
387
|
const result = arg(createFieldProxy(combined), fns);
|
|
388
388
|
return dir === "asc" ? OrderByItem.asc(result.buildAst()) : OrderByItem.desc(result.buildAst());
|
|
389
389
|
}
|
|
@@ -399,7 +399,7 @@ function resolveGroupBy(args, scope, rowFields, ctx) {
|
|
|
399
399
|
}
|
|
400
400
|
if (typeof args[0] === "function") {
|
|
401
401
|
const combined = orderByScopeOf(scope, rowFields);
|
|
402
|
-
const fns = createFunctions(ctx.queryOperationTypes);
|
|
402
|
+
const fns = createFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);
|
|
403
403
|
return [args[0](createFieldProxy(combined), fns).buildAst()];
|
|
404
404
|
}
|
|
405
405
|
throw new Error("Invalid groupBy arguments");
|
|
@@ -407,7 +407,7 @@ function resolveGroupBy(args, scope, rowFields, ctx) {
|
|
|
407
407
|
function resolveDistinctOn(args, scope, rowFields, ctx) {
|
|
408
408
|
if (args.length === 1 && typeof args[0] === "function") {
|
|
409
409
|
const combined = orderByScopeOf(scope, rowFields);
|
|
410
|
-
const fns = createFunctions(ctx.queryOperationTypes);
|
|
410
|
+
const fns = createFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);
|
|
411
411
|
return [args[0](createFieldProxy(combined), fns).buildAst()];
|
|
412
412
|
}
|
|
413
413
|
const combined = orderByScopeOf(scope, rowFields);
|
|
@@ -503,7 +503,7 @@ var SelectQueryImpl = class SelectQueryImpl extends QueryBase {
|
|
|
503
503
|
}), this.ctx);
|
|
504
504
|
}
|
|
505
505
|
where(expr) {
|
|
506
|
-
const result = expr(createFieldProxy(this.state.scope), createFunctions(this.ctx.queryOperationTypes));
|
|
506
|
+
const result = expr(createFieldProxy(this.state.scope), createFunctions(this.ctx.queryOperationTypes, this.ctx.rawCodecInferer));
|
|
507
507
|
return new SelectQueryImpl(cloneState(this.state, { where: [...this.state.where, result.buildAst()] }), this.ctx);
|
|
508
508
|
}
|
|
509
509
|
orderBy(arg, options) {
|
|
@@ -517,7 +517,7 @@ var GroupedQueryImpl = class GroupedQueryImpl extends QueryBase {
|
|
|
517
517
|
}
|
|
518
518
|
having(expr) {
|
|
519
519
|
const combined = orderByScopeOf(this.state.scope, this.state.rowFields);
|
|
520
|
-
const fns = createAggregateFunctions(this.ctx.queryOperationTypes);
|
|
520
|
+
const fns = createAggregateFunctions(this.ctx.queryOperationTypes, this.ctx.rawCodecInferer);
|
|
521
521
|
const result = expr(createFieldProxy(combined), fns);
|
|
522
522
|
return new GroupedQueryImpl(cloneState(this.state, { having: result.buildAst() }), this.ctx);
|
|
523
523
|
}
|
|
@@ -571,7 +571,7 @@ var JoinedTablesImpl = class JoinedTablesImpl extends BuilderBase {
|
|
|
571
571
|
return this.#addJoin(other, "full", targetScope, on);
|
|
572
572
|
}
|
|
573
573
|
#addJoin(other, joinType, resultScope, onExpr) {
|
|
574
|
-
const onResult = onExpr(createFieldProxy(mergeScopes(this.#state.scope, other.getJoinOuterScope())), createFunctions(this.ctx.queryOperationTypes));
|
|
574
|
+
const onResult = onExpr(createFieldProxy(mergeScopes(this.#state.scope, other.getJoinOuterScope())), createFunctions(this.ctx.queryOperationTypes, this.ctx.rawCodecInferer));
|
|
575
575
|
const joinAst = new JoinAst(joinType, other.buildAst(), onResult.buildAst());
|
|
576
576
|
return new JoinedTablesImpl(cloneState(this.#state, {
|
|
577
577
|
joins: [...this.#state.joins, joinAst],
|
|
@@ -641,11 +641,11 @@ function buildParamValues(values, table, tableName, op, ctx) {
|
|
|
641
641
|
function buildReturningProjections(tableName, columns, rowFields) {
|
|
642
642
|
return columns.map((col) => ProjectionItem.of(col, ColumnRef.of(tableName, col), rowFields[col]?.codec));
|
|
643
643
|
}
|
|
644
|
-
function evaluateWhere(whereCallback, scope, queryOperationTypes) {
|
|
645
|
-
return whereCallback(createFieldProxy(scope), createFunctions(queryOperationTypes)).buildAst();
|
|
644
|
+
function evaluateWhere(whereCallback, scope, queryOperationTypes, rawCodecInferer) {
|
|
645
|
+
return whereCallback(createFieldProxy(scope), createFunctions(queryOperationTypes, rawCodecInferer)).buildAst();
|
|
646
646
|
}
|
|
647
|
-
function evaluateUpdateCallback(callback, scope, queryOperationTypes) {
|
|
648
|
-
const result = callback(createFieldProxy(scope), createFunctions(queryOperationTypes));
|
|
647
|
+
function evaluateUpdateCallback(callback, scope, queryOperationTypes, rawCodecInferer) {
|
|
648
|
+
const result = callback(createFieldProxy(scope), createFunctions(queryOperationTypes, rawCodecInferer));
|
|
649
649
|
const set = {};
|
|
650
650
|
for (const [col, expr] of Object.entries(result)) if (expr !== void 0) set[col] = expr.buildAst();
|
|
651
651
|
return set;
|
|
@@ -726,7 +726,7 @@ var UpdateQueryImpl = class UpdateQueryImpl extends BuilderBase {
|
|
|
726
726
|
this.#annotations = annotations;
|
|
727
727
|
}
|
|
728
728
|
where(expr) {
|
|
729
|
-
const result = expr(createFieldProxy(this.#scope), createFunctions(this.ctx.queryOperationTypes));
|
|
729
|
+
const result = expr(createFieldProxy(this.#scope), createFunctions(this.ctx.queryOperationTypes, this.ctx.rawCodecInferer));
|
|
730
730
|
return new UpdateQueryImpl(this.#tableName, this.#scope, this.#setExpressions, this.ctx, [...this.#whereExprs, result.buildAst()], this.#returningColumns, this.#rowFields, this.#annotations);
|
|
731
731
|
}
|
|
732
732
|
returning = this._gate({ sql: { returning: true } }, "returning", (...columns) => {
|
|
@@ -788,7 +788,7 @@ var DeleteQueryImpl = class DeleteQueryImpl extends BuilderBase {
|
|
|
788
788
|
return new DeleteQueryImpl(this.#tableName, this.#scope, this.ctx, this.#whereCallbacks, this.#returningColumns, this.#rowFields, mergeWriteAnnotations(this.#annotations, annotations));
|
|
789
789
|
}
|
|
790
790
|
build() {
|
|
791
|
-
const whereExpr = combineWhereExprs(this.#whereCallbacks.map((cb) => evaluateWhere(cb, this.#scope, this.ctx.queryOperationTypes)));
|
|
791
|
+
const whereExpr = combineWhereExprs(this.#whereCallbacks.map((cb) => evaluateWhere(cb, this.#scope, this.ctx.queryOperationTypes, this.ctx.rawCodecInferer)));
|
|
792
792
|
let ast = DeleteAst.from(TableSource.named(this.#tableName)).withWhere(whereExpr);
|
|
793
793
|
if (this.#returningColumns.length > 0) ast = ast.withReturning(buildReturningProjections(this.#tableName, this.#returningColumns, this.#rowFields));
|
|
794
794
|
return buildQueryPlan(ast, this.ctx, this.#annotations);
|
|
@@ -846,7 +846,7 @@ var TableProxyImpl = class TableProxyImpl extends BuilderBase {
|
|
|
846
846
|
}
|
|
847
847
|
update(setOrCallback) {
|
|
848
848
|
if (typeof setOrCallback === "function") {
|
|
849
|
-
const setExpressions = buildSetExpressions(evaluateUpdateCallback(setOrCallback, this.#scope, this.ctx.queryOperationTypes), this.#table, this.#tableName, "update", this.ctx);
|
|
849
|
+
const setExpressions = buildSetExpressions(evaluateUpdateCallback(setOrCallback, this.#scope, this.ctx.queryOperationTypes, this.ctx.rawCodecInferer), this.#table, this.#tableName, "update", this.ctx);
|
|
850
850
|
return new UpdateQueryImpl(this.#tableName, this.#scope, setExpressions, this.ctx);
|
|
851
851
|
}
|
|
852
852
|
const setExpressions = buildParamValues(setOrCallback, this.#table, this.#tableName, "update", this.ctx);
|
|
@@ -868,14 +868,15 @@ function findTableAcrossNamespaces(storage, name) {
|
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
870
|
function sql(options) {
|
|
871
|
-
const { context } = options;
|
|
871
|
+
const { context, rawCodecInferer } = options;
|
|
872
872
|
const ctx = {
|
|
873
873
|
capabilities: context.contract.capabilities,
|
|
874
874
|
queryOperationTypes: context.queryOperations.entries(),
|
|
875
875
|
target: context.contract.target ?? "unknown",
|
|
876
876
|
storageHash: context.contract.storage.storageHash ?? "unknown",
|
|
877
877
|
storage: context.contract.storage,
|
|
878
|
-
applyMutationDefaults: (options) => context.applyMutationDefaults(options)
|
|
878
|
+
applyMutationDefaults: (options) => context.applyMutationDefaults(options),
|
|
879
|
+
rawCodecInferer
|
|
879
880
|
};
|
|
880
881
|
return new Proxy({}, { get(_target, prop) {
|
|
881
882
|
const table = findTableAcrossNamespaces(context.contract.storage, prop);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["#state","#buildLateral","#addLateralJoin","#addJoin","#tableName","#table","#scope","#rows","#returningColumns","#rowFields","#annotations","#setExpressions","#whereExprs","#whereCallbacks","#tableName","#table","#fromSource","#scope","#toJoined"],"sources":["../../src/runtime/expression-impl.ts","../../src/runtime/field-proxy.ts","../../src/runtime/functions.ts","../../../../../1-framework/0-foundation/utils/dist/defined-BYcWqtXq.mjs","../../src/runtime/builder-base.ts","../../src/runtime/query-impl.ts","../../src/runtime/joined-tables-impl.ts","../../src/runtime/mutation-impl.ts","../../src/runtime/table-proxy-impl.ts","../../src/runtime/sql.ts"],"sourcesContent":["import type { CodecRef } from '@prisma-next/framework-components/codec';\nimport type { AnyExpression as AstExpression } from '@prisma-next/sql-relational-core/ast';\nimport type { Expression } from '@prisma-next/sql-relational-core/expression';\nimport type { ScopeField } from '../scope';\n\n/**\n * Runtime wrapper around a relational-core AST expression node. Carries ScopeField metadata (codecId, nullable) so aggregate-like combinators can propagate the input codec onto their result.\n *\n * `codec` records the column-bound {@link CodecRef} when the field-proxy knows the binding — both the namespaced form (`f.user.email` → `ColumnRef`) and the top-level shortcut (`f.email` → `IdentifierRef`) stamp the ref derived from contract storage. `codecOf(expression)` exposes it for operation implementations forwarding the ref to `toExpr`.\n */\nexport class ExpressionImpl<T extends ScopeField = ScopeField> implements Expression<T> {\n private readonly ast: AstExpression;\n readonly returnType: T;\n readonly codec: CodecRef | undefined;\n\n constructor(ast: AstExpression, returnType: T, codec?: CodecRef) {\n this.ast = ast;\n this.returnType = returnType;\n this.codec = codec;\n }\n\n buildAst(): AstExpression {\n return this.ast;\n }\n}\n","import { ColumnRef, IdentifierRef } from '@prisma-next/sql-relational-core/ast';\nimport type { FieldProxy } from '../expression';\nimport type { Scope, ScopeTable } from '../scope';\nimport { ExpressionImpl } from './expression-impl';\n\nexport function createFieldProxy<S extends Scope>(scope: S): FieldProxy<S> {\n return new Proxy({} as FieldProxy<S>, {\n get(_target, prop: string) {\n if (Object.hasOwn(scope.topLevel, prop)) {\n const topField = scope.topLevel[prop];\n if (topField) {\n return new ExpressionImpl(IdentifierRef.of(prop), topField, topField.codec);\n }\n }\n\n if (Object.hasOwn(scope.namespaces, prop)) {\n const nsFields = scope.namespaces[prop];\n if (nsFields) return createNamespaceProxy(prop, nsFields);\n }\n\n return undefined;\n },\n });\n}\n\nfunction createNamespaceProxy(\n namespaceName: string,\n fields: ScopeTable,\n): Record<string, ExpressionImpl> {\n return new Proxy({} as Record<string, ExpressionImpl>, {\n get(_target, prop: string) {\n if (Object.hasOwn(fields, prop)) {\n const field = fields[prop];\n if (field) return new ExpressionImpl(ColumnRef.of(namespaceName, prop), field, field.codec);\n }\n return undefined;\n },\n });\n}\n","import type { SqlOperationEntry } from '@prisma-next/sql-operations';\nimport {\n AggregateExpr,\n AndExpr,\n type AnyExpression as AstExpression,\n BinaryExpr,\n type BinaryOp,\n type CodecRef,\n ExistsExpr,\n ListExpression,\n LiteralExpr,\n NullCheckExpr,\n OrExpr,\n SubqueryExpr,\n} from '@prisma-next/sql-relational-core/ast';\nimport { codecOf, toExpr } from '@prisma-next/sql-relational-core/expression';\nimport type {\n AggregateFunctions,\n AggregateOnlyFunctions,\n BooleanCodecType,\n BuiltinFunctions,\n CodecExpression,\n Expression,\n Functions,\n} from '../expression';\nimport type { QueryContext, ScopeField, Subquery } from '../scope';\nimport { ExpressionImpl } from './expression-impl';\n\ntype CodecTypes = Record<string, { readonly input: unknown }>;\n// Runtime-level ExprOrVal — accepts any codec, any nullability. Concrete codec typing lives on the public BuiltinFunctions surface in `../expression`.\ntype ExprOrVal<CodecId extends string = string, N extends boolean = boolean> = CodecExpression<\n CodecId,\n N,\n CodecTypes\n>;\n\nconst BOOL_FIELD: BooleanCodecType = { codecId: 'pg/bool@1', nullable: false };\n\nconst resolve = toExpr;\n\n/**\n * Resolve a binary-comparison operand into an AST expression, threading the column-bound side's {@link CodecRef} to the raw-value side.\n *\n * For `fns.eq(f.email, 'alice@example.com')`, `f.email` is the column-bound expression carrying a `ColumnRef` AST and a `CodecRef` derived from contract storage; the raw string operand has no codec context. By deriving the codec context from the column-bound side and forwarding it via `toExpr(value, codec)`, the resulting `ParamRef` carries the `CodecRef` that encode-side dispatch needs to materialise the per-instance codec for parameterized codec ids (`vector(1024)` vs. `vector(1536)`).\n */\nfunction resolveOperand(operand: ExprOrVal, otherCodec?: CodecRef): AstExpression {\n if (isExpressionLike(operand)) return operand.buildAst();\n return toExpr(operand, otherCodec);\n}\n\nfunction isExpressionLike(\n value: unknown,\n): value is { buildAst: () => AstExpression; returnType?: { codecId: string } } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'buildAst' in value &&\n typeof (value as { buildAst: unknown }).buildAst === 'function'\n );\n}\n\n/**\n * Resolves an Expression via `buildAst()`, or wraps a raw value as a `LiteralExpr` — an SQL literal inlined into the query text, not a bound parameter.\n *\n * Used for `and` / `or` operands. The usual operand is an `Expression<bool>` (e.g. the result of `fns.eq`), which this function passes through by calling `buildAst()`. The only time the raw-value branch fires is when the caller writes `fns.and(true, x)` or similar — inlining `TRUE`/`FALSE` literals lets the SQL planner statically simplify `TRUE AND x` to `x`, which it cannot do for an opaque `ParamRef`.\n */\nfunction toLiteralExpr(value: unknown): AstExpression {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'buildAst' in value &&\n typeof (value as { buildAst: unknown }).buildAst === 'function'\n ) {\n return (value as { buildAst(): AstExpression }).buildAst();\n }\n return new LiteralExpr(value);\n}\n\nfunction boolExpr(astNode: AstExpression): ExpressionImpl<BooleanCodecType> {\n return new ExpressionImpl(astNode, BOOL_FIELD);\n}\n\nfunction binaryWithSharedCodec(\n a: ExprOrVal,\n b: ExprOrVal,\n build: (left: AstExpression, right: AstExpression) => AstExpression,\n): AstExpression {\n const aCodec = codecOf(a);\n const bCodec = codecOf(b);\n const left = resolveOperand(a, bCodec);\n const right = resolveOperand(b, aCodec);\n return build(left, right);\n}\n\nfunction eq(a: ExprOrVal, b: ExprOrVal): ExpressionImpl<BooleanCodecType> {\n if (b === null) return boolExpr(NullCheckExpr.isNull(resolve(a)));\n if (a === null) return boolExpr(NullCheckExpr.isNull(resolve(b)));\n return boolExpr(binaryWithSharedCodec(a, b, (l, r) => new BinaryExpr('eq', l, r)));\n}\n\nfunction ne(a: ExprOrVal, b: ExprOrVal): ExpressionImpl<BooleanCodecType> {\n if (b === null) return boolExpr(NullCheckExpr.isNotNull(resolve(a)));\n if (a === null) return boolExpr(NullCheckExpr.isNotNull(resolve(b)));\n return boolExpr(binaryWithSharedCodec(a, b, (l, r) => new BinaryExpr('neq', l, r)));\n}\n\nfunction comparison(a: ExprOrVal, b: ExprOrVal, op: BinaryOp): ExpressionImpl<BooleanCodecType> {\n return boolExpr(binaryWithSharedCodec(a, b, (l, r) => new BinaryExpr(op, l, r)));\n}\n\nfunction inOrNotIn(\n expr: Expression<ScopeField>,\n valuesOrSubquery: Subquery<Record<string, ScopeField>> | ExprOrVal[],\n op: 'in' | 'notIn',\n): ExpressionImpl<BooleanCodecType> {\n const left = expr.buildAst();\n const leftCodec = codecOf(expr);\n const binaryFn = op === 'in' ? BinaryExpr.in : BinaryExpr.notIn;\n\n if (Array.isArray(valuesOrSubquery)) {\n const refs = valuesOrSubquery.map((v) => resolveOperand(v, leftCodec));\n return boolExpr(binaryFn(left, ListExpression.of(refs)));\n }\n return boolExpr(binaryFn(left, SubqueryExpr.of(valuesOrSubquery.buildAst())));\n}\n\nfunction numericAgg(\n fn: 'sum' | 'avg' | 'min' | 'max',\n expr: Expression<ScopeField>,\n): ExpressionImpl<{ codecId: string; nullable: true }> {\n return new ExpressionImpl(AggregateExpr[fn](expr.buildAst()), {\n codecId: expr.returnType.codecId,\n nullable: true as const,\n });\n}\n\nfunction createBuiltinFunctions() {\n return {\n eq: (a: ExprOrVal, b: ExprOrVal) => eq(a, b),\n ne: (a: ExprOrVal, b: ExprOrVal) => ne(a, b),\n gt: (a: ExprOrVal, b: ExprOrVal) => comparison(a, b, 'gt'),\n gte: (a: ExprOrVal, b: ExprOrVal) => comparison(a, b, 'gte'),\n lt: (a: ExprOrVal, b: ExprOrVal) => comparison(a, b, 'lt'),\n lte: (a: ExprOrVal, b: ExprOrVal) => comparison(a, b, 'lte'),\n and: (...exprs: ExprOrVal<'pg/bool@1', boolean>[]) =>\n boolExpr(AndExpr.of(exprs.map(toLiteralExpr))),\n or: (...exprs: ExprOrVal<'pg/bool@1', boolean>[]) =>\n boolExpr(OrExpr.of(exprs.map(toLiteralExpr))),\n exists: (subquery: Subquery<Record<string, ScopeField>>) =>\n boolExpr(ExistsExpr.exists(subquery.buildAst())),\n notExists: (subquery: Subquery<Record<string, ScopeField>>) =>\n boolExpr(ExistsExpr.notExists(subquery.buildAst())),\n in: (\n expr: Expression<ScopeField>,\n valuesOrSubquery: Subquery<Record<string, ScopeField>> | ExprOrVal[],\n ) => inOrNotIn(expr, valuesOrSubquery, 'in'),\n notIn: (\n expr: Expression<ScopeField>,\n valuesOrSubquery: Subquery<Record<string, ScopeField>> | ExprOrVal[],\n ) => inOrNotIn(expr, valuesOrSubquery, 'notIn'),\n } satisfies BuiltinFunctions<CodecTypes>;\n}\n\nfunction createAggregateOnlyFunctions() {\n return {\n count: (expr?: Expression<ScopeField>) => {\n const astExpr = expr ? expr.buildAst() : undefined;\n return new ExpressionImpl(AggregateExpr.count(astExpr), {\n codecId: 'pg/int8@1',\n nullable: false,\n });\n },\n sum: (expr: Expression<ScopeField>) => numericAgg('sum', expr),\n avg: (expr: Expression<ScopeField>) => numericAgg('avg', expr),\n min: (expr: Expression<ScopeField>) => numericAgg('min', expr),\n max: (expr: Expression<ScopeField>) => numericAgg('max', expr),\n } satisfies AggregateOnlyFunctions;\n}\n\nexport function createFunctions<QC extends QueryContext>(\n operations: Readonly<Record<string, SqlOperationEntry>>,\n): Functions<QC> {\n const builtins = createBuiltinFunctions();\n\n return new Proxy({} as Functions<QC>, {\n get(_target, prop: string) {\n const builtin = (builtins as Record<string, unknown>)[prop];\n if (builtin) return builtin;\n\n const op = operations[prop];\n if (op) return op.impl;\n return undefined;\n },\n });\n}\n\nexport function createAggregateFunctions<QC extends QueryContext>(\n operations: Readonly<Record<string, SqlOperationEntry>>,\n): AggregateFunctions<QC> {\n const baseFns = createFunctions<QC>(operations);\n const aggregates = createAggregateOnlyFunctions();\n\n return new Proxy({} as AggregateFunctions<QC>, {\n get(_target, prop: string) {\n const agg = (aggregates as Record<string, unknown>)[prop];\n if (agg) return agg;\n\n return (baseFns as Record<string, unknown>)[prop];\n },\n });\n}\n","//#region src/defined.ts\n/**\n* Returns an object with the key/value if value is defined, otherwise an empty object.\n*\n* Use with spread to conditionally include optional properties while satisfying\n* exactOptionalPropertyTypes. This is explicit about which properties are optional\n* and won't inadvertently strip other undefined values.\n*\n* @example\n* ```typescript\n* // Instead of:\n* const obj = {\n* required: 'value',\n* ...(optional ? { optional } : {}),\n* };\n*\n* // Use:\n* const obj = {\n* required: 'value',\n* ...ifDefined('optional', optional),\n* };\n* ```\n*/\nfunction ifDefined(key, value) {\n\treturn value !== void 0 ? { [key]: value } : {};\n}\n//#endregion\nexport { ifDefined as t };\n\n//# sourceMappingURL=defined-BYcWqtXq.mjs.map","import type { PlanMeta } from '@prisma-next/contract/types';\nimport type { CodecRef } from '@prisma-next/framework-components/codec';\nimport type { AnnotationValue, OperationKind } from '@prisma-next/framework-components/runtime';\nimport type { SqlStorage, StorageTable } from '@prisma-next/sql-contract/types';\nimport type { SqlOperationEntry } from '@prisma-next/sql-operations';\nimport {\n AndExpr,\n type AnyExpression as AstExpression,\n collectOrderedParamRefs,\n IdentifierRef,\n type LimitOffsetValue,\n OrderByItem,\n ProjectionItem,\n SelectAst,\n type TableSource,\n} from '@prisma-next/sql-relational-core/ast';\nimport { codecRefForStorageColumn } from '@prisma-next/sql-relational-core/codec-descriptor-registry';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport type {\n AppliedMutationDefault,\n MutationDefaultsOptions,\n} from '@prisma-next/sql-relational-core/query-lane-context';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type {\n AggregateFunctions,\n Expression,\n FieldProxy,\n OrderByOptions,\n OrderByScope,\n} from '../expression';\nimport type {\n GatedMethod,\n MergeScopes,\n NullableScope,\n QueryContext,\n Scope,\n ScopeField,\n ScopeTable,\n} from '../scope';\nimport { createFieldProxy } from './field-proxy';\nimport { createAggregateFunctions, createFunctions } from './functions';\n\nexport type ExprCallback = (fields: FieldProxy<Scope>, fns: unknown) => Expression<ScopeField>;\n\nexport class BuilderBase<Capabilities = unknown> {\n protected readonly ctx: BuilderContext;\n\n constructor(ctx: BuilderContext) {\n this.ctx = ctx;\n }\n\n protected _gate<Req extends Record<string, Record<string, boolean>>, Args extends unknown[], R>(\n required: Req,\n methodName: string,\n method: (...args: Args) => R,\n ): GatedMethod<Capabilities, Req, (...args: Args) => R> {\n return ((...args: Args): R => {\n assertCapability(this.ctx, required, methodName);\n return method(...args);\n }) as GatedMethod<Capabilities, Req, (...args: Args) => R>;\n }\n}\n\nexport interface BuilderState {\n readonly from: TableSource;\n readonly joins: readonly import('@prisma-next/sql-relational-core/ast').JoinAst[];\n readonly projections: readonly ProjectionItem[];\n readonly where: readonly AstExpression[];\n readonly orderBy: readonly OrderByItem[];\n readonly groupBy: readonly AstExpression[];\n readonly having: AstExpression | undefined;\n readonly limit: LimitOffsetValue | undefined;\n readonly offset: LimitOffsetValue | undefined;\n readonly distinct: true | undefined;\n readonly distinctOn: readonly AstExpression[] | undefined;\n readonly scope: Scope;\n readonly rowFields: Record<string, ScopeField>;\n /**\n * Annotations accumulated through `.annotate(...)` calls. Stored as\n * a `Map<namespace, AnnotationValue>` so duplicate namespaces\n * last-write-win. Empty on a fresh state.\n */\n readonly annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>;\n}\n\nexport interface BuilderContext {\n readonly capabilities: Record<string, Record<string, boolean>>;\n readonly queryOperationTypes: Readonly<Record<string, SqlOperationEntry>>;\n readonly target: string;\n readonly storageHash: string;\n /**\n * Contract storage carried by the builder context so column-bound `ParamRef` / `ProjectionItem` construction sites can derive a {@link CodecRef} for each `(table, column)` via {@link codecRefFor}. Builder paths that mint AST nodes without storage (rare — tests, ad-hoc lower paths) leave it undefined; the codec slot then stays `undefined` on the resulting nodes.\n */\n readonly storage: SqlStorage | undefined;\n readonly applyMutationDefaults: (\n options: MutationDefaultsOptions,\n ) => ReadonlyArray<AppliedMutationDefault>;\n}\n\n/**\n * Derive the canonical {@link CodecRef} for a `(table, column)` from the builder context's storage. Returns `undefined` when the builder context has no storage attached or when the column is unknown to the contract.\n */\nexport function codecRefFor(\n ctx: BuilderContext,\n tableName: string,\n columnName: string,\n): CodecRef | undefined {\n if (!ctx.storage) return undefined;\n return codecRefForStorageColumn(ctx.storage, tableName, columnName);\n}\n\nexport function emptyState(from: TableSource, scope: Scope): BuilderState {\n return {\n from,\n joins: [],\n projections: [],\n where: [],\n orderBy: [],\n groupBy: [],\n having: undefined,\n limit: undefined,\n offset: undefined,\n distinct: undefined,\n distinctOn: undefined,\n scope,\n rowFields: {},\n annotations: new Map(),\n };\n}\n\nexport function cloneState(state: BuilderState, overrides: Partial<BuilderState>): BuilderState {\n return { ...state, ...overrides };\n}\n\nexport function combineWhereExprs(exprs: readonly AstExpression[]): AstExpression | undefined {\n if (exprs.length === 0) return undefined;\n if (exprs.length === 1) return exprs[0];\n return AndExpr.of(exprs);\n}\n\nexport function buildSelectAst(state: BuilderState): SelectAst {\n const where = combineWhereExprs(state.where);\n return new SelectAst({\n from: state.from,\n joins: state.joins.length > 0 ? state.joins : undefined,\n projection: state.projections,\n where,\n orderBy: state.orderBy.length > 0 ? state.orderBy : undefined,\n distinct: state.distinct,\n distinctOn: state.distinctOn && state.distinctOn.length > 0 ? state.distinctOn : undefined,\n groupBy: state.groupBy.length > 0 ? state.groupBy : undefined,\n having: state.having,\n limit: state.limit,\n offset: state.offset,\n selectAllIntent: undefined,\n });\n}\n\nexport function buildQueryPlan<Row = unknown>(\n ast: import('@prisma-next/sql-relational-core/ast').AnyQueryAst,\n ctx: BuilderContext,\n annotations?: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>,\n): SqlQueryPlan<Row> {\n const paramValues = collectOrderedParamRefs(ast).map((r) =>\n r.kind === 'param-ref' ? r.value : undefined,\n );\n\n // SQL DSL has no framework-reserved namespace keys (e.g. `codecs`) in\n // scope at `.build()` time, so user annotations land verbatim here. The\n // ORM dispatch path — which compiles to plans that may already carry\n // reserved keys — enforces the precedence rule in `mergeAnnotations`\n // (`sql-orm-client/src/query-plan-meta.ts`).\n const annotationsRecord =\n annotations !== undefined && annotations.size > 0\n ? Object.freeze(Object.fromEntries(annotations))\n : undefined;\n const meta: PlanMeta = Object.freeze({\n target: ctx.target,\n storageHash: ctx.storageHash,\n lane: 'dsl',\n ...ifDefined('annotations', annotationsRecord),\n });\n\n return Object.freeze({ ast, params: paramValues, meta });\n}\n\nexport function buildPlan<Row = unknown>(\n state: BuilderState,\n ctx: BuilderContext,\n): SqlQueryPlan<Row> {\n return buildQueryPlan<Row>(buildSelectAst(state), ctx, state.annotations);\n}\n\nexport function tableToScope(\n alias: string,\n table: StorageTable,\n options?: { readonly storage?: SqlStorage | undefined; readonly tableName?: string | undefined },\n): Scope {\n const storage = options?.storage;\n const lookupName = options?.tableName;\n const fields: ScopeTable = {};\n for (const [colName, col] of Object.entries(table.columns)) {\n const codec =\n storage && lookupName ? codecRefForStorageColumn(storage, lookupName, colName) : undefined;\n fields[colName] = {\n codecId: col.codecId,\n nullable: col.nullable,\n ...(codec !== undefined ? { codec } : {}),\n };\n }\n return { topLevel: { ...fields }, namespaces: { [alias]: fields } };\n}\n\nexport function mergeScopes<A extends Scope, B extends Scope>(a: A, b: B): MergeScopes<A, B> {\n const topLevel: ScopeTable = {};\n for (const [k, v] of Object.entries(a.topLevel)) {\n if (!(k in b.topLevel)) topLevel[k] = v;\n }\n for (const [k, v] of Object.entries(b.topLevel)) {\n if (!(k in a.topLevel)) topLevel[k] = v;\n }\n return {\n topLevel,\n namespaces: { ...a.namespaces, ...b.namespaces },\n } as MergeScopes<A, B>;\n}\n\nexport function nullableScope<S extends Scope>(scope: S): NullableScope<S> {\n const mkNullable = (tbl: ScopeTable): ScopeTable => {\n const result: ScopeTable = {};\n for (const [k, v] of Object.entries(tbl)) {\n result[k] = {\n codecId: v.codecId,\n nullable: true,\n ...(v.codec !== undefined ? { codec: v.codec } : {}),\n };\n }\n return result;\n };\n const namespaces: Record<string, ScopeTable> = {};\n for (const [k, v] of Object.entries(scope.namespaces)) {\n namespaces[k] = mkNullable(v);\n }\n return { topLevel: mkNullable(scope.topLevel), namespaces } as NullableScope<S>;\n}\n\nexport function orderByScopeOf<S extends Scope, R extends Record<string, ScopeField>>(\n scope: S,\n rowFields: R,\n): OrderByScope<S, R> {\n return {\n topLevel: { ...scope.topLevel, ...rowFields },\n namespaces: scope.namespaces,\n };\n}\n\nexport function assertCapability(\n ctx: BuilderContext,\n required: Record<string, Record<string, boolean>>,\n methodName: string,\n): void {\n for (const [ns, keys] of Object.entries(required)) {\n for (const key of Object.keys(keys)) {\n if (!ctx.capabilities[ns]?.[key]) {\n throw new Error(`${methodName}() requires capability ${ns}.${key}`);\n }\n }\n }\n}\n\nexport function resolveSelectArgs(\n args: unknown[],\n scope: Scope,\n ctx: BuilderContext,\n): { projections: ProjectionItem[]; newRowFields: Record<string, ScopeField> } {\n const projections: ProjectionItem[] = [];\n const newRowFields: Record<string, ScopeField> = {};\n\n if (args.length === 0) return { projections, newRowFields };\n\n if (typeof args[0] === 'string' && (args.length === 1 || typeof args[1] !== 'function')) {\n for (const colName of args as string[]) {\n const field = scope.topLevel[colName];\n if (!field) throw new Error(`Column \"${colName}\" not found in scope`);\n projections.push(ProjectionItem.of(colName, IdentifierRef.of(colName), field.codec));\n newRowFields[colName] = field;\n }\n return { projections, newRowFields };\n }\n\n if (typeof args[0] === 'string' && typeof args[1] === 'function') {\n const alias = args[0] as string;\n const exprFn = args[1] as (\n f: FieldProxy<Scope>,\n fns: AggregateFunctions<QueryContext>,\n ) => Expression<ScopeField>;\n const fns = createAggregateFunctions(ctx.queryOperationTypes);\n const result = exprFn(createFieldProxy(scope), fns);\n const field = result.returnType;\n projections.push(ProjectionItem.of(alias, result.buildAst(), field.codec));\n newRowFields[alias] = field;\n return { projections, newRowFields };\n }\n\n if (typeof args[0] === 'function') {\n const callbackFn = args[0] as (\n f: FieldProxy<Scope>,\n fns: AggregateFunctions<QueryContext>,\n ) => Record<string, Expression<ScopeField>>;\n const fns = createAggregateFunctions(ctx.queryOperationTypes);\n const record = callbackFn(createFieldProxy(scope), fns);\n for (const [key, expr] of Object.entries(record)) {\n const field = expr.returnType;\n projections.push(ProjectionItem.of(key, expr.buildAst(), field.codec));\n newRowFields[key] = field;\n }\n return { projections, newRowFields };\n }\n\n throw new Error('Invalid .select() arguments');\n}\n\nexport function resolveOrderBy(\n arg: unknown,\n options: OrderByOptions | undefined,\n scope: Scope,\n rowFields: Record<string, ScopeField>,\n ctx: BuilderContext,\n useAggregateFns: boolean,\n): OrderByItem {\n const dir = options?.direction ?? 'asc';\n\n if (typeof arg === 'string') {\n const combined = orderByScopeOf(scope, rowFields);\n if (!(arg in combined.topLevel))\n throw new Error(`Column \"${arg}\" not found in scope for orderBy`);\n const expr = IdentifierRef.of(arg);\n return dir === 'asc' ? OrderByItem.asc(expr) : OrderByItem.desc(expr);\n }\n\n if (typeof arg === 'function') {\n const combined = orderByScopeOf(scope, rowFields);\n const fns = useAggregateFns\n ? createAggregateFunctions(ctx.queryOperationTypes)\n : createFunctions(ctx.queryOperationTypes);\n const result = (arg as ExprCallback)(createFieldProxy(combined), fns);\n return dir === 'asc' ? OrderByItem.asc(result.buildAst()) : OrderByItem.desc(result.buildAst());\n }\n\n throw new Error('Invalid orderBy argument');\n}\n\nexport function resolveGroupBy(\n args: unknown[],\n scope: Scope,\n rowFields: Record<string, ScopeField>,\n ctx: BuilderContext,\n): AstExpression[] {\n if (typeof args[0] === 'string') {\n const combined = orderByScopeOf(scope, rowFields);\n return (args as string[]).map((colName) => {\n if (!(colName in combined.topLevel))\n throw new Error(`Column \"${colName}\" not found in scope for groupBy`);\n return IdentifierRef.of(colName);\n });\n }\n\n if (typeof args[0] === 'function') {\n const combined = orderByScopeOf(scope, rowFields);\n const fns = createFunctions(ctx.queryOperationTypes);\n const result = (args[0] as ExprCallback)(createFieldProxy(combined), fns);\n return [result.buildAst()];\n }\n\n throw new Error('Invalid groupBy arguments');\n}\n\nexport function resolveDistinctOn(\n args: unknown[],\n scope: Scope,\n rowFields: Record<string, ScopeField>,\n ctx: BuilderContext,\n): AstExpression[] {\n if (args.length === 1 && typeof args[0] === 'function') {\n const combined = orderByScopeOf(scope, rowFields);\n const fns = createFunctions(ctx.queryOperationTypes);\n const result = (args[0] as ExprCallback)(createFieldProxy(combined), fns);\n return [result.buildAst()];\n }\n const combined = orderByScopeOf(scope, rowFields);\n return (args as string[]).map((colName) => {\n if (!(colName in combined.topLevel))\n throw new Error(`Column \"${colName}\" not found in scope for distinctOn`);\n return IdentifierRef.of(colName);\n });\n}\n","import type {\n AnnotationValue,\n OperationKind,\n ValidAnnotations,\n} from '@prisma-next/framework-components/runtime';\nimport { assertAnnotationsApplicable } from '@prisma-next/framework-components/runtime';\nimport { DerivedTableSource, type SelectAst } from '@prisma-next/sql-relational-core/ast';\nimport { toExpr } from '@prisma-next/sql-relational-core/expression';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport type {\n AggregateFunctions,\n BooleanCodecType,\n Expression,\n ExpressionBuilder,\n ExtractScopeFields,\n FieldProxy,\n Functions,\n OrderByOptions,\n OrderByScope,\n WithField,\n WithFields,\n} from '../expression';\nimport type { ResolveRow } from '../resolve';\nimport type {\n Expand,\n JoinOuterScope,\n JoinSource,\n QueryContext,\n Scope,\n ScopeField,\n // biome-ignore lint/correctness/noUnusedImports: used in `declare` property\n SubqueryMarker,\n} from '../scope';\nimport type { GroupedQuery } from '../types/grouped-query';\nimport type { SelectQuery } from '../types/select-query';\nimport type { PaginationValue } from '../types/shared';\nimport {\n BuilderBase,\n type BuilderContext,\n type BuilderState,\n buildPlan,\n buildSelectAst,\n cloneState,\n orderByScopeOf,\n resolveDistinctOn,\n resolveGroupBy,\n resolveOrderBy,\n resolveSelectArgs,\n} from './builder-base';\nimport { createFieldProxy } from './field-proxy';\nimport { createAggregateFunctions, createFunctions } from './functions';\n\nabstract class QueryBase<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n> extends BuilderBase<QC['capabilities']> {\n protected readonly state: BuilderState;\n\n constructor(state: BuilderState, ctx: BuilderContext) {\n super(ctx);\n this.state = state;\n }\n\n protected abstract clone(state: BuilderState): this;\n\n distinctOn = this._gate(\n { postgres: { distinctOn: true } },\n 'distinctOn',\n (...args: unknown[]) => {\n const exprs = resolveDistinctOn(args, this.state.scope, this.state.rowFields, this.ctx);\n return this.clone(\n cloneState(this.state, {\n distinctOn: [...(this.state.distinctOn ?? []), ...exprs],\n }),\n );\n },\n );\n\n limit(count: PaginationValue<QC>): this {\n const limit = typeof count === 'number' ? count : toExpr(count);\n return this.clone(cloneState(this.state, { limit }));\n }\n\n offset(count: PaginationValue<QC>): this {\n const offset = typeof count === 'number' ? count : toExpr(count);\n return this.clone(cloneState(this.state, { offset }));\n }\n\n distinct(): this {\n return this.clone(cloneState(this.state, { distinct: true }));\n }\n\n /**\n * Attach one or more annotations to this query plan.\n *\n * Read builders (`SelectQueryImpl`, `GroupedQueryImpl`) accept\n * annotations whose declared `applicableTo` includes `'read'`.\n * The type-level `As & ValidAnnotations<'read', As>` gate rejects\n * write-only annotations at the call site; the runtime check below\n * fails closed for callers that bypass the type gate (cast / `any`).\n *\n * Multiple `.annotate(...)` calls compose; duplicate namespaces use\n * last-write-wins. The accumulated annotations are merged into\n * `plan.meta.annotations` at `.build()` time, alongside any framework-\n * internal metadata under reserved namespaces (e.g. `codecs`).\n *\n * Chainable in any position (before / after `.where`, `.select`,\n * `.limit`, etc.); the returned builder has the same row type.\n */\n annotate<As extends readonly AnnotationValue<unknown, OperationKind>[]>(\n ...annotations: As & ValidAnnotations<'read', As>\n ): this {\n assertAnnotationsApplicable(\n annotations as readonly AnnotationValue<unknown, OperationKind>[],\n 'read',\n 'sql-dsl.annotate',\n );\n const next = new Map(this.state.annotations);\n for (const annotation of annotations as readonly AnnotationValue<unknown, OperationKind>[]) {\n next.set(annotation.namespace, annotation);\n }\n return this.clone(cloneState(this.state, { annotations: next }));\n }\n\n groupBy(\n ...fields: ((keyof RowType | keyof AvailableScope['topLevel']) & string)[]\n ): GroupedQuery<QC, AvailableScope, RowType>;\n groupBy(\n expr: (\n fields: FieldProxy<OrderByScope<AvailableScope, RowType>>,\n fns: Functions<QC>,\n ) => Expression<ScopeField>,\n ): GroupedQuery<QC, AvailableScope, RowType>;\n groupBy(...args: unknown[]): unknown {\n const exprs = resolveGroupBy(args, this.state.scope, this.state.rowFields, this.ctx);\n return new GroupedQueryImpl<QC, AvailableScope, RowType>(\n cloneState(this.state, { groupBy: [...this.state.groupBy, ...exprs] }),\n this.ctx,\n );\n }\n\n as<Alias extends string>(alias: Alias): JoinSource<RowType, Alias> {\n const ast = buildSelectAst(this.state);\n const derivedSource = DerivedTableSource.as(alias, ast);\n const scope = {\n topLevel: this.state.rowFields as RowType,\n namespaces: { [alias]: this.state.rowFields } as Record<Alias, RowType>,\n };\n return {\n getJoinOuterScope: () => scope,\n buildAst: () => derivedSource,\n\n // `as unknown` is necessary, because JoinOuterScope is a phantom type-only property that does not exist at runtime\n } satisfies Omit<JoinSource<RowType, Alias>, typeof JoinOuterScope> as unknown as JoinSource<\n RowType,\n Alias\n >;\n }\n\n getRowFields(): Record<string, ScopeField> {\n return this.state.rowFields;\n }\n\n buildAst(): SelectAst {\n return buildSelectAst(this.state);\n }\n\n build(): SqlQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>> {\n return buildPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>>(\n this.state,\n this.ctx,\n );\n }\n}\n\nexport class SelectQueryImpl<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n >\n extends QueryBase<QC, AvailableScope, RowType>\n implements SelectQuery<QC, AvailableScope, RowType>\n{\n declare readonly [SubqueryMarker]: RowType;\n\n protected clone(state: BuilderState): this {\n return new SelectQueryImpl<QC, AvailableScope, RowType>(state, this.ctx) as this;\n }\n\n select<Columns extends (keyof AvailableScope['topLevel'] & string)[]>(\n ...columns: Columns\n ): SelectQuery<QC, AvailableScope, WithFields<RowType, AvailableScope['topLevel'], Columns>>;\n select<Alias extends string, Field extends ScopeField>(\n alias: Alias,\n expr: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Expression<Field>,\n ): SelectQuery<QC, AvailableScope, WithField<RowType, Field, Alias>>;\n select<Result extends Record<string, Expression<ScopeField>>>(\n callback: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Result,\n ): SelectQuery<QC, AvailableScope, Expand<RowType & ExtractScopeFields<Result>>>;\n select(...args: unknown[]): unknown {\n const { projections, newRowFields } = resolveSelectArgs(args, this.state.scope, this.ctx);\n return new SelectQueryImpl(\n cloneState(this.state, {\n projections: [...this.state.projections, ...projections],\n rowFields: { ...this.state.rowFields, ...newRowFields },\n }),\n this.ctx,\n );\n }\n\n where(expr: ExpressionBuilder<AvailableScope, QC>): SelectQuery<QC, AvailableScope, RowType> {\n const fieldProxy = createFieldProxy(this.state.scope);\n const fns = createFunctions<QC>(this.ctx.queryOperationTypes);\n const result = (expr as ExpressionBuilder<Scope, QueryContext>)(fieldProxy, fns as never);\n return new SelectQueryImpl(\n cloneState(this.state, {\n where: [...this.state.where, result.buildAst()],\n }),\n this.ctx,\n );\n }\n\n orderBy(\n field: (keyof RowType | keyof AvailableScope['topLevel']) & string,\n options?: OrderByOptions,\n ): SelectQuery<QC, AvailableScope, RowType>;\n orderBy(\n expr: (\n fields: FieldProxy<OrderByScope<AvailableScope, RowType>>,\n fns: Functions<QC>,\n ) => Expression<ScopeField>,\n options?: OrderByOptions,\n ): SelectQuery<QC, AvailableScope, RowType>;\n orderBy(arg: unknown, options?: OrderByOptions): unknown {\n const item = resolveOrderBy(\n arg,\n options,\n this.state.scope,\n this.state.rowFields,\n this.ctx,\n false,\n );\n return this.clone(cloneState(this.state, { orderBy: [...this.state.orderBy, item] }));\n }\n}\n\nexport class GroupedQueryImpl<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n >\n extends QueryBase<QC, AvailableScope, RowType>\n implements GroupedQuery<QC, AvailableScope, RowType>\n{\n declare readonly [SubqueryMarker]: RowType;\n\n protected clone(state: BuilderState): this {\n return new GroupedQueryImpl<QC, AvailableScope, RowType>(state, this.ctx) as this;\n }\n\n having(\n expr: (\n fields: FieldProxy<OrderByScope<AvailableScope, RowType>>,\n fns: AggregateFunctions<QC>,\n ) => Expression<BooleanCodecType>,\n ): GroupedQuery<QC, AvailableScope, RowType> {\n const combined = orderByScopeOf(\n this.state.scope as AvailableScope,\n this.state.rowFields as RowType,\n );\n const fns = createAggregateFunctions(this.ctx.queryOperationTypes);\n const result = expr(createFieldProxy(combined), fns);\n return new GroupedQueryImpl(cloneState(this.state, { having: result.buildAst() }), this.ctx);\n }\n\n orderBy(\n field: (keyof RowType | keyof AvailableScope['topLevel']) & string,\n options?: OrderByOptions,\n ): GroupedQuery<QC, AvailableScope, RowType>;\n orderBy(\n expr: (\n fields: FieldProxy<OrderByScope<AvailableScope, RowType>>,\n fns: AggregateFunctions<QC>,\n ) => Expression<ScopeField>,\n options?: OrderByOptions,\n ): GroupedQuery<QC, AvailableScope, RowType>;\n orderBy(arg: unknown, options?: OrderByOptions): unknown {\n const item = resolveOrderBy(\n arg,\n options,\n this.state.scope,\n this.state.rowFields,\n this.ctx,\n true,\n );\n return this.clone(cloneState(this.state, { orderBy: [...this.state.orderBy, item] }));\n }\n}\n","import {\n AndExpr,\n DerivedTableSource,\n JoinAst,\n type TableSource,\n} from '@prisma-next/sql-relational-core/ast';\nimport type {\n AggregateFunctions,\n Expression,\n ExpressionBuilder,\n ExtractScopeFields,\n FieldProxy,\n WithField,\n WithFields,\n} from '../expression';\nimport type {\n EmptyRow,\n Expand,\n JoinOuterScope,\n JoinSource,\n MergeScopes,\n NullableScope,\n QueryContext,\n Scope,\n ScopeField,\n ScopeTable,\n Subquery,\n} from '../scope';\nimport type { JoinedTables } from '../types/joined-tables';\nimport type { SelectQuery } from '../types/select-query';\nimport type { LateralBuilder } from '../types/shared';\nimport {\n BuilderBase,\n type BuilderContext,\n type BuilderState,\n cloneState,\n emptyState,\n mergeScopes,\n nullableScope,\n resolveSelectArgs,\n} from './builder-base';\nimport { createFieldProxy } from './field-proxy';\nimport { createFunctions } from './functions';\nimport { SelectQueryImpl } from './query-impl';\n\nexport class JoinedTablesImpl<QC extends QueryContext, AvailableScope extends Scope>\n extends BuilderBase<QC['capabilities']>\n implements JoinedTables<QC, AvailableScope>\n{\n readonly #state: BuilderState;\n\n constructor(state: BuilderState, ctx: BuilderContext) {\n super(ctx);\n this.#state = state;\n }\n\n lateralJoin = this._gate(\n { sql: { lateral: true } },\n 'lateralJoin',\n <Alias extends string, LateralRow extends Record<string, ScopeField>>(\n alias: Alias,\n builder: (lateral: LateralBuilder<QC, AvailableScope>) => Subquery<LateralRow>,\n ): JoinedTables<\n QC,\n MergeScopes<AvailableScope, { topLevel: LateralRow; namespaces: Record<Alias, LateralRow> }>\n > => {\n const { derivedSource, lateralScope } = this.#buildLateral(alias, builder);\n const resultScope = mergeScopes(\n this.#state.scope as AvailableScope,\n lateralScope as { topLevel: LateralRow; namespaces: Record<Alias, LateralRow> },\n );\n return this.#addLateralJoin('inner', resultScope, derivedSource);\n },\n ) as JoinedTables<QC, AvailableScope>['lateralJoin'];\n\n outerLateralJoin = this._gate(\n { sql: { lateral: true } },\n 'outerLateralJoin',\n <Alias extends string, LateralRow extends Record<string, ScopeField>>(\n alias: Alias,\n builder: (lateral: LateralBuilder<QC, AvailableScope>) => Subquery<LateralRow>,\n ): JoinedTables<\n QC,\n MergeScopes<\n AvailableScope,\n NullableScope<{ topLevel: LateralRow; namespaces: Record<Alias, LateralRow> }>\n >\n > => {\n const { derivedSource, lateralScope } = this.#buildLateral(alias, builder);\n const resultScope = mergeScopes(\n this.#state.scope as AvailableScope,\n nullableScope(\n lateralScope as { topLevel: LateralRow; namespaces: Record<Alias, LateralRow> },\n ),\n );\n return this.#addLateralJoin('left', resultScope, derivedSource);\n },\n ) as JoinedTables<QC, AvailableScope>['outerLateralJoin'];\n\n select<Columns extends (keyof AvailableScope['topLevel'] & string)[]>(\n ...columns: Columns\n ): SelectQuery<QC, AvailableScope, WithFields<EmptyRow, AvailableScope['topLevel'], Columns>>;\n select<Alias extends string, Field extends ScopeField>(\n alias: Alias,\n expr: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Expression<Field>,\n ): SelectQuery<QC, AvailableScope, WithField<EmptyRow, Field, Alias>>;\n select<Result extends Record<string, Expression<ScopeField>>>(\n callback: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Result,\n ): SelectQuery<QC, AvailableScope, Expand<ExtractScopeFields<Result>>>;\n select(...args: unknown[]): unknown {\n const { projections, newRowFields } = resolveSelectArgs(args, this.#state.scope, this.ctx);\n return new SelectQueryImpl<QC, AvailableScope>(\n cloneState(this.#state, {\n projections: [...this.#state.projections, ...projections],\n rowFields: { ...this.#state.rowFields, ...newRowFields },\n }),\n this.ctx,\n );\n }\n\n innerJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>> {\n const targetScope = mergeScopes(\n this.#state.scope as AvailableScope,\n other.getJoinOuterScope() as Other[typeof JoinOuterScope],\n );\n return this.#addJoin(other, 'inner', targetScope, on);\n }\n\n outerLeftJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<AvailableScope, NullableScope<Other[typeof JoinOuterScope]>>> {\n const targetScope = mergeScopes(\n this.#state.scope as AvailableScope,\n nullableScope(other.getJoinOuterScope() as Other[typeof JoinOuterScope]),\n );\n return this.#addJoin(other, 'left', targetScope, on);\n }\n\n outerRightJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<NullableScope<AvailableScope>, Other[typeof JoinOuterScope]>> {\n const targetScope = mergeScopes(\n nullableScope(this.#state.scope as AvailableScope),\n other.getJoinOuterScope() as Other[typeof JoinOuterScope],\n );\n return this.#addJoin(other, 'right', targetScope, on);\n }\n\n outerFullJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<\n QC,\n MergeScopes<NullableScope<AvailableScope>, NullableScope<Other[typeof JoinOuterScope]>>\n > {\n const targetScope = mergeScopes(\n nullableScope(this.#state.scope as AvailableScope),\n nullableScope(other.getJoinOuterScope() as Other[typeof JoinOuterScope]),\n );\n return this.#addJoin(other, 'full', targetScope, on);\n }\n\n #addJoin<Other extends JoinSource<ScopeTable, string | never>, ResultScope extends Scope>(\n other: Other,\n joinType: 'inner' | 'left' | 'right' | 'full',\n resultScope: ResultScope,\n onExpr: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, ResultScope> {\n const fieldProxy = createFieldProxy(\n mergeScopes(\n this.#state.scope as AvailableScope,\n other.getJoinOuterScope() as Other[typeof JoinOuterScope],\n ),\n ) as FieldProxy<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>>;\n const fns = createFunctions<QC>(this.ctx.queryOperationTypes);\n const onResult = onExpr(fieldProxy, fns);\n const joinAst = new JoinAst(joinType, other.buildAst(), onResult.buildAst());\n\n return new JoinedTablesImpl(\n cloneState(this.#state, {\n joins: [...this.#state.joins, joinAst],\n scope: resultScope,\n }),\n this.ctx,\n );\n }\n\n #buildLateral(\n alias: string,\n builderFn: (\n lateral: LateralBuilder<QC, AvailableScope>,\n ) => Subquery<Record<string, ScopeField>>,\n ) {\n const lateralBuilder: LateralBuilder<QC, AvailableScope> = {\n from: (other) => {\n const otherScope = other.getJoinOuterScope();\n const parentMerged = mergeScopes(this.#state.scope, otherScope);\n return new SelectQueryImpl(\n emptyState(other.buildAst() as TableSource, parentMerged),\n this.ctx,\n ) as unknown as SelectQuery<QC, AvailableScope, EmptyRow>;\n },\n };\n\n const subquery = builderFn(lateralBuilder);\n const subqueryAst = subquery.buildAst();\n const derivedSource = DerivedTableSource.as(alias, subqueryAst);\n const subqueryRowFields: ScopeTable = subquery.getRowFields();\n const lateralScope: Scope = {\n topLevel: subqueryRowFields,\n namespaces: { [alias]: subqueryRowFields },\n };\n\n return { derivedSource, lateralScope };\n }\n\n #addLateralJoin<ResultScope extends Scope>(\n joinType: 'inner' | 'left',\n resultScope: ResultScope,\n derivedSource: DerivedTableSource,\n ): JoinedTables<QC, ResultScope> {\n const onExpr = AndExpr.of([]);\n const joinAst = new JoinAst(joinType, derivedSource, onExpr, true);\n\n return new JoinedTablesImpl(\n cloneState(this.#state, {\n joins: [...this.#state.joins, joinAst],\n scope: resultScope,\n }),\n this.ctx,\n );\n }\n}\n","import type {\n AnnotationValue,\n OperationKind,\n ValidAnnotations,\n} from '@prisma-next/framework-components/runtime';\nimport { assertAnnotationsApplicable } from '@prisma-next/framework-components/runtime';\nimport type { StorageTable } from '@prisma-next/sql-contract/types';\nimport {\n type AnyExpression as AstExpression,\n ColumnRef,\n DeleteAst,\n InsertAst,\n ParamRef,\n ProjectionItem,\n TableSource,\n UpdateAst,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport type { MutationDefaultsOp } from '@prisma-next/sql-relational-core/query-lane-context';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Expression, ExpressionBuilder } from '../expression';\nimport type { ResolveRow } from '../resolve';\nimport type { QueryContext, Scope, ScopeField } from '../scope';\nimport type {\n DeleteQuery,\n InsertQuery,\n ReturningCapability,\n UpdateQuery,\n} from '../types/mutation-query';\nimport {\n BuilderBase,\n type BuilderContext,\n buildQueryPlan,\n codecRefFor,\n combineWhereExprs,\n} from './builder-base';\nimport { createFieldProxy } from './field-proxy';\nimport { createFunctions } from './functions';\n\n/**\n * Validates and merges a variadic annotations call into a builder's\n * accumulated user-annotations map. Used by `.annotate(...)` on each of\n * the three mutation builders (`InsertQueryImpl`, `UpdateQueryImpl`,\n * `DeleteQueryImpl`); the read builders share the same logic via\n * `QueryBase.annotate()` in `./query-impl.ts`.\n *\n * Runs `assertAnnotationsApplicable` at call time (not at `.build()`) so\n * inapplicable annotations forced through casts surface immediately\n * rather than at plan-construction time.\n */\nfunction mergeWriteAnnotations(\n current: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>,\n annotations: readonly AnnotationValue<unknown, OperationKind>[],\n): ReadonlyMap<string, AnnotationValue<unknown, OperationKind>> {\n assertAnnotationsApplicable(annotations, 'write', 'sql-dsl.annotate');\n const next = new Map(current);\n for (const annotation of annotations) {\n next.set(annotation.namespace, annotation);\n }\n return next;\n}\n\ntype WhereCallback = ExpressionBuilder<Scope, QueryContext>;\nexport type UpdateSetCallback = (\n fields: ReturnType<typeof createFieldProxy>,\n fns: ReturnType<typeof createFunctions>,\n) => Record<string, Expression<ScopeField> | undefined>;\n\nexport function buildParamValues(\n values: Record<string, unknown>,\n table: StorageTable,\n tableName: string,\n op: MutationDefaultsOp,\n ctx: BuilderContext,\n): Record<string, ParamRef> {\n const params: Record<string, ParamRef> = {};\n for (const [col, value] of Object.entries(values)) {\n const column = table.columns[col];\n const codec = column ? codecRefFor(ctx, tableName, col) : undefined;\n params[col] = ParamRef.of(value, codec ? { codec } : undefined);\n }\n for (const def of ctx.applyMutationDefaults({ op, table: tableName, values })) {\n const column = table.columns[def.column];\n const codec = column ? codecRefFor(ctx, tableName, def.column) : undefined;\n params[def.column] = ParamRef.of(def.value, codec ? { codec } : undefined);\n }\n return params;\n}\n\nfunction buildReturningProjections(\n tableName: string,\n columns: string[],\n rowFields: Record<string, ScopeField>,\n): ProjectionItem[] {\n return columns.map((col) =>\n ProjectionItem.of(col, ColumnRef.of(tableName, col), rowFields[col]?.codec),\n );\n}\n\nfunction evaluateWhere(\n whereCallback: WhereCallback,\n scope: Scope,\n queryOperationTypes: BuilderContext['queryOperationTypes'],\n): AstExpression {\n const fieldProxy = createFieldProxy(scope);\n const fns = createFunctions(queryOperationTypes);\n const result = whereCallback(fieldProxy, fns as never);\n return result.buildAst();\n}\n\nexport function evaluateUpdateCallback(\n callback: UpdateSetCallback,\n scope: Scope,\n queryOperationTypes: BuilderContext['queryOperationTypes'],\n): Record<string, AstExpression> {\n const fieldProxy = createFieldProxy(scope);\n const fns = createFunctions(queryOperationTypes);\n const result = callback(fieldProxy, fns as never);\n const set: Record<string, AstExpression> = {};\n for (const [col, expr] of Object.entries(result)) {\n if (expr !== undefined) {\n set[col] = expr.buildAst();\n }\n }\n return set;\n}\n\nexport function buildSetExpressions(\n exprs: Record<string, AstExpression>,\n table: StorageTable,\n tableName: string,\n op: MutationDefaultsOp,\n ctx: BuilderContext,\n): Record<string, AstExpression> {\n const set: Record<string, AstExpression> = { ...exprs };\n for (const def of ctx.applyMutationDefaults({ op, table: tableName, values: exprs })) {\n if (!(def.column in set)) {\n const column = table.columns[def.column];\n const codec = column ? codecRefFor(ctx, tableName, def.column) : undefined;\n set[def.column] = ParamRef.of(def.value, ifDefined('codec', codec));\n }\n }\n return set;\n}\n\nexport class InsertQueryImpl<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n >\n extends BuilderBase<QC['capabilities']>\n implements InsertQuery<QC, AvailableScope, RowType>\n{\n readonly #tableName: string;\n readonly #table: StorageTable;\n readonly #scope: Scope;\n readonly #rows: ReadonlyArray<Record<string, unknown>>;\n readonly #returningColumns: string[];\n readonly #rowFields: Record<string, ScopeField>;\n readonly #annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>;\n\n constructor(\n tableName: string,\n table: StorageTable,\n scope: Scope,\n rows: ReadonlyArray<Record<string, unknown>>,\n ctx: BuilderContext,\n returningColumns: string[] = [],\n rowFields: Record<string, ScopeField> = {},\n annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>> = new Map(),\n ) {\n super(ctx);\n this.#tableName = tableName;\n this.#table = table;\n this.#scope = scope;\n this.#rows = rows;\n this.#returningColumns = returningColumns;\n this.#rowFields = rowFields;\n this.#annotations = annotations;\n }\n\n returning = this._gate<ReturningCapability, string[], InsertQuery<QC, AvailableScope, never>>(\n { sql: { returning: true } },\n 'returning',\n (...columns: string[]) => {\n const newRowFields: Record<string, ScopeField> = {};\n for (const col of columns) {\n const field = this.#scope.topLevel[col];\n if (!field) throw new Error(`Column \"${col}\" not found in scope`);\n newRowFields[col] = field;\n }\n return new InsertQueryImpl(\n this.#tableName,\n this.#table,\n this.#scope,\n this.#rows,\n this.ctx,\n columns,\n newRowFields,\n this.#annotations,\n ) as unknown as InsertQuery<QC, AvailableScope, never>;\n },\n );\n\n /**\n * Attach one or more write-typed annotations to this query plan.\n * The type-level `As & ValidAnnotations<'write', As>` gate rejects\n * read-only annotations at the call site; the runtime check fails\n * closed for callers that bypass the type gate. See `QueryBase.annotate`\n * in `./query-impl.ts` for the read-builder counterpart.\n */\n annotate<As extends readonly AnnotationValue<unknown, OperationKind>[]>(\n ...annotations: As & ValidAnnotations<'write', As>\n ): InsertQuery<QC, AvailableScope, RowType> {\n return new InsertQueryImpl(\n this.#tableName,\n this.#table,\n this.#scope,\n this.#rows,\n this.ctx,\n this.#returningColumns,\n this.#rowFields,\n mergeWriteAnnotations(\n this.#annotations,\n annotations as readonly AnnotationValue<unknown, OperationKind>[],\n ),\n );\n }\n\n build(): SqlQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>> {\n if (this.#rows.length === 0) {\n throw new Error('insert() called with an empty row array — at least one row is required');\n }\n\n const paramRows = this.#rows.map((rowValues) =>\n buildParamValues(rowValues, this.#table, this.#tableName, 'create', this.ctx),\n );\n\n let ast = InsertAst.into(TableSource.named(this.#tableName)).withRows(paramRows);\n\n if (this.#returningColumns.length > 0) {\n ast = ast.withReturning(\n buildReturningProjections(this.#tableName, this.#returningColumns, this.#rowFields),\n );\n }\n\n return buildQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>>(\n ast,\n this.ctx,\n this.#annotations,\n );\n }\n}\n\nexport class UpdateQueryImpl<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n >\n extends BuilderBase<QC['capabilities']>\n implements UpdateQuery<QC, AvailableScope, RowType>\n{\n readonly #tableName: string;\n readonly #scope: Scope;\n readonly #setExpressions: Record<string, AstExpression>;\n readonly #whereExprs: readonly AstExpression[];\n readonly #returningColumns: string[];\n readonly #rowFields: Record<string, ScopeField>;\n readonly #annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>;\n\n constructor(\n tableName: string,\n scope: Scope,\n setExpressions: Record<string, AstExpression>,\n ctx: BuilderContext,\n whereExprs: readonly AstExpression[] = [],\n returningColumns: string[] = [],\n rowFields: Record<string, ScopeField> = {},\n annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>> = new Map(),\n ) {\n super(ctx);\n this.#tableName = tableName;\n this.#scope = scope;\n this.#setExpressions = setExpressions;\n this.#whereExprs = whereExprs;\n this.#returningColumns = returningColumns;\n this.#rowFields = rowFields;\n this.#annotations = annotations;\n }\n\n where(expr: ExpressionBuilder<AvailableScope, QC>): UpdateQuery<QC, AvailableScope, RowType> {\n const fieldProxy = createFieldProxy(this.#scope);\n const fns = createFunctions(this.ctx.queryOperationTypes);\n const result = (expr as ExpressionBuilder<Scope, QueryContext>)(fieldProxy, fns as never);\n return new UpdateQueryImpl(\n this.#tableName,\n this.#scope,\n this.#setExpressions,\n this.ctx,\n [...this.#whereExprs, result.buildAst()],\n this.#returningColumns,\n this.#rowFields,\n this.#annotations,\n );\n }\n\n returning = this._gate<ReturningCapability, string[], UpdateQuery<QC, AvailableScope, never>>(\n { sql: { returning: true } },\n 'returning',\n (...columns: string[]) => {\n const newRowFields: Record<string, ScopeField> = {};\n for (const col of columns) {\n const field = this.#scope.topLevel[col];\n if (!field) throw new Error(`Column \"${col}\" not found in scope`);\n newRowFields[col] = field;\n }\n return new UpdateQueryImpl(\n this.#tableName,\n this.#scope,\n this.#setExpressions,\n this.ctx,\n this.#whereExprs,\n columns,\n newRowFields,\n this.#annotations,\n ) as unknown as UpdateQuery<QC, AvailableScope, never>;\n },\n );\n\n /**\n * Attach one or more write-typed annotations to this query plan.\n * See `InsertQueryImpl.annotate` for semantics; the runtime check\n * fails closed for callers that bypass the type-level gate.\n */\n annotate<As extends readonly AnnotationValue<unknown, OperationKind>[]>(\n ...annotations: As & ValidAnnotations<'write', As>\n ): UpdateQuery<QC, AvailableScope, RowType> {\n return new UpdateQueryImpl(\n this.#tableName,\n this.#scope,\n this.#setExpressions,\n this.ctx,\n this.#whereExprs,\n this.#returningColumns,\n this.#rowFields,\n mergeWriteAnnotations(\n this.#annotations,\n annotations as readonly AnnotationValue<unknown, OperationKind>[],\n ),\n );\n }\n\n build(): SqlQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>> {\n let ast = UpdateAst.table(TableSource.named(this.#tableName))\n .withSet(this.#setExpressions)\n .withWhere(combineWhereExprs(this.#whereExprs));\n\n if (this.#returningColumns.length > 0) {\n ast = ast.withReturning(\n buildReturningProjections(this.#tableName, this.#returningColumns, this.#rowFields),\n );\n }\n\n return buildQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>>(\n ast,\n this.ctx,\n this.#annotations,\n );\n }\n}\n\nexport class DeleteQueryImpl<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n >\n extends BuilderBase<QC['capabilities']>\n implements DeleteQuery<QC, AvailableScope, RowType>\n{\n readonly #tableName: string;\n readonly #scope: Scope;\n readonly #whereCallbacks: readonly WhereCallback[];\n readonly #returningColumns: string[];\n readonly #rowFields: Record<string, ScopeField>;\n readonly #annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>;\n\n constructor(\n tableName: string,\n scope: Scope,\n ctx: BuilderContext,\n whereCallbacks: readonly WhereCallback[] = [],\n returningColumns: string[] = [],\n rowFields: Record<string, ScopeField> = {},\n annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>> = new Map(),\n ) {\n super(ctx);\n this.#tableName = tableName;\n this.#scope = scope;\n this.#whereCallbacks = whereCallbacks;\n this.#returningColumns = returningColumns;\n this.#rowFields = rowFields;\n this.#annotations = annotations;\n }\n\n where(expr: ExpressionBuilder<AvailableScope, QC>): DeleteQuery<QC, AvailableScope, RowType> {\n return new DeleteQueryImpl(\n this.#tableName,\n this.#scope,\n this.ctx,\n [...this.#whereCallbacks, expr as unknown as WhereCallback],\n this.#returningColumns,\n this.#rowFields,\n this.#annotations,\n );\n }\n\n returning = this._gate<ReturningCapability, string[], DeleteQuery<QC, AvailableScope, never>>(\n { sql: { returning: true } },\n 'returning',\n (...columns: string[]) => {\n const newRowFields: Record<string, ScopeField> = {};\n for (const col of columns) {\n const field = this.#scope.topLevel[col];\n if (!field) throw new Error(`Column \"${col}\" not found in scope`);\n newRowFields[col] = field;\n }\n return new DeleteQueryImpl(\n this.#tableName,\n this.#scope,\n this.ctx,\n this.#whereCallbacks,\n columns,\n newRowFields,\n this.#annotations,\n ) as unknown as DeleteQuery<QC, AvailableScope, never>;\n },\n );\n\n /**\n * Attach one or more write-typed annotations to this query plan.\n * See `InsertQueryImpl.annotate` for semantics.\n */\n annotate<As extends readonly AnnotationValue<unknown, OperationKind>[]>(\n ...annotations: As & ValidAnnotations<'write', As>\n ): DeleteQuery<QC, AvailableScope, RowType> {\n return new DeleteQueryImpl(\n this.#tableName,\n this.#scope,\n this.ctx,\n this.#whereCallbacks,\n this.#returningColumns,\n this.#rowFields,\n mergeWriteAnnotations(\n this.#annotations,\n annotations as readonly AnnotationValue<unknown, OperationKind>[],\n ),\n );\n }\n\n build(): SqlQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>> {\n const whereExpr = combineWhereExprs(\n this.#whereCallbacks.map((cb) =>\n evaluateWhere(cb, this.#scope, this.ctx.queryOperationTypes),\n ),\n );\n\n let ast = DeleteAst.from(TableSource.named(this.#tableName)).withWhere(whereExpr);\n\n if (this.#returningColumns.length > 0) {\n ast = ast.withReturning(\n buildReturningProjections(this.#tableName, this.#returningColumns, this.#rowFields),\n );\n }\n\n return buildQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>>(\n ast,\n this.ctx,\n this.#annotations,\n );\n }\n}\n","import type { StorageTable } from '@prisma-next/sql-contract/types';\nimport { type AnyFromSource, TableSource } from '@prisma-next/sql-relational-core/ast';\nimport type {\n AggregateFunctions,\n Expression,\n ExpressionBuilder,\n ExtractScopeFields,\n FieldProxy,\n Functions,\n WithField,\n WithFields,\n} from '../expression';\nimport type {\n EmptyRow,\n Expand,\n JoinOuterScope,\n JoinSource,\n MergeScopes,\n NullableScope,\n QueryContext,\n RebindScope,\n Scope,\n ScopeField,\n ScopeTable,\n StorageTableToScopeTable,\n Subquery,\n} from '../scope';\nimport type { TableProxyContract, UnboundTables } from '../types/db';\nimport type { JoinedTables } from '../types/joined-tables';\nimport type { DeleteQuery, InsertQuery, UpdateQuery } from '../types/mutation-query';\nimport type { SelectQuery } from '../types/select-query';\nimport type { LateralBuilder } from '../types/shared';\nimport type { TableProxy } from '../types/table-proxy';\nimport { BuilderBase, type BuilderContext, emptyState, tableToScope } from './builder-base';\nimport { JoinedTablesImpl } from './joined-tables-impl';\nimport {\n buildParamValues,\n buildSetExpressions,\n DeleteQueryImpl,\n evaluateUpdateCallback,\n InsertQueryImpl,\n UpdateQueryImpl,\n type UpdateSetCallback,\n} from './mutation-impl';\nimport { SelectQueryImpl } from './query-impl';\n\nexport class TableProxyImpl<\n C extends TableProxyContract,\n Name extends string & keyof UnboundTables<C>,\n Alias extends string,\n AvailableScope extends Scope,\n QC extends QueryContext,\n >\n extends BuilderBase<C['capabilities']>\n implements TableProxy<C, Name, Alias, AvailableScope, QC>\n{\n declare readonly [JoinOuterScope]: JoinSource<\n StorageTableToScopeTable<UnboundTables<C>[Name]>,\n Alias\n >[typeof JoinOuterScope];\n\n readonly #tableName: string;\n readonly #table: StorageTable;\n readonly #fromSource: TableSource;\n readonly #scope: Scope;\n\n constructor(tableName: string, table: StorageTable, alias: string, ctx: BuilderContext) {\n super(ctx);\n this.#tableName = tableName;\n this.#table = table;\n this.#scope = tableToScope(alias, table, { storage: ctx.storage, tableName });\n this.#fromSource = TableSource.named(tableName, alias !== tableName ? alias : undefined);\n }\n\n lateralJoin = this._gate(\n { sql: { lateral: true } },\n 'lateralJoin',\n <LAlias extends string, LateralRow extends Record<string, ScopeField>>(\n alias: LAlias,\n builder: (lateral: LateralBuilder<QC, AvailableScope>) => Subquery<LateralRow>,\n ): JoinedTables<\n QC,\n MergeScopes<AvailableScope, { topLevel: LateralRow; namespaces: Record<LAlias, LateralRow> }>\n > => {\n return this.#toJoined().lateralJoin(alias, builder);\n },\n ) as TableProxy<C, Name, Alias, AvailableScope, QC>['lateralJoin'];\n\n outerLateralJoin = this._gate(\n { sql: { lateral: true } },\n 'outerLateralJoin',\n <LAlias extends string, LateralRow extends Record<string, ScopeField>>(\n alias: LAlias,\n builder: (lateral: LateralBuilder<QC, AvailableScope>) => Subquery<LateralRow>,\n ): JoinedTables<\n QC,\n MergeScopes<\n AvailableScope,\n NullableScope<{ topLevel: LateralRow; namespaces: Record<LAlias, LateralRow> }>\n >\n > => {\n return this.#toJoined().outerLateralJoin(alias, builder);\n },\n ) as TableProxy<C, Name, Alias, AvailableScope, QC>['outerLateralJoin'];\n\n getJoinOuterScope(): Scope {\n return this.#scope;\n }\n\n buildAst(): AnyFromSource {\n return this.#fromSource;\n }\n\n as<NewAlias extends string>(\n newAlias: NewAlias,\n ): TableProxy<C, Name, NewAlias, RebindScope<AvailableScope, Alias, NewAlias>> {\n return new TableProxyImpl(this.#tableName, this.#table, newAlias, this.ctx);\n }\n\n select<Columns extends (keyof AvailableScope['topLevel'] & string)[]>(\n ...columns: Columns\n ): SelectQuery<QC, AvailableScope, WithFields<EmptyRow, AvailableScope['topLevel'], Columns>>;\n select<LAlias extends string, Field extends ScopeField>(\n alias: LAlias,\n expr: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Expression<Field>,\n ): SelectQuery<QC, AvailableScope, WithField<EmptyRow, Field, LAlias>>;\n select<Result extends Record<string, Expression<ScopeField>>>(\n callback: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Result,\n ): SelectQuery<QC, AvailableScope, Expand<ExtractScopeFields<Result>>>;\n select(...args: unknown[]): unknown {\n return new SelectQueryImpl(emptyState(this.#fromSource, this.#scope), this.ctx).select(\n ...(args as string[]),\n );\n }\n\n innerJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>> {\n return this.#toJoined().innerJoin(other, on);\n }\n\n outerLeftJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<AvailableScope, NullableScope<Other[typeof JoinOuterScope]>>> {\n return this.#toJoined().outerLeftJoin(other, on);\n }\n\n outerRightJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<NullableScope<AvailableScope>, Other[typeof JoinOuterScope]>> {\n return this.#toJoined().outerRightJoin(other, on);\n }\n\n outerFullJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<\n QC,\n MergeScopes<NullableScope<AvailableScope>, NullableScope<Other[typeof JoinOuterScope]>>\n > {\n return this.#toJoined().outerFullJoin(other, on);\n }\n\n insert(rows: ReadonlyArray<Record<string, unknown>>): InsertQuery<QC, AvailableScope, EmptyRow> {\n return new InsertQueryImpl(this.#tableName, this.#table, this.#scope, rows, this.ctx);\n }\n\n update(\n setOrCallback:\n | Record<string, unknown>\n | ((\n fields: FieldProxy<AvailableScope>,\n fns: Functions<QC>,\n ) => Record<string, Expression<ScopeField> | undefined>),\n ): UpdateQuery<QC, AvailableScope, EmptyRow> {\n if (typeof setOrCallback === 'function') {\n const callbackExprs = evaluateUpdateCallback(\n setOrCallback as UpdateSetCallback,\n this.#scope,\n this.ctx.queryOperationTypes,\n );\n const setExpressions = buildSetExpressions(\n callbackExprs,\n this.#table,\n this.#tableName,\n 'update',\n this.ctx,\n );\n return new UpdateQueryImpl(this.#tableName, this.#scope, setExpressions, this.ctx);\n }\n const setExpressions = buildParamValues(\n setOrCallback,\n this.#table,\n this.#tableName,\n 'update',\n this.ctx,\n );\n return new UpdateQueryImpl(this.#tableName, this.#scope, setExpressions, this.ctx);\n }\n\n delete(): DeleteQuery<QC, AvailableScope, EmptyRow> {\n return new DeleteQueryImpl(this.#tableName, this.#scope, this.ctx);\n }\n\n #toJoined(): JoinedTables<QC, AvailableScope> {\n return new JoinedTablesImpl(emptyState(this.#fromSource, this.#scope), this.ctx);\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlStorage, StorageTable } from '@prisma-next/sql-contract/types';\nimport type { ExecutionContext } from '@prisma-next/sql-relational-core/query-lane-context';\nimport type { Db, TableProxyContract } from '../types/db';\nimport type { BuilderContext } from './builder-base';\nimport { TableProxyImpl } from './table-proxy-impl';\n\nexport interface SqlOptions<C extends Contract<SqlStorage> & TableProxyContract> {\n readonly context: ExecutionContext<C>;\n}\n\n// Find a table by name across every declared namespace. Mirrors the\n// flat-DSL contract (db.<tableName>): the first namespace that declares\n// `name` wins. Name collisions across namespaces are a type-level error\n// at the DSL call site; landing the namespace-aware DSL is tracked\n// separately.\nfunction findTableAcrossNamespaces(storage: SqlStorage, name: string): StorageTable | undefined {\n for (const ns of Object.values(storage.namespaces)) {\n const tables = (ns as { tables?: Readonly<Record<string, StorageTable>> }).tables ?? {};\n if (Object.hasOwn(tables, name)) {\n return tables[name];\n }\n }\n return undefined;\n}\n\nexport function sql<C extends Contract<SqlStorage> & TableProxyContract>(\n options: SqlOptions<C>,\n): Db<C> {\n const { context } = options;\n const ctx: BuilderContext = {\n capabilities: context.contract.capabilities,\n queryOperationTypes: context.queryOperations.entries(),\n target: context.contract.target ?? 'unknown',\n storageHash: context.contract.storage.storageHash ?? 'unknown',\n storage: context.contract.storage,\n applyMutationDefaults: (options) => context.applyMutationDefaults(options),\n };\n\n return new Proxy({} as Db<C>, {\n get(_target, prop: string) {\n const table = findTableAcrossNamespaces(context.contract.storage, prop);\n if (table) {\n return new TableProxyImpl(prop, table, prop, ctx);\n }\n return undefined;\n },\n });\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAa,iBAAb,MAAwF;CACtF;CACA;CACA;CAEA,YAAY,KAAoB,YAAe,OAAkB;EAC/D,KAAK,MAAM;EACX,KAAK,aAAa;EAClB,KAAK,QAAQ;;CAGf,WAA0B;EACxB,OAAO,KAAK;;;;;ACjBhB,SAAgB,iBAAkC,OAAyB;CACzE,OAAO,IAAI,MAAM,EAAE,EAAmB,EACpC,IAAI,SAAS,MAAc;EACzB,IAAI,OAAO,OAAO,MAAM,UAAU,KAAK,EAAE;GACvC,MAAM,WAAW,MAAM,SAAS;GAChC,IAAI,UACF,OAAO,IAAI,eAAe,cAAc,GAAG,KAAK,EAAE,UAAU,SAAS,MAAM;;EAI/E,IAAI,OAAO,OAAO,MAAM,YAAY,KAAK,EAAE;GACzC,MAAM,WAAW,MAAM,WAAW;GAClC,IAAI,UAAU,OAAO,qBAAqB,MAAM,SAAS;;IAK9D,CAAC;;AAGJ,SAAS,qBACP,eACA,QACgC;CAChC,OAAO,IAAI,MAAM,EAAE,EAAoC,EACrD,IAAI,SAAS,MAAc;EACzB,IAAI,OAAO,OAAO,QAAQ,KAAK,EAAE;GAC/B,MAAM,QAAQ,OAAO;GACrB,IAAI,OAAO,OAAO,IA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C,aAAa,QAAQ,SAAS,QAAQ,eAAe;EACrD,SAAS,QAAQ,SAAS;EAC1B,wBAAwB,YAAY,QAAQ,sBAAsB,QAAQ;EAC3E;CAED,OAAO,IAAI,MAAM,EAAE,EAAW,EAC5B,IAAI,SAAS,MAAc;EACzB,MAAM,QAAQ,0BAA0B,QAAQ,SAAS,SAAS,KAAK;EACvE,IAAI,OACF,OAAO,IAAI,eAAe,MAAM,OAAO,MAAM,IAAI;IAItD,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["#state","#buildLateral","#addLateralJoin","#addJoin","#tableName","#table","#scope","#rows","#returningColumns","#rowFields","#annotations","#setExpressions","#whereExprs","#whereCallbacks","#tableName","#table","#fromSource","#scope","#toJoined"],"sources":["../../src/runtime/expression-impl.ts","../../src/runtime/field-proxy.ts","../../src/runtime/functions.ts","../../../../../1-framework/0-foundation/utils/dist/defined-BnXRnErx.mjs","../../src/runtime/builder-base.ts","../../src/runtime/query-impl.ts","../../src/runtime/joined-tables-impl.ts","../../src/runtime/mutation-impl.ts","../../src/runtime/table-proxy-impl.ts","../../src/runtime/sql.ts"],"sourcesContent":["import type { CodecRef } from '@prisma-next/framework-components/codec';\nimport type { AnyExpression as AstExpression } from '@prisma-next/sql-relational-core/ast';\nimport type { Expression } from '@prisma-next/sql-relational-core/expression';\nimport type { ScopeField } from '../scope';\n\n/**\n * Runtime wrapper around a relational-core AST expression node. Carries ScopeField metadata (codecId, nullable) so aggregate-like combinators can propagate the input codec onto their result.\n *\n * `codec` records the column-bound {@link CodecRef} when the field-proxy knows the binding — both the namespaced form (`f.user.email` → `ColumnRef`) and the top-level shortcut (`f.email` → `IdentifierRef`) stamp the ref derived from contract storage. `codecOf(expression)` exposes it for operation implementations forwarding the ref to `toExpr`.\n */\nexport class ExpressionImpl<T extends ScopeField = ScopeField> implements Expression<T> {\n private readonly ast: AstExpression;\n readonly returnType: T;\n readonly codec: CodecRef | undefined;\n\n constructor(ast: AstExpression, returnType: T, codec?: CodecRef) {\n this.ast = ast;\n this.returnType = returnType;\n this.codec = codec;\n }\n\n buildAst(): AstExpression {\n return this.ast;\n }\n}\n","import { ColumnRef, IdentifierRef } from '@prisma-next/sql-relational-core/ast';\nimport type { FieldProxy } from '../expression';\nimport type { Scope, ScopeTable } from '../scope';\nimport { ExpressionImpl } from './expression-impl';\n\nexport function createFieldProxy<S extends Scope>(scope: S): FieldProxy<S> {\n return new Proxy({} as FieldProxy<S>, {\n get(_target, prop: string) {\n if (Object.hasOwn(scope.topLevel, prop)) {\n const topField = scope.topLevel[prop];\n if (topField) {\n return new ExpressionImpl(IdentifierRef.of(prop), topField, topField.codec);\n }\n }\n\n if (Object.hasOwn(scope.namespaces, prop)) {\n const nsFields = scope.namespaces[prop];\n if (nsFields) return createNamespaceProxy(prop, nsFields);\n }\n\n return undefined;\n },\n });\n}\n\nfunction createNamespaceProxy(\n namespaceName: string,\n fields: ScopeTable,\n): Record<string, ExpressionImpl> {\n return new Proxy({} as Record<string, ExpressionImpl>, {\n get(_target, prop: string) {\n if (Object.hasOwn(fields, prop)) {\n const field = fields[prop];\n if (field) return new ExpressionImpl(ColumnRef.of(namespaceName, prop), field, field.codec);\n }\n return undefined;\n },\n });\n}\n","import type { SqlOperationEntry } from '@prisma-next/sql-operations';\nimport {\n AggregateExpr,\n AndExpr,\n type AnyExpression as AstExpression,\n BinaryExpr,\n type BinaryOp,\n type CodecRef,\n ExistsExpr,\n ListExpression,\n LiteralExpr,\n NullCheckExpr,\n OrExpr,\n SubqueryExpr,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { RawCodecInferer } from '@prisma-next/sql-relational-core/expression';\nimport { codecOf, createRawSql, toExpr } from '@prisma-next/sql-relational-core/expression';\nimport type {\n AggregateFunctions,\n AggregateOnlyFunctions,\n BooleanCodecType,\n BuiltinFunctions,\n CodecExpression,\n Expression,\n Functions,\n} from '../expression';\nimport type { QueryContext, ScopeField, Subquery } from '../scope';\nimport { ExpressionImpl } from './expression-impl';\n\ntype CodecTypes = Record<string, { readonly input: unknown }>;\n// Runtime-level ExprOrVal — accepts any codec, any nullability. Concrete codec typing lives on the public BuiltinFunctions surface in `../expression`.\ntype ExprOrVal<CodecId extends string = string, N extends boolean = boolean> = CodecExpression<\n CodecId,\n N,\n CodecTypes\n>;\n\nconst BOOL_FIELD: BooleanCodecType = { codecId: 'pg/bool@1', nullable: false };\n\nconst resolve = toExpr;\n\n/**\n * Resolve a binary-comparison operand into an AST expression, threading the column-bound side's {@link CodecRef} to the raw-value side.\n *\n * For `fns.eq(f.email, 'alice@example.com')`, `f.email` is the column-bound expression carrying a `ColumnRef` AST and a `CodecRef` derived from contract storage; the raw string operand has no codec context. By deriving the codec context from the column-bound side and forwarding it via `toExpr(value, codec)`, the resulting `ParamRef` carries the `CodecRef` that encode-side dispatch needs to materialise the per-instance codec for parameterized codec ids (`vector(1024)` vs. `vector(1536)`).\n */\nfunction resolveOperand(operand: ExprOrVal, otherCodec?: CodecRef): AstExpression {\n if (isExpressionLike(operand)) return operand.buildAst();\n return toExpr(operand, otherCodec);\n}\n\nfunction isExpressionLike(\n value: unknown,\n): value is { buildAst: () => AstExpression; returnType?: { codecId: string } } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'buildAst' in value &&\n typeof (value as { buildAst: unknown }).buildAst === 'function'\n );\n}\n\n/**\n * Resolves an Expression via `buildAst()`, or wraps a raw value as a `LiteralExpr` — an SQL literal inlined into the query text, not a bound parameter.\n *\n * Used for `and` / `or` operands. The usual operand is an `Expression<bool>` (e.g. the result of `fns.eq`), which this function passes through by calling `buildAst()`. The only time the raw-value branch fires is when the caller writes `fns.and(true, x)` or similar — inlining `TRUE`/`FALSE` literals lets the SQL planner statically simplify `TRUE AND x` to `x`, which it cannot do for an opaque `ParamRef`.\n */\nfunction toLiteralExpr(value: unknown): AstExpression {\n if (\n typeof value === 'object' &&\n value !== null &&\n 'buildAst' in value &&\n typeof (value as { buildAst: unknown }).buildAst === 'function'\n ) {\n return (value as { buildAst(): AstExpression }).buildAst();\n }\n return new LiteralExpr(value);\n}\n\nfunction boolExpr(astNode: AstExpression): ExpressionImpl<BooleanCodecType> {\n return new ExpressionImpl(astNode, BOOL_FIELD);\n}\n\nfunction binaryWithSharedCodec(\n a: ExprOrVal,\n b: ExprOrVal,\n build: (left: AstExpression, right: AstExpression) => AstExpression,\n): AstExpression {\n const aCodec = codecOf(a);\n const bCodec = codecOf(b);\n const left = resolveOperand(a, bCodec);\n const right = resolveOperand(b, aCodec);\n return build(left, right);\n}\n\nfunction eq(a: ExprOrVal, b: ExprOrVal): ExpressionImpl<BooleanCodecType> {\n if (b === null) return boolExpr(NullCheckExpr.isNull(resolve(a)));\n if (a === null) return boolExpr(NullCheckExpr.isNull(resolve(b)));\n return boolExpr(binaryWithSharedCodec(a, b, (l, r) => new BinaryExpr('eq', l, r)));\n}\n\nfunction ne(a: ExprOrVal, b: ExprOrVal): ExpressionImpl<BooleanCodecType> {\n if (b === null) return boolExpr(NullCheckExpr.isNotNull(resolve(a)));\n if (a === null) return boolExpr(NullCheckExpr.isNotNull(resolve(b)));\n return boolExpr(binaryWithSharedCodec(a, b, (l, r) => new BinaryExpr('neq', l, r)));\n}\n\nfunction comparison(a: ExprOrVal, b: ExprOrVal, op: BinaryOp): ExpressionImpl<BooleanCodecType> {\n return boolExpr(binaryWithSharedCodec(a, b, (l, r) => new BinaryExpr(op, l, r)));\n}\n\nfunction inOrNotIn(\n expr: Expression<ScopeField>,\n valuesOrSubquery: Subquery<Record<string, ScopeField>> | ExprOrVal[],\n op: 'in' | 'notIn',\n): ExpressionImpl<BooleanCodecType> {\n const left = expr.buildAst();\n const leftCodec = codecOf(expr);\n const binaryFn = op === 'in' ? BinaryExpr.in : BinaryExpr.notIn;\n\n if (Array.isArray(valuesOrSubquery)) {\n const refs = valuesOrSubquery.map((v) => resolveOperand(v, leftCodec));\n return boolExpr(binaryFn(left, ListExpression.of(refs)));\n }\n return boolExpr(binaryFn(left, SubqueryExpr.of(valuesOrSubquery.buildAst())));\n}\n\nfunction numericAgg(\n fn: 'sum' | 'avg' | 'min' | 'max',\n expr: Expression<ScopeField>,\n): ExpressionImpl<{ codecId: string; nullable: true }> {\n return new ExpressionImpl(AggregateExpr[fn](expr.buildAst()), {\n codecId: expr.returnType.codecId,\n nullable: true as const,\n });\n}\n\nfunction createBuiltinFunctions(rawCodecInferer: RawCodecInferer) {\n return {\n eq: (a: ExprOrVal, b: ExprOrVal) => eq(a, b),\n ne: (a: ExprOrVal, b: ExprOrVal) => ne(a, b),\n gt: (a: ExprOrVal, b: ExprOrVal) => comparison(a, b, 'gt'),\n gte: (a: ExprOrVal, b: ExprOrVal) => comparison(a, b, 'gte'),\n lt: (a: ExprOrVal, b: ExprOrVal) => comparison(a, b, 'lt'),\n lte: (a: ExprOrVal, b: ExprOrVal) => comparison(a, b, 'lte'),\n and: (...exprs: ExprOrVal<'pg/bool@1', boolean>[]) =>\n boolExpr(AndExpr.of(exprs.map(toLiteralExpr))),\n or: (...exprs: ExprOrVal<'pg/bool@1', boolean>[]) =>\n boolExpr(OrExpr.of(exprs.map(toLiteralExpr))),\n exists: (subquery: Subquery<Record<string, ScopeField>>) =>\n boolExpr(ExistsExpr.exists(subquery.buildAst())),\n notExists: (subquery: Subquery<Record<string, ScopeField>>) =>\n boolExpr(ExistsExpr.notExists(subquery.buildAst())),\n in: (\n expr: Expression<ScopeField>,\n valuesOrSubquery: Subquery<Record<string, ScopeField>> | ExprOrVal[],\n ) => inOrNotIn(expr, valuesOrSubquery, 'in'),\n notIn: (\n expr: Expression<ScopeField>,\n valuesOrSubquery: Subquery<Record<string, ScopeField>> | ExprOrVal[],\n ) => inOrNotIn(expr, valuesOrSubquery, 'notIn'),\n raw: createRawSql(rawCodecInferer),\n } satisfies BuiltinFunctions<CodecTypes>;\n}\n\nfunction createAggregateOnlyFunctions() {\n return {\n count: (expr?: Expression<ScopeField>) => {\n const astExpr = expr ? expr.buildAst() : undefined;\n return new ExpressionImpl(AggregateExpr.count(astExpr), {\n codecId: 'pg/int8@1',\n nullable: false,\n });\n },\n sum: (expr: Expression<ScopeField>) => numericAgg('sum', expr),\n avg: (expr: Expression<ScopeField>) => numericAgg('avg', expr),\n min: (expr: Expression<ScopeField>) => numericAgg('min', expr),\n max: (expr: Expression<ScopeField>) => numericAgg('max', expr),\n } satisfies AggregateOnlyFunctions;\n}\n\nexport function createFunctions<QC extends QueryContext>(\n operations: Readonly<Record<string, SqlOperationEntry>>,\n rawCodecInferer: RawCodecInferer,\n): Functions<QC> {\n const builtins = createBuiltinFunctions(rawCodecInferer);\n\n return new Proxy({} as Functions<QC>, {\n get(_target, prop: string) {\n if (Object.hasOwn(builtins, prop)) {\n return (builtins as Record<string, unknown>)[prop];\n }\n\n const op = operations[prop];\n if (op) return op.impl;\n return undefined;\n },\n });\n}\n\nexport function createAggregateFunctions<QC extends QueryContext>(\n operations: Readonly<Record<string, SqlOperationEntry>>,\n rawCodecInferer: RawCodecInferer,\n): AggregateFunctions<QC> {\n const baseFns = createFunctions<QC>(operations, rawCodecInferer);\n const aggregates = createAggregateOnlyFunctions();\n\n return new Proxy({} as AggregateFunctions<QC>, {\n get(_target, prop: string) {\n const agg = (aggregates as Record<string, unknown>)[prop];\n if (agg) return agg;\n\n return (baseFns as Record<string, unknown>)[prop];\n },\n });\n}\n","//#region src/defined.ts\n/**\n* Returns an object with the key/value if value is defined, otherwise an empty object.\n*\n* Use with spread to conditionally include optional properties while satisfying\n* exactOptionalPropertyTypes. This is explicit about which properties are optional\n* and won't inadvertently strip other undefined values.\n*\n* @example\n* ```typescript\n* // Instead of:\n* const obj = {\n* required: 'value',\n* ...(optional ? { optional } : {}),\n* };\n*\n* // Use:\n* const obj = {\n* required: 'value',\n* ...ifDefined('optional', optional),\n* };\n* ```\n*/\nfunction ifDefined(key, value) {\n\treturn value !== void 0 ? { [key]: value } : {};\n}\n//#endregion\nexport { ifDefined as t };\n\n//# sourceMappingURL=defined-BnXRnErx.mjs.map","import type { PlanMeta } from '@prisma-next/contract/types';\nimport type { CodecRef } from '@prisma-next/framework-components/codec';\nimport type { AnnotationValue, OperationKind } from '@prisma-next/framework-components/runtime';\nimport type { SqlStorage, StorageTable } from '@prisma-next/sql-contract/types';\nimport type { SqlOperationEntry } from '@prisma-next/sql-operations';\nimport {\n AndExpr,\n type AnyExpression as AstExpression,\n collectOrderedParamRefs,\n IdentifierRef,\n type LimitOffsetValue,\n OrderByItem,\n ProjectionItem,\n SelectAst,\n type TableSource,\n} from '@prisma-next/sql-relational-core/ast';\nimport { codecRefForStorageColumn } from '@prisma-next/sql-relational-core/codec-descriptor-registry';\nimport type { RawCodecInferer } from '@prisma-next/sql-relational-core/expression';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport type {\n AppliedMutationDefault,\n MutationDefaultsOptions,\n} from '@prisma-next/sql-relational-core/query-lane-context';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type {\n AggregateFunctions,\n Expression,\n FieldProxy,\n OrderByOptions,\n OrderByScope,\n} from '../expression';\nimport type {\n GatedMethod,\n MergeScopes,\n NullableScope,\n QueryContext,\n Scope,\n ScopeField,\n ScopeTable,\n} from '../scope';\nimport { createFieldProxy } from './field-proxy';\nimport { createAggregateFunctions, createFunctions } from './functions';\n\nexport type ExprCallback = (fields: FieldProxy<Scope>, fns: unknown) => Expression<ScopeField>;\n\nexport class BuilderBase<Capabilities = unknown> {\n protected readonly ctx: BuilderContext;\n\n constructor(ctx: BuilderContext) {\n this.ctx = ctx;\n }\n\n protected _gate<Req extends Record<string, Record<string, boolean>>, Args extends unknown[], R>(\n required: Req,\n methodName: string,\n method: (...args: Args) => R,\n ): GatedMethod<Capabilities, Req, (...args: Args) => R> {\n return ((...args: Args): R => {\n assertCapability(this.ctx, required, methodName);\n return method(...args);\n }) as GatedMethod<Capabilities, Req, (...args: Args) => R>;\n }\n}\n\nexport interface BuilderState {\n readonly from: TableSource;\n readonly joins: readonly import('@prisma-next/sql-relational-core/ast').JoinAst[];\n readonly projections: readonly ProjectionItem[];\n readonly where: readonly AstExpression[];\n readonly orderBy: readonly OrderByItem[];\n readonly groupBy: readonly AstExpression[];\n readonly having: AstExpression | undefined;\n readonly limit: LimitOffsetValue | undefined;\n readonly offset: LimitOffsetValue | undefined;\n readonly distinct: true | undefined;\n readonly distinctOn: readonly AstExpression[] | undefined;\n readonly scope: Scope;\n readonly rowFields: Record<string, ScopeField>;\n /**\n * Annotations accumulated through `.annotate(...)` calls. Stored as\n * a `Map<namespace, AnnotationValue>` so duplicate namespaces\n * last-write-win. Empty on a fresh state.\n */\n readonly annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>;\n}\n\nexport interface BuilderContext {\n readonly capabilities: Record<string, Record<string, boolean>>;\n readonly queryOperationTypes: Readonly<Record<string, SqlOperationEntry>>;\n readonly target: string;\n readonly storageHash: string;\n /**\n * Contract storage carried by the builder context so column-bound `ParamRef` / `ProjectionItem` construction sites can derive a {@link CodecRef} for each `(table, column)` via {@link codecRefFor}. Builder paths that mint AST nodes without storage (rare — tests, ad-hoc lower paths) leave it undefined; the codec slot then stays `undefined` on the resulting nodes.\n */\n readonly storage: SqlStorage | undefined;\n readonly applyMutationDefaults: (\n options: MutationDefaultsOptions,\n ) => ReadonlyArray<AppliedMutationDefault>;\n /**\n * Codec inferer used inside `createBuiltinFunctions` to construct the raw-SQL tag — `fns.raw` dispatches through `inferCodec(value)` for bare-literal interpolations.\n */\n readonly rawCodecInferer: RawCodecInferer;\n}\n\n/**\n * Derive the canonical {@link CodecRef} for a `(table, column)` from the builder context's storage. Returns `undefined` when the builder context has no storage attached or when the column is unknown to the contract.\n */\nexport function codecRefFor(\n ctx: BuilderContext,\n tableName: string,\n columnName: string,\n): CodecRef | undefined {\n if (!ctx.storage) return undefined;\n return codecRefForStorageColumn(ctx.storage, tableName, columnName);\n}\n\nexport function emptyState(from: TableSource, scope: Scope): BuilderState {\n return {\n from,\n joins: [],\n projections: [],\n where: [],\n orderBy: [],\n groupBy: [],\n having: undefined,\n limit: undefined,\n offset: undefined,\n distinct: undefined,\n distinctOn: undefined,\n scope,\n rowFields: {},\n annotations: new Map(),\n };\n}\n\nexport function cloneState(state: BuilderState, overrides: Partial<BuilderState>): BuilderState {\n return { ...state, ...overrides };\n}\n\nexport function combineWhereExprs(exprs: readonly AstExpression[]): AstExpression | undefined {\n if (exprs.length === 0) return undefined;\n if (exprs.length === 1) return exprs[0];\n return AndExpr.of(exprs);\n}\n\nexport function buildSelectAst(state: BuilderState): SelectAst {\n const where = combineWhereExprs(state.where);\n return new SelectAst({\n from: state.from,\n joins: state.joins.length > 0 ? state.joins : undefined,\n projection: state.projections,\n where,\n orderBy: state.orderBy.length > 0 ? state.orderBy : undefined,\n distinct: state.distinct,\n distinctOn: state.distinctOn && state.distinctOn.length > 0 ? state.distinctOn : undefined,\n groupBy: state.groupBy.length > 0 ? state.groupBy : undefined,\n having: state.having,\n limit: state.limit,\n offset: state.offset,\n selectAllIntent: undefined,\n });\n}\n\nexport function buildQueryPlan<Row = unknown>(\n ast: import('@prisma-next/sql-relational-core/ast').AnyQueryAst,\n ctx: BuilderContext,\n annotations?: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>,\n): SqlQueryPlan<Row> {\n const paramValues = collectOrderedParamRefs(ast).map((r) =>\n r.kind === 'param-ref' ? r.value : undefined,\n );\n\n // SQL DSL has no framework-reserved namespace keys (e.g. `codecs`) in\n // scope at `.build()` time, so user annotations land verbatim here. The\n // ORM dispatch path — which compiles to plans that may already carry\n // reserved keys — enforces the precedence rule in `mergeAnnotations`\n // (`sql-orm-client/src/query-plan-meta.ts`).\n const annotationsRecord =\n annotations !== undefined && annotations.size > 0\n ? Object.freeze(Object.fromEntries(annotations))\n : undefined;\n const meta: PlanMeta = Object.freeze({\n target: ctx.target,\n storageHash: ctx.storageHash,\n lane: 'dsl',\n ...ifDefined('annotations', annotationsRecord),\n });\n\n return Object.freeze({ ast, params: paramValues, meta });\n}\n\nexport function buildPlan<Row = unknown>(\n state: BuilderState,\n ctx: BuilderContext,\n): SqlQueryPlan<Row> {\n return buildQueryPlan<Row>(buildSelectAst(state), ctx, state.annotations);\n}\n\nexport function tableToScope(\n alias: string,\n table: StorageTable,\n options?: { readonly storage?: SqlStorage | undefined; readonly tableName?: string | undefined },\n): Scope {\n const storage = options?.storage;\n const lookupName = options?.tableName;\n const fields: ScopeTable = {};\n for (const [colName, col] of Object.entries(table.columns)) {\n const codec =\n storage && lookupName ? codecRefForStorageColumn(storage, lookupName, colName) : undefined;\n fields[colName] = {\n codecId: col.codecId,\n nullable: col.nullable,\n ...(codec !== undefined ? { codec } : {}),\n };\n }\n return { topLevel: { ...fields }, namespaces: { [alias]: fields } };\n}\n\nexport function mergeScopes<A extends Scope, B extends Scope>(a: A, b: B): MergeScopes<A, B> {\n const topLevel: ScopeTable = {};\n for (const [k, v] of Object.entries(a.topLevel)) {\n if (!(k in b.topLevel)) topLevel[k] = v;\n }\n for (const [k, v] of Object.entries(b.topLevel)) {\n if (!(k in a.topLevel)) topLevel[k] = v;\n }\n return {\n topLevel,\n namespaces: { ...a.namespaces, ...b.namespaces },\n } as MergeScopes<A, B>;\n}\n\nexport function nullableScope<S extends Scope>(scope: S): NullableScope<S> {\n const mkNullable = (tbl: ScopeTable): ScopeTable => {\n const result: ScopeTable = {};\n for (const [k, v] of Object.entries(tbl)) {\n result[k] = {\n codecId: v.codecId,\n nullable: true,\n ...(v.codec !== undefined ? { codec: v.codec } : {}),\n };\n }\n return result;\n };\n const namespaces: Record<string, ScopeTable> = {};\n for (const [k, v] of Object.entries(scope.namespaces)) {\n namespaces[k] = mkNullable(v);\n }\n return { topLevel: mkNullable(scope.topLevel), namespaces } as NullableScope<S>;\n}\n\nexport function orderByScopeOf<S extends Scope, R extends Record<string, ScopeField>>(\n scope: S,\n rowFields: R,\n): OrderByScope<S, R> {\n return {\n topLevel: { ...scope.topLevel, ...rowFields },\n namespaces: scope.namespaces,\n };\n}\n\nexport function assertCapability(\n ctx: BuilderContext,\n required: Record<string, Record<string, boolean>>,\n methodName: string,\n): void {\n for (const [ns, keys] of Object.entries(required)) {\n for (const key of Object.keys(keys)) {\n if (!ctx.capabilities[ns]?.[key]) {\n throw new Error(`${methodName}() requires capability ${ns}.${key}`);\n }\n }\n }\n}\n\nexport function resolveSelectArgs(\n args: unknown[],\n scope: Scope,\n ctx: BuilderContext,\n): { projections: ProjectionItem[]; newRowFields: Record<string, ScopeField> } {\n const projections: ProjectionItem[] = [];\n const newRowFields: Record<string, ScopeField> = {};\n\n if (args.length === 0) return { projections, newRowFields };\n\n if (typeof args[0] === 'string' && (args.length === 1 || typeof args[1] !== 'function')) {\n for (const colName of args as string[]) {\n const field = scope.topLevel[colName];\n if (!field) throw new Error(`Column \"${colName}\" not found in scope`);\n projections.push(ProjectionItem.of(colName, IdentifierRef.of(colName), field.codec));\n newRowFields[colName] = field;\n }\n return { projections, newRowFields };\n }\n\n if (typeof args[0] === 'string' && typeof args[1] === 'function') {\n const alias = args[0] as string;\n const exprFn = args[1] as (\n f: FieldProxy<Scope>,\n fns: AggregateFunctions<QueryContext>,\n ) => Expression<ScopeField>;\n const fns = createAggregateFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);\n const result = exprFn(createFieldProxy(scope), fns);\n const field = result.returnType;\n projections.push(ProjectionItem.of(alias, result.buildAst(), field.codec));\n newRowFields[alias] = field;\n return { projections, newRowFields };\n }\n\n if (typeof args[0] === 'function') {\n const callbackFn = args[0] as (\n f: FieldProxy<Scope>,\n fns: AggregateFunctions<QueryContext>,\n ) => Record<string, Expression<ScopeField>>;\n const fns = createAggregateFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);\n const record = callbackFn(createFieldProxy(scope), fns);\n for (const [key, expr] of Object.entries(record)) {\n const field = expr.returnType;\n projections.push(ProjectionItem.of(key, expr.buildAst(), field.codec));\n newRowFields[key] = field;\n }\n return { projections, newRowFields };\n }\n\n throw new Error('Invalid .select() arguments');\n}\n\nexport function resolveOrderBy(\n arg: unknown,\n options: OrderByOptions | undefined,\n scope: Scope,\n rowFields: Record<string, ScopeField>,\n ctx: BuilderContext,\n useAggregateFns: boolean,\n): OrderByItem {\n const dir = options?.direction ?? 'asc';\n\n if (typeof arg === 'string') {\n const combined = orderByScopeOf(scope, rowFields);\n if (!(arg in combined.topLevel))\n throw new Error(`Column \"${arg}\" not found in scope for orderBy`);\n const expr = IdentifierRef.of(arg);\n return dir === 'asc' ? OrderByItem.asc(expr) : OrderByItem.desc(expr);\n }\n\n if (typeof arg === 'function') {\n const combined = orderByScopeOf(scope, rowFields);\n const fns = useAggregateFns\n ? createAggregateFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer)\n : createFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);\n const result = (arg as ExprCallback)(createFieldProxy(combined), fns);\n return dir === 'asc' ? OrderByItem.asc(result.buildAst()) : OrderByItem.desc(result.buildAst());\n }\n\n throw new Error('Invalid orderBy argument');\n}\n\nexport function resolveGroupBy(\n args: unknown[],\n scope: Scope,\n rowFields: Record<string, ScopeField>,\n ctx: BuilderContext,\n): AstExpression[] {\n if (typeof args[0] === 'string') {\n const combined = orderByScopeOf(scope, rowFields);\n return (args as string[]).map((colName) => {\n if (!(colName in combined.topLevel))\n throw new Error(`Column \"${colName}\" not found in scope for groupBy`);\n return IdentifierRef.of(colName);\n });\n }\n\n if (typeof args[0] === 'function') {\n const combined = orderByScopeOf(scope, rowFields);\n const fns = createFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);\n const result = (args[0] as ExprCallback)(createFieldProxy(combined), fns);\n return [result.buildAst()];\n }\n\n throw new Error('Invalid groupBy arguments');\n}\n\nexport function resolveDistinctOn(\n args: unknown[],\n scope: Scope,\n rowFields: Record<string, ScopeField>,\n ctx: BuilderContext,\n): AstExpression[] {\n if (args.length === 1 && typeof args[0] === 'function') {\n const combined = orderByScopeOf(scope, rowFields);\n const fns = createFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);\n const result = (args[0] as ExprCallback)(createFieldProxy(combined), fns);\n return [result.buildAst()];\n }\n const combined = orderByScopeOf(scope, rowFields);\n return (args as string[]).map((colName) => {\n if (!(colName in combined.topLevel))\n throw new Error(`Column \"${colName}\" not found in scope for distinctOn`);\n return IdentifierRef.of(colName);\n });\n}\n","import type {\n AnnotationValue,\n OperationKind,\n ValidAnnotations,\n} from '@prisma-next/framework-components/runtime';\nimport { assertAnnotationsApplicable } from '@prisma-next/framework-components/runtime';\nimport { DerivedTableSource, type SelectAst } from '@prisma-next/sql-relational-core/ast';\nimport { toExpr } from '@prisma-next/sql-relational-core/expression';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport type {\n AggregateFunctions,\n BooleanCodecType,\n Expression,\n ExpressionBuilder,\n ExtractScopeFields,\n FieldProxy,\n Functions,\n OrderByOptions,\n OrderByScope,\n WithField,\n WithFields,\n} from '../expression';\nimport type { ResolveRow } from '../resolve';\nimport type {\n Expand,\n JoinOuterScope,\n JoinSource,\n QueryContext,\n Scope,\n ScopeField,\n // biome-ignore lint/correctness/noUnusedImports: used in `declare` property\n SubqueryMarker,\n} from '../scope';\nimport type { GroupedQuery } from '../types/grouped-query';\nimport type { SelectQuery } from '../types/select-query';\nimport type { PaginationValue } from '../types/shared';\nimport {\n BuilderBase,\n type BuilderContext,\n type BuilderState,\n buildPlan,\n buildSelectAst,\n cloneState,\n orderByScopeOf,\n resolveDistinctOn,\n resolveGroupBy,\n resolveOrderBy,\n resolveSelectArgs,\n} from './builder-base';\nimport { createFieldProxy } from './field-proxy';\nimport { createAggregateFunctions, createFunctions } from './functions';\n\nabstract class QueryBase<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n> extends BuilderBase<QC['capabilities']> {\n protected readonly state: BuilderState;\n\n constructor(state: BuilderState, ctx: BuilderContext) {\n super(ctx);\n this.state = state;\n }\n\n protected abstract clone(state: BuilderState): this;\n\n distinctOn = this._gate(\n { postgres: { distinctOn: true } },\n 'distinctOn',\n (...args: unknown[]) => {\n const exprs = resolveDistinctOn(args, this.state.scope, this.state.rowFields, this.ctx);\n return this.clone(\n cloneState(this.state, {\n distinctOn: [...(this.state.distinctOn ?? []), ...exprs],\n }),\n );\n },\n );\n\n limit(count: PaginationValue<QC>): this {\n const limit = typeof count === 'number' ? count : toExpr(count);\n return this.clone(cloneState(this.state, { limit }));\n }\n\n offset(count: PaginationValue<QC>): this {\n const offset = typeof count === 'number' ? count : toExpr(count);\n return this.clone(cloneState(this.state, { offset }));\n }\n\n distinct(): this {\n return this.clone(cloneState(this.state, { distinct: true }));\n }\n\n /**\n * Attach one or more annotations to this query plan.\n *\n * Read builders (`SelectQueryImpl`, `GroupedQueryImpl`) accept\n * annotations whose declared `applicableTo` includes `'read'`.\n * The type-level `As & ValidAnnotations<'read', As>` gate rejects\n * write-only annotations at the call site; the runtime check below\n * fails closed for callers that bypass the type gate (cast / `any`).\n *\n * Multiple `.annotate(...)` calls compose; duplicate namespaces use\n * last-write-wins. The accumulated annotations are merged into\n * `plan.meta.annotations` at `.build()` time, alongside any framework-\n * internal metadata under reserved namespaces (e.g. `codecs`).\n *\n * Chainable in any position (before / after `.where`, `.select`,\n * `.limit`, etc.); the returned builder has the same row type.\n */\n annotate<As extends readonly AnnotationValue<unknown, OperationKind>[]>(\n ...annotations: As & ValidAnnotations<'read', As>\n ): this {\n assertAnnotationsApplicable(\n annotations as readonly AnnotationValue<unknown, OperationKind>[],\n 'read',\n 'sql-dsl.annotate',\n );\n const next = new Map(this.state.annotations);\n for (const annotation of annotations as readonly AnnotationValue<unknown, OperationKind>[]) {\n next.set(annotation.namespace, annotation);\n }\n return this.clone(cloneState(this.state, { annotations: next }));\n }\n\n groupBy(\n ...fields: ((keyof RowType | keyof AvailableScope['topLevel']) & string)[]\n ): GroupedQuery<QC, AvailableScope, RowType>;\n groupBy(\n expr: (\n fields: FieldProxy<OrderByScope<AvailableScope, RowType>>,\n fns: Functions<QC>,\n ) => Expression<ScopeField>,\n ): GroupedQuery<QC, AvailableScope, RowType>;\n groupBy(...args: unknown[]): unknown {\n const exprs = resolveGroupBy(args, this.state.scope, this.state.rowFields, this.ctx);\n return new GroupedQueryImpl<QC, AvailableScope, RowType>(\n cloneState(this.state, { groupBy: [...this.state.groupBy, ...exprs] }),\n this.ctx,\n );\n }\n\n as<Alias extends string>(alias: Alias): JoinSource<RowType, Alias> {\n const ast = buildSelectAst(this.state);\n const derivedSource = DerivedTableSource.as(alias, ast);\n const scope = {\n topLevel: this.state.rowFields as RowType,\n namespaces: { [alias]: this.state.rowFields } as Record<Alias, RowType>,\n };\n return {\n getJoinOuterScope: () => scope,\n buildAst: () => derivedSource,\n\n // `as unknown` is necessary, because JoinOuterScope is a phantom type-only property that does not exist at runtime\n } satisfies Omit<JoinSource<RowType, Alias>, typeof JoinOuterScope> as unknown as JoinSource<\n RowType,\n Alias\n >;\n }\n\n getRowFields(): Record<string, ScopeField> {\n return this.state.rowFields;\n }\n\n buildAst(): SelectAst {\n return buildSelectAst(this.state);\n }\n\n build(): SqlQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>> {\n return buildPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>>(\n this.state,\n this.ctx,\n );\n }\n}\n\nexport class SelectQueryImpl<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n >\n extends QueryBase<QC, AvailableScope, RowType>\n implements SelectQuery<QC, AvailableScope, RowType>\n{\n declare readonly [SubqueryMarker]: RowType;\n\n protected clone(state: BuilderState): this {\n return new SelectQueryImpl<QC, AvailableScope, RowType>(state, this.ctx) as this;\n }\n\n select<Columns extends (keyof AvailableScope['topLevel'] & string)[]>(\n ...columns: Columns\n ): SelectQuery<QC, AvailableScope, WithFields<RowType, AvailableScope['topLevel'], Columns>>;\n select<Alias extends string, Field extends ScopeField>(\n alias: Alias,\n expr: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Expression<Field>,\n ): SelectQuery<QC, AvailableScope, WithField<RowType, Field, Alias>>;\n select<Result extends Record<string, Expression<ScopeField>>>(\n callback: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Result,\n ): SelectQuery<QC, AvailableScope, Expand<RowType & ExtractScopeFields<Result>>>;\n select(...args: unknown[]): unknown {\n const { projections, newRowFields } = resolveSelectArgs(args, this.state.scope, this.ctx);\n return new SelectQueryImpl(\n cloneState(this.state, {\n projections: [...this.state.projections, ...projections],\n rowFields: { ...this.state.rowFields, ...newRowFields },\n }),\n this.ctx,\n );\n }\n\n where(expr: ExpressionBuilder<AvailableScope, QC>): SelectQuery<QC, AvailableScope, RowType> {\n const fieldProxy = createFieldProxy(this.state.scope);\n const fns = createFunctions<QC>(this.ctx.queryOperationTypes, this.ctx.rawCodecInferer);\n const result = (expr as ExpressionBuilder<Scope, QueryContext>)(fieldProxy, fns as never);\n return new SelectQueryImpl(\n cloneState(this.state, {\n where: [...this.state.where, result.buildAst()],\n }),\n this.ctx,\n );\n }\n\n orderBy(\n field: (keyof RowType | keyof AvailableScope['topLevel']) & string,\n options?: OrderByOptions,\n ): SelectQuery<QC, AvailableScope, RowType>;\n orderBy(\n expr: (\n fields: FieldProxy<OrderByScope<AvailableScope, RowType>>,\n fns: Functions<QC>,\n ) => Expression<ScopeField>,\n options?: OrderByOptions,\n ): SelectQuery<QC, AvailableScope, RowType>;\n orderBy(arg: unknown, options?: OrderByOptions): unknown {\n const item = resolveOrderBy(\n arg,\n options,\n this.state.scope,\n this.state.rowFields,\n this.ctx,\n false,\n );\n return this.clone(cloneState(this.state, { orderBy: [...this.state.orderBy, item] }));\n }\n}\n\nexport class GroupedQueryImpl<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n >\n extends QueryBase<QC, AvailableScope, RowType>\n implements GroupedQuery<QC, AvailableScope, RowType>\n{\n declare readonly [SubqueryMarker]: RowType;\n\n protected clone(state: BuilderState): this {\n return new GroupedQueryImpl<QC, AvailableScope, RowType>(state, this.ctx) as this;\n }\n\n having(\n expr: (\n fields: FieldProxy<OrderByScope<AvailableScope, RowType>>,\n fns: AggregateFunctions<QC>,\n ) => Expression<BooleanCodecType>,\n ): GroupedQuery<QC, AvailableScope, RowType> {\n const combined = orderByScopeOf(\n this.state.scope as AvailableScope,\n this.state.rowFields as RowType,\n );\n const fns = createAggregateFunctions<QC>(\n this.ctx.queryOperationTypes,\n this.ctx.rawCodecInferer,\n );\n const result = expr(createFieldProxy(combined), fns);\n return new GroupedQueryImpl(cloneState(this.state, { having: result.buildAst() }), this.ctx);\n }\n\n orderBy(\n field: (keyof RowType | keyof AvailableScope['topLevel']) & string,\n options?: OrderByOptions,\n ): GroupedQuery<QC, AvailableScope, RowType>;\n orderBy(\n expr: (\n fields: FieldProxy<OrderByScope<AvailableScope, RowType>>,\n fns: AggregateFunctions<QC>,\n ) => Expression<ScopeField>,\n options?: OrderByOptions,\n ): GroupedQuery<QC, AvailableScope, RowType>;\n orderBy(arg: unknown, options?: OrderByOptions): unknown {\n const item = resolveOrderBy(\n arg,\n options,\n this.state.scope,\n this.state.rowFields,\n this.ctx,\n true,\n );\n return this.clone(cloneState(this.state, { orderBy: [...this.state.orderBy, item] }));\n }\n}\n","import {\n AndExpr,\n DerivedTableSource,\n JoinAst,\n type TableSource,\n} from '@prisma-next/sql-relational-core/ast';\nimport type {\n AggregateFunctions,\n Expression,\n ExpressionBuilder,\n ExtractScopeFields,\n FieldProxy,\n WithField,\n WithFields,\n} from '../expression';\nimport type {\n EmptyRow,\n Expand,\n JoinOuterScope,\n JoinSource,\n MergeScopes,\n NullableScope,\n QueryContext,\n Scope,\n ScopeField,\n ScopeTable,\n Subquery,\n} from '../scope';\nimport type { JoinedTables } from '../types/joined-tables';\nimport type { SelectQuery } from '../types/select-query';\nimport type { LateralBuilder } from '../types/shared';\nimport {\n BuilderBase,\n type BuilderContext,\n type BuilderState,\n cloneState,\n emptyState,\n mergeScopes,\n nullableScope,\n resolveSelectArgs,\n} from './builder-base';\nimport { createFieldProxy } from './field-proxy';\nimport { createFunctions } from './functions';\nimport { SelectQueryImpl } from './query-impl';\n\nexport class JoinedTablesImpl<QC extends QueryContext, AvailableScope extends Scope>\n extends BuilderBase<QC['capabilities']>\n implements JoinedTables<QC, AvailableScope>\n{\n readonly #state: BuilderState;\n\n constructor(state: BuilderState, ctx: BuilderContext) {\n super(ctx);\n this.#state = state;\n }\n\n lateralJoin = this._gate(\n { sql: { lateral: true } },\n 'lateralJoin',\n <Alias extends string, LateralRow extends Record<string, ScopeField>>(\n alias: Alias,\n builder: (lateral: LateralBuilder<QC, AvailableScope>) => Subquery<LateralRow>,\n ): JoinedTables<\n QC,\n MergeScopes<AvailableScope, { topLevel: LateralRow; namespaces: Record<Alias, LateralRow> }>\n > => {\n const { derivedSource, lateralScope } = this.#buildLateral(alias, builder);\n const resultScope = mergeScopes(\n this.#state.scope as AvailableScope,\n lateralScope as { topLevel: LateralRow; namespaces: Record<Alias, LateralRow> },\n );\n return this.#addLateralJoin('inner', resultScope, derivedSource);\n },\n ) as JoinedTables<QC, AvailableScope>['lateralJoin'];\n\n outerLateralJoin = this._gate(\n { sql: { lateral: true } },\n 'outerLateralJoin',\n <Alias extends string, LateralRow extends Record<string, ScopeField>>(\n alias: Alias,\n builder: (lateral: LateralBuilder<QC, AvailableScope>) => Subquery<LateralRow>,\n ): JoinedTables<\n QC,\n MergeScopes<\n AvailableScope,\n NullableScope<{ topLevel: LateralRow; namespaces: Record<Alias, LateralRow> }>\n >\n > => {\n const { derivedSource, lateralScope } = this.#buildLateral(alias, builder);\n const resultScope = mergeScopes(\n this.#state.scope as AvailableScope,\n nullableScope(\n lateralScope as { topLevel: LateralRow; namespaces: Record<Alias, LateralRow> },\n ),\n );\n return this.#addLateralJoin('left', resultScope, derivedSource);\n },\n ) as JoinedTables<QC, AvailableScope>['outerLateralJoin'];\n\n select<Columns extends (keyof AvailableScope['topLevel'] & string)[]>(\n ...columns: Columns\n ): SelectQuery<QC, AvailableScope, WithFields<EmptyRow, AvailableScope['topLevel'], Columns>>;\n select<Alias extends string, Field extends ScopeField>(\n alias: Alias,\n expr: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Expression<Field>,\n ): SelectQuery<QC, AvailableScope, WithField<EmptyRow, Field, Alias>>;\n select<Result extends Record<string, Expression<ScopeField>>>(\n callback: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Result,\n ): SelectQuery<QC, AvailableScope, Expand<ExtractScopeFields<Result>>>;\n select(...args: unknown[]): unknown {\n const { projections, newRowFields } = resolveSelectArgs(args, this.#state.scope, this.ctx);\n return new SelectQueryImpl<QC, AvailableScope>(\n cloneState(this.#state, {\n projections: [...this.#state.projections, ...projections],\n rowFields: { ...this.#state.rowFields, ...newRowFields },\n }),\n this.ctx,\n );\n }\n\n innerJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>> {\n const targetScope = mergeScopes(\n this.#state.scope as AvailableScope,\n other.getJoinOuterScope() as Other[typeof JoinOuterScope],\n );\n return this.#addJoin(other, 'inner', targetScope, on);\n }\n\n outerLeftJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<AvailableScope, NullableScope<Other[typeof JoinOuterScope]>>> {\n const targetScope = mergeScopes(\n this.#state.scope as AvailableScope,\n nullableScope(other.getJoinOuterScope() as Other[typeof JoinOuterScope]),\n );\n return this.#addJoin(other, 'left', targetScope, on);\n }\n\n outerRightJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<NullableScope<AvailableScope>, Other[typeof JoinOuterScope]>> {\n const targetScope = mergeScopes(\n nullableScope(this.#state.scope as AvailableScope),\n other.getJoinOuterScope() as Other[typeof JoinOuterScope],\n );\n return this.#addJoin(other, 'right', targetScope, on);\n }\n\n outerFullJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<\n QC,\n MergeScopes<NullableScope<AvailableScope>, NullableScope<Other[typeof JoinOuterScope]>>\n > {\n const targetScope = mergeScopes(\n nullableScope(this.#state.scope as AvailableScope),\n nullableScope(other.getJoinOuterScope() as Other[typeof JoinOuterScope]),\n );\n return this.#addJoin(other, 'full', targetScope, on);\n }\n\n #addJoin<Other extends JoinSource<ScopeTable, string | never>, ResultScope extends Scope>(\n other: Other,\n joinType: 'inner' | 'left' | 'right' | 'full',\n resultScope: ResultScope,\n onExpr: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, ResultScope> {\n const fieldProxy = createFieldProxy(\n mergeScopes(\n this.#state.scope as AvailableScope,\n other.getJoinOuterScope() as Other[typeof JoinOuterScope],\n ),\n ) as FieldProxy<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>>;\n const fns = createFunctions<QC>(this.ctx.queryOperationTypes, this.ctx.rawCodecInferer);\n const onResult = onExpr(fieldProxy, fns);\n const joinAst = new JoinAst(joinType, other.buildAst(), onResult.buildAst());\n\n return new JoinedTablesImpl(\n cloneState(this.#state, {\n joins: [...this.#state.joins, joinAst],\n scope: resultScope,\n }),\n this.ctx,\n );\n }\n\n #buildLateral(\n alias: string,\n builderFn: (\n lateral: LateralBuilder<QC, AvailableScope>,\n ) => Subquery<Record<string, ScopeField>>,\n ) {\n const lateralBuilder: LateralBuilder<QC, AvailableScope> = {\n from: (other) => {\n const otherScope = other.getJoinOuterScope();\n const parentMerged = mergeScopes(this.#state.scope, otherScope);\n return new SelectQueryImpl(\n emptyState(other.buildAst() as TableSource, parentMerged),\n this.ctx,\n ) as unknown as SelectQuery<QC, AvailableScope, EmptyRow>;\n },\n };\n\n const subquery = builderFn(lateralBuilder);\n const subqueryAst = subquery.buildAst();\n const derivedSource = DerivedTableSource.as(alias, subqueryAst);\n const subqueryRowFields: ScopeTable = subquery.getRowFields();\n const lateralScope: Scope = {\n topLevel: subqueryRowFields,\n namespaces: { [alias]: subqueryRowFields },\n };\n\n return { derivedSource, lateralScope };\n }\n\n #addLateralJoin<ResultScope extends Scope>(\n joinType: 'inner' | 'left',\n resultScope: ResultScope,\n derivedSource: DerivedTableSource,\n ): JoinedTables<QC, ResultScope> {\n const onExpr = AndExpr.of([]);\n const joinAst = new JoinAst(joinType, derivedSource, onExpr, true);\n\n return new JoinedTablesImpl(\n cloneState(this.#state, {\n joins: [...this.#state.joins, joinAst],\n scope: resultScope,\n }),\n this.ctx,\n );\n }\n}\n","import type {\n AnnotationValue,\n OperationKind,\n ValidAnnotations,\n} from '@prisma-next/framework-components/runtime';\nimport { assertAnnotationsApplicable } from '@prisma-next/framework-components/runtime';\nimport type { StorageTable } from '@prisma-next/sql-contract/types';\nimport {\n type AnyExpression as AstExpression,\n ColumnRef,\n DeleteAst,\n InsertAst,\n ParamRef,\n ProjectionItem,\n TableSource,\n UpdateAst,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport type { MutationDefaultsOp } from '@prisma-next/sql-relational-core/query-lane-context';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Expression, ExpressionBuilder } from '../expression';\nimport type { ResolveRow } from '../resolve';\nimport type { QueryContext, Scope, ScopeField } from '../scope';\nimport type {\n DeleteQuery,\n InsertQuery,\n ReturningCapability,\n UpdateQuery,\n} from '../types/mutation-query';\nimport {\n BuilderBase,\n type BuilderContext,\n buildQueryPlan,\n codecRefFor,\n combineWhereExprs,\n} from './builder-base';\nimport { createFieldProxy } from './field-proxy';\nimport { createFunctions } from './functions';\n\n/**\n * Validates and merges a variadic annotations call into a builder's\n * accumulated user-annotations map. Used by `.annotate(...)` on each of\n * the three mutation builders (`InsertQueryImpl`, `UpdateQueryImpl`,\n * `DeleteQueryImpl`); the read builders share the same logic via\n * `QueryBase.annotate()` in `./query-impl.ts`.\n *\n * Runs `assertAnnotationsApplicable` at call time (not at `.build()`) so\n * inapplicable annotations forced through casts surface immediately\n * rather than at plan-construction time.\n */\nfunction mergeWriteAnnotations(\n current: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>,\n annotations: readonly AnnotationValue<unknown, OperationKind>[],\n): ReadonlyMap<string, AnnotationValue<unknown, OperationKind>> {\n assertAnnotationsApplicable(annotations, 'write', 'sql-dsl.annotate');\n const next = new Map(current);\n for (const annotation of annotations) {\n next.set(annotation.namespace, annotation);\n }\n return next;\n}\n\ntype WhereCallback = ExpressionBuilder<Scope, QueryContext>;\nexport type UpdateSetCallback = (\n fields: ReturnType<typeof createFieldProxy>,\n fns: ReturnType<typeof createFunctions>,\n) => Record<string, Expression<ScopeField> | undefined>;\n\nexport function buildParamValues(\n values: Record<string, unknown>,\n table: StorageTable,\n tableName: string,\n op: MutationDefaultsOp,\n ctx: BuilderContext,\n): Record<string, ParamRef> {\n const params: Record<string, ParamRef> = {};\n for (const [col, value] of Object.entries(values)) {\n const column = table.columns[col];\n const codec = column ? codecRefFor(ctx, tableName, col) : undefined;\n params[col] = ParamRef.of(value, codec ? { codec } : undefined);\n }\n for (const def of ctx.applyMutationDefaults({ op, table: tableName, values })) {\n const column = table.columns[def.column];\n const codec = column ? codecRefFor(ctx, tableName, def.column) : undefined;\n params[def.column] = ParamRef.of(def.value, codec ? { codec } : undefined);\n }\n return params;\n}\n\nfunction buildReturningProjections(\n tableName: string,\n columns: string[],\n rowFields: Record<string, ScopeField>,\n): ProjectionItem[] {\n return columns.map((col) =>\n ProjectionItem.of(col, ColumnRef.of(tableName, col), rowFields[col]?.codec),\n );\n}\n\nfunction evaluateWhere(\n whereCallback: WhereCallback,\n scope: Scope,\n queryOperationTypes: BuilderContext['queryOperationTypes'],\n rawCodecInferer: BuilderContext['rawCodecInferer'],\n): AstExpression {\n const fieldProxy = createFieldProxy(scope);\n const fns = createFunctions(queryOperationTypes, rawCodecInferer);\n const result = whereCallback(fieldProxy, fns as never);\n return result.buildAst();\n}\n\nexport function evaluateUpdateCallback(\n callback: UpdateSetCallback,\n scope: Scope,\n queryOperationTypes: BuilderContext['queryOperationTypes'],\n rawCodecInferer: BuilderContext['rawCodecInferer'],\n): Record<string, AstExpression> {\n const fieldProxy = createFieldProxy(scope);\n const fns = createFunctions(queryOperationTypes, rawCodecInferer);\n const result = callback(fieldProxy, fns as never);\n const set: Record<string, AstExpression> = {};\n for (const [col, expr] of Object.entries(result)) {\n if (expr !== undefined) {\n set[col] = expr.buildAst();\n }\n }\n return set;\n}\n\nexport function buildSetExpressions(\n exprs: Record<string, AstExpression>,\n table: StorageTable,\n tableName: string,\n op: MutationDefaultsOp,\n ctx: BuilderContext,\n): Record<string, AstExpression> {\n const set: Record<string, AstExpression> = { ...exprs };\n for (const def of ctx.applyMutationDefaults({ op, table: tableName, values: exprs })) {\n if (!(def.column in set)) {\n const column = table.columns[def.column];\n const codec = column ? codecRefFor(ctx, tableName, def.column) : undefined;\n set[def.column] = ParamRef.of(def.value, ifDefined('codec', codec));\n }\n }\n return set;\n}\n\nexport class InsertQueryImpl<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n >\n extends BuilderBase<QC['capabilities']>\n implements InsertQuery<QC, AvailableScope, RowType>\n{\n readonly #tableName: string;\n readonly #table: StorageTable;\n readonly #scope: Scope;\n readonly #rows: ReadonlyArray<Record<string, unknown>>;\n readonly #returningColumns: string[];\n readonly #rowFields: Record<string, ScopeField>;\n readonly #annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>;\n\n constructor(\n tableName: string,\n table: StorageTable,\n scope: Scope,\n rows: ReadonlyArray<Record<string, unknown>>,\n ctx: BuilderContext,\n returningColumns: string[] = [],\n rowFields: Record<string, ScopeField> = {},\n annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>> = new Map(),\n ) {\n super(ctx);\n this.#tableName = tableName;\n this.#table = table;\n this.#scope = scope;\n this.#rows = rows;\n this.#returningColumns = returningColumns;\n this.#rowFields = rowFields;\n this.#annotations = annotations;\n }\n\n returning = this._gate<ReturningCapability, string[], InsertQuery<QC, AvailableScope, never>>(\n { sql: { returning: true } },\n 'returning',\n (...columns: string[]) => {\n const newRowFields: Record<string, ScopeField> = {};\n for (const col of columns) {\n const field = this.#scope.topLevel[col];\n if (!field) throw new Error(`Column \"${col}\" not found in scope`);\n newRowFields[col] = field;\n }\n return new InsertQueryImpl(\n this.#tableName,\n this.#table,\n this.#scope,\n this.#rows,\n this.ctx,\n columns,\n newRowFields,\n this.#annotations,\n ) as unknown as InsertQuery<QC, AvailableScope, never>;\n },\n );\n\n /**\n * Attach one or more write-typed annotations to this query plan.\n * The type-level `As & ValidAnnotations<'write', As>` gate rejects\n * read-only annotations at the call site; the runtime check fails\n * closed for callers that bypass the type gate. See `QueryBase.annotate`\n * in `./query-impl.ts` for the read-builder counterpart.\n */\n annotate<As extends readonly AnnotationValue<unknown, OperationKind>[]>(\n ...annotations: As & ValidAnnotations<'write', As>\n ): InsertQuery<QC, AvailableScope, RowType> {\n return new InsertQueryImpl(\n this.#tableName,\n this.#table,\n this.#scope,\n this.#rows,\n this.ctx,\n this.#returningColumns,\n this.#rowFields,\n mergeWriteAnnotations(\n this.#annotations,\n annotations as readonly AnnotationValue<unknown, OperationKind>[],\n ),\n );\n }\n\n build(): SqlQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>> {\n if (this.#rows.length === 0) {\n throw new Error('insert() called with an empty row array — at least one row is required');\n }\n\n const paramRows = this.#rows.map((rowValues) =>\n buildParamValues(rowValues, this.#table, this.#tableName, 'create', this.ctx),\n );\n\n let ast = InsertAst.into(TableSource.named(this.#tableName)).withRows(paramRows);\n\n if (this.#returningColumns.length > 0) {\n ast = ast.withReturning(\n buildReturningProjections(this.#tableName, this.#returningColumns, this.#rowFields),\n );\n }\n\n return buildQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>>(\n ast,\n this.ctx,\n this.#annotations,\n );\n }\n}\n\nexport class UpdateQueryImpl<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n >\n extends BuilderBase<QC['capabilities']>\n implements UpdateQuery<QC, AvailableScope, RowType>\n{\n readonly #tableName: string;\n readonly #scope: Scope;\n readonly #setExpressions: Record<string, AstExpression>;\n readonly #whereExprs: readonly AstExpression[];\n readonly #returningColumns: string[];\n readonly #rowFields: Record<string, ScopeField>;\n readonly #annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>;\n\n constructor(\n tableName: string,\n scope: Scope,\n setExpressions: Record<string, AstExpression>,\n ctx: BuilderContext,\n whereExprs: readonly AstExpression[] = [],\n returningColumns: string[] = [],\n rowFields: Record<string, ScopeField> = {},\n annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>> = new Map(),\n ) {\n super(ctx);\n this.#tableName = tableName;\n this.#scope = scope;\n this.#setExpressions = setExpressions;\n this.#whereExprs = whereExprs;\n this.#returningColumns = returningColumns;\n this.#rowFields = rowFields;\n this.#annotations = annotations;\n }\n\n where(expr: ExpressionBuilder<AvailableScope, QC>): UpdateQuery<QC, AvailableScope, RowType> {\n const fieldProxy = createFieldProxy(this.#scope);\n const fns = createFunctions(this.ctx.queryOperationTypes, this.ctx.rawCodecInferer);\n const result = (expr as ExpressionBuilder<Scope, QueryContext>)(fieldProxy, fns as never);\n return new UpdateQueryImpl(\n this.#tableName,\n this.#scope,\n this.#setExpressions,\n this.ctx,\n [...this.#whereExprs, result.buildAst()],\n this.#returningColumns,\n this.#rowFields,\n this.#annotations,\n );\n }\n\n returning = this._gate<ReturningCapability, string[], UpdateQuery<QC, AvailableScope, never>>(\n { sql: { returning: true } },\n 'returning',\n (...columns: string[]) => {\n const newRowFields: Record<string, ScopeField> = {};\n for (const col of columns) {\n const field = this.#scope.topLevel[col];\n if (!field) throw new Error(`Column \"${col}\" not found in scope`);\n newRowFields[col] = field;\n }\n return new UpdateQueryImpl(\n this.#tableName,\n this.#scope,\n this.#setExpressions,\n this.ctx,\n this.#whereExprs,\n columns,\n newRowFields,\n this.#annotations,\n ) as unknown as UpdateQuery<QC, AvailableScope, never>;\n },\n );\n\n /**\n * Attach one or more write-typed annotations to this query plan.\n * See `InsertQueryImpl.annotate` for semantics; the runtime check\n * fails closed for callers that bypass the type-level gate.\n */\n annotate<As extends readonly AnnotationValue<unknown, OperationKind>[]>(\n ...annotations: As & ValidAnnotations<'write', As>\n ): UpdateQuery<QC, AvailableScope, RowType> {\n return new UpdateQueryImpl(\n this.#tableName,\n this.#scope,\n this.#setExpressions,\n this.ctx,\n this.#whereExprs,\n this.#returningColumns,\n this.#rowFields,\n mergeWriteAnnotations(\n this.#annotations,\n annotations as readonly AnnotationValue<unknown, OperationKind>[],\n ),\n );\n }\n\n build(): SqlQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>> {\n let ast = UpdateAst.table(TableSource.named(this.#tableName))\n .withSet(this.#setExpressions)\n .withWhere(combineWhereExprs(this.#whereExprs));\n\n if (this.#returningColumns.length > 0) {\n ast = ast.withReturning(\n buildReturningProjections(this.#tableName, this.#returningColumns, this.#rowFields),\n );\n }\n\n return buildQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>>(\n ast,\n this.ctx,\n this.#annotations,\n );\n }\n}\n\nexport class DeleteQueryImpl<\n QC extends QueryContext = QueryContext,\n AvailableScope extends Scope = Scope,\n RowType extends Record<string, ScopeField> = Record<string, ScopeField>,\n >\n extends BuilderBase<QC['capabilities']>\n implements DeleteQuery<QC, AvailableScope, RowType>\n{\n readonly #tableName: string;\n readonly #scope: Scope;\n readonly #whereCallbacks: readonly WhereCallback[];\n readonly #returningColumns: string[];\n readonly #rowFields: Record<string, ScopeField>;\n readonly #annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>>;\n\n constructor(\n tableName: string,\n scope: Scope,\n ctx: BuilderContext,\n whereCallbacks: readonly WhereCallback[] = [],\n returningColumns: string[] = [],\n rowFields: Record<string, ScopeField> = {},\n annotations: ReadonlyMap<string, AnnotationValue<unknown, OperationKind>> = new Map(),\n ) {\n super(ctx);\n this.#tableName = tableName;\n this.#scope = scope;\n this.#whereCallbacks = whereCallbacks;\n this.#returningColumns = returningColumns;\n this.#rowFields = rowFields;\n this.#annotations = annotations;\n }\n\n where(expr: ExpressionBuilder<AvailableScope, QC>): DeleteQuery<QC, AvailableScope, RowType> {\n return new DeleteQueryImpl(\n this.#tableName,\n this.#scope,\n this.ctx,\n [...this.#whereCallbacks, expr as unknown as WhereCallback],\n this.#returningColumns,\n this.#rowFields,\n this.#annotations,\n );\n }\n\n returning = this._gate<ReturningCapability, string[], DeleteQuery<QC, AvailableScope, never>>(\n { sql: { returning: true } },\n 'returning',\n (...columns: string[]) => {\n const newRowFields: Record<string, ScopeField> = {};\n for (const col of columns) {\n const field = this.#scope.topLevel[col];\n if (!field) throw new Error(`Column \"${col}\" not found in scope`);\n newRowFields[col] = field;\n }\n return new DeleteQueryImpl(\n this.#tableName,\n this.#scope,\n this.ctx,\n this.#whereCallbacks,\n columns,\n newRowFields,\n this.#annotations,\n ) as unknown as DeleteQuery<QC, AvailableScope, never>;\n },\n );\n\n /**\n * Attach one or more write-typed annotations to this query plan.\n * See `InsertQueryImpl.annotate` for semantics.\n */\n annotate<As extends readonly AnnotationValue<unknown, OperationKind>[]>(\n ...annotations: As & ValidAnnotations<'write', As>\n ): DeleteQuery<QC, AvailableScope, RowType> {\n return new DeleteQueryImpl(\n this.#tableName,\n this.#scope,\n this.ctx,\n this.#whereCallbacks,\n this.#returningColumns,\n this.#rowFields,\n mergeWriteAnnotations(\n this.#annotations,\n annotations as readonly AnnotationValue<unknown, OperationKind>[],\n ),\n );\n }\n\n build(): SqlQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>> {\n const whereExpr = combineWhereExprs(\n this.#whereCallbacks.map((cb) =>\n evaluateWhere(cb, this.#scope, this.ctx.queryOperationTypes, this.ctx.rawCodecInferer),\n ),\n );\n\n let ast = DeleteAst.from(TableSource.named(this.#tableName)).withWhere(whereExpr);\n\n if (this.#returningColumns.length > 0) {\n ast = ast.withReturning(\n buildReturningProjections(this.#tableName, this.#returningColumns, this.#rowFields),\n );\n }\n\n return buildQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>>(\n ast,\n this.ctx,\n this.#annotations,\n );\n }\n}\n","import type { StorageTable } from '@prisma-next/sql-contract/types';\nimport { type AnyFromSource, TableSource } from '@prisma-next/sql-relational-core/ast';\nimport type {\n AggregateFunctions,\n Expression,\n ExpressionBuilder,\n ExtractScopeFields,\n FieldProxy,\n Functions,\n WithField,\n WithFields,\n} from '../expression';\nimport type {\n EmptyRow,\n Expand,\n JoinOuterScope,\n JoinSource,\n MergeScopes,\n NullableScope,\n QueryContext,\n RebindScope,\n Scope,\n ScopeField,\n ScopeTable,\n StorageTableToScopeTable,\n Subquery,\n} from '../scope';\nimport type { TableProxyContract, UnboundTables } from '../types/db';\nimport type { JoinedTables } from '../types/joined-tables';\nimport type { DeleteQuery, InsertQuery, UpdateQuery } from '../types/mutation-query';\nimport type { SelectQuery } from '../types/select-query';\nimport type { LateralBuilder } from '../types/shared';\nimport type { TableProxy } from '../types/table-proxy';\nimport { BuilderBase, type BuilderContext, emptyState, tableToScope } from './builder-base';\nimport { JoinedTablesImpl } from './joined-tables-impl';\nimport {\n buildParamValues,\n buildSetExpressions,\n DeleteQueryImpl,\n evaluateUpdateCallback,\n InsertQueryImpl,\n UpdateQueryImpl,\n type UpdateSetCallback,\n} from './mutation-impl';\nimport { SelectQueryImpl } from './query-impl';\n\nexport class TableProxyImpl<\n C extends TableProxyContract,\n Name extends string & keyof UnboundTables<C>,\n Alias extends string,\n AvailableScope extends Scope,\n QC extends QueryContext,\n >\n extends BuilderBase<C['capabilities']>\n implements TableProxy<C, Name, Alias, AvailableScope, QC>\n{\n declare readonly [JoinOuterScope]: JoinSource<\n StorageTableToScopeTable<UnboundTables<C>[Name]>,\n Alias\n >[typeof JoinOuterScope];\n\n readonly #tableName: string;\n readonly #table: StorageTable;\n readonly #fromSource: TableSource;\n readonly #scope: Scope;\n\n constructor(tableName: string, table: StorageTable, alias: string, ctx: BuilderContext) {\n super(ctx);\n this.#tableName = tableName;\n this.#table = table;\n this.#scope = tableToScope(alias, table, { storage: ctx.storage, tableName });\n this.#fromSource = TableSource.named(tableName, alias !== tableName ? alias : undefined);\n }\n\n lateralJoin = this._gate(\n { sql: { lateral: true } },\n 'lateralJoin',\n <LAlias extends string, LateralRow extends Record<string, ScopeField>>(\n alias: LAlias,\n builder: (lateral: LateralBuilder<QC, AvailableScope>) => Subquery<LateralRow>,\n ): JoinedTables<\n QC,\n MergeScopes<AvailableScope, { topLevel: LateralRow; namespaces: Record<LAlias, LateralRow> }>\n > => {\n return this.#toJoined().lateralJoin(alias, builder);\n },\n ) as TableProxy<C, Name, Alias, AvailableScope, QC>['lateralJoin'];\n\n outerLateralJoin = this._gate(\n { sql: { lateral: true } },\n 'outerLateralJoin',\n <LAlias extends string, LateralRow extends Record<string, ScopeField>>(\n alias: LAlias,\n builder: (lateral: LateralBuilder<QC, AvailableScope>) => Subquery<LateralRow>,\n ): JoinedTables<\n QC,\n MergeScopes<\n AvailableScope,\n NullableScope<{ topLevel: LateralRow; namespaces: Record<LAlias, LateralRow> }>\n >\n > => {\n return this.#toJoined().outerLateralJoin(alias, builder);\n },\n ) as TableProxy<C, Name, Alias, AvailableScope, QC>['outerLateralJoin'];\n\n getJoinOuterScope(): Scope {\n return this.#scope;\n }\n\n buildAst(): AnyFromSource {\n return this.#fromSource;\n }\n\n as<NewAlias extends string>(\n newAlias: NewAlias,\n ): TableProxy<C, Name, NewAlias, RebindScope<AvailableScope, Alias, NewAlias>, QC> {\n return new TableProxyImpl(this.#tableName, this.#table, newAlias, this.ctx);\n }\n\n select<Columns extends (keyof AvailableScope['topLevel'] & string)[]>(\n ...columns: Columns\n ): SelectQuery<QC, AvailableScope, WithFields<EmptyRow, AvailableScope['topLevel'], Columns>>;\n select<LAlias extends string, Field extends ScopeField>(\n alias: LAlias,\n expr: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Expression<Field>,\n ): SelectQuery<QC, AvailableScope, WithField<EmptyRow, Field, LAlias>>;\n select<Result extends Record<string, Expression<ScopeField>>>(\n callback: (fields: FieldProxy<AvailableScope>, fns: AggregateFunctions<QC>) => Result,\n ): SelectQuery<QC, AvailableScope, Expand<ExtractScopeFields<Result>>>;\n select(...args: unknown[]): unknown {\n return new SelectQueryImpl(emptyState(this.#fromSource, this.#scope), this.ctx).select(\n ...(args as string[]),\n );\n }\n\n innerJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>> {\n return this.#toJoined().innerJoin(other, on);\n }\n\n outerLeftJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<AvailableScope, NullableScope<Other[typeof JoinOuterScope]>>> {\n return this.#toJoined().outerLeftJoin(other, on);\n }\n\n outerRightJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<QC, MergeScopes<NullableScope<AvailableScope>, Other[typeof JoinOuterScope]>> {\n return this.#toJoined().outerRightJoin(other, on);\n }\n\n outerFullJoin<Other extends JoinSource<ScopeTable, string | never>>(\n other: Other,\n on: ExpressionBuilder<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>, QC>,\n ): JoinedTables<\n QC,\n MergeScopes<NullableScope<AvailableScope>, NullableScope<Other[typeof JoinOuterScope]>>\n > {\n return this.#toJoined().outerFullJoin(other, on);\n }\n\n insert(rows: ReadonlyArray<Record<string, unknown>>): InsertQuery<QC, AvailableScope, EmptyRow> {\n return new InsertQueryImpl(this.#tableName, this.#table, this.#scope, rows, this.ctx);\n }\n\n update(\n setOrCallback:\n | Record<string, unknown>\n | ((\n fields: FieldProxy<AvailableScope>,\n fns: Functions<QC>,\n ) => Record<string, Expression<ScopeField> | undefined>),\n ): UpdateQuery<QC, AvailableScope, EmptyRow> {\n if (typeof setOrCallback === 'function') {\n const callbackExprs = evaluateUpdateCallback(\n setOrCallback as UpdateSetCallback,\n this.#scope,\n this.ctx.queryOperationTypes,\n this.ctx.rawCodecInferer,\n );\n const setExpressions = buildSetExpressions(\n callbackExprs,\n this.#table,\n this.#tableName,\n 'update',\n this.ctx,\n );\n return new UpdateQueryImpl(this.#tableName, this.#scope, setExpressions, this.ctx);\n }\n const setExpressions = buildParamValues(\n setOrCallback,\n this.#table,\n this.#tableName,\n 'update',\n this.ctx,\n );\n return new UpdateQueryImpl(this.#tableName, this.#scope, setExpressions, this.ctx);\n }\n\n delete(): DeleteQuery<QC, AvailableScope, EmptyRow> {\n return new DeleteQueryImpl(this.#tableName, this.#scope, this.ctx);\n }\n\n #toJoined(): JoinedTables<QC, AvailableScope> {\n return new JoinedTablesImpl(emptyState(this.#fromSource, this.#scope), this.ctx);\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlStorage, StorageTable } from '@prisma-next/sql-contract/types';\nimport type { RawCodecInferer } from '@prisma-next/sql-relational-core/expression';\nimport type { ExecutionContext } from '@prisma-next/sql-relational-core/query-lane-context';\nimport type { Db, TableProxyContract } from '../types/db';\nimport type { BuilderContext } from './builder-base';\nimport { TableProxyImpl } from './table-proxy-impl';\n\nexport interface SqlOptions<C extends Contract<SqlStorage> & TableProxyContract> {\n readonly context: ExecutionContext<C>;\n readonly rawCodecInferer: RawCodecInferer;\n}\n\n// Find a table by name across every declared namespace. Mirrors the\n// flat-DSL contract (db.<tableName>): the first namespace that declares\n// `name` wins. Name collisions across namespaces are a type-level error\n// at the DSL call site; landing the namespace-aware DSL is tracked\n// separately.\nfunction findTableAcrossNamespaces(storage: SqlStorage, name: string): StorageTable | undefined {\n for (const ns of Object.values(storage.namespaces)) {\n const tables = (ns as { tables?: Readonly<Record<string, StorageTable>> }).tables ?? {};\n if (Object.hasOwn(tables, name)) {\n return tables[name];\n }\n }\n return undefined;\n}\n\nexport function sql<C extends Contract<SqlStorage> & TableProxyContract>(\n options: SqlOptions<C>,\n): Db<C> {\n const { context, rawCodecInferer } = options;\n const ctx: BuilderContext = {\n capabilities: context.contract.capabilities,\n queryOperationTypes: context.queryOperations.entries(),\n target: context.contract.target ?? 'unknown',\n storageHash: context.contract.storage.storageHash ?? 'unknown',\n storage: context.contract.storage,\n applyMutationDefaults: (options) => context.applyMutationDefaults(options),\n rawCodecInferer,\n };\n\n return new Proxy({} as Db<C>, {\n get(_target, prop: string) {\n const table = findTableAcrossNamespaces(context.contract.storage, prop);\n if (table) {\n return new TableProxyImpl(prop, table, prop, ctx);\n }\n return undefined;\n },\n });\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAa,iBAAb,MAAwF;CACtF;CACA;CACA;CAEA,YAAY,KAAoB,YAAe,OAAkB;EAC/D,KAAK,MAAM;EACX,KAAK,aAAa;EAClB,KAAK,QAAQ;CACf;CAEA,WAA0B;EACxB,OAAO,KAAK;CACd;AACF;;;ACnB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M,MAAsB;EAC1B,cAAc,QAAQ,SAAS;EAC/B,qBAAqB,QAAQ,gBAAgB,QAAQ;EACrD,QAAQ,QAAQ,SAAS,UAAU;EACnC,aAAa,QAAQ,SAAS,QAAQ,eAAe;EACrD,SAAS,QAAQ,SAAS;EAC1B,wBAAwB,YAAY,QAAQ,sBAAsB,OAAO;EACzE;CACF;CAEA,OAAO,IAAI,MAAM,CAAC,GAAY,EAC5B,IAAI,SAAS,MAAc;EACzB,MAAM,QAAQ,0BAA0B,QAAQ,SAAS,SAAS,IAAI;EACtE,IAAI,OACF,OAAO,IAAI,eAAe,MAAM,OAAO,MAAM,GAAG;CAGpD,EACF,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sql-builder",
|
|
3
|
-
"version": "0.11.0-dev.
|
|
3
|
+
"version": "0.11.0-dev.61",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "SQL builder lane for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/contract": "0.11.0-dev.
|
|
10
|
-
"@prisma-next/framework-components": "0.11.0-dev.
|
|
11
|
-
"@prisma-next/sql-contract": "0.11.0-dev.
|
|
12
|
-
"@prisma-next/sql-operations": "0.11.0-dev.
|
|
13
|
-
"@prisma-next/sql-relational-core": "0.11.0-dev.
|
|
9
|
+
"@prisma-next/contract": "0.11.0-dev.61",
|
|
10
|
+
"@prisma-next/framework-components": "0.11.0-dev.61",
|
|
11
|
+
"@prisma-next/sql-contract": "0.11.0-dev.61",
|
|
12
|
+
"@prisma-next/sql-operations": "0.11.0-dev.61",
|
|
13
|
+
"@prisma-next/sql-relational-core": "0.11.0-dev.61"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@prisma-next/adapter-postgres": "0.11.0-dev.
|
|
17
|
-
"@prisma-next/ids": "0.11.0-dev.
|
|
18
|
-
"@prisma-next/sql-contract-ts": "0.11.0-dev.
|
|
19
|
-
"@prisma-next/target-postgres": "0.11.0-dev.
|
|
20
|
-
"@prisma-next/test-utils": "0.11.0-dev.
|
|
21
|
-
"@prisma-next/utils": "0.11.0-dev.
|
|
22
|
-
"@prisma-next/tsconfig": "0.11.0-dev.
|
|
23
|
-
"@prisma-next/tsdown": "0.11.0-dev.
|
|
16
|
+
"@prisma-next/adapter-postgres": "0.11.0-dev.61",
|
|
17
|
+
"@prisma-next/ids": "0.11.0-dev.61",
|
|
18
|
+
"@prisma-next/sql-contract-ts": "0.11.0-dev.61",
|
|
19
|
+
"@prisma-next/target-postgres": "0.11.0-dev.61",
|
|
20
|
+
"@prisma-next/test-utils": "0.11.0-dev.61",
|
|
21
|
+
"@prisma-next/utils": "0.11.0-dev.61",
|
|
22
|
+
"@prisma-next/tsconfig": "0.11.0-dev.61",
|
|
23
|
+
"@prisma-next/tsdown": "0.11.0-dev.61",
|
|
24
24
|
"tsdown": "0.22.0",
|
|
25
25
|
"typescript": "5.9.3",
|
|
26
26
|
"vitest": "4.1.6"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsdown",
|
|
49
|
-
"emit": "cd ../../../../test/integration && node ../../packages/1-framework/3-tooling/cli/dist/cli.js contract emit --config test/sql-builder/fixtures/prisma-next.config.ts && cp test/sql-builder/fixtures/generated/contract.json ../../packages/2-sql/4-lanes/sql-builder/test/fixtures/generated/",
|
|
49
|
+
"emit": "cd ../../../../test/integration && node ../../packages/1-framework/3-tooling/cli/dist/cli.js contract emit --config test/sql-builder/fixtures/prisma-next.config.ts && cp test/sql-builder/fixtures/generated/contract.json test/sql-builder/fixtures/generated/contract.d.ts ../../packages/2-sql/4-lanes/sql-builder/test/fixtures/generated/",
|
|
50
50
|
"emit:check": "pnpm emit && git diff --exit-code test/fixtures/generated/",
|
|
51
51
|
"test": "vitest run --passWithNoTests",
|
|
52
52
|
"~test:coverage": "vitest run --coverage --passWithNoTests",
|
package/src/expression.ts
CHANGED
|
@@ -2,11 +2,12 @@ import type { QueryOperationTypesBase } from '@prisma-next/sql-contract/types';
|
|
|
2
2
|
import type {
|
|
3
3
|
CodecExpression,
|
|
4
4
|
Expression,
|
|
5
|
+
RawSqlTag,
|
|
5
6
|
TraitExpression,
|
|
6
7
|
} from '@prisma-next/sql-relational-core/expression';
|
|
7
8
|
import type { Expand, QueryContext, Scope, ScopeField, ScopeTable, Subquery } from './scope';
|
|
8
9
|
|
|
9
|
-
export type { CodecExpression, Expression, TraitExpression };
|
|
10
|
+
export type { CodecExpression, Expression, RawSqlTag, TraitExpression };
|
|
10
11
|
|
|
11
12
|
export type BooleanCodecType = { codecId: 'pg/bool@1'; nullable: boolean };
|
|
12
13
|
|
|
@@ -111,6 +112,8 @@ export type BuiltinFunctions<CT extends Record<string, { readonly input: unknown
|
|
|
111
112
|
values: Array<CodecExpression<CodecId, boolean, CT>>,
|
|
112
113
|
): Expression<BooleanCodecType>;
|
|
113
114
|
};
|
|
115
|
+
|
|
116
|
+
readonly raw: RawSqlTag;
|
|
114
117
|
};
|
|
115
118
|
|
|
116
119
|
export type Functions<QC extends QueryContext> = BuiltinFunctions<QC['codecTypes']> &
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
type TableSource,
|
|
16
16
|
} from '@prisma-next/sql-relational-core/ast';
|
|
17
17
|
import { codecRefForStorageColumn } from '@prisma-next/sql-relational-core/codec-descriptor-registry';
|
|
18
|
+
import type { RawCodecInferer } from '@prisma-next/sql-relational-core/expression';
|
|
18
19
|
import type { SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';
|
|
19
20
|
import type {
|
|
20
21
|
AppliedMutationDefault,
|
|
@@ -95,6 +96,10 @@ export interface BuilderContext {
|
|
|
95
96
|
readonly applyMutationDefaults: (
|
|
96
97
|
options: MutationDefaultsOptions,
|
|
97
98
|
) => ReadonlyArray<AppliedMutationDefault>;
|
|
99
|
+
/**
|
|
100
|
+
* Codec inferer used inside `createBuiltinFunctions` to construct the raw-SQL tag — `fns.raw` dispatches through `inferCodec(value)` for bare-literal interpolations.
|
|
101
|
+
*/
|
|
102
|
+
readonly rawCodecInferer: RawCodecInferer;
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
/**
|
|
@@ -294,7 +299,7 @@ export function resolveSelectArgs(
|
|
|
294
299
|
f: FieldProxy<Scope>,
|
|
295
300
|
fns: AggregateFunctions<QueryContext>,
|
|
296
301
|
) => Expression<ScopeField>;
|
|
297
|
-
const fns = createAggregateFunctions(ctx.queryOperationTypes);
|
|
302
|
+
const fns = createAggregateFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);
|
|
298
303
|
const result = exprFn(createFieldProxy(scope), fns);
|
|
299
304
|
const field = result.returnType;
|
|
300
305
|
projections.push(ProjectionItem.of(alias, result.buildAst(), field.codec));
|
|
@@ -307,7 +312,7 @@ export function resolveSelectArgs(
|
|
|
307
312
|
f: FieldProxy<Scope>,
|
|
308
313
|
fns: AggregateFunctions<QueryContext>,
|
|
309
314
|
) => Record<string, Expression<ScopeField>>;
|
|
310
|
-
const fns = createAggregateFunctions(ctx.queryOperationTypes);
|
|
315
|
+
const fns = createAggregateFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);
|
|
311
316
|
const record = callbackFn(createFieldProxy(scope), fns);
|
|
312
317
|
for (const [key, expr] of Object.entries(record)) {
|
|
313
318
|
const field = expr.returnType;
|
|
@@ -341,8 +346,8 @@ export function resolveOrderBy(
|
|
|
341
346
|
if (typeof arg === 'function') {
|
|
342
347
|
const combined = orderByScopeOf(scope, rowFields);
|
|
343
348
|
const fns = useAggregateFns
|
|
344
|
-
? createAggregateFunctions(ctx.queryOperationTypes)
|
|
345
|
-
: createFunctions(ctx.queryOperationTypes);
|
|
349
|
+
? createAggregateFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer)
|
|
350
|
+
: createFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);
|
|
346
351
|
const result = (arg as ExprCallback)(createFieldProxy(combined), fns);
|
|
347
352
|
return dir === 'asc' ? OrderByItem.asc(result.buildAst()) : OrderByItem.desc(result.buildAst());
|
|
348
353
|
}
|
|
@@ -367,7 +372,7 @@ export function resolveGroupBy(
|
|
|
367
372
|
|
|
368
373
|
if (typeof args[0] === 'function') {
|
|
369
374
|
const combined = orderByScopeOf(scope, rowFields);
|
|
370
|
-
const fns = createFunctions(ctx.queryOperationTypes);
|
|
375
|
+
const fns = createFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);
|
|
371
376
|
const result = (args[0] as ExprCallback)(createFieldProxy(combined), fns);
|
|
372
377
|
return [result.buildAst()];
|
|
373
378
|
}
|
|
@@ -383,7 +388,7 @@ export function resolveDistinctOn(
|
|
|
383
388
|
): AstExpression[] {
|
|
384
389
|
if (args.length === 1 && typeof args[0] === 'function') {
|
|
385
390
|
const combined = orderByScopeOf(scope, rowFields);
|
|
386
|
-
const fns = createFunctions(ctx.queryOperationTypes);
|
|
391
|
+
const fns = createFunctions(ctx.queryOperationTypes, ctx.rawCodecInferer);
|
|
387
392
|
const result = (args[0] as ExprCallback)(createFieldProxy(combined), fns);
|
|
388
393
|
return [result.buildAst()];
|
|
389
394
|
}
|
package/src/runtime/functions.ts
CHANGED
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
OrExpr,
|
|
14
14
|
SubqueryExpr,
|
|
15
15
|
} from '@prisma-next/sql-relational-core/ast';
|
|
16
|
-
import {
|
|
16
|
+
import type { RawCodecInferer } from '@prisma-next/sql-relational-core/expression';
|
|
17
|
+
import { codecOf, createRawSql, toExpr } from '@prisma-next/sql-relational-core/expression';
|
|
17
18
|
import type {
|
|
18
19
|
AggregateFunctions,
|
|
19
20
|
AggregateOnlyFunctions,
|
|
@@ -134,7 +135,7 @@ function numericAgg(
|
|
|
134
135
|
});
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
function createBuiltinFunctions() {
|
|
138
|
+
function createBuiltinFunctions(rawCodecInferer: RawCodecInferer) {
|
|
138
139
|
return {
|
|
139
140
|
eq: (a: ExprOrVal, b: ExprOrVal) => eq(a, b),
|
|
140
141
|
ne: (a: ExprOrVal, b: ExprOrVal) => ne(a, b),
|
|
@@ -158,6 +159,7 @@ function createBuiltinFunctions() {
|
|
|
158
159
|
expr: Expression<ScopeField>,
|
|
159
160
|
valuesOrSubquery: Subquery<Record<string, ScopeField>> | ExprOrVal[],
|
|
160
161
|
) => inOrNotIn(expr, valuesOrSubquery, 'notIn'),
|
|
162
|
+
raw: createRawSql(rawCodecInferer),
|
|
161
163
|
} satisfies BuiltinFunctions<CodecTypes>;
|
|
162
164
|
}
|
|
163
165
|
|
|
@@ -179,13 +181,15 @@ function createAggregateOnlyFunctions() {
|
|
|
179
181
|
|
|
180
182
|
export function createFunctions<QC extends QueryContext>(
|
|
181
183
|
operations: Readonly<Record<string, SqlOperationEntry>>,
|
|
184
|
+
rawCodecInferer: RawCodecInferer,
|
|
182
185
|
): Functions<QC> {
|
|
183
|
-
const builtins = createBuiltinFunctions();
|
|
186
|
+
const builtins = createBuiltinFunctions(rawCodecInferer);
|
|
184
187
|
|
|
185
188
|
return new Proxy({} as Functions<QC>, {
|
|
186
189
|
get(_target, prop: string) {
|
|
187
|
-
|
|
188
|
-
|
|
190
|
+
if (Object.hasOwn(builtins, prop)) {
|
|
191
|
+
return (builtins as Record<string, unknown>)[prop];
|
|
192
|
+
}
|
|
189
193
|
|
|
190
194
|
const op = operations[prop];
|
|
191
195
|
if (op) return op.impl;
|
|
@@ -196,8 +200,9 @@ export function createFunctions<QC extends QueryContext>(
|
|
|
196
200
|
|
|
197
201
|
export function createAggregateFunctions<QC extends QueryContext>(
|
|
198
202
|
operations: Readonly<Record<string, SqlOperationEntry>>,
|
|
203
|
+
rawCodecInferer: RawCodecInferer,
|
|
199
204
|
): AggregateFunctions<QC> {
|
|
200
|
-
const baseFns = createFunctions<QC>(operations);
|
|
205
|
+
const baseFns = createFunctions<QC>(operations, rawCodecInferer);
|
|
201
206
|
const aggregates = createAggregateOnlyFunctions();
|
|
202
207
|
|
|
203
208
|
return new Proxy({} as AggregateFunctions<QC>, {
|
|
@@ -177,7 +177,7 @@ export class JoinedTablesImpl<QC extends QueryContext, AvailableScope extends Sc
|
|
|
177
177
|
other.getJoinOuterScope() as Other[typeof JoinOuterScope],
|
|
178
178
|
),
|
|
179
179
|
) as FieldProxy<MergeScopes<AvailableScope, Other[typeof JoinOuterScope]>>;
|
|
180
|
-
const fns = createFunctions<QC>(this.ctx.queryOperationTypes);
|
|
180
|
+
const fns = createFunctions<QC>(this.ctx.queryOperationTypes, this.ctx.rawCodecInferer);
|
|
181
181
|
const onResult = onExpr(fieldProxy, fns);
|
|
182
182
|
const joinAst = new JoinAst(joinType, other.buildAst(), onResult.buildAst());
|
|
183
183
|
|
|
@@ -101,9 +101,10 @@ function evaluateWhere(
|
|
|
101
101
|
whereCallback: WhereCallback,
|
|
102
102
|
scope: Scope,
|
|
103
103
|
queryOperationTypes: BuilderContext['queryOperationTypes'],
|
|
104
|
+
rawCodecInferer: BuilderContext['rawCodecInferer'],
|
|
104
105
|
): AstExpression {
|
|
105
106
|
const fieldProxy = createFieldProxy(scope);
|
|
106
|
-
const fns = createFunctions(queryOperationTypes);
|
|
107
|
+
const fns = createFunctions(queryOperationTypes, rawCodecInferer);
|
|
107
108
|
const result = whereCallback(fieldProxy, fns as never);
|
|
108
109
|
return result.buildAst();
|
|
109
110
|
}
|
|
@@ -112,9 +113,10 @@ export function evaluateUpdateCallback(
|
|
|
112
113
|
callback: UpdateSetCallback,
|
|
113
114
|
scope: Scope,
|
|
114
115
|
queryOperationTypes: BuilderContext['queryOperationTypes'],
|
|
116
|
+
rawCodecInferer: BuilderContext['rawCodecInferer'],
|
|
115
117
|
): Record<string, AstExpression> {
|
|
116
118
|
const fieldProxy = createFieldProxy(scope);
|
|
117
|
-
const fns = createFunctions(queryOperationTypes);
|
|
119
|
+
const fns = createFunctions(queryOperationTypes, rawCodecInferer);
|
|
118
120
|
const result = callback(fieldProxy, fns as never);
|
|
119
121
|
const set: Record<string, AstExpression> = {};
|
|
120
122
|
for (const [col, expr] of Object.entries(result)) {
|
|
@@ -290,7 +292,7 @@ export class UpdateQueryImpl<
|
|
|
290
292
|
|
|
291
293
|
where(expr: ExpressionBuilder<AvailableScope, QC>): UpdateQuery<QC, AvailableScope, RowType> {
|
|
292
294
|
const fieldProxy = createFieldProxy(this.#scope);
|
|
293
|
-
const fns = createFunctions(this.ctx.queryOperationTypes);
|
|
295
|
+
const fns = createFunctions(this.ctx.queryOperationTypes, this.ctx.rawCodecInferer);
|
|
294
296
|
const result = (expr as ExpressionBuilder<Scope, QueryContext>)(fieldProxy, fns as never);
|
|
295
297
|
return new UpdateQueryImpl(
|
|
296
298
|
this.#tableName,
|
|
@@ -460,7 +462,7 @@ export class DeleteQueryImpl<
|
|
|
460
462
|
build(): SqlQueryPlan<ResolveRow<RowType, QC['codecTypes'], QC['resolvedColumnOutputTypes']>> {
|
|
461
463
|
const whereExpr = combineWhereExprs(
|
|
462
464
|
this.#whereCallbacks.map((cb) =>
|
|
463
|
-
evaluateWhere(cb, this.#scope, this.ctx.queryOperationTypes),
|
|
465
|
+
evaluateWhere(cb, this.#scope, this.ctx.queryOperationTypes, this.ctx.rawCodecInferer),
|
|
464
466
|
),
|
|
465
467
|
);
|
|
466
468
|
|
|
@@ -211,7 +211,7 @@ export class SelectQueryImpl<
|
|
|
211
211
|
|
|
212
212
|
where(expr: ExpressionBuilder<AvailableScope, QC>): SelectQuery<QC, AvailableScope, RowType> {
|
|
213
213
|
const fieldProxy = createFieldProxy(this.state.scope);
|
|
214
|
-
const fns = createFunctions<QC>(this.ctx.queryOperationTypes);
|
|
214
|
+
const fns = createFunctions<QC>(this.ctx.queryOperationTypes, this.ctx.rawCodecInferer);
|
|
215
215
|
const result = (expr as ExpressionBuilder<Scope, QueryContext>)(fieldProxy, fns as never);
|
|
216
216
|
return new SelectQueryImpl(
|
|
217
217
|
cloneState(this.state, {
|
|
@@ -269,7 +269,10 @@ export class GroupedQueryImpl<
|
|
|
269
269
|
this.state.scope as AvailableScope,
|
|
270
270
|
this.state.rowFields as RowType,
|
|
271
271
|
);
|
|
272
|
-
const fns = createAggregateFunctions(
|
|
272
|
+
const fns = createAggregateFunctions<QC>(
|
|
273
|
+
this.ctx.queryOperationTypes,
|
|
274
|
+
this.ctx.rawCodecInferer,
|
|
275
|
+
);
|
|
273
276
|
const result = expr(createFieldProxy(combined), fns);
|
|
274
277
|
return new GroupedQueryImpl(cloneState(this.state, { having: result.buildAst() }), this.ctx);
|
|
275
278
|
}
|
package/src/runtime/sql.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Contract } from '@prisma-next/contract/types';
|
|
2
2
|
import type { SqlStorage, StorageTable } from '@prisma-next/sql-contract/types';
|
|
3
|
+
import type { RawCodecInferer } from '@prisma-next/sql-relational-core/expression';
|
|
3
4
|
import type { ExecutionContext } from '@prisma-next/sql-relational-core/query-lane-context';
|
|
4
5
|
import type { Db, TableProxyContract } from '../types/db';
|
|
5
6
|
import type { BuilderContext } from './builder-base';
|
|
@@ -7,6 +8,7 @@ import { TableProxyImpl } from './table-proxy-impl';
|
|
|
7
8
|
|
|
8
9
|
export interface SqlOptions<C extends Contract<SqlStorage> & TableProxyContract> {
|
|
9
10
|
readonly context: ExecutionContext<C>;
|
|
11
|
+
readonly rawCodecInferer: RawCodecInferer;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
// Find a table by name across every declared namespace. Mirrors the
|
|
@@ -27,7 +29,7 @@ function findTableAcrossNamespaces(storage: SqlStorage, name: string): StorageTa
|
|
|
27
29
|
export function sql<C extends Contract<SqlStorage> & TableProxyContract>(
|
|
28
30
|
options: SqlOptions<C>,
|
|
29
31
|
): Db<C> {
|
|
30
|
-
const { context } = options;
|
|
32
|
+
const { context, rawCodecInferer } = options;
|
|
31
33
|
const ctx: BuilderContext = {
|
|
32
34
|
capabilities: context.contract.capabilities,
|
|
33
35
|
queryOperationTypes: context.queryOperations.entries(),
|
|
@@ -35,6 +37,7 @@ export function sql<C extends Contract<SqlStorage> & TableProxyContract>(
|
|
|
35
37
|
storageHash: context.contract.storage.storageHash ?? 'unknown',
|
|
36
38
|
storage: context.contract.storage,
|
|
37
39
|
applyMutationDefaults: (options) => context.applyMutationDefaults(options),
|
|
40
|
+
rawCodecInferer,
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
return new Proxy({} as Db<C>, {
|
|
@@ -113,7 +113,7 @@ export class TableProxyImpl<
|
|
|
113
113
|
|
|
114
114
|
as<NewAlias extends string>(
|
|
115
115
|
newAlias: NewAlias,
|
|
116
|
-
): TableProxy<C, Name, NewAlias, RebindScope<AvailableScope, Alias, NewAlias
|
|
116
|
+
): TableProxy<C, Name, NewAlias, RebindScope<AvailableScope, Alias, NewAlias>, QC> {
|
|
117
117
|
return new TableProxyImpl(this.#tableName, this.#table, newAlias, this.ctx);
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -181,6 +181,7 @@ export class TableProxyImpl<
|
|
|
181
181
|
setOrCallback as UpdateSetCallback,
|
|
182
182
|
this.#scope,
|
|
183
183
|
this.ctx.queryOperationTypes,
|
|
184
|
+
this.ctx.rawCodecInferer,
|
|
184
185
|
);
|
|
185
186
|
const setExpressions = buildSetExpressions(
|
|
186
187
|
callbackExprs,
|
package/src/types/table-proxy.ts
CHANGED
|
@@ -119,7 +119,7 @@ type ResolvedUpdateExpressions<Table extends StorageTable> = {
|
|
|
119
119
|
}>;
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
type ContractToQC<C extends TableProxyContract, Name extends string = string> = {
|
|
122
|
+
export type ContractToQC<C extends TableProxyContract, Name extends string = string> = {
|
|
123
123
|
readonly codecTypes: ExtractCodecTypes<C>;
|
|
124
124
|
readonly capabilities: C['capabilities'];
|
|
125
125
|
readonly queryOperationTypes: ExtractQueryOperationTypes<C>;
|
|
@@ -137,7 +137,7 @@ export interface TableProxy<
|
|
|
137
137
|
WithJoin<QC, AvailableScope, C['capabilities']> {
|
|
138
138
|
as<NewAlias extends string>(
|
|
139
139
|
newAlias: NewAlias,
|
|
140
|
-
): TableProxy<C, Name, NewAlias, RebindScope<AvailableScope, Alias, NewAlias
|
|
140
|
+
): TableProxy<C, Name, NewAlias, RebindScope<AvailableScope, Alias, NewAlias>, QC>;
|
|
141
141
|
|
|
142
142
|
insert(
|
|
143
143
|
rows: ReadonlyArray<
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db-Tp8O0y-a.d.mts","names":[],"sources":["../src/scope.ts","../src/expression.ts","../src/resolve.ts","../src/types/mutation-query.ts","../src/types/joined-tables.ts","../src/types/grouped-query.ts","../src/types/select-query.ts","../src/types/shared.ts","../src/types/table-proxy.ts","../src/types/db.ts"],"mappings":";;;;;;;KASY,WAAA,mCAA8C,YAAA,SAAqB,QAAA,GAC3E,MAAA;AAAA,cAGiB,cAAA;AAAA,cACA,cAAA;AAAA,KAET,MAAA,oBAA0B,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KAChC,QAAA,GAAW,MAAA,QAAc,UAAA;AAAA,KAEzB,UAAA,GAAa,MAAA,SAAe,UAAA;AAAA,KAE5B,KAAA;EACV,QAAA,EAAU,UAAA;EACV,UAAA,EAAY,MAAA,SAAe,UAAA;AAAA;AAAA,KAGjB,UAAA,aAAuB,UAAA;EAAA,UACvB,cAAA;IACR,QAAA,EAAU,GAAA;IACV,UAAA,EAAY,MAAA,CAAO,KAAA,EAAO,GAAA;EAAA;EAG5B,iBAAA,IAAqB,KAAA;EACrB,QAAA,IAAY,aAAA;AAAA;AAAA,KAGF,YAAA,oCAAgD,cAAA;EAC1D,QAAA,EAAU,wBAAA,CAAyB,KAAA;EACnC,UAAA,UACQ,IAAA,GAAO,wBAAA,CAAyB,KAAA;AAAA;AAAA,KAI9B,wBAAA,WAAmC,cAAA,kBACjC,C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