@prisma-next/sql-relational-core 0.16.0-dev.3 → 0.16.0-dev.31
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-C8vFGWij.d.mts → codec-types-Bayoa4PI.d.mts} +3 -2
- package/dist/codec-types-Bayoa4PI.d.mts.map +1 -0
- package/dist/{ddl-types-DzaZCtFT.d.mts → ddl-types-B3SfjPGI.d.mts} +3 -3
- package/dist/ddl-types-B3SfjPGI.d.mts.map +1 -0
- package/dist/{ddl-types-DFKQr_qQ.mjs → ddl-types-BUoa33yk.mjs} +3 -2
- package/dist/ddl-types-BUoa33yk.mjs.map +1 -0
- package/dist/exports/ast.d.mts +4 -4
- package/dist/exports/ast.d.mts.map +1 -1
- package/dist/exports/ast.mjs +82 -8
- package/dist/exports/ast.mjs.map +1 -1
- package/dist/exports/codec-descriptor-registry.d.mts +2 -2
- package/dist/exports/codec-descriptor-registry.d.mts.map +1 -1
- package/dist/exports/codec-descriptor-registry.mjs +2 -1
- package/dist/exports/codec-descriptor-registry.mjs.map +1 -1
- package/dist/exports/contract-free.d.mts +3 -3
- package/dist/exports/contract-free.d.mts.map +1 -1
- package/dist/exports/contract-free.mjs +4 -3
- package/dist/exports/contract-free.mjs.map +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/plan.d.mts +2 -2
- package/dist/exports/query-lane-context.d.mts +1 -1
- package/dist/exports/types.d.mts +1 -1
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +4 -4
- package/dist/{middleware-CFDg6XOc.d.mts → middleware-_9-4TYKC.d.mts} +2 -2
- package/dist/{middleware-CFDg6XOc.d.mts.map → middleware-_9-4TYKC.d.mts.map} +1 -1
- package/dist/{plan-CBT55zev.d.mts → plan-Dq94efZJ.d.mts} +2 -2
- package/dist/{plan-CBT55zev.d.mts.map → plan-Dq94efZJ.d.mts.map} +1 -1
- package/dist/{query-lane-context-BNbbusGn.d.mts → query-lane-context-DTCOHMXn.d.mts} +2 -2
- package/dist/{query-lane-context-BNbbusGn.d.mts.map → query-lane-context-DTCOHMXn.d.mts.map} +1 -1
- package/dist/{sql-execution-plan-CPw3uKrJ.d.mts → sql-execution-plan-B-C-6cZN.d.mts} +2 -2
- package/dist/{sql-execution-plan-CPw3uKrJ.d.mts.map → sql-execution-plan-B-C-6cZN.d.mts.map} +1 -1
- package/dist/{types-DtzFztRV.mjs → types-CINOak-F.mjs} +164 -27
- package/dist/types-CINOak-F.mjs.map +1 -0
- package/dist/{types-BR266jxM.d.mts → types-CRV7uuOC.d.mts} +5 -5
- package/dist/{types-BR266jxM.d.mts.map → types-CRV7uuOC.d.mts.map} +1 -1
- package/dist/{types-Dr3jep6j.d.mts → types-CWlaErjN.d.mts} +97 -13
- package/dist/types-CWlaErjN.d.mts.map +1 -0
- package/package.json +11 -11
- package/src/ast/codec-types.ts +37 -0
- package/src/ast/ddl-types.ts +2 -1
- package/src/ast/json-value-projection.ts +100 -0
- package/src/ast/sql-codec-helpers.ts +20 -5
- package/src/ast/types.ts +235 -52
- package/src/codec-descriptor-registry.ts +4 -1
- package/src/contract-free/table.ts +5 -1
- package/src/exports/ast.ts +1 -0
- package/dist/codec-types-C8vFGWij.d.mts.map +0 -1
- package/dist/ddl-types-DFKQr_qQ.mjs.map +0 -1
- package/dist/ddl-types-DzaZCtFT.d.mts.map +0 -1
- package/dist/types-Dr3jep6j.d.mts.map +0 -1
- package/dist/types-DtzFztRV.mjs.map +0 -1
|
@@ -1,6 +1,44 @@
|
|
|
1
|
-
import { o as CodecRef } from "./codec-types-
|
|
1
|
+
import { o as CodecRef } from "./codec-types-Bayoa4PI.mjs";
|
|
2
2
|
import { ParamSpec } from "@prisma-next/operations";
|
|
3
3
|
import { SqlLoweringSpec } from "@prisma-next/sql-operations";
|
|
4
|
+
//#region src/ast/json-value-projection.d.ts
|
|
5
|
+
declare abstract class JsonValueProjection {
|
|
6
|
+
abstract readonly kind: string;
|
|
7
|
+
readonly value: ProjectionExpr;
|
|
8
|
+
protected constructor(value: ProjectionExpr);
|
|
9
|
+
abstract accept<R>(visitor: JsonValueProjectionVisitor<R>): R;
|
|
10
|
+
abstract rewrite(rewriter: ExpressionRewriter): AnyJsonValueProjection;
|
|
11
|
+
fold<T>(folder: ExpressionFolder<T>): T;
|
|
12
|
+
collectColumnRefs(): ColumnRef[];
|
|
13
|
+
collectParamRefs(): AnyParamRef[];
|
|
14
|
+
protected freeze(): void;
|
|
15
|
+
}
|
|
16
|
+
interface JsonValueProjectionVisitor<R> {
|
|
17
|
+
codec(projection: CodecJsonValueProjection): R;
|
|
18
|
+
native(projection: NativeJsonValueProjection): R;
|
|
19
|
+
document(projection: JsonDocumentProjection): R;
|
|
20
|
+
}
|
|
21
|
+
declare class CodecJsonValueProjection extends JsonValueProjection {
|
|
22
|
+
readonly kind: "codec";
|
|
23
|
+
readonly codec: CodecRef;
|
|
24
|
+
constructor(value: ProjectionExpr, codec: CodecRef);
|
|
25
|
+
accept<R>(visitor: JsonValueProjectionVisitor<R>): R;
|
|
26
|
+
rewrite(rewriter: ExpressionRewriter): CodecJsonValueProjection;
|
|
27
|
+
}
|
|
28
|
+
declare class NativeJsonValueProjection extends JsonValueProjection {
|
|
29
|
+
readonly kind: "native";
|
|
30
|
+
constructor(value: ProjectionExpr);
|
|
31
|
+
accept<R>(visitor: JsonValueProjectionVisitor<R>): R;
|
|
32
|
+
rewrite(rewriter: ExpressionRewriter): NativeJsonValueProjection;
|
|
33
|
+
}
|
|
34
|
+
declare class JsonDocumentProjection extends JsonValueProjection {
|
|
35
|
+
readonly kind: "document";
|
|
36
|
+
constructor(value: ProjectionExpr);
|
|
37
|
+
accept<R>(visitor: JsonValueProjectionVisitor<R>): R;
|
|
38
|
+
rewrite(rewriter: ExpressionRewriter): JsonDocumentProjection;
|
|
39
|
+
}
|
|
40
|
+
type AnyJsonValueProjection = CodecJsonValueProjection | NativeJsonValueProjection | JsonDocumentProjection;
|
|
41
|
+
//#endregion
|
|
4
42
|
//#region src/ast/types.d.ts
|
|
5
43
|
type Direction = 'asc' | 'desc';
|
|
6
44
|
type BinaryOp = 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte' | 'like' | 'in' | 'notIn';
|
|
@@ -41,6 +79,9 @@ interface ExprVisitor<R> {
|
|
|
41
79
|
operation(expr: OperationExpr): R;
|
|
42
80
|
aggregate(expr: AggregateExpr): R;
|
|
43
81
|
windowFunc(expr: WindowFuncExpr): R;
|
|
82
|
+
functionCall(expr: FunctionCallExpr): R;
|
|
83
|
+
cast(expr: CastExpr): R;
|
|
84
|
+
case(expr: CaseExpr): R;
|
|
44
85
|
jsonObject(expr: JsonObjectExpr): R;
|
|
45
86
|
jsonArrayAgg(expr: JsonArrayAggExpr): R;
|
|
46
87
|
binary(expr: BinaryExpr): R;
|
|
@@ -74,7 +115,7 @@ type JoinOnExpr = EqColJoinOn | AnyExpression;
|
|
|
74
115
|
type WhereArg = AnyExpression | ToWhereExpr;
|
|
75
116
|
type JsonObjectEntry = {
|
|
76
117
|
readonly key: string;
|
|
77
|
-
readonly value:
|
|
118
|
+
readonly value: AnyJsonValueProjection;
|
|
78
119
|
};
|
|
79
120
|
declare abstract class AstNode {
|
|
80
121
|
abstract readonly kind: string;
|
|
@@ -89,6 +130,7 @@ declare abstract class FromSource extends AstNode {
|
|
|
89
130
|
abstract toFromSource(): AnyFromSource;
|
|
90
131
|
}
|
|
91
132
|
declare abstract class Expression extends AstNode implements ExpressionSource {
|
|
133
|
+
#private;
|
|
92
134
|
abstract accept<R>(visitor: ExprVisitor<R>): R;
|
|
93
135
|
abstract rewrite(rewriter: ExpressionRewriter): AnyExpression;
|
|
94
136
|
abstract fold<T>(folder: ExpressionFolder<T>): T;
|
|
@@ -127,13 +169,21 @@ declare class DerivedTableSource extends FromSource {
|
|
|
127
169
|
rewrite(rewriter: AstRewriter): AnyFromSource;
|
|
128
170
|
toFromSource(): AnyFromSource;
|
|
129
171
|
}
|
|
172
|
+
interface FunctionSourceAlias {
|
|
173
|
+
readonly alias: string;
|
|
174
|
+
readonly columnAliases?: ReadonlyArray<string>;
|
|
175
|
+
}
|
|
130
176
|
declare class FunctionSource extends FromSource {
|
|
177
|
+
#private;
|
|
131
178
|
readonly kind: "function-source";
|
|
132
179
|
readonly fn: string;
|
|
133
180
|
readonly args: ReadonlyArray<AnyExpression>;
|
|
134
181
|
readonly alias: string | undefined;
|
|
135
|
-
|
|
136
|
-
|
|
182
|
+
readonly columnAliases: ReadonlyArray<string> | undefined;
|
|
183
|
+
readonly ordinality: boolean;
|
|
184
|
+
protected constructor(fn: string, args: ReadonlyArray<AnyExpression>, alias?: FunctionSourceAlias, ordinality?: boolean);
|
|
185
|
+
static of(fn: string, args: ReadonlyArray<AnyExpression>, alias?: FunctionSourceAlias): FunctionSource;
|
|
186
|
+
withOrdinality(): FunctionSource;
|
|
137
187
|
rewrite(rewriter: AstRewriter): AnyFromSource;
|
|
138
188
|
toFromSource(): AnyFromSource;
|
|
139
189
|
}
|
|
@@ -295,11 +345,45 @@ declare class WindowFuncExpr extends Expression {
|
|
|
295
345
|
rewrite(rewriter: ExpressionRewriter): AnyExpression;
|
|
296
346
|
fold<T>(folder: ExpressionFolder<T>): T;
|
|
297
347
|
}
|
|
348
|
+
declare class FunctionCallExpr extends Expression {
|
|
349
|
+
readonly kind: "function-call";
|
|
350
|
+
readonly fn: string;
|
|
351
|
+
readonly args: ReadonlyArray<AnyExpression>;
|
|
352
|
+
constructor(fn: string, args: ReadonlyArray<AnyExpression>);
|
|
353
|
+
static of(fn: string, args: ReadonlyArray<AnyExpression>): FunctionCallExpr;
|
|
354
|
+
accept<R>(visitor: ExprVisitor<R>): R;
|
|
355
|
+
rewrite(rewriter: ExpressionRewriter): AnyExpression;
|
|
356
|
+
fold<T>(folder: ExpressionFolder<T>): T;
|
|
357
|
+
}
|
|
358
|
+
declare class CastExpr extends Expression {
|
|
359
|
+
readonly kind: "cast";
|
|
360
|
+
readonly expr: AnyExpression;
|
|
361
|
+
readonly targetType: string;
|
|
362
|
+
constructor(expr: AnyExpression, targetType: string);
|
|
363
|
+
static as(expr: AnyExpression, targetType: string): CastExpr;
|
|
364
|
+
accept<R>(visitor: ExprVisitor<R>): R;
|
|
365
|
+
rewrite(rewriter: ExpressionRewriter): AnyExpression;
|
|
366
|
+
fold<T>(folder: ExpressionFolder<T>): T;
|
|
367
|
+
}
|
|
368
|
+
interface CaseBranch {
|
|
369
|
+
readonly condition: AnyExpression;
|
|
370
|
+
readonly value: AnyExpression;
|
|
371
|
+
}
|
|
372
|
+
declare class CaseExpr extends Expression {
|
|
373
|
+
readonly kind: "case";
|
|
374
|
+
readonly branches: ReadonlyArray<Readonly<CaseBranch>>;
|
|
375
|
+
readonly elseExpr: AnyExpression | undefined;
|
|
376
|
+
constructor(branches: ReadonlyArray<CaseBranch>, elseExpr?: AnyExpression);
|
|
377
|
+
static of(branches: ReadonlyArray<CaseBranch>, elseExpr?: AnyExpression): CaseExpr;
|
|
378
|
+
accept<R>(visitor: ExprVisitor<R>): R;
|
|
379
|
+
rewrite(rewriter: ExpressionRewriter): AnyExpression;
|
|
380
|
+
fold<T>(folder: ExpressionFolder<T>): T;
|
|
381
|
+
}
|
|
298
382
|
declare class JsonObjectExpr extends Expression {
|
|
299
383
|
readonly kind: "json-object";
|
|
300
384
|
readonly entries: ReadonlyArray<JsonObjectEntry>;
|
|
301
385
|
constructor(entries: ReadonlyArray<JsonObjectEntry>);
|
|
302
|
-
static entry(key: string, value:
|
|
386
|
+
static entry(key: string, value: AnyJsonValueProjection): JsonObjectEntry;
|
|
303
387
|
static fromEntries(entries: ReadonlyArray<JsonObjectEntry>): JsonObjectExpr;
|
|
304
388
|
accept<R>(visitor: ExprVisitor<R>): R;
|
|
305
389
|
rewrite(rewriter: ExpressionRewriter): AnyExpression;
|
|
@@ -322,11 +406,11 @@ declare class OrderByItem extends AstNode {
|
|
|
322
406
|
}
|
|
323
407
|
declare class JsonArrayAggExpr extends Expression {
|
|
324
408
|
readonly kind: "json-array-agg";
|
|
325
|
-
readonly expr:
|
|
409
|
+
readonly expr: AnyJsonValueProjection;
|
|
326
410
|
readonly onEmpty: 'null' | 'emptyArray';
|
|
327
411
|
readonly orderBy: ReadonlyArray<OrderByItem> | undefined;
|
|
328
|
-
constructor(expr:
|
|
329
|
-
static of(expr:
|
|
412
|
+
constructor(expr: AnyJsonValueProjection, onEmpty?: 'null' | 'emptyArray', orderBy?: ReadonlyArray<OrderByItem>);
|
|
413
|
+
static of(expr: AnyJsonValueProjection, onEmpty?: 'null' | 'emptyArray', orderBy?: ReadonlyArray<OrderByItem>): JsonArrayAggExpr;
|
|
330
414
|
accept<R>(visitor: ExprVisitor<R>): R;
|
|
331
415
|
rewrite(rewriter: ExpressionRewriter): AnyExpression;
|
|
332
416
|
fold<T>(folder: ExpressionFolder<T>): T;
|
|
@@ -437,9 +521,9 @@ declare class ProjectionItem extends AstNode {
|
|
|
437
521
|
readonly alias: string;
|
|
438
522
|
readonly expr: ProjectionExpr;
|
|
439
523
|
/**
|
|
440
|
-
* Codec identity for
|
|
524
|
+
* Codec identity for any known projected result, whether read directly from a contract column or forwarded through a query wrapper. Decode-side dispatch resolves the per-instance codec through `contractCodecs.forCodecRef(codec)` — content-keyed memoisation collapses repeated lookups for the same logical result onto one shared {@link Codec}.
|
|
441
525
|
*
|
|
442
|
-
* Stays `undefined`
|
|
526
|
+
* Stays `undefined` only when the projected result's codec is unknown, such as computed expressions, subqueries, or raw aliases whose decoded type the runtime cannot infer.
|
|
443
527
|
*/
|
|
444
528
|
readonly codec: CodecRef | undefined;
|
|
445
529
|
constructor(alias: string, expr: ProjectionExpr, codec?: CodecRef);
|
|
@@ -595,7 +679,7 @@ declare class RawSqlExpr extends QueryAst {
|
|
|
595
679
|
}
|
|
596
680
|
type AnyQueryAst = SelectAst | InsertAst | UpdateAst | DeleteAst | RawSqlExpr;
|
|
597
681
|
type AnyFromSource = TableSource | DerivedTableSource | FunctionSource;
|
|
598
|
-
type AnyExpression = ColumnRef | IdentifierRef | ParamRef | PreparedParamRef | LiteralExpr | SubqueryExpr | OperationExpr | AggregateExpr | WindowFuncExpr | JsonObjectExpr | JsonArrayAggExpr | ListExpression | BinaryExpr | AndExpr | OrExpr | ExistsExpr | NullCheckExpr | NotExpr | RawExpr;
|
|
682
|
+
type AnyExpression = ColumnRef | IdentifierRef | ParamRef | PreparedParamRef | LiteralExpr | SubqueryExpr | OperationExpr | AggregateExpr | WindowFuncExpr | FunctionCallExpr | CastExpr | CaseExpr | JsonObjectExpr | JsonArrayAggExpr | ListExpression | BinaryExpr | AndExpr | OrExpr | ExistsExpr | NullCheckExpr | NotExpr | RawExpr;
|
|
599
683
|
type AnyParamRef = ParamRef | PreparedParamRef;
|
|
600
684
|
type AnyInsertOnConflictAction = DoNothingConflictAction | DoUpdateSetConflictAction;
|
|
601
685
|
type AnyInsertValue = ColumnRef | ParamRef | PreparedParamRef | DefaultValueExpr | RawExpr;
|
|
@@ -634,5 +718,5 @@ interface LoweredStatement {
|
|
|
634
718
|
readonly annotations?: Record<string, unknown>;
|
|
635
719
|
}
|
|
636
720
|
//#endregion
|
|
637
|
-
export {
|
|
638
|
-
//# sourceMappingURL=types-
|
|
721
|
+
export { OrderByItem as $, ExpressionRewriter as A, JoinOnExpr as B, Direction as C, JsonDocumentProjection as Ct, ExistsExpr as D, EqColJoinOn as E, IdentifierRef as F, ListExpression as G, JsonObjectEntry as H, InsertAst as I, LoweredStatement as J, LiteralExpr as K, InsertOnConflict as L, FunctionCallExpr as M, FunctionSource as N, ExprVisitor as O, FunctionSourceAlias as P, OrExpr as Q, InsertValue as R, DerivedTableSource as S, CodecJsonValueProjection as St, DoUpdateSetConflictAction as T, NativeJsonValueProjection as Tt, JsonObjectExpr as U, JsonArrayAggExpr as V, LimitOffsetValue as W, NullCheckExpr as X, NotExpr as Y, OperationExpr as Z, CaseExpr as _, isQueryAst as _t, AndExpr as a, RawSqlExpr as at, DefaultValueExpr as b, whereExprKinds as bt, AnyInsertOnConflictAction as c, SelectAstOptions as ct, AnyParamRef as d, TableSource as dt, ParamRef as et, AnyQueryAst as f, ToWhereExpr as ft, CaseBranch as g, WindowFuncExpr as gt, BinaryOp as h, WindowFn as ht, AggregateOpFn as i, RawExpr as it, ExpressionSource as j, ExpressionFolder as k, AnyInsertValue as l, SubqueryExpr as lt, BinaryExpr as m, WhereArg as mt, AggregateExpr as n, ProjectionExpr as nt, AnyExpression as o, RawSqlLiteral as ot, AstRewriter as p, UpdateAst as pt, LoweredParam as q, AggregateFn as r, ProjectionItem as rt, AnyFromSource as s, SelectAst as st, AggregateCountFn as t, PreparedParamRef as tt, AnyOperationArg as u, TableRef as ut, CastExpr as v, isWhereExpr as vt, DoNothingConflictAction as w, JsonValueProjectionVisitor as wt, DeleteAst as x, AnyJsonValueProjection as xt, ColumnRef as y, queryAstKinds as yt, JoinAst as z };
|
|
722
|
+
//# sourceMappingURL=types-CWlaErjN.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CWlaErjN.d.mts","names":[],"sources":["../src/ast/json-value-projection.ts","../src/ast/types.ts"],"mappings":";;;;uBASe;oBACK;WACT,OAAO;YAEP,YAAa,OAAO;WAIpB,OAAO,GAAG,SAAS,2BAA2B,KAAK;WACnD,QAAQ,UAAU,qBAAqB;EAEhD,KAAK,GAAG,QAAQ,iBAAiB,KAAK;EAItC,qBAAqB;EAIrB,oBAAoB;YAIV;;UAKK,2BAA2B;EAC1C,MAAM,YAAY,2BAA2B;EAC7C,OAAO,YAAY,4BAA4B;EAC/C,SAAS,YAAY,yBAAyB;;cAGnC,iCAAiC;WACnC;WACA,OAAO;cAEJ,OAAO,gBAAgB,OAAO;EAMjC,OAAO,GAAG,SAAS,2BAA2B,KAAK;EAInD,QAAQ,UAAU,qBAAqB;;cAKrC,kCAAkC;WACpC;cAEG,OAAO;EAKV,OAAO,GAAG,SAAS,2BAA2B,KAAK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BAAgB;iBASb,WAAW,iBAAiB,SAAS;iBAUrC,YAAY,iBAAiB,SAAS;UAUrC;EACf,eAAe;;;;;;;;;;;;;;;;KAiBL;WACG;WAA0B;;WAC1B;WAAuB;;UAErB;WACN;WACA,iBAAiB;WACjB,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sql-relational-core",
|
|
3
|
-
"version": "0.16.0-dev.
|
|
3
|
+
"version": "0.16.0-dev.31",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "AST types, query lane context, and type utilities for Prisma Next SQL lanes",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/contract": "0.16.0-dev.
|
|
10
|
-
"@prisma-next/framework-components": "0.16.0-dev.
|
|
11
|
-
"@prisma-next/operations": "0.16.0-dev.
|
|
12
|
-
"@prisma-next/sql-contract": "0.16.0-dev.
|
|
13
|
-
"@prisma-next/sql-operations": "0.16.0-dev.
|
|
14
|
-
"@prisma-next/utils": "0.16.0-dev.
|
|
9
|
+
"@prisma-next/contract": "0.16.0-dev.31",
|
|
10
|
+
"@prisma-next/framework-components": "0.16.0-dev.31",
|
|
11
|
+
"@prisma-next/operations": "0.16.0-dev.31",
|
|
12
|
+
"@prisma-next/sql-contract": "0.16.0-dev.31",
|
|
13
|
+
"@prisma-next/sql-operations": "0.16.0-dev.31",
|
|
14
|
+
"@prisma-next/utils": "0.16.0-dev.31",
|
|
15
15
|
"@standard-schema/spec": "^1.1.0",
|
|
16
16
|
"arktype": "^2.2.2",
|
|
17
17
|
"ts-toolbelt": "^9.6.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@prisma-next/sql-contract-ts": "0.16.0-dev.
|
|
21
|
-
"@prisma-next/test-utils": "0.16.0-dev.
|
|
22
|
-
"@prisma-next/tsconfig": "0.16.0-dev.
|
|
23
|
-
"@prisma-next/tsdown": "0.16.0-dev.
|
|
20
|
+
"@prisma-next/sql-contract-ts": "0.16.0-dev.31",
|
|
21
|
+
"@prisma-next/test-utils": "0.16.0-dev.31",
|
|
22
|
+
"@prisma-next/tsconfig": "0.16.0-dev.31",
|
|
23
|
+
"@prisma-next/tsdown": "0.16.0-dev.31",
|
|
24
24
|
"tsdown": "0.22.8",
|
|
25
25
|
"typescript": "5.9.3",
|
|
26
26
|
"vitest": "4.1.10"
|
package/src/ast/codec-types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JsonValue } from '@prisma-next/contract/types';
|
|
1
2
|
import type {
|
|
2
3
|
Codec as BaseCodec,
|
|
3
4
|
CodecCallContext,
|
|
@@ -6,6 +7,7 @@ import type {
|
|
|
6
7
|
CodecRef,
|
|
7
8
|
CodecTrait,
|
|
8
9
|
} from '@prisma-next/framework-components/codec';
|
|
10
|
+
import { ifDefined } from '@prisma-next/utils/defined';
|
|
9
11
|
|
|
10
12
|
export type {
|
|
11
13
|
CodecCallContext,
|
|
@@ -14,6 +16,41 @@ export type {
|
|
|
14
16
|
CodecTrait,
|
|
15
17
|
} from '@prisma-next/framework-components/codec';
|
|
16
18
|
|
|
19
|
+
function isJsonArray(value: JsonValue): value is readonly JsonValue[] {
|
|
20
|
+
return Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function freezeJsonValue(value: JsonValue): void {
|
|
24
|
+
if (value === null || typeof value !== 'object') {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (isJsonArray(value)) {
|
|
29
|
+
for (const item of value) {
|
|
30
|
+
freezeJsonValue(item);
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
for (const item of Object.values(value)) {
|
|
34
|
+
freezeJsonValue(item);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Object.freeze(value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function frozenCodecRef(codec: CodecRef): CodecRef {
|
|
42
|
+
const typeParams = codec.typeParams === undefined ? undefined : structuredClone(codec.typeParams);
|
|
43
|
+
if (typeParams !== undefined) {
|
|
44
|
+
freezeJsonValue(typeParams);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return Object.freeze({
|
|
48
|
+
codecId: codec.codecId,
|
|
49
|
+
...ifDefined('typeParams', typeParams),
|
|
50
|
+
...ifDefined('many', codec.many),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
17
54
|
/**
|
|
18
55
|
* SQL-family addressing of a single column. The decode site populates a `SqlColumnRef` whenever it can resolve the cell to a single underlying `(table, column)` (the typical case for projected columns from a single-table source); cells the runtime cannot resolve (aggregate aliases, include aggregate fields, computed projections without a simple ref) get `column = undefined`.
|
|
19
56
|
*
|
package/src/ast/ddl-types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ColumnDefaultLiteralInputValue } from '@prisma-next/contract/types';
|
|
2
2
|
import { isColumnDefaultLiteralInputValue } from '@prisma-next/contract/types';
|
|
3
3
|
import type { ReferentialAction } from '@prisma-next/sql-contract/types';
|
|
4
|
+
import { structuredError } from '@prisma-next/utils/structured-error';
|
|
4
5
|
import type { CodecRef } from './codec-types';
|
|
5
6
|
import type { AnyParamRef } from './types';
|
|
6
7
|
|
|
@@ -38,7 +39,7 @@ export class LiteralColumnDefault extends DdlColumnDefault {
|
|
|
38
39
|
constructor(value: ColumnDefaultLiteralInputValue) {
|
|
39
40
|
super();
|
|
40
41
|
if (!isColumnDefaultLiteralInputValue(value)) {
|
|
41
|
-
throw
|
|
42
|
+
throw structuredError('CONTRACT.DEFAULT_INVALID', 'Invalid column default literal value');
|
|
42
43
|
}
|
|
43
44
|
this.value = value;
|
|
44
45
|
this.freeze();
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type CodecRef, frozenCodecRef } from './codec-types';
|
|
2
|
+
import type {
|
|
3
|
+
AnyParamRef,
|
|
4
|
+
ColumnRef,
|
|
5
|
+
ExpressionFolder,
|
|
6
|
+
ExpressionRewriter,
|
|
7
|
+
ProjectionExpr,
|
|
8
|
+
} from './types';
|
|
9
|
+
|
|
10
|
+
abstract class JsonValueProjection {
|
|
11
|
+
abstract readonly kind: string;
|
|
12
|
+
readonly value: ProjectionExpr;
|
|
13
|
+
|
|
14
|
+
protected constructor(value: ProjectionExpr) {
|
|
15
|
+
this.value = value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
abstract accept<R>(visitor: JsonValueProjectionVisitor<R>): R;
|
|
19
|
+
abstract rewrite(rewriter: ExpressionRewriter): AnyJsonValueProjection;
|
|
20
|
+
|
|
21
|
+
fold<T>(folder: ExpressionFolder<T>): T {
|
|
22
|
+
return this.value.fold(folder);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
collectColumnRefs(): ColumnRef[] {
|
|
26
|
+
return this.value.collectColumnRefs();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
collectParamRefs(): AnyParamRef[] {
|
|
30
|
+
return this.value.collectParamRefs();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
protected freeze(): void {
|
|
34
|
+
Object.freeze(this);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface JsonValueProjectionVisitor<R> {
|
|
39
|
+
codec(projection: CodecJsonValueProjection): R;
|
|
40
|
+
native(projection: NativeJsonValueProjection): R;
|
|
41
|
+
document(projection: JsonDocumentProjection): R;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class CodecJsonValueProjection extends JsonValueProjection {
|
|
45
|
+
readonly kind = 'codec' as const;
|
|
46
|
+
readonly codec: CodecRef;
|
|
47
|
+
|
|
48
|
+
constructor(value: ProjectionExpr, codec: CodecRef) {
|
|
49
|
+
super(value);
|
|
50
|
+
this.codec = frozenCodecRef(codec);
|
|
51
|
+
this.freeze();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override accept<R>(visitor: JsonValueProjectionVisitor<R>): R {
|
|
55
|
+
return visitor.codec(this);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override rewrite(rewriter: ExpressionRewriter): CodecJsonValueProjection {
|
|
59
|
+
return new CodecJsonValueProjection(this.value.rewrite(rewriter), this.codec);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class NativeJsonValueProjection extends JsonValueProjection {
|
|
64
|
+
readonly kind = 'native' as const;
|
|
65
|
+
|
|
66
|
+
constructor(value: ProjectionExpr) {
|
|
67
|
+
super(value);
|
|
68
|
+
this.freeze();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
override accept<R>(visitor: JsonValueProjectionVisitor<R>): R {
|
|
72
|
+
return visitor.native(this);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override rewrite(rewriter: ExpressionRewriter): NativeJsonValueProjection {
|
|
76
|
+
return new NativeJsonValueProjection(this.value.rewrite(rewriter));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class JsonDocumentProjection extends JsonValueProjection {
|
|
81
|
+
readonly kind = 'document' as const;
|
|
82
|
+
|
|
83
|
+
constructor(value: ProjectionExpr) {
|
|
84
|
+
super(value);
|
|
85
|
+
this.freeze();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
override accept<R>(visitor: JsonValueProjectionVisitor<R>): R {
|
|
89
|
+
return visitor.document(this);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
override rewrite(rewriter: ExpressionRewriter): JsonDocumentProjection {
|
|
93
|
+
return new JsonDocumentProjection(this.value.rewrite(rewriter));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type AnyJsonValueProjection =
|
|
98
|
+
| CodecJsonValueProjection
|
|
99
|
+
| NativeJsonValueProjection
|
|
100
|
+
| JsonDocumentProjection;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { JsonValue } from '@prisma-next/contract/types';
|
|
8
|
+
import { structuredError } from '@prisma-next/utils/structured-error';
|
|
8
9
|
|
|
9
10
|
export const SQL_CHAR_CODEC_ID = 'sql/char@1' as const;
|
|
10
11
|
export const SQL_VARCHAR_CODEC_ID = 'sql/varchar@1' as const;
|
|
@@ -19,8 +20,10 @@ export const sqlCharRenderOutputType = (typeParams: { readonly length?: number }
|
|
|
19
20
|
const length = typeParams.length;
|
|
20
21
|
if (length === undefined) return undefined;
|
|
21
22
|
if (typeof length !== 'number' || !Number.isFinite(length) || !Number.isInteger(length)) {
|
|
22
|
-
throw
|
|
23
|
+
throw structuredError(
|
|
24
|
+
'RUNTIME.TYPE_PARAMS_INVALID',
|
|
23
25
|
`renderOutputType: expected integer "length" in typeParams for Char, got ${String(length)}`,
|
|
26
|
+
{ meta: { codec: SQL_CHAR_CODEC_ID, param: 'length', received: String(length) } },
|
|
24
27
|
);
|
|
25
28
|
}
|
|
26
29
|
return `Char<${length}>`;
|
|
@@ -32,8 +35,10 @@ export const sqlVarcharRenderOutputType = (typeParams: { readonly length?: numbe
|
|
|
32
35
|
const length = typeParams.length;
|
|
33
36
|
if (length === undefined) return undefined;
|
|
34
37
|
if (typeof length !== 'number' || !Number.isFinite(length) || !Number.isInteger(length)) {
|
|
35
|
-
throw
|
|
38
|
+
throw structuredError(
|
|
39
|
+
'RUNTIME.TYPE_PARAMS_INVALID',
|
|
36
40
|
`renderOutputType: expected integer "length" in typeParams for Varchar, got ${String(length)}`,
|
|
41
|
+
{ meta: { codec: SQL_VARCHAR_CODEC_ID, param: 'length', received: String(length) } },
|
|
37
42
|
);
|
|
38
43
|
}
|
|
39
44
|
return `Varchar<${length}>`;
|
|
@@ -53,11 +58,19 @@ export const sqlTimestampDecode = (wire: Date): Date => wire;
|
|
|
53
58
|
export const sqlTimestampEncodeJson = (value: Date): JsonValue => value.toISOString();
|
|
54
59
|
export const sqlTimestampDecodeJson = (json: JsonValue): Date => {
|
|
55
60
|
if (typeof json !== 'string') {
|
|
56
|
-
throw
|
|
61
|
+
throw structuredError(
|
|
62
|
+
'RUNTIME.DECODE_FAILED',
|
|
63
|
+
`Expected ISO date string for sql/timestamp@1, got ${typeof json}`,
|
|
64
|
+
{ meta: { codec: SQL_TIMESTAMP_CODEC_ID } },
|
|
65
|
+
);
|
|
57
66
|
}
|
|
58
67
|
const date = new Date(json);
|
|
59
68
|
if (Number.isNaN(date.getTime())) {
|
|
60
|
-
throw
|
|
69
|
+
throw structuredError(
|
|
70
|
+
'RUNTIME.DECODE_FAILED',
|
|
71
|
+
`Invalid ISO date string for sql/timestamp@1: ${json}`,
|
|
72
|
+
{ meta: { codec: SQL_TIMESTAMP_CODEC_ID } },
|
|
73
|
+
);
|
|
61
74
|
}
|
|
62
75
|
return date;
|
|
63
76
|
};
|
|
@@ -71,8 +84,10 @@ export const sqlTimestampRenderOutputType = (typeParams: { readonly precision?:
|
|
|
71
84
|
!Number.isFinite(precision) ||
|
|
72
85
|
!Number.isInteger(precision)
|
|
73
86
|
) {
|
|
74
|
-
throw
|
|
87
|
+
throw structuredError(
|
|
88
|
+
'RUNTIME.TYPE_PARAMS_INVALID',
|
|
75
89
|
`renderOutputType: expected integer "precision" in typeParams for Timestamp, got ${String(precision)}`,
|
|
90
|
+
{ meta: { codec: SQL_TIMESTAMP_CODEC_ID, param: 'precision', received: String(precision) } },
|
|
76
91
|
);
|
|
77
92
|
}
|
|
78
93
|
return `Timestamp<${precision}>`;
|