@prisma-next/sql-relational-core 0.12.0-dev.4 → 0.12.0-dev.40
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/{codec-types-Cezo7k-i.d.mts → codec-types-Ey_MAEly.d.mts} +1 -1
- package/dist/{codec-types-Cezo7k-i.d.mts.map → codec-types-Ey_MAEly.d.mts.map} +1 -1
- package/dist/ddl-types-BV7GsGNt.d.mts +56 -0
- package/dist/ddl-types-BV7GsGNt.d.mts.map +1 -0
- package/dist/ddl-types-wqxUC57D.mjs +71 -0
- package/dist/ddl-types-wqxUC57D.mjs.map +1 -0
- package/dist/{errors-Bavu5wZA.d.mts → errors-CI1oIVmU.d.mts} +2 -2
- package/dist/{errors-Bavu5wZA.d.mts.map → errors-CI1oIVmU.d.mts.map} +1 -1
- package/dist/{errors-BF7W5uUd.mjs → errors-HvB_h2on.mjs} +1 -1
- package/dist/{errors-BF7W5uUd.mjs.map → errors-HvB_h2on.mjs.map} +1 -1
- package/dist/exports/ast.d.mts +5 -8
- package/dist/exports/ast.d.mts.map +1 -1
- package/dist/exports/ast.mjs +4 -3
- package/dist/exports/ast.mjs.map +1 -1
- package/dist/exports/codec-descriptor-registry.d.mts +2 -2
- package/dist/exports/contract-free.d.mts +149 -0
- package/dist/exports/contract-free.d.mts.map +1 -0
- package/dist/exports/contract-free.mjs +248 -0
- package/dist/exports/contract-free.mjs.map +1 -0
- package/dist/exports/errors.d.mts +1 -1
- package/dist/exports/errors.mjs +1 -1
- package/dist/exports/expression.d.mts +2 -2
- package/dist/exports/expression.mjs +1 -1
- package/dist/exports/middleware.d.mts +1 -1
- package/dist/exports/middleware.mjs +1 -1
- package/dist/exports/plan.d.mts +2 -2
- package/dist/exports/query-lane-context.d.mts +1 -1
- package/dist/exports/types.d.mts +3 -3
- package/dist/index.d.mts +12 -11
- package/dist/index.mjs +6 -5
- package/dist/{middleware-B0yz0pff.mjs → middleware-CbHPs9WK.mjs} +2 -2
- package/dist/{middleware-B0yz0pff.mjs.map → middleware-CbHPs9WK.mjs.map} +1 -1
- package/dist/{middleware-EOcO8Ogo.d.mts → middleware-DkAjjPxq.d.mts} +2 -2
- package/dist/{middleware-EOcO8Ogo.d.mts.map → middleware-DkAjjPxq.d.mts.map} +1 -1
- package/dist/{plan-CG3sy5kw.d.mts → plan-Ds9oN5QU.d.mts} +3 -3
- package/dist/{plan-CG3sy5kw.d.mts.map → plan-Ds9oN5QU.d.mts.map} +1 -1
- package/dist/{query-lane-context-Dw1Tz0kv.d.mts → query-lane-context-BUYT0tOb.d.mts} +3 -3
- package/dist/{query-lane-context-Dw1Tz0kv.d.mts.map → query-lane-context-BUYT0tOb.d.mts.map} +1 -1
- package/dist/{sql-execution-plan-D4OimCVH.d.mts → sql-execution-plan-Dopo3SDj.d.mts} +2 -2
- package/dist/{sql-execution-plan-D4OimCVH.d.mts.map → sql-execution-plan-Dopo3SDj.d.mts.map} +1 -1
- package/dist/{types-DoolOzqd.d.mts → types-CLirmH9F.d.mts} +8 -20
- package/dist/types-CLirmH9F.d.mts.map +1 -0
- package/dist/{types-C4EdOD-s.mjs → types-CMznS9Yh.mjs} +24 -5
- package/dist/types-CMznS9Yh.mjs.map +1 -0
- package/dist/{types-C_1ZqLwZ.d.mts → types-CXQF5KS8.d.mts} +19 -6
- package/dist/types-CXQF5KS8.d.mts.map +1 -0
- package/dist/{types-CkTDkFcK.d.mts → types-DRBn98H_.d.mts} +3 -3
- package/dist/{types-CkTDkFcK.d.mts.map → types-DRBn98H_.d.mts.map} +1 -1
- package/dist/{util-DWmhUCEO.mjs → util-DUXs0nZ9.mjs} +1 -1
- package/dist/{util-DWmhUCEO.mjs.map → util-DUXs0nZ9.mjs.map} +1 -1
- package/package.json +12 -11
- package/src/ast/adapter-types.ts +0 -5
- package/src/ast/ddl-types.ts +106 -0
- package/src/ast/types.ts +31 -6
- package/src/contract-free/column.ts +21 -0
- package/src/contract-free/dml.ts +17 -0
- package/src/contract-free/table.ts +390 -0
- package/src/exports/ast.ts +1 -0
- package/src/exports/contract-free.ts +18 -0
- package/src/types.ts +3 -23
- package/dist/types-C4EdOD-s.mjs.map +0 -1
- package/dist/types-C_1ZqLwZ.d.mts.map +0 -1
- package/dist/types-DoolOzqd.d.mts.map +0 -1
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { a as LiteralColumnDefault, i as FunctionColumnDefault, t as DdlColumn } from "../ddl-types-wqxUC57D.mjs";
|
|
2
|
+
import { A as SelectAst, C as OrExpr, D as ProjectionItem, N as UpdateAst, T as ParamRef, i as ColumnRef, m as InsertOnConflict, n as AndExpr, p as InsertAst, r as BinaryExpr, w as OrderByItem, x as NullCheckExpr } from "../types-CMznS9Yh.mjs";
|
|
3
|
+
import { blindCast } from "@prisma-next/utils/casts";
|
|
4
|
+
//#region src/contract-free/column.ts
|
|
5
|
+
function lit(value) {
|
|
6
|
+
return new LiteralColumnDefault(value);
|
|
7
|
+
}
|
|
8
|
+
function fn(expression) {
|
|
9
|
+
return new FunctionColumnDefault(expression);
|
|
10
|
+
}
|
|
11
|
+
function col(name, type, options) {
|
|
12
|
+
return new DdlColumn({
|
|
13
|
+
name,
|
|
14
|
+
type,
|
|
15
|
+
...options
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/contract-free/table.ts
|
|
20
|
+
/**
|
|
21
|
+
* A composable WHERE / ON expression. Wraps an `AnyExpression` and exposes
|
|
22
|
+
* fluent boolean combinators, mirroring the spirit of `sql-builder`'s
|
|
23
|
+
* `Expression` interface without the contract-bound type machinery.
|
|
24
|
+
*/
|
|
25
|
+
var CfExpr = class CfExpr {
|
|
26
|
+
ast;
|
|
27
|
+
constructor(ast) {
|
|
28
|
+
this.ast = ast;
|
|
29
|
+
}
|
|
30
|
+
and(other) {
|
|
31
|
+
return new CfExpr(AndExpr.of([this.ast, other.ast]));
|
|
32
|
+
}
|
|
33
|
+
or(other) {
|
|
34
|
+
return new CfExpr(OrExpr.of([this.ast, other.ast]));
|
|
35
|
+
}
|
|
36
|
+
not() {
|
|
37
|
+
return new CfExpr(this.ast.not());
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var CfInsertQuery = class CfInsertQuery {
|
|
41
|
+
src;
|
|
42
|
+
schema;
|
|
43
|
+
rowValues;
|
|
44
|
+
returningItems;
|
|
45
|
+
constructor(src, schema, rowValues, returningItems = void 0) {
|
|
46
|
+
this.src = src;
|
|
47
|
+
this.schema = schema;
|
|
48
|
+
this.rowValues = rowValues;
|
|
49
|
+
this.returningItems = returningItems;
|
|
50
|
+
}
|
|
51
|
+
returning(...columns) {
|
|
52
|
+
return new CfInsertQuery(this.src, this.schema, this.rowValues, columns.map((col) => col.toProjectionItem()));
|
|
53
|
+
}
|
|
54
|
+
build() {
|
|
55
|
+
const row = buildInsertRow(this.schema, this.rowValues);
|
|
56
|
+
const ast = InsertAst.into(this.src).withRows([row]);
|
|
57
|
+
return this.returningItems ? ast.withReturning(this.returningItems) : ast;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var CfUpsertBuilder = class {
|
|
61
|
+
src;
|
|
62
|
+
schema;
|
|
63
|
+
rowValues;
|
|
64
|
+
constructor(src, schema, rowValues) {
|
|
65
|
+
this.src = src;
|
|
66
|
+
this.schema = schema;
|
|
67
|
+
this.rowValues = rowValues;
|
|
68
|
+
}
|
|
69
|
+
onConflict(...columns) {
|
|
70
|
+
return new CfConflictClause(this.src, this.schema, this.rowValues, [...columns]);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var CfConflictClause = class {
|
|
74
|
+
src;
|
|
75
|
+
schema;
|
|
76
|
+
rowValues;
|
|
77
|
+
conflictCols;
|
|
78
|
+
constructor(src, schema, rowValues, conflictCols) {
|
|
79
|
+
this.src = src;
|
|
80
|
+
this.schema = schema;
|
|
81
|
+
this.rowValues = rowValues;
|
|
82
|
+
this.conflictCols = conflictCols;
|
|
83
|
+
}
|
|
84
|
+
doUpdate(setOrCallback) {
|
|
85
|
+
const set = typeof setOrCallback === "function" ? setOrCallback(buildExcludedProxy(this.schema)) : setOrCallback;
|
|
86
|
+
return new CfUpsertQuery(this.src, this.schema, this.rowValues, this.conflictCols, set);
|
|
87
|
+
}
|
|
88
|
+
doNothing() {
|
|
89
|
+
return new CfUpsertQuery(this.src, this.schema, this.rowValues, this.conflictCols, void 0);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var CfUpsertQuery = class {
|
|
93
|
+
src;
|
|
94
|
+
schema;
|
|
95
|
+
rowValues;
|
|
96
|
+
conflictCols;
|
|
97
|
+
updateSet;
|
|
98
|
+
constructor(src, schema, rowValues, conflictCols, updateSet) {
|
|
99
|
+
this.src = src;
|
|
100
|
+
this.schema = schema;
|
|
101
|
+
this.rowValues = rowValues;
|
|
102
|
+
this.conflictCols = conflictCols;
|
|
103
|
+
this.updateSet = updateSet;
|
|
104
|
+
}
|
|
105
|
+
build() {
|
|
106
|
+
const row = buildInsertRow(this.schema, this.rowValues);
|
|
107
|
+
const conflictRefs = this.conflictCols.map((col) => col.toRef());
|
|
108
|
+
const onConflict = this.updateSet === void 0 ? InsertOnConflict.on(conflictRefs).doNothing() : InsertOnConflict.on(conflictRefs).doUpdateSet(buildSetMap(this.schema, this.updateSet));
|
|
109
|
+
return InsertAst.into(this.src).withRows([row]).withOnConflict(onConflict);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var CfUpdateQuery = class CfUpdateQuery {
|
|
113
|
+
src;
|
|
114
|
+
schema;
|
|
115
|
+
setValues;
|
|
116
|
+
whereExpr;
|
|
117
|
+
returningItems;
|
|
118
|
+
constructor(src, schema, setValues = void 0, whereExpr = void 0, returningItems = void 0) {
|
|
119
|
+
this.src = src;
|
|
120
|
+
this.schema = schema;
|
|
121
|
+
this.setValues = setValues;
|
|
122
|
+
this.whereExpr = whereExpr;
|
|
123
|
+
this.returningItems = returningItems;
|
|
124
|
+
}
|
|
125
|
+
set(values) {
|
|
126
|
+
return new CfUpdateQuery(this.src, this.schema, values, this.whereExpr, this.returningItems);
|
|
127
|
+
}
|
|
128
|
+
where(expr) {
|
|
129
|
+
return new CfUpdateQuery(this.src, this.schema, this.setValues, expr, this.returningItems);
|
|
130
|
+
}
|
|
131
|
+
returning(...columns) {
|
|
132
|
+
return new CfUpdateQuery(this.src, this.schema, this.setValues, this.whereExpr, columns.map((col) => col.toProjectionItem()));
|
|
133
|
+
}
|
|
134
|
+
build() {
|
|
135
|
+
const set = buildSetMap(this.schema, this.setValues);
|
|
136
|
+
const base = UpdateAst.table(this.src).withSet(set);
|
|
137
|
+
const withWhere = this.whereExpr ? base.withWhere(this.whereExpr.ast) : base;
|
|
138
|
+
return this.returningItems ? withWhere.withReturning(this.returningItems) : withWhere;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var CfSelectQuery = class CfSelectQuery {
|
|
142
|
+
src;
|
|
143
|
+
projectionItems;
|
|
144
|
+
whereExpr;
|
|
145
|
+
orderByItems;
|
|
146
|
+
constructor(src, projectionItems, whereExpr = void 0, orderByItems = []) {
|
|
147
|
+
this.src = src;
|
|
148
|
+
this.projectionItems = projectionItems;
|
|
149
|
+
this.whereExpr = whereExpr;
|
|
150
|
+
this.orderByItems = orderByItems;
|
|
151
|
+
}
|
|
152
|
+
where(expr) {
|
|
153
|
+
return new CfSelectQuery(this.src, this.projectionItems, expr, this.orderByItems);
|
|
154
|
+
}
|
|
155
|
+
orderBy(column, dir = "asc") {
|
|
156
|
+
const item = dir === "asc" ? OrderByItem.asc(column.toRef()) : OrderByItem.desc(column.toRef());
|
|
157
|
+
return new CfSelectQuery(this.src, this.projectionItems, this.whereExpr, [...this.orderByItems, item]);
|
|
158
|
+
}
|
|
159
|
+
build() {
|
|
160
|
+
const base = SelectAst.from(this.src).withProjection(this.projectionItems);
|
|
161
|
+
const withWhere = this.whereExpr ? base.withWhere(this.whereExpr.ast) : base;
|
|
162
|
+
return this.orderByItems.length > 0 ? withWhere.withOrderBy(this.orderByItems) : withWhere;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Declare a control-plane table once, binding column codecs at declaration time.
|
|
167
|
+
* Returns a `TableHandle` whose column properties compose expressions directly
|
|
168
|
+
* without per-call-site codec or column-name threading.
|
|
169
|
+
*
|
|
170
|
+
* ```ts
|
|
171
|
+
* const marker = pgTable({ name: 'marker', schema: 'prisma_contract' }, {
|
|
172
|
+
* space: text(),
|
|
173
|
+
* core_hash: text(),
|
|
174
|
+
* updated_at: timestamptz(),
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* const query = marker.update()
|
|
178
|
+
* .set({ core_hash: newHash, updated_at: NOW })
|
|
179
|
+
* .where(marker.space.eq(space).and(marker.core_hash.eq(expectedFrom)))
|
|
180
|
+
* .returning(marker.space)
|
|
181
|
+
* .build();
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
function table(source, schema) {
|
|
185
|
+
const proxies = {};
|
|
186
|
+
for (const [col, desc] of Object.entries(schema)) proxies[col] = makeColumnProxy(source.alias ?? source.name, col, desc);
|
|
187
|
+
return blindCast({
|
|
188
|
+
...proxies,
|
|
189
|
+
source,
|
|
190
|
+
insert: (row) => new CfInsertQuery(source, schema, row),
|
|
191
|
+
upsert: (row) => new CfUpsertBuilder(source, schema, row),
|
|
192
|
+
update: () => new CfUpdateQuery(source, schema),
|
|
193
|
+
select: (...cols) => new CfSelectQuery(source, cols.map((col) => col.toProjectionItem()))
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function makeColumnProxy(tableName, columnName, desc) {
|
|
197
|
+
const ref = ColumnRef.of(tableName, columnName);
|
|
198
|
+
return {
|
|
199
|
+
codecId: desc.codecId,
|
|
200
|
+
nullable: desc.nullable,
|
|
201
|
+
columnName,
|
|
202
|
+
tableName,
|
|
203
|
+
eq: (value) => value === null ? new CfExpr(NullCheckExpr.isNull(ref)) : new CfExpr(BinaryExpr.eq(ref, toSetExpression(value, desc))),
|
|
204
|
+
neq: (value) => value === null ? new CfExpr(NullCheckExpr.isNotNull(ref)) : new CfExpr(BinaryExpr.neq(ref, toSetExpression(value, desc))),
|
|
205
|
+
isNull: () => new CfExpr(NullCheckExpr.isNull(ref)),
|
|
206
|
+
isNotNull: () => new CfExpr(NullCheckExpr.isNotNull(ref)),
|
|
207
|
+
toRef: () => ref,
|
|
208
|
+
toProjectionItem: (alias = columnName) => ProjectionItem.of(alias, ref, { codecId: desc.codecId })
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function buildExcludedProxy(schema) {
|
|
212
|
+
return blindCast(Object.fromEntries(Object.keys(schema).map((col) => [col, ColumnRef.of("excluded", col)])));
|
|
213
|
+
}
|
|
214
|
+
function isExpressionSource(value) {
|
|
215
|
+
return typeof value === "object" && value !== null && "toExpr" in value && typeof value.toExpr === "function";
|
|
216
|
+
}
|
|
217
|
+
function toInsertValue(value, desc) {
|
|
218
|
+
if (isExpressionSource(value)) {
|
|
219
|
+
const expr = value.toExpr();
|
|
220
|
+
if (expr.kind === "column-ref" || expr.kind === "param-ref" || expr.kind === "prepared-param-ref" || expr.kind === "raw-expr") return expr;
|
|
221
|
+
}
|
|
222
|
+
return ParamRef.of(value, { codec: { codecId: desc.codecId } });
|
|
223
|
+
}
|
|
224
|
+
function toSetExpression(value, desc) {
|
|
225
|
+
if (isExpressionSource(value)) return value.toExpr();
|
|
226
|
+
return ParamRef.of(value, { codec: { codecId: desc.codecId } });
|
|
227
|
+
}
|
|
228
|
+
function buildInsertRow(schema, values) {
|
|
229
|
+
const row = {};
|
|
230
|
+
const rawValues = blindCast(values);
|
|
231
|
+
for (const [col, desc] of Object.entries(schema)) row[col] = toInsertValue(rawValues[col], desc);
|
|
232
|
+
return row;
|
|
233
|
+
}
|
|
234
|
+
function buildSetMap(schema, values) {
|
|
235
|
+
if (values === void 0) return {};
|
|
236
|
+
const set = {};
|
|
237
|
+
const rawSchema = blindCast(schema);
|
|
238
|
+
const rawValues = blindCast(values);
|
|
239
|
+
for (const [col, value] of Object.entries(rawValues)) {
|
|
240
|
+
const desc = rawSchema[col];
|
|
241
|
+
if (desc !== void 0) set[col] = toSetExpression(value, desc);
|
|
242
|
+
}
|
|
243
|
+
return set;
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
246
|
+
export { CfConflictClause, CfExpr, CfInsertQuery, CfSelectQuery, CfUpdateQuery, CfUpsertBuilder, CfUpsertQuery, col, fn, lit, table };
|
|
247
|
+
|
|
248
|
+
//# sourceMappingURL=contract-free.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-free.mjs","names":[],"sources":["../../src/contract-free/column.ts","../../src/contract-free/table.ts"],"sourcesContent":["import type { ColumnDefaultLiteralInputValue } from '@prisma-next/contract/types';\nimport type { DdlColumnDefault } from '../ast/ddl-types';\nimport { DdlColumn, FunctionColumnDefault, LiteralColumnDefault } from '../ast/ddl-types';\n\nexport interface DdlColumnOptions {\n readonly notNull?: boolean;\n readonly primaryKey?: boolean;\n readonly default?: DdlColumnDefault;\n}\n\nexport function lit(value: ColumnDefaultLiteralInputValue): LiteralColumnDefault {\n return new LiteralColumnDefault(value);\n}\n\nexport function fn(expression: string): FunctionColumnDefault {\n return new FunctionColumnDefault(expression);\n}\n\nexport function col(name: string, type: string, options?: DdlColumnOptions): DdlColumn {\n return new DdlColumn({ name, type, ...options });\n}\n","import { blindCast } from '@prisma-next/utils/casts';\nimport {\n AndExpr,\n type AnyExpression,\n BinaryExpr,\n ColumnRef,\n InsertAst,\n InsertOnConflict,\n type InsertValue,\n NullCheckExpr,\n OrderByItem,\n OrExpr,\n ParamRef,\n ProjectionItem,\n SelectAst,\n type TableSource,\n UpdateAst,\n} from '../ast/types';\n\nexport interface ColumnDescriptor {\n readonly codecId: string;\n readonly nullable: boolean;\n}\n\nexport type ColumnSchema = Record<string, ColumnDescriptor>;\n\n/**\n * A composable WHERE / ON expression. Wraps an `AnyExpression` and exposes\n * fluent boolean combinators, mirroring the spirit of `sql-builder`'s\n * `Expression` interface without the contract-bound type machinery.\n */\nexport class CfExpr {\n constructor(readonly ast: AnyExpression) {}\n\n and(other: CfExpr): CfExpr {\n return new CfExpr(AndExpr.of([this.ast, other.ast]));\n }\n\n or(other: CfExpr): CfExpr {\n return new CfExpr(OrExpr.of([this.ast, other.ast]));\n }\n\n not(): CfExpr {\n return new CfExpr(this.ast.not());\n }\n}\n\n/**\n * Per-column authoring handle exposed as a keyed property on a {@link TableHandle}.\n * Carries codec metadata baked at declaration time so no codec ID, table name, or\n * column name needs to be repeated at the call site.\n */\nexport interface ColumnProxy {\n readonly codecId: string;\n readonly nullable: boolean;\n readonly columnName: string;\n readonly tableName: string;\n eq(value: unknown): CfExpr;\n neq(value: unknown): CfExpr;\n isNull(): CfExpr;\n isNotNull(): CfExpr;\n toRef(): ColumnRef;\n toProjectionItem(alias?: string): ProjectionItem;\n}\n\n/**\n * Object passed to the {@link CfConflictClause.doUpdate} callback. Each key\n * resolves to a `ColumnRef` for the corresponding `excluded.<column>`, so the\n * upsert conflict-update branch can copy proposed values without re-binding\n * parameters.\n */\nexport type ExcludedProxy<Schema extends ColumnSchema> = {\n readonly [K in keyof Schema]: ColumnRef;\n};\n\nexport type TableInsertRow<Schema extends ColumnSchema> = {\n readonly [K in keyof Schema]: unknown;\n};\n\nexport type TableSetValues<Schema extends ColumnSchema> = {\n readonly [K in keyof Schema]?: unknown;\n};\n\n/**\n * Fluent authoring handle for a fixed control-plane table. Column proxies are\n * exposed as keyed properties so `handle.columnName.eq(value)` composes without\n * threading codec IDs, table names, or column refs at the call site.\n */\nexport type TableHandle<Schema extends ColumnSchema> = {\n readonly source: TableSource;\n insert(row: TableInsertRow<Schema>): CfInsertQuery<Schema>;\n upsert(row: TableInsertRow<Schema>): CfUpsertBuilder<Schema>;\n update(): CfUpdateQuery<Schema>;\n select(...columns: ReadonlyArray<ColumnProxy>): CfSelectQuery;\n} & {\n readonly [K in keyof Schema]: ColumnProxy;\n};\n\nexport class CfInsertQuery<Schema extends ColumnSchema> {\n constructor(\n private readonly src: TableSource,\n private readonly schema: Schema,\n private readonly rowValues: TableInsertRow<Schema>,\n private readonly returningItems: ReadonlyArray<ProjectionItem> | undefined = undefined,\n ) {}\n\n returning(...columns: ReadonlyArray<ColumnProxy>): CfInsertQuery<Schema> {\n return new CfInsertQuery(\n this.src,\n this.schema,\n this.rowValues,\n columns.map((col) => col.toProjectionItem()),\n );\n }\n\n build(): InsertAst {\n const row = buildInsertRow(this.schema, this.rowValues);\n const ast = InsertAst.into(this.src).withRows([row]);\n return this.returningItems ? ast.withReturning(this.returningItems) : ast;\n }\n}\n\nexport class CfUpsertBuilder<Schema extends ColumnSchema> {\n constructor(\n private readonly src: TableSource,\n private readonly schema: Schema,\n private readonly rowValues: TableInsertRow<Schema>,\n ) {}\n\n onConflict(...columns: ReadonlyArray<ColumnProxy>): CfConflictClause<Schema> {\n return new CfConflictClause(this.src, this.schema, this.rowValues, [...columns]);\n }\n}\n\nexport class CfConflictClause<Schema extends ColumnSchema> {\n constructor(\n private readonly src: TableSource,\n private readonly schema: Schema,\n private readonly rowValues: TableInsertRow<Schema>,\n private readonly conflictCols: ReadonlyArray<ColumnProxy>,\n ) {}\n\n doUpdate(\n setOrCallback:\n | TableSetValues<Schema>\n | ((excluded: ExcludedProxy<Schema>) => TableSetValues<Schema>),\n ): CfUpsertQuery<Schema> {\n const set =\n typeof setOrCallback === 'function'\n ? setOrCallback(buildExcludedProxy(this.schema))\n : setOrCallback;\n return new CfUpsertQuery(this.src, this.schema, this.rowValues, this.conflictCols, set);\n }\n\n doNothing(): CfUpsertQuery<Schema> {\n return new CfUpsertQuery(this.src, this.schema, this.rowValues, this.conflictCols, undefined);\n }\n}\n\nexport class CfUpsertQuery<Schema extends ColumnSchema> {\n constructor(\n private readonly src: TableSource,\n private readonly schema: Schema,\n private readonly rowValues: TableInsertRow<Schema>,\n private readonly conflictCols: ReadonlyArray<ColumnProxy>,\n private readonly updateSet: TableSetValues<Schema> | undefined,\n ) {}\n\n build(): InsertAst {\n const row = buildInsertRow(this.schema, this.rowValues);\n const conflictRefs = this.conflictCols.map((col) => col.toRef());\n const onConflict =\n this.updateSet === undefined\n ? InsertOnConflict.on(conflictRefs).doNothing()\n : InsertOnConflict.on(conflictRefs).doUpdateSet(buildSetMap(this.schema, this.updateSet));\n return InsertAst.into(this.src).withRows([row]).withOnConflict(onConflict);\n }\n}\n\nexport class CfUpdateQuery<Schema extends ColumnSchema> {\n constructor(\n private readonly src: TableSource,\n private readonly schema: Schema,\n private readonly setValues: TableSetValues<Schema> | undefined = undefined,\n private readonly whereExpr: CfExpr | undefined = undefined,\n private readonly returningItems: ReadonlyArray<ProjectionItem> | undefined = undefined,\n ) {}\n\n set(values: TableSetValues<Schema>): CfUpdateQuery<Schema> {\n return new CfUpdateQuery(this.src, this.schema, values, this.whereExpr, this.returningItems);\n }\n\n where(expr: CfExpr): CfUpdateQuery<Schema> {\n return new CfUpdateQuery(this.src, this.schema, this.setValues, expr, this.returningItems);\n }\n\n returning(...columns: ReadonlyArray<ColumnProxy>): CfUpdateQuery<Schema> {\n return new CfUpdateQuery(\n this.src,\n this.schema,\n this.setValues,\n this.whereExpr,\n columns.map((col) => col.toProjectionItem()),\n );\n }\n\n build(): UpdateAst {\n const set = buildSetMap(this.schema, this.setValues);\n const base = UpdateAst.table(this.src).withSet(set);\n const withWhere = this.whereExpr ? base.withWhere(this.whereExpr.ast) : base;\n return this.returningItems ? withWhere.withReturning(this.returningItems) : withWhere;\n }\n}\n\nexport class CfSelectQuery {\n constructor(\n private readonly src: TableSource,\n private readonly projectionItems: ReadonlyArray<ProjectionItem>,\n private readonly whereExpr: CfExpr | undefined = undefined,\n private readonly orderByItems: ReadonlyArray<OrderByItem> = [],\n ) {}\n\n where(expr: CfExpr): CfSelectQuery {\n return new CfSelectQuery(this.src, this.projectionItems, expr, this.orderByItems);\n }\n\n orderBy(column: ColumnProxy, dir: 'asc' | 'desc' = 'asc'): CfSelectQuery {\n const item = dir === 'asc' ? OrderByItem.asc(column.toRef()) : OrderByItem.desc(column.toRef());\n return new CfSelectQuery(this.src, this.projectionItems, this.whereExpr, [\n ...this.orderByItems,\n item,\n ]);\n }\n\n build(): SelectAst {\n const base = SelectAst.from(this.src).withProjection(this.projectionItems);\n const withWhere = this.whereExpr ? base.withWhere(this.whereExpr.ast) : base;\n return this.orderByItems.length > 0 ? withWhere.withOrderBy(this.orderByItems) : withWhere;\n }\n}\n\n/**\n * Declare a control-plane table once, binding column codecs at declaration time.\n * Returns a `TableHandle` whose column properties compose expressions directly\n * without per-call-site codec or column-name threading.\n *\n * ```ts\n * const marker = pgTable({ name: 'marker', schema: 'prisma_contract' }, {\n * space: text(),\n * core_hash: text(),\n * updated_at: timestamptz(),\n * });\n *\n * const query = marker.update()\n * .set({ core_hash: newHash, updated_at: NOW })\n * .where(marker.space.eq(space).and(marker.core_hash.eq(expectedFrom)))\n * .returning(marker.space)\n * .build();\n * ```\n */\nexport function table<Schema extends ColumnSchema>(\n source: TableSource,\n schema: Schema,\n): TableHandle<Schema> {\n const proxies: Record<string, ColumnProxy> = {};\n for (const [col, desc] of Object.entries(schema)) {\n proxies[col] = makeColumnProxy(source.alias ?? source.name, col, desc);\n }\n\n const handle = {\n ...proxies,\n source,\n insert: (row: TableInsertRow<Schema>) => new CfInsertQuery(source, schema, row),\n upsert: (row: TableInsertRow<Schema>) => new CfUpsertBuilder(source, schema, row),\n update: () => new CfUpdateQuery(source, schema),\n select: (...cols: ReadonlyArray<ColumnProxy>) =>\n new CfSelectQuery(\n source,\n cols.map((col) => col.toProjectionItem()),\n ),\n };\n\n return blindCast<\n TableHandle<Schema>,\n 'Column proxies are dynamically built from Schema keys — TypeScript cannot verify the per-key ColumnProxy constraint at the spread call site. Construction is correct by construction: every key maps to makeColumnProxy(source.name, key, schema[key]).'\n >(handle);\n}\n\nfunction makeColumnProxy(\n tableName: string,\n columnName: string,\n desc: ColumnDescriptor,\n): ColumnProxy {\n const ref = ColumnRef.of(tableName, columnName);\n return {\n codecId: desc.codecId,\n nullable: desc.nullable,\n columnName,\n tableName,\n eq: (value) =>\n value === null\n ? new CfExpr(NullCheckExpr.isNull(ref))\n : new CfExpr(BinaryExpr.eq(ref, toSetExpression(value, desc))),\n neq: (value) =>\n value === null\n ? new CfExpr(NullCheckExpr.isNotNull(ref))\n : new CfExpr(BinaryExpr.neq(ref, toSetExpression(value, desc))),\n isNull: () => new CfExpr(NullCheckExpr.isNull(ref)),\n isNotNull: () => new CfExpr(NullCheckExpr.isNotNull(ref)),\n toRef: () => ref,\n toProjectionItem: (alias = columnName) =>\n ProjectionItem.of(alias, ref, { codecId: desc.codecId }),\n };\n}\n\nfunction buildExcludedProxy<Schema extends ColumnSchema>(schema: Schema): ExcludedProxy<Schema> {\n return blindCast<\n ExcludedProxy<Schema>,\n 'Object.fromEntries cannot preserve per-key ColumnRef types — correct by construction: every key maps to ColumnRef.of(\"excluded\", key).'\n >(Object.fromEntries(Object.keys(schema).map((col) => [col, ColumnRef.of('excluded', col)])));\n}\n\nfunction isExpressionSource(value: unknown): value is { toExpr(): AnyExpression } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'toExpr' in value &&\n typeof value.toExpr === 'function'\n );\n}\n\nfunction toInsertValue(value: unknown, desc: ColumnDescriptor): InsertValue {\n if (isExpressionSource(value)) {\n const expr = value.toExpr();\n if (\n expr.kind === 'column-ref' ||\n expr.kind === 'param-ref' ||\n expr.kind === 'prepared-param-ref' ||\n expr.kind === 'raw-expr'\n ) {\n return expr;\n }\n }\n return ParamRef.of(value, { codec: { codecId: desc.codecId } });\n}\n\nfunction toSetExpression(value: unknown, desc: ColumnDescriptor): AnyExpression {\n if (isExpressionSource(value)) {\n return value.toExpr();\n }\n return ParamRef.of(value, { codec: { codecId: desc.codecId } });\n}\n\nfunction buildInsertRow<Schema extends ColumnSchema>(\n schema: Schema,\n values: TableInsertRow<Schema>,\n): Record<string, InsertValue> {\n const row: Record<string, InsertValue> = {};\n const rawValues = blindCast<\n Record<string, unknown>,\n 'TableInsertRow<Schema> maps Schema keys to unknown; indexing by the same string keys is correct by construction'\n >(values);\n for (const [col, desc] of Object.entries(schema)) {\n row[col] = toInsertValue(rawValues[col], desc);\n }\n return row;\n}\n\nfunction buildSetMap<Schema extends ColumnSchema>(\n schema: Schema,\n values: TableSetValues<Schema> | undefined,\n): Record<string, AnyExpression> {\n if (values === undefined) return {};\n const set: Record<string, AnyExpression> = {};\n const rawSchema = blindCast<\n Record<string, ColumnDescriptor>,\n 'Schema extends ColumnSchema = Record<string, ColumnDescriptor>; runtime key access is correct by construction'\n >(schema);\n const rawValues = blindCast<\n Record<string, unknown>,\n 'TableSetValues<Schema> maps Schema keys to unknown; iterating with Object.entries is correct by construction'\n >(values);\n for (const [col, value] of Object.entries(rawValues)) {\n const desc = rawSchema[col];\n if (desc !== undefined) {\n set[col] = toSetExpression(value, desc);\n }\n }\n return set;\n}\n"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as planUnsupported, t as planInvalid } from "../errors-
|
|
1
|
+
import { n as planUnsupported, t as planInvalid } from "../errors-CI1oIVmU.mjs";
|
|
2
2
|
export { planInvalid, planUnsupported };
|
package/dist/exports/errors.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as planUnsupported, t as planInvalid } from "../errors-
|
|
1
|
+
import { n as planUnsupported, t as planInvalid } from "../errors-HvB_h2on.mjs";
|
|
2
2
|
export { planInvalid, planUnsupported };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as CodecRef } from "../codec-types-
|
|
2
|
-
import { J as ParamRef, et as RawSqlLiteral, o as AnyExpression } from "../types-
|
|
1
|
+
import { o as CodecRef } from "../codec-types-Ey_MAEly.mjs";
|
|
2
|
+
import { J as ParamRef, et as RawSqlLiteral, o as AnyExpression } from "../types-CXQF5KS8.mjs";
|
|
3
3
|
import { QueryOperationReturn } from "@prisma-next/sql-contract/types";
|
|
4
4
|
import { ParamSpec } from "@prisma-next/operations";
|
|
5
5
|
import { SqlLoweringSpec } from "@prisma-next/sql-operations";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as RawExpr, S as OperationExpr, T as ParamRef } from "../types-
|
|
1
|
+
import { O as RawExpr, S as OperationExpr, T as ParamRef } from "../types-CMznS9Yh.mjs";
|
|
2
2
|
import { runtimeError } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
//#region src/expression.ts
|
|
4
4
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SqlParamRefMutatorInternal, i as SqlParamRefMutator, n as ParamRefEntryUnion, o as createSqlParamRefMutator, r as ParamRefHandle, t as ParamRefEntry } from "../middleware-
|
|
1
|
+
import { a as SqlParamRefMutatorInternal, i as SqlParamRefMutator, n as ParamRefEntryUnion, o as createSqlParamRefMutator, r as ParamRefHandle, t as ParamRefEntry } from "../middleware-DkAjjPxq.mjs";
|
|
2
2
|
export { ParamRefEntry, ParamRefEntryUnion, ParamRefHandle, SqlParamRefMutator, SqlParamRefMutatorInternal, createSqlParamRefMutator };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createSqlParamRefMutator } from "../middleware-
|
|
1
|
+
import { t as createSqlParamRefMutator } from "../middleware-CbHPs9WK.mjs";
|
|
2
2
|
export { createSqlParamRefMutator };
|
package/dist/exports/plan.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as SqlExecutionPlan } from "../sql-execution-plan-
|
|
2
|
-
import { n as planFromAst, t as SqlQueryPlan } from "../plan-
|
|
1
|
+
import { t as SqlExecutionPlan } from "../sql-execution-plan-Dopo3SDj.mjs";
|
|
2
|
+
import { n as planFromAst, t as SqlQueryPlan } from "../plan-Ds9oN5QU.mjs";
|
|
3
3
|
export { type SqlExecutionPlan, SqlQueryPlan, planFromAst };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MutationDefaultsOptions, i as MutationDefaultsOp, n as CodecDescriptorRegistry, o as TypeHelperRegistry, r as ExecutionContext, t as AppliedMutationDefault } from "../query-lane-context-
|
|
1
|
+
import { a as MutationDefaultsOptions, i as MutationDefaultsOp, n as CodecDescriptorRegistry, o as TypeHelperRegistry, r as ExecutionContext, t as AppliedMutationDefault } from "../query-lane-context-BUYT0tOb.mjs";
|
|
2
2
|
export { AppliedMutationDefault, CodecDescriptorRegistry, ExecutionContext, MutationDefaultsOp, MutationDefaultsOptions, TypeHelperRegistry };
|
package/dist/exports/types.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { n as SqlOrmPlan, t as RuntimeScope } from "../types-
|
|
3
|
-
export { BuildOptions, BuildParamsMap, CodecTypes, ColumnsOf, ComputeColumnJsType, Expr,
|
|
1
|
+
import { C as TableMetadata, S as TableKey, _ as RawTemplateOptions, a as ComputeColumnJsType, b as SqlPlan, c as Meta, d as OperationTypeSignature, f as OperationTypes, g as RawTemplateFactory, h as RawFunctionOptions, i as ColumnsOf, l as ModelDef, m as RawFactory, n as BuildParamsMap, o as Expr, p as OperationsForTypeId, r as CodecTypes, s as META, t as BuildOptions, u as ModelMetadata, v as RuntimeError, w as TablesOf, x as TableDef, y as SqlBuilderOptions } from "../types-CLirmH9F.mjs";
|
|
2
|
+
import { n as SqlOrmPlan, t as RuntimeScope } from "../types-DRBn98H_.mjs";
|
|
3
|
+
export { BuildOptions, BuildParamsMap, CodecTypes, ColumnsOf, ComputeColumnJsType, Expr, META, Meta, ModelDef, ModelMetadata, OperationTypeSignature, OperationTypes, OperationsForTypeId, RawFactory, RawFunctionOptions, RawTemplateFactory, RawTemplateOptions, RuntimeError, RuntimeScope, SqlBuilderOptions, SqlOrmPlan, SqlPlan, TableDef, TableKey, TableMetadata, TablesOf };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { a as CodecMeta, c as ContractCodecRegistry, d as DescriptorCodecTraits, f as ExtractCodecTypes, h as SqlColumnRef, i as CodecDescriptor, l as DescriptorCodecId, m as SqlCodecInstanceContext, n as Codec, o as CodecRef, p as SqlCodecCallContext, r as CodecCallContext, s as CodecTrait, t as AnyCodecDescriptor, u as DescriptorCodecInput } from "./codec-types-
|
|
2
|
-
import { $ as RawSqlExpr, A as InsertAst, B as LiteralExpr, C as EqColJoinOn, D as ExpressionRewriter, E as ExpressionFolder, F as JsonArrayAggExpr, G as OperationExpr, H as LoweredStatement, I as JsonObjectEntry, J as ParamRef, K as OrExpr, L as JsonObjectExpr, M as InsertValue, N as JoinAst, O as ExpressionSource, P as JoinOnExpr, Q as RawExpr, R as LimitOffsetValue, S as DoUpdateSetConflictAction, T as ExprVisitor, U as NotExpr, V as LoweredParam, W as NullCheckExpr, X as ProjectionExpr, Y as PreparedParamRef, Z as ProjectionItem, _ as DefaultValueExpr, a as AndExpr, at as TableSource, b as Direction, c as AnyInsertOnConflictAction, ct as WhereArg, d as AnyParamRef, dt as isQueryAst, et as RawSqlLiteral, f as AnyQueryAst, ft as isWhereExpr, g as ColumnRef, h as BinaryOp, i as AggregateOpFn, it as TableRef, j as InsertOnConflict, k as IdentifierRef, l as AnyInsertValue, lt as WindowFn, m as BinaryExpr, mt as whereExprKinds, n as AggregateExpr, nt as SelectAstOptions, o as AnyExpression, ot as ToWhereExpr, p as AstRewriter, pt as queryAstKinds, q as OrderByItem, r as AggregateFn, rt as SubqueryExpr, s as AnyFromSource, st as UpdateAst, t as AggregateCountFn, tt as SelectAst, u as AnyOperationArg, ut as WindowFuncExpr, v as DeleteAst, w as ExistsExpr, x as DoNothingConflictAction, y as DerivedTableSource, z as ListExpression } from "./types-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import { n as
|
|
1
|
+
import { a as CodecMeta, c as ContractCodecRegistry, d as DescriptorCodecTraits, f as ExtractCodecTypes, h as SqlColumnRef, i as CodecDescriptor, l as DescriptorCodecId, m as SqlCodecInstanceContext, n as Codec, o as CodecRef, p as SqlCodecCallContext, r as CodecCallContext, s as CodecTrait, t as AnyCodecDescriptor, u as DescriptorCodecInput } from "./codec-types-Ey_MAEly.mjs";
|
|
2
|
+
import { $ as RawSqlExpr, A as InsertAst, B as LiteralExpr, C as EqColJoinOn, D as ExpressionRewriter, E as ExpressionFolder, F as JsonArrayAggExpr, G as OperationExpr, H as LoweredStatement, I as JsonObjectEntry, J as ParamRef, K as OrExpr, L as JsonObjectExpr, M as InsertValue, N as JoinAst, O as ExpressionSource, P as JoinOnExpr, Q as RawExpr, R as LimitOffsetValue, S as DoUpdateSetConflictAction, T as ExprVisitor, U as NotExpr, V as LoweredParam, W as NullCheckExpr, X as ProjectionExpr, Y as PreparedParamRef, Z as ProjectionItem, _ as DefaultValueExpr, a as AndExpr, at as TableSource, b as Direction, c as AnyInsertOnConflictAction, ct as WhereArg, d as AnyParamRef, dt as isQueryAst, et as RawSqlLiteral, f as AnyQueryAst, ft as isWhereExpr, g as ColumnRef, h as BinaryOp, i as AggregateOpFn, it as TableRef, j as InsertOnConflict, k as IdentifierRef, l as AnyInsertValue, lt as WindowFn, m as BinaryExpr, mt as whereExprKinds, n as AggregateExpr, nt as SelectAstOptions, o as AnyExpression, ot as ToWhereExpr, p as AstRewriter, pt as queryAstKinds, q as OrderByItem, r as AggregateFn, rt as SubqueryExpr, s as AnyFromSource, st as UpdateAst, t as AggregateCountFn, tt as SelectAst, u as AnyOperationArg, ut as WindowFuncExpr, v as DeleteAst, w as ExistsExpr, x as DoNothingConflictAction, y as DerivedTableSource, z as ListExpression } from "./types-CXQF5KS8.mjs";
|
|
3
|
+
import { a as DdlNode, c as isDdlNode, i as DdlColumnDefaultVisitor, n as DdlColumn, o as FunctionColumnDefault, r as DdlColumnDefault, s as LiteralColumnDefault, t as AnyDdlColumnDefault } from "./ddl-types-BV7GsGNt.mjs";
|
|
4
|
+
import { Adapter, AdapterProfile, AdapterTarget, Lowerer, LowererContext, MarkerReadResult, PreparedExecuteRequest, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SqlCharCodec, SqlCharDescriptor, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlQueryResult, SqlQueryable, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlTransaction, SqlVarcharCodec, SqlVarcharDescriptor, collectOrderedParamRefs, compact, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType } from "./exports/ast.mjs";
|
|
5
|
+
import { a as MutationDefaultsOptions, i as MutationDefaultsOp, n as CodecDescriptorRegistry, o as TypeHelperRegistry, r as ExecutionContext, t as AppliedMutationDefault } from "./query-lane-context-BUYT0tOb.mjs";
|
|
6
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-Dopo3SDj.mjs";
|
|
7
|
+
import { C as TableMetadata, S as TableKey, _ as RawTemplateOptions, a as ComputeColumnJsType, b as SqlPlan, c as Meta, d as OperationTypeSignature, f as OperationTypes, g as RawTemplateFactory, h as RawFunctionOptions, i as ColumnsOf, l as ModelDef, m as RawFactory, n as BuildParamsMap, o as Expr, p as OperationsForTypeId, r as CodecTypes, s as META, t as BuildOptions, u as ModelMetadata, v as RuntimeError, w as TablesOf, x as TableDef, y as SqlBuilderOptions } from "./types-CLirmH9F.mjs";
|
|
8
|
+
import { n as planUnsupported, t as planInvalid } from "./errors-CI1oIVmU.mjs";
|
|
8
9
|
import { BuildOperationSpec, CodecExpression, CodecTypesBase, CodecValue, Expression, RawCodecInferer, RawSqlBuilder, RawSqlTag, ScopeField, TraitExpression, buildOperation, codecOf, createRawSql, param, toExpr } from "./exports/expression.mjs";
|
|
9
|
-
import { a as SqlParamRefMutatorInternal, i as SqlParamRefMutator, n as ParamRefEntryUnion, o as createSqlParamRefMutator, r as ParamRefHandle, t as ParamRefEntry } from "./middleware-
|
|
10
|
-
import { n as planFromAst, t as SqlQueryPlan } from "./plan-
|
|
11
|
-
import { n as SqlOrmPlan, t as RuntimeScope } from "./types-
|
|
12
|
-
export { Adapter, AdapterProfile, AdapterTarget, AggregateCountFn, AggregateExpr, AggregateFn, AggregateOpFn, AndExpr, AnyCodecDescriptor, AnyExpression, AnyFromSource, AnyInsertOnConflictAction, AnyInsertValue, AnyOperationArg, AnyParamRef, AnyQueryAst, AppliedMutationDefault, AstRewriter, BinaryExpr, BinaryOp, BuildOperationSpec, BuildOptions, BuildParamsMap, Codec, CodecCallContext, CodecDescriptor, CodecDescriptorRegistry, CodecExpression, CodecMeta, CodecRef, CodecTrait, CodecTypes, CodecTypesBase, CodecValue, ColumnRef, ColumnsOf, ComputeColumnJsType, ContractCodecRegistry, DefaultValueExpr, DeleteAst, DerivedTableSource, DescriptorCodecId, DescriptorCodecInput, DescriptorCodecTraits, Direction, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExecutionContext, ExistsExpr, Expr, ExprVisitor, Expression, ExpressionFolder, ExpressionRewriter, ExpressionSource, ExtractCodecTypes,
|
|
10
|
+
import { a as SqlParamRefMutatorInternal, i as SqlParamRefMutator, n as ParamRefEntryUnion, o as createSqlParamRefMutator, r as ParamRefHandle, t as ParamRefEntry } from "./middleware-DkAjjPxq.mjs";
|
|
11
|
+
import { n as planFromAst, t as SqlQueryPlan } from "./plan-Ds9oN5QU.mjs";
|
|
12
|
+
import { n as SqlOrmPlan, t as RuntimeScope } from "./types-DRBn98H_.mjs";
|
|
13
|
+
export { Adapter, AdapterProfile, AdapterTarget, AggregateCountFn, AggregateExpr, AggregateFn, AggregateOpFn, AndExpr, AnyCodecDescriptor, AnyDdlColumnDefault, AnyExpression, AnyFromSource, AnyInsertOnConflictAction, AnyInsertValue, AnyOperationArg, AnyParamRef, AnyQueryAst, AppliedMutationDefault, AstRewriter, BinaryExpr, BinaryOp, BuildOperationSpec, BuildOptions, BuildParamsMap, Codec, CodecCallContext, CodecDescriptor, CodecDescriptorRegistry, CodecExpression, CodecMeta, CodecRef, CodecTrait, CodecTypes, CodecTypesBase, CodecValue, ColumnRef, ColumnsOf, ComputeColumnJsType, ContractCodecRegistry, DdlColumn, DdlColumnDefault, DdlColumnDefaultVisitor, DdlNode, DefaultValueExpr, DeleteAst, DerivedTableSource, DescriptorCodecId, DescriptorCodecInput, DescriptorCodecTraits, Direction, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExecutionContext, ExistsExpr, Expr, ExprVisitor, Expression, ExpressionFolder, ExpressionRewriter, ExpressionSource, ExtractCodecTypes, FunctionColumnDefault, IdentifierRef, InsertAst, InsertOnConflict, InsertValue, JoinAst, JoinOnExpr, JsonArrayAggExpr, JsonObjectEntry, JsonObjectExpr, LimitOffsetValue, ListExpression, LiteralColumnDefault, LiteralExpr, LoweredParam, LoweredStatement, Lowerer, LowererContext, META, MarkerReadResult, Meta, ModelDef, ModelMetadata, MutationDefaultsOp, MutationDefaultsOptions, NotExpr, NullCheckExpr, OperationExpr, OperationTypeSignature, OperationTypes, OperationsForTypeId, OrExpr, OrderByItem, ParamRef, ParamRefEntry, ParamRefEntryUnion, ParamRefHandle, PreparedExecuteRequest, PreparedParamRef, ProjectionExpr, ProjectionItem, RawCodecInferer, RawExpr, RawFactory, RawFunctionOptions, RawSqlBuilder, RawSqlExpr, RawSqlLiteral, RawSqlTag, RawTemplateFactory, RawTemplateOptions, RuntimeError, RuntimeScope, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, ScopeField, SelectAst, SelectAstOptions, SqlBuilderOptions, SqlCharCodec, SqlCharDescriptor, SqlCodecCallContext, SqlCodecInstanceContext, SqlColumnRef, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExecutionPlan, SqlExplainResult, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlOrmPlan, SqlParamRefMutator, SqlParamRefMutatorInternal, SqlPlan, SqlQueryPlan, SqlQueryResult, SqlQueryable, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlTransaction, SqlVarcharCodec, SqlVarcharDescriptor, SubqueryExpr, TableDef, TableKey, TableMetadata, TableRef, TableSource, TablesOf, ToWhereExpr, TraitExpression, TypeHelperRegistry, UpdateAst, WhereArg, WindowFn, WindowFuncExpr, buildOperation, codecOf, collectOrderedParamRefs, compact, createRawSql, createSqlParamRefMutator, isDdlNode, isQueryAst, isWhereExpr, param, planFromAst, planInvalid, planUnsupported, queryAstKinds, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType, toExpr, whereExprKinds };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
1
|
+
import { a as LiteralColumnDefault, i as FunctionColumnDefault, n as DdlColumnDefault, o as isDdlNode, r as DdlNode, t as DdlColumn } from "./ddl-types-wqxUC57D.mjs";
|
|
2
|
+
import { A as SelectAst, C as OrExpr, D as ProjectionItem, E as PreparedParamRef, F as isQueryAst, I as isWhereExpr, L as queryAstKinds, M as TableSource, N as UpdateAst, O as RawExpr, P as WindowFuncExpr, R as whereExprKinds, S as OperationExpr, T as ParamRef, _ as JsonObjectExpr, a as DefaultValueExpr, b as NotExpr, c as DoNothingConflictAction, d as ExistsExpr, f as IdentifierRef, g as JsonArrayAggExpr, h as JoinAst, i as ColumnRef, j as SubqueryExpr, k as RawSqlExpr, l as DoUpdateSetConflictAction, m as InsertOnConflict, n as AndExpr, o as DeleteAst, p as InsertAst, r as BinaryExpr, s as DerivedTableSource, t as AggregateExpr, u as EqColJoinOn, v as ListExpression, w as OrderByItem, x as NullCheckExpr, y as LiteralExpr } from "./types-CMznS9Yh.mjs";
|
|
3
|
+
import { n as compact, t as collectOrderedParamRefs } from "./util-DUXs0nZ9.mjs";
|
|
3
4
|
import { SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SqlCharCodec, SqlCharDescriptor, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlVarcharCodec, SqlVarcharDescriptor, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType } from "./exports/ast.mjs";
|
|
4
|
-
import { n as planUnsupported, t as planInvalid } from "./errors-
|
|
5
|
+
import { n as planUnsupported, t as planInvalid } from "./errors-HvB_h2on.mjs";
|
|
5
6
|
import { buildOperation, codecOf, createRawSql, param, toExpr } from "./exports/expression.mjs";
|
|
6
|
-
import { t as createSqlParamRefMutator } from "./middleware-
|
|
7
|
+
import { t as createSqlParamRefMutator } from "./middleware-CbHPs9WK.mjs";
|
|
7
8
|
import { planFromAst } from "./exports/plan.mjs";
|
|
8
9
|
import "./exports/query-lane-context.mjs";
|
|
9
10
|
import "./exports/types.mjs";
|
|
10
|
-
export { AggregateExpr, AndExpr, BinaryExpr, ColumnRef, DefaultValueExpr, DeleteAst, DerivedTableSource, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExistsExpr, IdentifierRef, InsertAst, InsertOnConflict, JoinAst, JsonArrayAggExpr, JsonObjectExpr, ListExpression, LiteralExpr, NotExpr, NullCheckExpr, OperationExpr, OrExpr, OrderByItem, ParamRef, PreparedParamRef, ProjectionItem, RawExpr, RawSqlExpr, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SelectAst, SqlCharCodec, SqlCharDescriptor, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlVarcharCodec, SqlVarcharDescriptor, SubqueryExpr, TableSource, UpdateAst, WindowFuncExpr, buildOperation, codecOf, collectOrderedParamRefs, compact, createRawSql, createSqlParamRefMutator, isQueryAst, isWhereExpr, param, planFromAst, planInvalid, planUnsupported, queryAstKinds, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType, toExpr, whereExprKinds };
|
|
11
|
+
export { AggregateExpr, AndExpr, BinaryExpr, ColumnRef, DdlColumn, DdlColumnDefault, DdlNode, DefaultValueExpr, DeleteAst, DerivedTableSource, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExistsExpr, FunctionColumnDefault, IdentifierRef, InsertAst, InsertOnConflict, JoinAst, JsonArrayAggExpr, JsonObjectExpr, ListExpression, LiteralColumnDefault, LiteralExpr, NotExpr, NullCheckExpr, OperationExpr, OrExpr, OrderByItem, ParamRef, PreparedParamRef, ProjectionItem, RawExpr, RawSqlExpr, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SelectAst, SqlCharCodec, SqlCharDescriptor, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlTextCodec, SqlTextDescriptor, SqlTimestampCodec, SqlTimestampDescriptor, SqlVarcharCodec, SqlVarcharDescriptor, SubqueryExpr, TableSource, UpdateAst, WindowFuncExpr, buildOperation, codecOf, collectOrderedParamRefs, compact, createRawSql, createSqlParamRefMutator, isDdlNode, isQueryAst, isWhereExpr, param, planFromAst, planInvalid, planUnsupported, queryAstKinds, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlTimestampColumn, sqlTimestampDecode, sqlTimestampDecodeJson, sqlTimestampDescriptor, sqlTimestampEncode, sqlTimestampEncodeJson, sqlTimestampRenderOutputType, sqlVarcharColumn, sqlVarcharDecode, sqlVarcharDescriptor, sqlVarcharEncode, sqlVarcharRenderOutputType, toExpr, whereExprKinds };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as collectOrderedParamRefs } from "./util-
|
|
1
|
+
import { t as collectOrderedParamRefs } from "./util-DUXs0nZ9.mjs";
|
|
2
2
|
//#region src/middleware/param-ref-mutator.ts
|
|
3
3
|
/**
|
|
4
4
|
* Build a {@link SqlParamRefMutatorInternal} for the given lowered plan.
|
|
@@ -77,4 +77,4 @@ function createSqlParamRefMutator(plan) {
|
|
|
77
77
|
//#endregion
|
|
78
78
|
export { createSqlParamRefMutator as t };
|
|
79
79
|
|
|
80
|
-
//# sourceMappingURL=middleware-
|
|
80
|
+
//# sourceMappingURL=middleware-CbHPs9WK.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-B0yz0pff.mjs","names":[],"sources":["../src/middleware/param-ref-mutator.ts"],"sourcesContent":["import type { ParamRefMutator } from '@prisma-next/framework-components/runtime';\nimport type { AnyParamRef } from '../ast/types';\nimport { collectOrderedParamRefs } from '../ast/util';\nimport type { SqlExecutionPlan } from '../sql-execution-plan';\n\n/**\n * Brand applied to {@link ParamRefHandle} so user-constructed handles\n * are rejected by the type system. The mutator only accepts handles it\n * produced from `entries()`.\n *\n * The brand is a phantom type — there is no runtime token. At runtime\n * the handle is the underlying `ParamRef` instance from the plan's\n * `ast`; the brand only narrows the type-level surface so callers\n * cannot fabricate a handle from a fresh `ParamRef.of(...)`.\n */\ndeclare const paramRefHandleBrand: unique symbol;\n\n/**\n * Opaque token identifying a single `ParamRef` in the plan. Produced by\n * {@link SqlParamRefMutator.entries}; consumed by `replaceValue` /\n * `replaceValues`.\n *\n * The phantom `TCodecId` parameter records the codec id of the\n * referenced `ParamRef` so type-level inference can route replacement\n * values through `TCodecMap` to the codec's declared `TInput`.\n */\nexport interface ParamRefHandle<TCodecId extends string | undefined = string | undefined> {\n readonly [paramRefHandleBrand]: TCodecId;\n}\n\n/**\n * One outbound `ParamRef` slot in the plan exposed to middleware.\n * `value` is the current value (post any prior middleware mutations);\n * `codecId` is the codec id declared on the underlying `ParamRef.codec`.\n */\nexport interface ParamRefEntry<TCodecId extends string | undefined = string | undefined> {\n readonly ref: ParamRefHandle<TCodecId>;\n readonly value: unknown;\n readonly codecId: TCodecId;\n}\n\n/**\n * Discriminated entry union over a codec map. For each `K` in\n * `TCodecMap`, `entries()` may yield a `ParamRefEntry<K>`; ParamRefs\n * with no codec id (or a codec id outside the map) yield a\n * `ParamRefEntry<undefined>`. Pattern-matching on `entry.codecId`\n * narrows `entry.ref` to a `ParamRefHandle<K>`, which routes through\n * the typed `replaceValue` overload.\n */\nexport type ParamRefEntryUnion<TCodecMap extends Record<string, unknown>> =\n | { [K in keyof TCodecMap & string]: ParamRefEntry<K> }[keyof TCodecMap & string]\n | ParamRefEntry<undefined>;\n\n/**\n * SQL-family mutator threaded into `SqlMiddleware.beforeExecute` as\n * `params`. Scope is `ParamRef.value` slots only — middleware cannot\n * insert / remove `ParamRef`s, rewrite SQL, or modify projection. The\n * type-level `ParamRefHandle` brand and the `replaceValue(ref,\n * newValue)` shape enforce this at compile time.\n *\n * `entries()` surfaces both literal call-site `ParamRef` slots and\n * `prepare()`-time `PreparedParamRef` bind slots; the handle and codec\n * id work the same for both.\n *\n * Allocation discipline: the mutator is constructed lazily from the\n * plan. `entries()` walks the plan's existing AST without allocating\n * an intermediate array; the working params buffer is only allocated\n * on the first `replaceValue` / `replaceValues` call. If no middleware\n * mutates, `currentParams()` returns the plan's original `params` by\n * reference identity.\n *\n * The `TCodecMap` parameter is a record keyed by codec id; `replaceValue`\n * infers `newValue` from `TCodecMap[H['codecId']]` for handles whose\n * codec id is statically resolvable. For codec ids the type system\n * cannot resolve, `newValue` falls back to `unknown` and the middleware\n * is on the hook for runtime correctness.\n */\nexport interface SqlParamRefMutator<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n> extends ParamRefMutator {\n /** Iterate every outbound `ParamRef` the plan currently carries, in canonical order. */\n entries(): IterableIterator<ParamRefEntryUnion<TCodecMap>>;\n\n /**\n * Replace one `ParamRef`'s value with the result of bulk processing.\n * `newValue` is constrained to the codec's declared `TInput` for codec\n * ids the type system can resolve via `TCodecMap`; for unresolvable\n * codec ids `newValue` is `unknown` (the second overload).\n */\n replaceValue<TCodecId extends keyof TCodecMap & string>(\n ref: ParamRefHandle<TCodecId>,\n newValue: TCodecMap[TCodecId],\n ): void;\n replaceValue(ref: ParamRefHandle<undefined>, newValue: unknown): void;\n\n /** Replace many at once (typical for bulk-pattern middleware). */\n replaceValues(\n updates: Iterable<{\n readonly ref: ParamRefHandle<(keyof TCodecMap & string) | undefined>;\n readonly newValue: unknown;\n }>,\n ): void;\n}\n\n/**\n * Internal-only view of the mutator that exposes the post-mutation params\n * array to the SQL runtime. The runtime calls `currentParams()` after the\n * `beforeExecute` chain has run; the result is the plan's original\n * `params` by reference identity if no middleware mutated, otherwise a\n * frozen new array carrying the mutations applied in chain order.\n *\n * Family-internal contract — `SqlMiddleware` consumers never see this\n * shape; they receive the public `SqlParamRefMutator` view above.\n */\nexport interface SqlParamRefMutatorInternal<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n> extends SqlParamRefMutator<TCodecMap> {\n currentParams(): readonly unknown[];\n}\n\ntype AnyHandle = ParamRefHandle<string | undefined>;\n\n/**\n * Build a {@link SqlParamRefMutatorInternal} for the given lowered plan.\n *\n * The mutator captures `plan.params` by reference and walks\n * `plan.ast` (via `collectOrderedParamRefs`) on demand to build\n * entries. Mutations write to a lazily-allocated working copy so the\n * fast path (no mutation) preserves bit-for-bit reference identity to\n * the original `plan.params`.\n *\n * Threading: `plan.ast` carries the canonical `ParamRef` ordering used\n * by every consumer (renderer's `$N` index map, encode-side metadata\n * walk, etc.). The mutator's `entries()` yields the same order so\n * middleware that filters by codec id sees ParamRefs in the order the\n * runtime will encode them.\n */\nexport function createSqlParamRefMutator<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n>(plan: SqlExecutionPlan): SqlParamRefMutatorInternal<TCodecMap> {\n const originalParams = plan.params;\n const refs: ReadonlyArray<AnyParamRef> = plan.ast ? collectOrderedParamRefs(plan.ast) : [];\n let workingParams: unknown[] | undefined;\n\n const indexOfRef = (handle: AnyHandle): number => {\n // The handle is the underlying ParamRef instance the mutator yielded\n // from entries(); equality is identity equality on the ParamRef. The\n // brand on ParamRefHandle is unforgeable from outside, so the only\n // legal handles came from this mutator's entries().\n return refs.indexOf(handle as unknown as AnyParamRef);\n };\n\n const ensureWorkingParams = (): unknown[] => {\n if (!workingParams) {\n workingParams = [...originalParams];\n }\n return workingParams;\n };\n\n const writeAt = (index: number, value: unknown): void => {\n const buffer = ensureWorkingParams();\n buffer[index] = value;\n };\n\n function* entries(): IterableIterator<ParamRefEntryUnion<TCodecMap>> {\n const view = workingParams ?? originalParams;\n for (let i = 0; i < refs.length; i++) {\n const ref = refs[i];\n if (!ref) continue;\n const handle = ref as unknown as ParamRefHandle<string | undefined>;\n let value: unknown;\n let codecId: string | undefined;\n if (ref.kind === 'param-ref') {\n value = i < view.length ? view[i] : ref.value;\n codecId = ref.codec?.codecId;\n } else {\n // PreparedParamRef positions carry no AST-side fallback value —\n // the slot value at index `i` is the only source.\n value = i < view.length ? view[i] : undefined;\n codecId = ref.codec.codecId;\n }\n // The runtime erases the discriminated union to a single shape; the\n // public type pins each entry's `ref` to the matching `codecId`\n // arm at compile time.\n const entry: ParamRefEntry<string | undefined> = { ref: handle, value, codecId };\n yield entry as ParamRefEntryUnion<TCodecMap>;\n }\n }\n\n function replaceValue(handle: AnyHandle, newValue: unknown): void {\n const index = indexOfRef(handle);\n if (index < 0) {\n // Handle does not belong to this plan. The type system pins this\n // at the brand level; this runtime check guards against handles\n // smuggled across plans.\n return;\n }\n writeAt(index, newValue);\n }\n\n function replaceValues(\n updates: Iterable<{ readonly ref: AnyHandle; readonly newValue: unknown }>,\n ): void {\n for (const { ref, newValue } of updates) {\n const index = indexOfRef(ref);\n if (index < 0) continue;\n writeAt(index, newValue);\n }\n }\n\n // The public `SqlParamRefMutator` declares overloaded `replaceValue`\n // signatures (typed-by-codec / unresolvable-codec). The implementation\n // is one function with a permissive runtime signature; the cast is the\n // single point at which the runtime function meets the typed overload\n // surface, matching the overload-implementation pattern.\n return {\n entries,\n replaceValue: replaceValue as SqlParamRefMutator<TCodecMap>['replaceValue'],\n replaceValues,\n currentParams(): readonly unknown[] {\n if (!workingParams) {\n return originalParams;\n }\n return Object.freeze([...workingParams]);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyIA,SAAgB,yBAEd,MAA+D;CAC/D,MAAM,iBAAiB,KAAK;CAC5B,MAAM,OAAmC,KAAK,MAAM,wBAAwB,KAAK,GAAG,IAAI,CAAC;CACzF,IAAI;CAEJ,MAAM,cAAc,WAA8B;EAKhD,OAAO,KAAK,QAAQ,MAAgC;CACtD;CAEA,MAAM,4BAAuC;EAC3C,IAAI,CAAC,eACH,gBAAgB,CAAC,GAAG,cAAc;EAEpC,OAAO;CACT;CAEA,MAAM,WAAW,OAAe,UAAyB;EACvD,MAAM,SAAS,oBAAoB;EACnC,OAAO,SAAS;CAClB;CAEA,UAAU,UAA2D;EACnE,MAAM,OAAO,iBAAiB;EAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;GACpC,MAAM,MAAM,KAAK;GACjB,IAAI,CAAC,KAAK;GACV,MAAM,SAAS;GACf,IAAI;GACJ,IAAI;GACJ,IAAI,IAAI,SAAS,aAAa;IAC5B,QAAQ,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI;IACxC,UAAU,IAAI,OAAO;GACvB,OAAO;IAGL,QAAQ,IAAI,KAAK,SAAS,KAAK,KAAK,KAAA;IACpC,UAAU,IAAI,MAAM;GACtB;GAKA,MAAM;IAD6C,KAAK;IAAQ;IAAO;GAC7D;EACZ;CACF;CAEA,SAAS,aAAa,QAAmB,UAAyB;EAChE,MAAM,QAAQ,WAAW,MAAM;EAC/B,IAAI,QAAQ,GAIV;EAEF,QAAQ,OAAO,QAAQ;CACzB;CAEA,SAAS,cACP,SACM;EACN,KAAK,MAAM,EAAE,KAAK,cAAc,SAAS;GACvC,MAAM,QAAQ,WAAW,GAAG;GAC5B,IAAI,QAAQ,GAAG;GACf,QAAQ,OAAO,QAAQ;EACzB;CACF;CAOA,OAAO;EACL;EACc;EACd;EACA,gBAAoC;GAClC,IAAI,CAAC,eACH,OAAO;GAET,OAAO,OAAO,OAAO,CAAC,GAAG,aAAa,CAAC;EACzC;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"middleware-CbHPs9WK.mjs","names":[],"sources":["../src/middleware/param-ref-mutator.ts"],"sourcesContent":["import type { ParamRefMutator } from '@prisma-next/framework-components/runtime';\nimport type { AnyParamRef } from '../ast/types';\nimport { collectOrderedParamRefs } from '../ast/util';\nimport type { SqlExecutionPlan } from '../sql-execution-plan';\n\n/**\n * Brand applied to {@link ParamRefHandle} so user-constructed handles\n * are rejected by the type system. The mutator only accepts handles it\n * produced from `entries()`.\n *\n * The brand is a phantom type — there is no runtime token. At runtime\n * the handle is the underlying `ParamRef` instance from the plan's\n * `ast`; the brand only narrows the type-level surface so callers\n * cannot fabricate a handle from a fresh `ParamRef.of(...)`.\n */\ndeclare const paramRefHandleBrand: unique symbol;\n\n/**\n * Opaque token identifying a single `ParamRef` in the plan. Produced by\n * {@link SqlParamRefMutator.entries}; consumed by `replaceValue` /\n * `replaceValues`.\n *\n * The phantom `TCodecId` parameter records the codec id of the\n * referenced `ParamRef` so type-level inference can route replacement\n * values through `TCodecMap` to the codec's declared `TInput`.\n */\nexport interface ParamRefHandle<TCodecId extends string | undefined = string | undefined> {\n readonly [paramRefHandleBrand]: TCodecId;\n}\n\n/**\n * One outbound `ParamRef` slot in the plan exposed to middleware.\n * `value` is the current value (post any prior middleware mutations);\n * `codecId` is the codec id declared on the underlying `ParamRef.codec`.\n */\nexport interface ParamRefEntry<TCodecId extends string | undefined = string | undefined> {\n readonly ref: ParamRefHandle<TCodecId>;\n readonly value: unknown;\n readonly codecId: TCodecId;\n}\n\n/**\n * Discriminated entry union over a codec map. For each `K` in\n * `TCodecMap`, `entries()` may yield a `ParamRefEntry<K>`; ParamRefs\n * with no codec id (or a codec id outside the map) yield a\n * `ParamRefEntry<undefined>`. Pattern-matching on `entry.codecId`\n * narrows `entry.ref` to a `ParamRefHandle<K>`, which routes through\n * the typed `replaceValue` overload.\n */\nexport type ParamRefEntryUnion<TCodecMap extends Record<string, unknown>> =\n | { [K in keyof TCodecMap & string]: ParamRefEntry<K> }[keyof TCodecMap & string]\n | ParamRefEntry<undefined>;\n\n/**\n * SQL-family mutator threaded into `SqlMiddleware.beforeExecute` as\n * `params`. Scope is `ParamRef.value` slots only — middleware cannot\n * insert / remove `ParamRef`s, rewrite SQL, or modify projection. The\n * type-level `ParamRefHandle` brand and the `replaceValue(ref,\n * newValue)` shape enforce this at compile time.\n *\n * `entries()` surfaces both literal call-site `ParamRef` slots and\n * `prepare()`-time `PreparedParamRef` bind slots; the handle and codec\n * id work the same for both.\n *\n * Allocation discipline: the mutator is constructed lazily from the\n * plan. `entries()` walks the plan's existing AST without allocating\n * an intermediate array; the working params buffer is only allocated\n * on the first `replaceValue` / `replaceValues` call. If no middleware\n * mutates, `currentParams()` returns the plan's original `params` by\n * reference identity.\n *\n * The `TCodecMap` parameter is a record keyed by codec id; `replaceValue`\n * infers `newValue` from `TCodecMap[H['codecId']]` for handles whose\n * codec id is statically resolvable. For codec ids the type system\n * cannot resolve, `newValue` falls back to `unknown` and the middleware\n * is on the hook for runtime correctness.\n */\nexport interface SqlParamRefMutator<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n> extends ParamRefMutator {\n /** Iterate every outbound `ParamRef` the plan currently carries, in canonical order. */\n entries(): IterableIterator<ParamRefEntryUnion<TCodecMap>>;\n\n /**\n * Replace one `ParamRef`'s value with the result of bulk processing.\n * `newValue` is constrained to the codec's declared `TInput` for codec\n * ids the type system can resolve via `TCodecMap`; for unresolvable\n * codec ids `newValue` is `unknown` (the second overload).\n */\n replaceValue<TCodecId extends keyof TCodecMap & string>(\n ref: ParamRefHandle<TCodecId>,\n newValue: TCodecMap[TCodecId],\n ): void;\n replaceValue(ref: ParamRefHandle<undefined>, newValue: unknown): void;\n\n /** Replace many at once (typical for bulk-pattern middleware). */\n replaceValues(\n updates: Iterable<{\n readonly ref: ParamRefHandle<(keyof TCodecMap & string) | undefined>;\n readonly newValue: unknown;\n }>,\n ): void;\n}\n\n/**\n * Internal-only view of the mutator that exposes the post-mutation params\n * array to the SQL runtime. The runtime calls `currentParams()` after the\n * `beforeExecute` chain has run; the result is the plan's original\n * `params` by reference identity if no middleware mutated, otherwise a\n * frozen new array carrying the mutations applied in chain order.\n *\n * Family-internal contract — `SqlMiddleware` consumers never see this\n * shape; they receive the public `SqlParamRefMutator` view above.\n */\nexport interface SqlParamRefMutatorInternal<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n> extends SqlParamRefMutator<TCodecMap> {\n currentParams(): readonly unknown[];\n}\n\ntype AnyHandle = ParamRefHandle<string | undefined>;\n\n/**\n * Build a {@link SqlParamRefMutatorInternal} for the given lowered plan.\n *\n * The mutator captures `plan.params` by reference and walks\n * `plan.ast` (via `collectOrderedParamRefs`) on demand to build\n * entries. Mutations write to a lazily-allocated working copy so the\n * fast path (no mutation) preserves bit-for-bit reference identity to\n * the original `plan.params`.\n *\n * Threading: `plan.ast` carries the canonical `ParamRef` ordering used\n * by every consumer (renderer's `$N` index map, encode-side metadata\n * walk, etc.). The mutator's `entries()` yields the same order so\n * middleware that filters by codec id sees ParamRefs in the order the\n * runtime will encode them.\n */\nexport function createSqlParamRefMutator<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n>(plan: SqlExecutionPlan): SqlParamRefMutatorInternal<TCodecMap> {\n const originalParams = plan.params;\n const refs: ReadonlyArray<AnyParamRef> = plan.ast ? collectOrderedParamRefs(plan.ast) : [];\n let workingParams: unknown[] | undefined;\n\n const indexOfRef = (handle: AnyHandle): number => {\n // The handle is the underlying ParamRef instance the mutator yielded\n // from entries(); equality is identity equality on the ParamRef. The\n // brand on ParamRefHandle is unforgeable from outside, so the only\n // legal handles came from this mutator's entries().\n return refs.indexOf(handle as unknown as AnyParamRef);\n };\n\n const ensureWorkingParams = (): unknown[] => {\n if (!workingParams) {\n workingParams = [...originalParams];\n }\n return workingParams;\n };\n\n const writeAt = (index: number, value: unknown): void => {\n const buffer = ensureWorkingParams();\n buffer[index] = value;\n };\n\n function* entries(): IterableIterator<ParamRefEntryUnion<TCodecMap>> {\n const view = workingParams ?? originalParams;\n for (let i = 0; i < refs.length; i++) {\n const ref = refs[i];\n if (!ref) continue;\n const handle = ref as unknown as ParamRefHandle<string | undefined>;\n let value: unknown;\n let codecId: string | undefined;\n if (ref.kind === 'param-ref') {\n value = i < view.length ? view[i] : ref.value;\n codecId = ref.codec?.codecId;\n } else {\n // PreparedParamRef positions carry no AST-side fallback value —\n // the slot value at index `i` is the only source.\n value = i < view.length ? view[i] : undefined;\n codecId = ref.codec.codecId;\n }\n // The runtime erases the discriminated union to a single shape; the\n // public type pins each entry's `ref` to the matching `codecId`\n // arm at compile time.\n const entry: ParamRefEntry<string | undefined> = { ref: handle, value, codecId };\n yield entry as ParamRefEntryUnion<TCodecMap>;\n }\n }\n\n function replaceValue(handle: AnyHandle, newValue: unknown): void {\n const index = indexOfRef(handle);\n if (index < 0) {\n // Handle does not belong to this plan. The type system pins this\n // at the brand level; this runtime check guards against handles\n // smuggled across plans.\n return;\n }\n writeAt(index, newValue);\n }\n\n function replaceValues(\n updates: Iterable<{ readonly ref: AnyHandle; readonly newValue: unknown }>,\n ): void {\n for (const { ref, newValue } of updates) {\n const index = indexOfRef(ref);\n if (index < 0) continue;\n writeAt(index, newValue);\n }\n }\n\n // The public `SqlParamRefMutator` declares overloaded `replaceValue`\n // signatures (typed-by-codec / unresolvable-codec). The implementation\n // is one function with a permissive runtime signature; the cast is the\n // single point at which the runtime function meets the typed overload\n // surface, matching the overload-implementation pattern.\n return {\n entries,\n replaceValue: replaceValue as SqlParamRefMutator<TCodecMap>['replaceValue'],\n replaceValues,\n currentParams(): readonly unknown[] {\n if (!workingParams) {\n return originalParams;\n }\n return Object.freeze([...workingParams]);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyIA,SAAgB,yBAEd,MAA+D;CAC/D,MAAM,iBAAiB,KAAK;CAC5B,MAAM,OAAmC,KAAK,MAAM,wBAAwB,KAAK,GAAG,IAAI,CAAC;CACzF,IAAI;CAEJ,MAAM,cAAc,WAA8B;EAKhD,OAAO,KAAK,QAAQ,MAAgC;CACtD;CAEA,MAAM,4BAAuC;EAC3C,IAAI,CAAC,eACH,gBAAgB,CAAC,GAAG,cAAc;EAEpC,OAAO;CACT;CAEA,MAAM,WAAW,OAAe,UAAyB;EACvD,MAAM,SAAS,oBAAoB;EACnC,OAAO,SAAS;CAClB;CAEA,UAAU,UAA2D;EACnE,MAAM,OAAO,iBAAiB;EAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;GACpC,MAAM,MAAM,KAAK;GACjB,IAAI,CAAC,KAAK;GACV,MAAM,SAAS;GACf,IAAI;GACJ,IAAI;GACJ,IAAI,IAAI,SAAS,aAAa;IAC5B,QAAQ,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI;IACxC,UAAU,IAAI,OAAO;GACvB,OAAO;IAGL,QAAQ,IAAI,KAAK,SAAS,KAAK,KAAK,KAAA;IACpC,UAAU,IAAI,MAAM;GACtB;GAKA,MAAM;IAD6C,KAAK;IAAQ;IAAO;GAC7D;EACZ;CACF;CAEA,SAAS,aAAa,QAAmB,UAAyB;EAChE,MAAM,QAAQ,WAAW,MAAM;EAC/B,IAAI,QAAQ,GAIV;EAEF,QAAQ,OAAO,QAAQ;CACzB;CAEA,SAAS,cACP,SACM;EACN,KAAK,MAAM,EAAE,KAAK,cAAc,SAAS;GACvC,MAAM,QAAQ,WAAW,GAAG;GAC5B,IAAI,QAAQ,GAAG;GACf,QAAQ,OAAO,QAAQ;EACzB;CACF;CAOA,OAAO;EACL;EACc;EACd;EACA,gBAAoC;GAClC,IAAI,CAAC,eACH,OAAO;GAET,OAAO,OAAO,OAAO,CAAC,GAAG,aAAa,CAAC;EACzC;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SqlExecutionPlan } from "./sql-execution-plan-
|
|
1
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-Dopo3SDj.mjs";
|
|
2
2
|
import { ParamRefMutator } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/param-ref-mutator.d.ts
|
|
@@ -116,4 +116,4 @@ interface SqlParamRefMutatorInternal<TCodecMap extends Record<string, unknown> =
|
|
|
116
116
|
declare function createSqlParamRefMutator<TCodecMap extends Record<string, unknown> = Record<string, unknown>>(plan: SqlExecutionPlan): SqlParamRefMutatorInternal<TCodecMap>;
|
|
117
117
|
//#endregion
|
|
118
118
|
export { SqlParamRefMutatorInternal as a, SqlParamRefMutator as i, ParamRefEntryUnion as n, createSqlParamRefMutator as o, ParamRefHandle as r, ParamRefEntry as t };
|
|
119
|
-
//# sourceMappingURL=middleware-
|
|
119
|
+
//# sourceMappingURL=middleware-DkAjjPxq.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-
|
|
1
|
+
{"version":3,"file":"middleware-DkAjjPxq.d.mts","names":[],"sources":["../src/middleware/param-ref-mutator.ts"],"mappings":";;;;;;AAG8D;;;;AAYd;AAWhD;;;cAXc,mBAAA;;;;;AAY4B;AAQ1C;;;;UATiB,cAAA;EAAA,UACL,mBAAmB,GAAG,QAAA;AAAA;;;;;;UAQjB,aAAA;EAAA,SACN,GAAA,EAAK,cAAA,CAAe,QAAA;EAAA,SACpB,KAAA;EAAA,SACA,OAAA,EAAS,QAAA;AAAA;AAWpB;;;;;;;;AAAA,KAAY,kBAAA,mBAAqC,MAAA,mCAC/B,SAAA,YAAqB,aAAA,CAAc,CAAA,UAAW,SAAA,aAC5D,aAAA;;;;;;;;;;AAAa;AA0BjB;;;;;;;;;;;;;;UAAiB,kBAAA,mBACG,MAAA,oBAA0B,MAAA,2BACpC,eAAA;EAmBU;EAjBlB,OAAA,IAAW,gBAAA,CAAiB,kBAAA,CAAmB,SAAA;EAFvC;;;;;;EAUR,YAAA,wBAAoC,SAAA,WAClC,GAAA,EAAK,cAAA,CAAe,QAAA,GACpB,QAAA,EAAU,SAAA,CAAU,QAAA;EAEtB,YAAA,CAAa,GAAA,EAAK,cAAA,aAA2B,QAAA;EAZlC;EAeX,aAAA,CACE,OAAA,EAAS,QAAA;IAAA,SACE,GAAA,EAAK,cAAA,QAAsB,SAAA;IAAA,SAC3B,QAAA;EAAA;AAAA;;;;;;;;;;;UAeE,0BAAA,mBACG,MAAA,oBAA0B,MAAA,2BACpC,kBAAA,CAAmB,SAAA;EAC3B,aAAA;AAAA;;;;;;AAjBI;AAcN;;;;;;;;;iBAuBgB,wBAAA,mBACI,MAAA,oBAA0B,MAAA,kBAAA,CAC5C,IAAA,EAAM,gBAAA,GAAmB,0BAAA,CAA2B,SAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as AnyQueryAst } from "./types-
|
|
1
|
+
import { f as AnyQueryAst } from "./types-CXQF5KS8.mjs";
|
|
2
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
2
3
|
import { QueryPlan } from "@prisma-next/framework-components/runtime";
|
|
3
4
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
|
-
import { Contract } from "@prisma-next/contract/types";
|
|
5
5
|
|
|
6
6
|
//#region src/plan.d.ts
|
|
7
7
|
/**
|
|
@@ -41,4 +41,4 @@ interface SqlQueryPlan<Row = unknown> extends QueryPlan<Row> {
|
|
|
41
41
|
declare function planFromAst<Row = unknown>(ast: AnyQueryAst, contract: Contract<SqlStorage>, laneId?: string): SqlQueryPlan<Row>;
|
|
42
42
|
//#endregion
|
|
43
43
|
export { planFromAst as n, SqlQueryPlan as t };
|
|
44
|
-
//# sourceMappingURL=plan-
|
|
44
|
+
//# sourceMappingURL=plan-Ds9oN5QU.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-
|
|
1
|
+
{"version":3,"file":"plan-Ds9oN5QU.d.mts","names":[],"sources":["../src/plan.ts"],"mappings":";;;;;;;;AAkBA;;;;;;;;;;;UAAiB,YAAA,wBAAoC,SAAA,CAAU,GAAA;EAAA,SACpD,GAAA,EAAK,WAAA;EAAA,SACL,MAAA;AAAA;AAAM;AAoBjB;;;;;;;;;;;;;;;;AApBiB,iBAoBD,WAAA,eAAA,CACd,GAAA,EAAK,WAAA,EACL,QAAA,EAAU,QAAA,CAAS,UAAA,GACnB,MAAA,YACC,YAAA,CAAa,GAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as ContractCodecRegistry } from "./codec-types-
|
|
1
|
+
import { c as ContractCodecRegistry } from "./codec-types-Ey_MAEly.mjs";
|
|
2
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
2
3
|
import { CodecDescriptor, CodecRef } from "@prisma-next/framework-components/codec";
|
|
3
4
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
|
-
import { Contract } from "@prisma-next/contract/types";
|
|
5
5
|
import { SqlOperationRegistry } from "@prisma-next/sql-operations";
|
|
6
6
|
|
|
7
7
|
//#region src/query-lane-context.d.ts
|
|
@@ -80,4 +80,4 @@ interface ExecutionContext<TContract extends Contract<SqlStorage> = Contract<Sql
|
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
82
|
export { MutationDefaultsOptions as a, MutationDefaultsOp as i, CodecDescriptorRegistry as n, TypeHelperRegistry as o, ExecutionContext as r, AppliedMutationDefault as t };
|
|
83
|
-
//# sourceMappingURL=query-lane-context-
|
|
83
|
+
//# sourceMappingURL=query-lane-context-BUYT0tOb.d.mts.map
|
package/dist/{query-lane-context-Dw1Tz0kv.d.mts.map → query-lane-context-BUYT0tOb.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-lane-context-
|
|
1
|
+
{"version":3,"file":"query-lane-context-BUYT0tOb.d.mts","names":[],"sources":["../src/query-lane-context.ts"],"mappings":";;;;;;;;;AASA;UAAiB,uBAAA;;;;EAIf,aAAA,CAAc,OAAA,WAAkB,eAAA;EAgBtB;;;;;;;;;;;EAJV,iBAAA,CAAkB,KAAA,UAAe,MAAA,WAAiB,QAAA;EAIxC;;;EAAV,MAAA,IAAU,gBAAA,CAAiB,eAAA;EAIgB;;AAAe;EAA1D,YAAA,CAAa,UAAA,oBAA8B,eAAA;AAAA;;;AAMN;KAA3B,kBAAA,GAAqB,MAAM;AAAA,KAE3B,kBAAA;AAAA,KAEA,sBAAA;EAAA,SACD,MAAA;EAAA,SACA,KAAK;AAAA;AAAA,KAGJ,uBAAA;EAAA,SACD,EAAA,EAAI,kBAAA;EAAA,SACJ,KAAA;EAAA,SACA,MAAA,EAAQ,MAAA;EAHP;;;;EAAA,SAQD,iBAAA,GAAoB,GAAA;AAAA;;;;;;UAQd,gBAAA,mBAAmC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA;EAAA,SACzE,QAAA,EAAU,SAAA;EATV;;;EAAA,SAaA,cAAA,EAAgB,qBAAA;EALV;;;EAAA,SASN,gBAAA,EAAkB,uBAAA;EAAA,SAClB,eAAA,EAAiB,oBAAA;EAVwD;;;EAAA,SAczE,KAAA,EAAO,kBAAA;EALW;;;EAS3B,qBAAA,CAAsB,OAAA,EAAS,uBAAA,GAA0B,aAAA,CAAc,sBAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as AnyQueryAst } from "./types-
|
|
1
|
+
import { f as AnyQueryAst } from "./types-CXQF5KS8.mjs";
|
|
2
2
|
import { ExecutionPlan } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/sql-execution-plan.d.ts
|
|
@@ -29,4 +29,4 @@ interface SqlExecutionPlan<Row = unknown> extends ExecutionPlan<Row> {
|
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
export { SqlExecutionPlan as t };
|
|
32
|
-
//# sourceMappingURL=sql-execution-plan-
|
|
32
|
+
//# sourceMappingURL=sql-execution-plan-Dopo3SDj.d.mts.map
|
package/dist/{sql-execution-plan-D4OimCVH.d.mts.map → sql-execution-plan-Dopo3SDj.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-execution-plan-
|
|
1
|
+
{"version":3,"file":"sql-execution-plan-Dopo3SDj.d.mts","names":[],"sources":["../src/sql-execution-plan.ts"],"mappings":";;;;;;AAuBA;;;;;;;;;;;;;;;;AAG2B;;UAHV,gBAAA,wBAAwC,aAAA,CAAc,GAAA;EAAA,SAC5D,GAAA;EAAA,SACA,MAAA;EAAA,SACA,GAAA,EAAK,WAAA;AAAA"}
|