@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.
Files changed (54) hide show
  1. package/dist/{codec-types-C8vFGWij.d.mts → codec-types-Bayoa4PI.d.mts} +3 -2
  2. package/dist/codec-types-Bayoa4PI.d.mts.map +1 -0
  3. package/dist/{ddl-types-DzaZCtFT.d.mts → ddl-types-B3SfjPGI.d.mts} +3 -3
  4. package/dist/ddl-types-B3SfjPGI.d.mts.map +1 -0
  5. package/dist/{ddl-types-DFKQr_qQ.mjs → ddl-types-BUoa33yk.mjs} +3 -2
  6. package/dist/ddl-types-BUoa33yk.mjs.map +1 -0
  7. package/dist/exports/ast.d.mts +4 -4
  8. package/dist/exports/ast.d.mts.map +1 -1
  9. package/dist/exports/ast.mjs +82 -8
  10. package/dist/exports/ast.mjs.map +1 -1
  11. package/dist/exports/codec-descriptor-registry.d.mts +2 -2
  12. package/dist/exports/codec-descriptor-registry.d.mts.map +1 -1
  13. package/dist/exports/codec-descriptor-registry.mjs +2 -1
  14. package/dist/exports/codec-descriptor-registry.mjs.map +1 -1
  15. package/dist/exports/contract-free.d.mts +3 -3
  16. package/dist/exports/contract-free.d.mts.map +1 -1
  17. package/dist/exports/contract-free.mjs +4 -3
  18. package/dist/exports/contract-free.mjs.map +1 -1
  19. package/dist/exports/expression.d.mts +2 -2
  20. package/dist/exports/expression.mjs +1 -1
  21. package/dist/exports/middleware.d.mts +1 -1
  22. package/dist/exports/plan.d.mts +2 -2
  23. package/dist/exports/query-lane-context.d.mts +1 -1
  24. package/dist/exports/types.d.mts +1 -1
  25. package/dist/index.d.mts +9 -9
  26. package/dist/index.mjs +4 -4
  27. package/dist/{middleware-CFDg6XOc.d.mts → middleware-_9-4TYKC.d.mts} +2 -2
  28. package/dist/{middleware-CFDg6XOc.d.mts.map → middleware-_9-4TYKC.d.mts.map} +1 -1
  29. package/dist/{plan-CBT55zev.d.mts → plan-Dq94efZJ.d.mts} +2 -2
  30. package/dist/{plan-CBT55zev.d.mts.map → plan-Dq94efZJ.d.mts.map} +1 -1
  31. package/dist/{query-lane-context-BNbbusGn.d.mts → query-lane-context-DTCOHMXn.d.mts} +2 -2
  32. package/dist/{query-lane-context-BNbbusGn.d.mts.map → query-lane-context-DTCOHMXn.d.mts.map} +1 -1
  33. package/dist/{sql-execution-plan-CPw3uKrJ.d.mts → sql-execution-plan-B-C-6cZN.d.mts} +2 -2
  34. package/dist/{sql-execution-plan-CPw3uKrJ.d.mts.map → sql-execution-plan-B-C-6cZN.d.mts.map} +1 -1
  35. package/dist/{types-DtzFztRV.mjs → types-CINOak-F.mjs} +164 -27
  36. package/dist/types-CINOak-F.mjs.map +1 -0
  37. package/dist/{types-BR266jxM.d.mts → types-CRV7uuOC.d.mts} +5 -5
  38. package/dist/{types-BR266jxM.d.mts.map → types-CRV7uuOC.d.mts.map} +1 -1
  39. package/dist/{types-Dr3jep6j.d.mts → types-CWlaErjN.d.mts} +97 -13
  40. package/dist/types-CWlaErjN.d.mts.map +1 -0
  41. package/package.json +11 -11
  42. package/src/ast/codec-types.ts +37 -0
  43. package/src/ast/ddl-types.ts +2 -1
  44. package/src/ast/json-value-projection.ts +100 -0
  45. package/src/ast/sql-codec-helpers.ts +20 -5
  46. package/src/ast/types.ts +235 -52
  47. package/src/codec-descriptor-registry.ts +4 -1
  48. package/src/contract-free/table.ts +5 -1
  49. package/src/exports/ast.ts +1 -0
  50. package/dist/codec-types-C8vFGWij.d.mts.map +0 -1
  51. package/dist/ddl-types-DFKQr_qQ.mjs.map +0 -1
  52. package/dist/ddl-types-DzaZCtFT.d.mts.map +0 -1
  53. package/dist/types-Dr3jep6j.d.mts.map +0 -1
  54. package/dist/types-DtzFztRV.mjs.map +0 -1
package/src/ast/types.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import type { ParamSpec } from '@prisma-next/operations';
2
2
  import type { SqlLoweringSpec } from '@prisma-next/sql-operations';
3
+
3
4
  import { ifDefined } from '@prisma-next/utils/defined';
4
- import type { CodecRef } from './codec-types';
5
+ import { InternalError } from '@prisma-next/utils/internal-error';
6
+ import { structuredError } from '@prisma-next/utils/structured-error';
7
+ import { type CodecRef, frozenCodecRef } from './codec-types';
8
+ import type { AnyJsonValueProjection } from './json-value-projection';
5
9
 
6
10
  export type Direction = 'asc' | 'desc';
7
11
 
@@ -50,6 +54,9 @@ export interface ExprVisitor<R> {
50
54
  operation(expr: OperationExpr): R;
51
55
  aggregate(expr: AggregateExpr): R;
52
56
  windowFunc(expr: WindowFuncExpr): R;
57
+ functionCall(expr: FunctionCallExpr): R;
58
+ cast(expr: CastExpr): R;
59
+ case(expr: CaseExpr): R;
53
60
  jsonObject(expr: JsonObjectExpr): R;
54
61
  jsonArrayAgg(expr: JsonArrayAggExpr): R;
55
62
  binary(expr: BinaryExpr): R;
@@ -65,6 +72,31 @@ export interface ExprVisitor<R> {
65
72
  rawExpr(expr: RawExpr): R;
66
73
  }
67
74
 
75
+ const toAnyExpressionVisitor: ExprVisitor<AnyExpression> = {
76
+ columnRef: (expr) => expr,
77
+ identifierRef: (expr) => expr,
78
+ subquery: (expr) => expr,
79
+ operation: (expr) => expr,
80
+ aggregate: (expr) => expr,
81
+ windowFunc: (expr) => expr,
82
+ functionCall: (expr) => expr,
83
+ cast: (expr) => expr,
84
+ case: (expr) => expr,
85
+ jsonObject: (expr) => expr,
86
+ jsonArrayAgg: (expr) => expr,
87
+ binary: (expr) => expr,
88
+ and: (expr) => expr,
89
+ or: (expr) => expr,
90
+ exists: (expr) => expr,
91
+ nullCheck: (expr) => expr,
92
+ not: (expr) => expr,
93
+ literal: (expr) => expr,
94
+ param: (expr) => expr,
95
+ preparedParam: (expr) => expr,
96
+ list: (expr) => expr,
97
+ rawExpr: (expr) => expr,
98
+ };
99
+
68
100
  export interface ExpressionFolder<T> {
69
101
  empty: T;
70
102
  combine(a: T, b: T): T;
@@ -85,7 +117,7 @@ export type JoinOnExpr = EqColJoinOn | AnyExpression;
85
117
  export type WhereArg = AnyExpression | ToWhereExpr;
86
118
  export type JsonObjectEntry = {
87
119
  readonly key: string;
88
- readonly value: ProjectionExpr;
120
+ readonly value: AnyJsonValueProjection;
89
121
  };
90
122
 
91
123
  function frozenArrayCopy<T>(values: readonly T[]): ReadonlyArray<T> {
@@ -102,18 +134,6 @@ function frozenRecordCopy<T>(record: Readonly<Record<string, T>>): Readonly<Reco
102
134
  return Object.freeze({ ...record });
103
135
  }
104
136
 
105
- function frozenCodecRef(codec: CodecRef): CodecRef {
106
- const typeParams =
107
- codec.typeParams === undefined
108
- ? undefined
109
- : (structuredClone(codec.typeParams) as CodecRef['typeParams']);
110
- const base = {
111
- codecId: codec.codecId,
112
- ...ifDefined('typeParams', typeParams),
113
- };
114
- return Object.freeze(codec.many ? { ...base, many: true } : base);
115
- }
116
-
117
137
  function freezeRows(
118
138
  rows: ReadonlyArray<Record<string, InsertValue>>,
119
139
  ): ReadonlyArray<Readonly<Record<string, InsertValue>>> {
@@ -242,7 +262,7 @@ function rewriteUpdateSet(
242
262
  ): Record<string, AnyExpression> {
243
263
  const result: Record<string, AnyExpression> = {};
244
264
  for (const [key, value] of Object.entries(set)) {
245
- result[key] = value.rewrite(rewriter as ExpressionRewriter);
265
+ result[key] = value.rewrite(rewriter);
246
266
  }
247
267
  return result;
248
268
  }
@@ -250,9 +270,13 @@ function rewriteUpdateSet(
250
270
  function rewriteLimitOffset<T extends number | AnyExpression | undefined>(
251
271
  value: T,
252
272
  rewriter: AstRewriter,
253
- ): T {
273
+ ): T;
274
+ function rewriteLimitOffset(
275
+ value: number | AnyExpression | undefined,
276
+ rewriter: AstRewriter,
277
+ ): number | AnyExpression | undefined {
254
278
  if (value === undefined || typeof value === 'number') return value;
255
- return value.rewrite(rewriter) as T;
279
+ return value.rewrite(rewriter);
256
280
  }
257
281
 
258
282
  function rewriteOnConflict(onConflict: InsertOnConflict, rewriter: AstRewriter): InsertOnConflict {
@@ -303,15 +327,19 @@ abstract class Expression extends AstNode implements ExpressionSource {
303
327
  }
304
328
 
305
329
  baseColumnRef(): ColumnRef {
306
- throw new Error(`${this.constructor.name} does not expose a base column reference`);
330
+ throw new InternalError(`${this.constructor.name} does not expose a base column reference`);
331
+ }
332
+
333
+ #asAnyExpression(): AnyExpression {
334
+ return this.accept(toAnyExpressionVisitor);
307
335
  }
308
336
 
309
337
  toExpr(): AnyExpression {
310
- return this as unknown as AnyExpression;
338
+ return this.#asAnyExpression();
311
339
  }
312
340
 
313
341
  not(): NotExpr {
314
- return new NotExpr(this as unknown as AnyExpression);
342
+ return new NotExpr(this.#asAnyExpression());
315
343
  }
316
344
  }
317
345
 
@@ -380,28 +408,65 @@ export class DerivedTableSource extends FromSource {
380
408
  }
381
409
  }
382
410
 
411
+ export interface FunctionSourceAlias {
412
+ readonly alias: string;
413
+ readonly columnAliases?: ReadonlyArray<string>;
414
+ }
415
+
383
416
  export class FunctionSource extends FromSource {
384
417
  readonly kind = 'function-source' as const;
385
418
  readonly fn: string;
386
419
  readonly args: ReadonlyArray<AnyExpression>;
387
420
  readonly alias: string | undefined;
388
-
389
- protected constructor(fn: string, args: ReadonlyArray<AnyExpression>, alias?: string) {
421
+ readonly columnAliases: ReadonlyArray<string> | undefined;
422
+ readonly ordinality: boolean;
423
+
424
+ protected constructor(
425
+ fn: string,
426
+ args: ReadonlyArray<AnyExpression>,
427
+ alias?: FunctionSourceAlias,
428
+ ordinality = false,
429
+ ) {
390
430
  super();
431
+ if (alias?.columnAliases?.length === 0) {
432
+ throw structuredError('SQL.AST_INVALID', 'FunctionSource column aliases must not be empty', {
433
+ meta: { kind: 'function-source', field: 'columnAliases' },
434
+ });
435
+ }
391
436
  this.fn = fn;
392
437
  this.args = frozenArrayCopy(args);
393
- this.alias = alias;
438
+ this.alias = alias?.alias;
439
+ this.columnAliases =
440
+ alias?.columnAliases === undefined ? undefined : frozenArrayCopy(alias.columnAliases);
441
+ this.ordinality = ordinality;
394
442
  this.freeze();
395
443
  }
396
444
 
397
- static of(fn: string, args: ReadonlyArray<AnyExpression>, alias?: string): FunctionSource {
445
+ static of(
446
+ fn: string,
447
+ args: ReadonlyArray<AnyExpression>,
448
+ alias?: FunctionSourceAlias,
449
+ ): FunctionSource {
398
450
  return new FunctionSource(fn, args, alias);
399
451
  }
400
452
 
453
+ #aliasOptions(): FunctionSourceAlias | undefined {
454
+ if (this.alias === undefined) return undefined;
455
+ return {
456
+ alias: this.alias,
457
+ ...ifDefined('columnAliases', this.columnAliases),
458
+ };
459
+ }
460
+
461
+ withOrdinality(): FunctionSource {
462
+ if (this.ordinality) return this;
463
+ return new FunctionSource(this.fn, this.args, this.#aliasOptions(), true);
464
+ }
465
+
401
466
  override rewrite(rewriter: AstRewriter): AnyFromSource {
402
467
  const rewrittenArgs = this.args.map((arg) => rewriteComparable(arg, rewriter));
403
468
  if (rewrittenArgs.every((arg, i) => arg === this.args[i])) return this;
404
- return new FunctionSource(this.fn, rewrittenArgs, this.alias);
469
+ return new FunctionSource(this.fn, rewrittenArgs, this.#aliasOptions(), this.ordinality);
405
470
  }
406
471
 
407
472
  override toFromSource(): AnyFromSource {
@@ -648,9 +713,7 @@ export class OperationExpr extends Expression {
648
713
  return new OperationExpr({
649
714
  method: this.method,
650
715
  self: this.self.rewrite(rewriter),
651
- args: this.args.map((arg) => rewriteComparable(arg, rewriter)) as ReadonlyArray<
652
- AnyExpression | ParamRef | LiteralExpr
653
- >,
716
+ args: this.args.map((arg) => rewriteComparable(arg, rewriter)),
654
717
  returns: this.returns,
655
718
  lowering: this.lowering,
656
719
  });
@@ -712,7 +775,11 @@ export class AggregateExpr extends Expression {
712
775
  constructor(fn: AggregateFn, expr?: AnyExpression) {
713
776
  super();
714
777
  if (fn !== 'count' && expr === undefined) {
715
- throw new Error(`Aggregate function "${fn}" requires an expression`);
778
+ throw structuredError(
779
+ 'ORM.ARGUMENT_INVALID',
780
+ `Aggregate function "${fn}" requires an expression`,
781
+ { meta: { fn } },
782
+ );
716
783
  }
717
784
  this.fn = fn;
718
785
  this.expr = expr;
@@ -825,6 +892,129 @@ export class WindowFuncExpr extends Expression {
825
892
  }
826
893
  }
827
894
 
895
+ export class FunctionCallExpr extends Expression {
896
+ readonly kind = 'function-call' as const;
897
+ readonly fn: string;
898
+ readonly args: ReadonlyArray<AnyExpression>;
899
+
900
+ constructor(fn: string, args: ReadonlyArray<AnyExpression>) {
901
+ super();
902
+ this.fn = fn;
903
+ this.args = frozenArrayCopy(args);
904
+ this.freeze();
905
+ }
906
+
907
+ static of(fn: string, args: ReadonlyArray<AnyExpression>): FunctionCallExpr {
908
+ return new FunctionCallExpr(fn, args);
909
+ }
910
+
911
+ override accept<R>(visitor: ExprVisitor<R>): R {
912
+ return visitor.functionCall(this);
913
+ }
914
+
915
+ override rewrite(rewriter: ExpressionRewriter): AnyExpression {
916
+ return new FunctionCallExpr(
917
+ this.fn,
918
+ this.args.map((arg) => arg.rewrite(rewriter)),
919
+ );
920
+ }
921
+
922
+ override fold<T>(folder: ExpressionFolder<T>): T {
923
+ return combineAll(
924
+ folder,
925
+ this.args.map((arg) => () => arg.fold(folder)),
926
+ );
927
+ }
928
+ }
929
+
930
+ export class CastExpr extends Expression {
931
+ readonly kind = 'cast' as const;
932
+ readonly expr: AnyExpression;
933
+ readonly targetType: string;
934
+
935
+ constructor(expr: AnyExpression, targetType: string) {
936
+ super();
937
+ this.expr = expr;
938
+ this.targetType = targetType;
939
+ this.freeze();
940
+ }
941
+
942
+ static as(expr: AnyExpression, targetType: string): CastExpr {
943
+ return new CastExpr(expr, targetType);
944
+ }
945
+
946
+ override accept<R>(visitor: ExprVisitor<R>): R {
947
+ return visitor.cast(this);
948
+ }
949
+
950
+ override rewrite(rewriter: ExpressionRewriter): AnyExpression {
951
+ return new CastExpr(this.expr.rewrite(rewriter), this.targetType);
952
+ }
953
+
954
+ override fold<T>(folder: ExpressionFolder<T>): T {
955
+ return this.expr.fold(folder);
956
+ }
957
+ }
958
+
959
+ export interface CaseBranch {
960
+ readonly condition: AnyExpression;
961
+ readonly value: AnyExpression;
962
+ }
963
+
964
+ export class CaseExpr extends Expression {
965
+ readonly kind = 'case' as const;
966
+ readonly branches: ReadonlyArray<Readonly<CaseBranch>>;
967
+ readonly elseExpr: AnyExpression | undefined;
968
+
969
+ constructor(branches: ReadonlyArray<CaseBranch>, elseExpr?: AnyExpression) {
970
+ super();
971
+ if (branches.length === 0) {
972
+ throw structuredError('SQL.AST_INVALID', 'CaseExpr requires at least one branch', {
973
+ meta: { kind: 'case', field: 'branches' },
974
+ });
975
+ }
976
+ this.branches = Object.freeze(
977
+ branches.map((branch) =>
978
+ Object.freeze({
979
+ condition: branch.condition,
980
+ value: branch.value,
981
+ }),
982
+ ),
983
+ );
984
+ this.elseExpr = elseExpr;
985
+ this.freeze();
986
+ }
987
+
988
+ static of(branches: ReadonlyArray<CaseBranch>, elseExpr?: AnyExpression): CaseExpr {
989
+ return new CaseExpr(branches, elseExpr);
990
+ }
991
+
992
+ override accept<R>(visitor: ExprVisitor<R>): R {
993
+ return visitor.case(this);
994
+ }
995
+
996
+ override rewrite(rewriter: ExpressionRewriter): AnyExpression {
997
+ return new CaseExpr(
998
+ this.branches.map((branch) => ({
999
+ condition: branch.condition.rewrite(rewriter),
1000
+ value: branch.value.rewrite(rewriter),
1001
+ })),
1002
+ this.elseExpr?.rewrite(rewriter),
1003
+ );
1004
+ }
1005
+
1006
+ override fold<T>(folder: ExpressionFolder<T>): T {
1007
+ const elseExpr = this.elseExpr;
1008
+ return combineAll(folder, [
1009
+ ...this.branches.flatMap((branch) => [
1010
+ () => branch.condition.fold(folder),
1011
+ () => branch.value.fold(folder),
1012
+ ]),
1013
+ ...(elseExpr === undefined ? [] : [() => elseExpr.fold(folder)]),
1014
+ ]);
1015
+ }
1016
+ }
1017
+
828
1018
  export class JsonObjectExpr extends Expression {
829
1019
  readonly kind = 'json-object' as const;
830
1020
  readonly entries: ReadonlyArray<JsonObjectEntry>;
@@ -835,7 +1025,7 @@ export class JsonObjectExpr extends Expression {
835
1025
  this.freeze();
836
1026
  }
837
1027
 
838
- static entry(key: string, value: ProjectionExpr): JsonObjectEntry {
1028
+ static entry(key: string, value: AnyJsonValueProjection): JsonObjectEntry {
839
1029
  return {
840
1030
  key,
841
1031
  value,
@@ -854,12 +1044,7 @@ export class JsonObjectExpr extends Expression {
854
1044
  return new JsonObjectExpr(
855
1045
  this.entries.map((entry) => ({
856
1046
  key: entry.key,
857
- value:
858
- entry.value.kind === 'literal'
859
- ? rewriter.literal
860
- ? rewriter.literal(entry.value)
861
- : entry.value
862
- : entry.value.rewrite(rewriter),
1047
+ value: entry.value.rewrite(rewriter),
863
1048
  })),
864
1049
  );
865
1050
  }
@@ -867,14 +1052,7 @@ export class JsonObjectExpr extends Expression {
867
1052
  override fold<T>(folder: ExpressionFolder<T>): T {
868
1053
  return combineAll(
869
1054
  folder,
870
- this.entries.map(
871
- (entry) => () =>
872
- entry.value.kind === 'literal'
873
- ? folder.literal
874
- ? folder.literal(entry.value)
875
- : folder.empty
876
- : entry.value.fold(folder),
877
- ),
1055
+ this.entries.map((entry) => () => entry.value.fold(folder)),
878
1056
  );
879
1057
  }
880
1058
  }
@@ -915,12 +1093,12 @@ export class OrderByItem extends AstNode {
915
1093
 
916
1094
  export class JsonArrayAggExpr extends Expression {
917
1095
  readonly kind = 'json-array-agg' as const;
918
- readonly expr: AnyExpression;
1096
+ readonly expr: AnyJsonValueProjection;
919
1097
  readonly onEmpty: 'null' | 'emptyArray';
920
1098
  readonly orderBy: ReadonlyArray<OrderByItem> | undefined;
921
1099
 
922
1100
  constructor(
923
- expr: AnyExpression,
1101
+ expr: AnyJsonValueProjection,
924
1102
  onEmpty: 'null' | 'emptyArray' = 'null',
925
1103
  orderBy?: ReadonlyArray<OrderByItem>,
926
1104
  ) {
@@ -932,7 +1110,7 @@ export class JsonArrayAggExpr extends Expression {
932
1110
  }
933
1111
 
934
1112
  static of(
935
- expr: AnyExpression,
1113
+ expr: AnyJsonValueProjection,
936
1114
  onEmpty: 'null' | 'emptyArray' = 'null',
937
1115
  orderBy?: ReadonlyArray<OrderByItem>,
938
1116
  ): JsonArrayAggExpr {
@@ -1304,9 +1482,9 @@ export class ProjectionItem extends AstNode {
1304
1482
  readonly alias: string;
1305
1483
  readonly expr: ProjectionExpr;
1306
1484
  /**
1307
- * Codec identity for the projected cell. Decode-side dispatch resolves the per-instance codec through `contractCodecs.forCodecRef(codec)` — content-keyed memoisation collapses repeated lookups for the same logical column onto one shared {@link Codec}.
1485
+ * 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}.
1308
1486
  *
1309
- * Stays `undefined` for non-column-bound projections (computed expressions, subqueries, raw aliases) whose decoded type the runtime cannot infer from a single contract column.
1487
+ * 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.
1310
1488
  */
1311
1489
  readonly codec: CodecRef | undefined;
1312
1490
 
@@ -1949,7 +2127,7 @@ export class RawSqlExpr extends QueryAst {
1949
2127
  constructor(fragments: readonly string[], args: readonly AnyExpression[]) {
1950
2128
  super();
1951
2129
  if (fragments.length !== args.length + 1) {
1952
- throw new Error(
2130
+ throw new InternalError(
1953
2131
  `RawSqlExpr: fragments.length must equal args.length + 1 (got fragments=${fragments.length}, args=${args.length})`,
1954
2132
  );
1955
2133
  }
@@ -1991,6 +2169,9 @@ export type AnyExpression =
1991
2169
  | OperationExpr
1992
2170
  | AggregateExpr
1993
2171
  | WindowFuncExpr
2172
+ | FunctionCallExpr
2173
+ | CastExpr
2174
+ | CaseExpr
1994
2175
  | JsonObjectExpr
1995
2176
  | JsonArrayAggExpr
1996
2177
  | ListExpression
@@ -2027,7 +2208,8 @@ export function isQueryAst(value: unknown): value is AnyQueryAst {
2027
2208
  typeof value === 'object' &&
2028
2209
  value !== null &&
2029
2210
  'kind' in value &&
2030
- queryAstKinds.has((value as { kind: string }).kind)
2211
+ typeof value.kind === 'string' &&
2212
+ queryAstKinds.has(value.kind)
2031
2213
  );
2032
2214
  }
2033
2215
 
@@ -2036,7 +2218,8 @@ export function isWhereExpr(value: unknown): value is AnyExpression {
2036
2218
  typeof value === 'object' &&
2037
2219
  value !== null &&
2038
2220
  'kind' in value &&
2039
- whereExprKinds.has((value as { kind: string }).kind)
2221
+ typeof value.kind === 'string' &&
2222
+ whereExprKinds.has(value.kind)
2040
2223
  );
2041
2224
  }
2042
2225
 
@@ -1,5 +1,6 @@
1
1
  import type { CodecDescriptor, CodecRef } from '@prisma-next/framework-components/codec';
2
2
  import type { SqlStorage } from '@prisma-next/sql-contract/types';
3
+ import { structuredError } from '@prisma-next/utils/structured-error';
3
4
  import type { AnyCodecDescriptor } from './ast/codec-types';
4
5
  import { codecRefForStorageColumn } from './codec-ref-for-column';
5
6
  import type { CodecDescriptorRegistry } from './query-lane-context';
@@ -24,9 +25,11 @@ export function buildCodecDescriptorRegistry(
24
25
 
25
26
  for (const descriptor of allDescriptors) {
26
27
  if (byId.has(descriptor.codecId)) {
27
- throw new Error(
28
+ throw structuredError(
29
+ 'RUNTIME.DUPLICATE_CODEC',
28
30
  `Duplicate codec descriptor id: '${descriptor.codecId}' — registered twice during registry construction. ` +
29
31
  'Each codecId must be contributed by exactly one component (target / adapter / extension pack).',
32
+ { meta: { codecId: descriptor.codecId } },
30
33
  );
31
34
  }
32
35
  const widened = descriptor as unknown as AnyDescriptor;
@@ -1,5 +1,6 @@
1
1
  import type { ParamSpec } from '@prisma-next/operations';
2
2
  import { blindCast } from '@prisma-next/utils/casts';
3
+ import { structuredError } from '@prisma-next/utils/structured-error';
3
4
  import {
4
5
  AggregateExpr,
5
6
  AndExpr,
@@ -218,7 +219,10 @@ export class CfExprSelectQuery {
218
219
 
219
220
  build(): SelectAst {
220
221
  if (this.joinItems.length > 0 && this.src === undefined) {
221
- throw new Error('CfExprSelectQuery: cannot add a JOIN without a FROM clause');
222
+ throw structuredError(
223
+ 'ORM.ARGUMENT_INVALID',
224
+ 'CfExprSelectQuery: cannot add a JOIN without a FROM clause',
225
+ );
222
226
  }
223
227
  const base =
224
228
  this.src !== undefined
@@ -2,6 +2,7 @@ export * from '../ast/adapter-types';
2
2
  export * from '../ast/codec-types';
3
3
  export * from '../ast/ddl-types';
4
4
  export * from '../ast/driver-types';
5
+ export * from '../ast/json-value-projection';
5
6
  export * from '../ast/sql-codec-helpers';
6
7
  export * from '../ast/sql-codecs';
7
8
  export * from '../ast/types';
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec-types-C8vFGWij.d.mts","names":[],"sources":["../src/ast/codec-types.ts"],"mappings":";;;;;;;UAqBiB;WACN;WACA;;;;;;;UAQM,4BAA4B;WAClC,SAAS;;;;;;;;;;;UAYH,gCAAgC;WACtC,QAAQ;aAAyB;aAAwB;;;;;;UAMnD;WACN;aACE;eACE;iBACE;;;;;;;;;;;;UAaA,QACf,4BACA,yBAAyB,wBAAwB,cACjD,iBACA,0BACQ,MAAU,IAAI,SAAS,OAAO;EACtC,OAAO,OAAO,QAAQ,KAAK,sBAAsB,QAAQ;EACzD,OAAO,MAAM,OAAO,KAAK,sBAAsB,QAAQ;;;;;;;;;UAUxC;;;;;;EAMf,UAAU,qBAAqB,eAAe,iBAAiB;;;;;;EAO/D,YAAY,KAAK,WAAW;;;;;;KAQlB,qBAAqB;KAE5B,wBAAwB,KAC3B,UAAU,sBAAsB,MAAM,WAAW,WAAW;KAElD,kBAAkB,KAAK,UAAU,qBAAqB;KAEtD,qBAAqB,KAC/B,wBAAwB,WAAW,uBAA2B,6BAA6B,MACvF;;;;;;;KASM,sBAAsB,KAAK;WAC5B,cAAc,yBAAyB;IAE9C,kBAAkB;;;;;;KAQV,kBACV,gCACY,WAAW,cAAc,wBACjC,oCAEM,WAAW,eAAe,kBAAkB,YAAY;WACvD,OAAO,qBAAqB,YAAY;WACxC,QAAQ,qBAAqB,YAAY;WACzC,QAAQ,sBAAsB,YAAY"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ddl-types-DFKQr_qQ.mjs","names":[],"sources":["../src/ast/ddl-types.ts"],"sourcesContent":["import type { ColumnDefaultLiteralInputValue } from '@prisma-next/contract/types';\nimport { isColumnDefaultLiteralInputValue } from '@prisma-next/contract/types';\nimport type { ReferentialAction } from '@prisma-next/sql-contract/types';\nimport type { CodecRef } from './codec-types';\nimport type { AnyParamRef } from './types';\n\n/**\n * Render-time context the column-default visitor needs to make dialect\n * decisions that depend on the parent column. Today only the parent\n * column's native type (`\"jsonb\"`, `\"text\"`, …) — the Postgres renderer\n * uses it to decide whether to emit a `::jsonb` / `::json` cast on JSON\n * literal defaults so the emitted DDL matches the column type without\n * relying on Postgres's implicit text → jsonb cast at default-evaluation\n * time. Additional fields can join without re-shaping the interface.\n */\nexport interface DdlColumnRenderContext {\n readonly nativeType: string;\n}\n\nexport interface DdlColumnDefaultVisitor<R> {\n literal(node: LiteralColumnDefault, ctx: DdlColumnRenderContext): R;\n function(node: FunctionColumnDefault, ctx: DdlColumnRenderContext): R;\n}\n\nexport abstract class DdlColumnDefault {\n abstract readonly kind: string;\n abstract accept<R>(visitor: DdlColumnDefaultVisitor<R>, ctx: DdlColumnRenderContext): R;\n\n protected freeze(): void {\n Object.freeze(this);\n }\n}\n\nexport class LiteralColumnDefault extends DdlColumnDefault {\n readonly kind = 'literal' as const;\n readonly value: ColumnDefaultLiteralInputValue;\n\n constructor(value: ColumnDefaultLiteralInputValue) {\n super();\n if (!isColumnDefaultLiteralInputValue(value)) {\n throw new Error('Invalid column default literal value');\n }\n this.value = value;\n this.freeze();\n }\n\n override accept<R>(visitor: DdlColumnDefaultVisitor<R>, ctx: DdlColumnRenderContext): R {\n return visitor.literal(this, ctx);\n }\n}\n\nexport class FunctionColumnDefault extends DdlColumnDefault {\n readonly kind = 'function' as const;\n readonly expression: string;\n\n constructor(expression: string) {\n super();\n this.expression = expression;\n this.freeze();\n }\n\n override accept<R>(visitor: DdlColumnDefaultVisitor<R>, ctx: DdlColumnRenderContext): R {\n return visitor.function(this, ctx);\n }\n}\n\nexport type AnyDdlColumnDefault = LiteralColumnDefault | FunctionColumnDefault;\n\nexport class DdlColumn {\n readonly name: string;\n readonly type: string;\n readonly notNull?: boolean | undefined;\n readonly primaryKey?: boolean | undefined;\n readonly default?: AnyDdlColumnDefault | undefined;\n /** Codec identity for this column. When present, the DDL walker resolves the codec via `codecLookup.get(codecRef.codecId)` and calls `codec.encode(default.value, {})` to obtain the wire value before inlining the literal default into the DDL string. When absent, literal defaults follow RawSqlLiteral wire-scalar semantics (string / number / boolean / bigint / null / Uint8Array / Date inlined directly). */\n readonly codecRef?: CodecRef | undefined;\n\n constructor(options: {\n readonly name: string;\n readonly type: string;\n readonly notNull?: boolean;\n readonly primaryKey?: boolean;\n readonly default?: AnyDdlColumnDefault;\n readonly codecRef?: CodecRef;\n }) {\n this.name = options.name;\n this.type = options.type;\n this.notNull = options.notNull;\n this.primaryKey = options.primaryKey;\n this.default = options.default;\n this.codecRef = options.codecRef;\n Object.freeze(this);\n }\n}\n\nexport abstract class DdlNode {\n abstract readonly kind: string;\n\n /**\n * Structural brand: every DDL node answers `true`. Lets {@link isDdlNode}\n * recognise any `DdlNode` subclass — including target-contributed kinds —\n * without a central kind registry that subclasses would have to register\n * into.\n */\n isDdlNode(): true {\n return true;\n }\n\n protected freeze(): void {\n Object.freeze(this);\n }\n\n collectParamRefs(): AnyParamRef[] {\n return [];\n }\n}\n\nexport function isDdlNode(value: unknown): value is DdlNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'isDdlNode' in value &&\n typeof value.isDdlNode === 'function'\n );\n}\n\n// ---------------------------------------------------------------------------\n// Table-level constraint nodes\n// ---------------------------------------------------------------------------\n\n/**\n * A composite (or single-column) PRIMARY KEY constraint on a `CreateTable`\n * node. When `name` is set, the adapter renders `CONSTRAINT <name> PRIMARY KEY\n * (…)`; otherwise it renders an anonymous `PRIMARY KEY (…)`.\n *\n * Frozen on construction — immutable after creation.\n */\nexport class PrimaryKeyConstraint {\n readonly kind = 'primary-key' as const;\n readonly columns: ReadonlyArray<string>;\n readonly name: string | undefined;\n\n constructor(options: { readonly columns: readonly string[]; readonly name?: string }) {\n this.columns = Object.freeze([...options.columns]);\n this.name = options.name;\n Object.freeze(this);\n }\n}\n\n/**\n * A FOREIGN KEY constraint on a `CreateTable` node. `onDelete` and `onUpdate`\n * use the same `ReferentialAction` vocabulary already used by the migration\n * planner and the contract IR — no parallel string enum.\n *\n * Frozen on construction — immutable after creation.\n */\nexport class ForeignKeyConstraint {\n readonly kind = 'foreign-key' as const;\n readonly columns: ReadonlyArray<string>;\n readonly refTable: string;\n readonly refColumns: ReadonlyArray<string>;\n readonly onDelete: ReferentialAction | undefined;\n readonly onUpdate: ReferentialAction | undefined;\n readonly name: string | undefined;\n\n constructor(options: {\n readonly columns: readonly string[];\n readonly refTable: string;\n readonly refColumns: readonly string[];\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n readonly name?: string;\n }) {\n this.columns = Object.freeze([...options.columns]);\n this.refTable = options.refTable;\n this.refColumns = Object.freeze([...options.refColumns]);\n this.onDelete = options.onDelete;\n this.onUpdate = options.onUpdate;\n this.name = options.name;\n Object.freeze(this);\n }\n}\n\n/**\n * A table-level UNIQUE constraint on a `CreateTable` node. When `name` is\n * set, the adapter renders `CONSTRAINT <name> UNIQUE (…)`; otherwise it\n * renders an anonymous `UNIQUE (…)`.\n *\n * Frozen on construction — immutable after creation.\n */\nexport class UniqueConstraint {\n readonly kind = 'unique' as const;\n readonly columns: ReadonlyArray<string>;\n readonly name: string | undefined;\n\n constructor(options: { readonly columns: readonly string[]; readonly name?: string }) {\n this.columns = Object.freeze([...options.columns]);\n this.name = options.name;\n Object.freeze(this);\n }\n}\n\n/**\n * A table-level CHECK constraint carrying a raw SQL predicate expression. Used\n * for checks that are not enum value-set restrictions — e.g. the element-non-null\n * constraint on a scalar-array column (`array_position(col, NULL) IS NULL`).\n * The `expression` is emitted verbatim, so callers must supply safe,\n * pre-validated SQL.\n *\n * Frozen on construction — immutable after creation.\n */\nexport class CheckExpressionConstraint {\n readonly kind = 'check-expression' as const;\n readonly name: string;\n readonly expression: string;\n\n constructor(options: { readonly name: string; readonly expression: string }) {\n this.name = options.name;\n this.expression = options.expression;\n Object.freeze(this);\n }\n}\n\nexport type DdlTableConstraint =\n | PrimaryKeyConstraint\n | ForeignKeyConstraint\n | UniqueConstraint\n | CheckExpressionConstraint;\n"],"mappings":";;AAwBA,IAAsB,mBAAtB,MAAuC;CAIrC,SAAyB;EACvB,OAAO,OAAO,IAAI;CACpB;AACF;AAEA,IAAa,uBAAb,cAA0C,iBAAiB;CACzD,OAAgB;CAChB;CAEA,YAAY,OAAuC;EACjD,MAAM;EACN,IAAI,CAAC,iCAAiC,KAAK,GACzC,MAAM,IAAI,MAAM,sCAAsC;EAExD,KAAK,QAAQ;EACb,KAAK,OAAO;CACd;CAEA,OAAmB,SAAqC,KAAgC;EACtF,OAAO,QAAQ,QAAQ,MAAM,GAAG;CAClC;AACF;AAEA,IAAa,wBAAb,cAA2C,iBAAiB;CAC1D,OAAgB;CAChB;CAEA,YAAY,YAAoB;EAC9B,MAAM;EACN,KAAK,aAAa;EAClB,KAAK,OAAO;CACd;CAEA,OAAmB,SAAqC,KAAgC;EACtF,OAAO,QAAQ,SAAS,MAAM,GAAG;CACnC;AACF;AAIA,IAAa,YAAb,MAAuB;CACrB;CACA;CACA;CACA;CACA;;CAEA;CAEA,YAAY,SAOT;EACD,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO,QAAQ;EACpB,KAAK,UAAU,QAAQ;EACvB,KAAK,aAAa,QAAQ;EAC1B,KAAK,UAAU,QAAQ;EACvB,KAAK,WAAW,QAAQ;EACxB,OAAO,OAAO,IAAI;CACpB;AACF;AAEA,IAAsB,UAAtB,MAA8B;;;;;;;CAS5B,YAAkB;EAChB,OAAO;CACT;CAEA,SAAyB;EACvB,OAAO,OAAO,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