@prisma-next/sql-relational-core 0.12.0-dev.4 → 0.12.0-dev.41

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 (66) hide show
  1. package/dist/{codec-types-Cezo7k-i.d.mts → codec-types-Ey_MAEly.d.mts} +1 -1
  2. package/dist/{codec-types-Cezo7k-i.d.mts.map → codec-types-Ey_MAEly.d.mts.map} +1 -1
  3. package/dist/ddl-types-BV7GsGNt.d.mts +56 -0
  4. package/dist/ddl-types-BV7GsGNt.d.mts.map +1 -0
  5. package/dist/ddl-types-wqxUC57D.mjs +71 -0
  6. package/dist/ddl-types-wqxUC57D.mjs.map +1 -0
  7. package/dist/{errors-Bavu5wZA.d.mts → errors-CI1oIVmU.d.mts} +2 -2
  8. package/dist/{errors-Bavu5wZA.d.mts.map → errors-CI1oIVmU.d.mts.map} +1 -1
  9. package/dist/{errors-BF7W5uUd.mjs → errors-HvB_h2on.mjs} +1 -1
  10. package/dist/{errors-BF7W5uUd.mjs.map → errors-HvB_h2on.mjs.map} +1 -1
  11. package/dist/exports/ast.d.mts +5 -8
  12. package/dist/exports/ast.d.mts.map +1 -1
  13. package/dist/exports/ast.mjs +4 -3
  14. package/dist/exports/ast.mjs.map +1 -1
  15. package/dist/exports/codec-descriptor-registry.d.mts +3 -3
  16. package/dist/exports/codec-descriptor-registry.mjs +6 -9
  17. package/dist/exports/codec-descriptor-registry.mjs.map +1 -1
  18. package/dist/exports/contract-free.d.mts +149 -0
  19. package/dist/exports/contract-free.d.mts.map +1 -0
  20. package/dist/exports/contract-free.mjs +248 -0
  21. package/dist/exports/contract-free.mjs.map +1 -0
  22. package/dist/exports/errors.d.mts +1 -1
  23. package/dist/exports/errors.mjs +1 -1
  24. package/dist/exports/expression.d.mts +2 -2
  25. package/dist/exports/expression.mjs +1 -1
  26. package/dist/exports/middleware.d.mts +1 -1
  27. package/dist/exports/middleware.mjs +1 -1
  28. package/dist/exports/plan.d.mts +2 -2
  29. package/dist/exports/query-lane-context.d.mts +1 -1
  30. package/dist/exports/types.d.mts +3 -3
  31. package/dist/index.d.mts +12 -11
  32. package/dist/index.mjs +6 -5
  33. package/dist/{middleware-B0yz0pff.mjs → middleware-CbHPs9WK.mjs} +2 -2
  34. package/dist/{middleware-B0yz0pff.mjs.map → middleware-CbHPs9WK.mjs.map} +1 -1
  35. package/dist/{middleware-EOcO8Ogo.d.mts → middleware-DkAjjPxq.d.mts} +2 -2
  36. package/dist/{middleware-EOcO8Ogo.d.mts.map → middleware-DkAjjPxq.d.mts.map} +1 -1
  37. package/dist/{plan-CG3sy5kw.d.mts → plan-Ds9oN5QU.d.mts} +3 -3
  38. package/dist/{plan-CG3sy5kw.d.mts.map → plan-Ds9oN5QU.d.mts.map} +1 -1
  39. package/dist/{query-lane-context-Dw1Tz0kv.d.mts → query-lane-context-BUYT0tOb.d.mts} +3 -3
  40. package/dist/{query-lane-context-Dw1Tz0kv.d.mts.map → query-lane-context-BUYT0tOb.d.mts.map} +1 -1
  41. package/dist/{sql-execution-plan-D4OimCVH.d.mts → sql-execution-plan-Dopo3SDj.d.mts} +2 -2
  42. package/dist/{sql-execution-plan-D4OimCVH.d.mts.map → sql-execution-plan-Dopo3SDj.d.mts.map} +1 -1
  43. package/dist/{types-DoolOzqd.d.mts → types-CLirmH9F.d.mts} +8 -20
  44. package/dist/types-CLirmH9F.d.mts.map +1 -0
  45. package/dist/{types-C4EdOD-s.mjs → types-CMznS9Yh.mjs} +24 -5
  46. package/dist/types-CMznS9Yh.mjs.map +1 -0
  47. package/dist/{types-C_1ZqLwZ.d.mts → types-CXQF5KS8.d.mts} +19 -6
  48. package/dist/types-CXQF5KS8.d.mts.map +1 -0
  49. package/dist/{types-CkTDkFcK.d.mts → types-DRBn98H_.d.mts} +3 -3
  50. package/dist/{types-CkTDkFcK.d.mts.map → types-DRBn98H_.d.mts.map} +1 -1
  51. package/dist/{util-DWmhUCEO.mjs → util-DUXs0nZ9.mjs} +1 -1
  52. package/dist/{util-DWmhUCEO.mjs.map → util-DUXs0nZ9.mjs.map} +1 -1
  53. package/package.json +12 -11
  54. package/src/ast/adapter-types.ts +0 -5
  55. package/src/ast/ddl-types.ts +106 -0
  56. package/src/ast/types.ts +31 -6
  57. package/src/codec-ref-for-column.ts +7 -9
  58. package/src/contract-free/column.ts +21 -0
  59. package/src/contract-free/dml.ts +17 -0
  60. package/src/contract-free/table.ts +390 -0
  61. package/src/exports/ast.ts +1 -0
  62. package/src/exports/contract-free.ts +18 -0
  63. package/src/types.ts +3 -23
  64. package/dist/types-C4EdOD-s.mjs.map +0 -1
  65. package/dist/types-C_1ZqLwZ.d.mts.map +0 -1
  66. package/dist/types-DoolOzqd.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types-CkTDkFcK.d.mts","names":[],"sources":["../src/runtime-scope.ts"],"mappings":";;;;;;;;AASA;;KAAY,UAAA,GAAa,gBAAA,GAAmB,YAAY;;AAAA;AAUxD;;;;;;KAAY,YAAA,GAAe,IAAA,CAAK,eAAA,CAAgB,UAAA"}
1
+ {"version":3,"file":"types-DRBn98H_.d.mts","names":[],"sources":["../src/runtime-scope.ts"],"mappings":";;;;;;;;AASA;;KAAY,UAAA,GAAa,gBAAA,GAAmB,YAAY;;AAAA;AAUxD;;;;;;KAAY,YAAA,GAAe,IAAA,CAAK,eAAA,CAAgB,UAAA"}
@@ -31,4 +31,4 @@ function collectOrderedParamRefs(ast) {
31
31
  //#endregion
32
32
  export { compact as n, collectOrderedParamRefs as t };
33
33
 
34
- //# sourceMappingURL=util-DWmhUCEO.mjs.map
34
+ //# sourceMappingURL=util-DUXs0nZ9.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"util-DWmhUCEO.mjs","names":[],"sources":["../src/ast/util.ts"],"sourcesContent":["import type { AnyParamRef, AnyQueryAst } from './types';\n\nexport function compact<T extends Record<string, unknown>>(o: T): T {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(o)) {\n if (v === undefined || v === null) continue;\n if (Array.isArray(v) && v.length === 0) continue;\n out[k] = v;\n }\n return out as T;\n}\n\n/**\n * Walks an AST's parameter references in first-encounter order and dedupes\n * by ParamRef identity. The single canonical helper used by every consumer\n * that aligns `plan.params` with metadata-by-index — the SQL builder lane,\n * the SQL ORM client, the SQL runtime encoder, and the Postgres renderer's\n * `$N` index map — so the four walks cannot drift in dedupe semantics.\n *\n * SQLite's `?`-placeholder renderer intentionally does NOT use this helper\n * because it needs one params entry per occurrence in the SQL.\n */\nexport function collectOrderedParamRefs(ast: AnyQueryAst): ReadonlyArray<AnyParamRef> {\n const seen = new Set<AnyParamRef>();\n const ordered: AnyParamRef[] = [];\n for (const ref of ast.collectParamRefs()) {\n if (seen.has(ref)) continue;\n seen.add(ref);\n ordered.push(ref);\n }\n return Object.freeze(ordered);\n}\n"],"mappings":";AAEA,SAAgB,QAA2C,GAAS;CAClE,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,CAAC,GAAG;EACtC,IAAI,MAAM,KAAA,KAAa,MAAM,MAAM;EACnC,IAAI,MAAM,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG;EACxC,IAAI,KAAK;CACX;CACA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,wBAAwB,KAA8C;CACpF,MAAM,uBAAO,IAAI,IAAiB;CAClC,MAAM,UAAyB,CAAC;CAChC,KAAK,MAAM,OAAO,IAAI,iBAAiB,GAAG;EACxC,IAAI,KAAK,IAAI,GAAG,GAAG;EACnB,KAAK,IAAI,GAAG;EACZ,QAAQ,KAAK,GAAG;CAClB;CACA,OAAO,OAAO,OAAO,OAAO;AAC9B"}
1
+ {"version":3,"file":"util-DUXs0nZ9.mjs","names":[],"sources":["../src/ast/util.ts"],"sourcesContent":["import type { AnyParamRef, AnyQueryAst } from './types';\n\nexport function compact<T extends Record<string, unknown>>(o: T): T {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(o)) {\n if (v === undefined || v === null) continue;\n if (Array.isArray(v) && v.length === 0) continue;\n out[k] = v;\n }\n return out as T;\n}\n\n/**\n * Walks an AST's parameter references in first-encounter order and dedupes\n * by ParamRef identity. The single canonical helper used by every consumer\n * that aligns `plan.params` with metadata-by-index — the SQL builder lane,\n * the SQL ORM client, the SQL runtime encoder, and the Postgres renderer's\n * `$N` index map — so the four walks cannot drift in dedupe semantics.\n *\n * SQLite's `?`-placeholder renderer intentionally does NOT use this helper\n * because it needs one params entry per occurrence in the SQL.\n */\nexport function collectOrderedParamRefs(ast: AnyQueryAst): ReadonlyArray<AnyParamRef> {\n const seen = new Set<AnyParamRef>();\n const ordered: AnyParamRef[] = [];\n for (const ref of ast.collectParamRefs()) {\n if (seen.has(ref)) continue;\n seen.add(ref);\n ordered.push(ref);\n }\n return Object.freeze(ordered);\n}\n"],"mappings":";AAEA,SAAgB,QAA2C,GAAS;CAClE,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,CAAC,GAAG;EACtC,IAAI,MAAM,KAAA,KAAa,MAAM,MAAM;EACnC,IAAI,MAAM,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG;EACxC,IAAI,KAAK;CACX;CACA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,wBAAwB,KAA8C;CACpF,MAAM,uBAAO,IAAI,IAAiB;CAClC,MAAM,UAAyB,CAAC;CAChC,KAAK,MAAM,OAAO,IAAI,iBAAiB,GAAG;EACxC,IAAI,KAAK,IAAI,GAAG,GAAG;EACnB,KAAK,IAAI,GAAG;EACZ,QAAQ,KAAK,GAAG;CAClB;CACA,OAAO,OAAO,OAAO,OAAO;AAC9B"}
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "@prisma-next/sql-relational-core",
3
- "version": "0.12.0-dev.4",
3
+ "version": "0.12.0-dev.41",
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.12.0-dev.4",
10
- "@prisma-next/framework-components": "0.12.0-dev.4",
11
- "@prisma-next/operations": "0.12.0-dev.4",
12
- "@prisma-next/sql-contract": "0.12.0-dev.4",
13
- "@prisma-next/sql-operations": "0.12.0-dev.4",
14
- "@prisma-next/utils": "0.12.0-dev.4",
9
+ "@prisma-next/contract": "0.12.0-dev.41",
10
+ "@prisma-next/framework-components": "0.12.0-dev.41",
11
+ "@prisma-next/operations": "0.12.0-dev.41",
12
+ "@prisma-next/sql-contract": "0.12.0-dev.41",
13
+ "@prisma-next/sql-operations": "0.12.0-dev.41",
14
+ "@prisma-next/utils": "0.12.0-dev.41",
15
15
  "@standard-schema/spec": "^1.1.0",
16
16
  "arktype": "^2.2.0",
17
17
  "ts-toolbelt": "^9.6.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@prisma-next/sql-contract-ts": "0.12.0-dev.4",
21
- "@prisma-next/test-utils": "0.12.0-dev.4",
22
- "@prisma-next/tsconfig": "0.12.0-dev.4",
23
- "@prisma-next/tsdown": "0.12.0-dev.4",
20
+ "@prisma-next/sql-contract-ts": "0.12.0-dev.41",
21
+ "@prisma-next/test-utils": "0.12.0-dev.41",
22
+ "@prisma-next/tsconfig": "0.12.0-dev.41",
23
+ "@prisma-next/tsdown": "0.12.0-dev.41",
24
24
  "tsdown": "0.22.0",
25
25
  "typescript": "5.9.3",
26
26
  "vitest": "4.1.6"
@@ -42,6 +42,7 @@
42
42
  ".": "./dist/index.mjs",
43
43
  "./ast": "./dist/exports/ast.mjs",
44
44
  "./codec-descriptor-registry": "./dist/exports/codec-descriptor-registry.mjs",
45
+ "./contract-free": "./dist/exports/contract-free.mjs",
45
46
  "./errors": "./dist/exports/errors.mjs",
46
47
  "./expression": "./dist/exports/expression.mjs",
47
48
  "./middleware": "./dist/exports/middleware.mjs",
@@ -4,11 +4,6 @@ import type { LoweredStatement } from './types';
4
4
 
5
5
  export type AdapterTarget = string;
6
6
 
7
- export interface MarkerStatement {
8
- readonly sql: string;
9
- readonly params: readonly unknown[];
10
- }
11
-
12
7
  /**
13
8
  * Outcome of an adapter's marker read. `no-table` means the marker storage itself is absent
14
9
  * (e.g. attaching to a database that was never `db init`'d); `absent` means the storage exists
@@ -0,0 +1,106 @@
1
+ import type { ColumnDefaultLiteralInputValue } from '@prisma-next/contract/types';
2
+ import { isColumnDefaultLiteralInputValue } from '@prisma-next/contract/types';
3
+ import type { AnyParamRef } from './types';
4
+
5
+ export interface DdlColumnDefaultVisitor<R> {
6
+ literal(node: LiteralColumnDefault): R;
7
+ function(node: FunctionColumnDefault): R;
8
+ }
9
+
10
+ export abstract class DdlColumnDefault {
11
+ abstract readonly kind: string;
12
+ abstract accept<R>(visitor: DdlColumnDefaultVisitor<R>): R;
13
+
14
+ protected freeze(): void {
15
+ Object.freeze(this);
16
+ }
17
+ }
18
+
19
+ export class LiteralColumnDefault extends DdlColumnDefault {
20
+ readonly kind = 'literal' as const;
21
+ readonly value: ColumnDefaultLiteralInputValue;
22
+
23
+ constructor(value: ColumnDefaultLiteralInputValue) {
24
+ super();
25
+ if (!isColumnDefaultLiteralInputValue(value)) {
26
+ throw new Error('Invalid column default literal value');
27
+ }
28
+ this.value = value;
29
+ this.freeze();
30
+ }
31
+
32
+ override accept<R>(visitor: DdlColumnDefaultVisitor<R>): R {
33
+ return visitor.literal(this);
34
+ }
35
+ }
36
+
37
+ export class FunctionColumnDefault extends DdlColumnDefault {
38
+ readonly kind = 'function' as const;
39
+ readonly expression: string;
40
+
41
+ constructor(expression: string) {
42
+ super();
43
+ this.expression = expression;
44
+ this.freeze();
45
+ }
46
+
47
+ override accept<R>(visitor: DdlColumnDefaultVisitor<R>): R {
48
+ return visitor.function(this);
49
+ }
50
+ }
51
+
52
+ export type AnyDdlColumnDefault = LiteralColumnDefault | FunctionColumnDefault;
53
+
54
+ export class DdlColumn {
55
+ readonly name: string;
56
+ readonly type: string;
57
+ readonly notNull?: boolean | undefined;
58
+ readonly primaryKey?: boolean | undefined;
59
+ readonly default?: DdlColumnDefault | undefined;
60
+
61
+ constructor(options: {
62
+ readonly name: string;
63
+ readonly type: string;
64
+ readonly notNull?: boolean;
65
+ readonly primaryKey?: boolean;
66
+ readonly default?: DdlColumnDefault;
67
+ }) {
68
+ this.name = options.name;
69
+ this.type = options.type;
70
+ this.notNull = options.notNull;
71
+ this.primaryKey = options.primaryKey;
72
+ this.default = options.default;
73
+ Object.freeze(this);
74
+ }
75
+ }
76
+
77
+ export abstract class DdlNode {
78
+ abstract readonly kind: string;
79
+
80
+ /**
81
+ * Structural brand: every DDL node answers `true`. Lets {@link isDdlNode}
82
+ * recognise any `DdlNode` subclass — including target-contributed kinds —
83
+ * without a central kind registry that subclasses would have to register
84
+ * into.
85
+ */
86
+ isDdlNode(): true {
87
+ return true;
88
+ }
89
+
90
+ protected freeze(): void {
91
+ Object.freeze(this);
92
+ }
93
+
94
+ collectParamRefs(): AnyParamRef[] {
95
+ return [];
96
+ }
97
+ }
98
+
99
+ export function isDdlNode(value: unknown): value is DdlNode {
100
+ return (
101
+ typeof value === 'object' &&
102
+ value !== null &&
103
+ 'isDdlNode' in value &&
104
+ typeof value.isDdlNode === 'function'
105
+ );
106
+ }
package/src/ast/types.ts CHANGED
@@ -80,7 +80,7 @@ export interface ExpressionFolder<T> {
80
80
  }
81
81
 
82
82
  export type ProjectionExpr = AnyExpression;
83
- export type InsertValue = ColumnRef | ParamRef | PreparedParamRef | DefaultValueExpr;
83
+ export type InsertValue = ColumnRef | ParamRef | PreparedParamRef | DefaultValueExpr | RawExpr;
84
84
  export type JoinOnExpr = EqColJoinOn | AnyExpression;
85
85
  export type WhereArg = AnyExpression | ToWhereExpr;
86
86
  export type JsonObjectEntry = {
@@ -205,6 +205,11 @@ function rewriteInsertValue(value: InsertValue, rewriter: AstRewriter): InsertVa
205
205
  return rewriter.columnRef ? rewriteColumnRefForInsert(value, rewriter) : value;
206
206
  case 'default-value':
207
207
  return value;
208
+ // RawExpr insert values are opaque DB-side expressions (e.g. `now()` /
209
+ // `datetime('now')`) carried in value position; they are not a rewrite
210
+ // target on the insert path.
211
+ case 'raw-expr':
212
+ return value;
208
213
  }
209
214
  }
210
215
 
@@ -312,16 +317,25 @@ export class TableSource extends FromSource {
312
317
  readonly kind = 'table-source' as const;
313
318
  readonly name: string;
314
319
  readonly alias: string | undefined;
320
+ /**
321
+ * Resolved storage namespace coordinate for this table, stamped when the
322
+ * table proxy constructs the AST. Renderers qualify via the namespace
323
+ * concretion's `qualifyTable()` using this id — never by re-resolving the
324
+ * bare table name at render time.
325
+ */
326
+ readonly namespaceId: string | undefined;
315
327
 
316
- constructor(name: string, alias?: string) {
328
+ protected constructor(name: string, alias?: string, namespaceId?: string) {
317
329
  super();
318
330
  this.name = name;
319
331
  this.alias = alias;
320
- this.freeze();
332
+ this.namespaceId = namespaceId;
321
333
  }
322
334
 
323
- static named(name: string, alias?: string): TableSource {
324
- return new TableSource(name, alias);
335
+ static named(name: string, alias?: string, namespaceId?: string): TableSource {
336
+ const source = new TableSource(name, alias, namespaceId);
337
+ source.freeze();
338
+ return source;
325
339
  }
326
340
 
327
341
  override rewrite(rewriter: AstRewriter): AnyFromSource {
@@ -857,6 +871,15 @@ export class OrderByItem extends AstNode {
857
871
  rewrite(rewriter: ExpressionRewriter): OrderByItem {
858
872
  return new OrderByItem(this.expr.rewrite(rewriter), this.dir);
859
873
  }
874
+
875
+ /**
876
+ * A new frozen item with the sort direction flipped and `expr` unchanged.
877
+ * Integrations that own pagination (e.g. backward cursor pagination) use
878
+ * this to reverse a user's sort order without reaching into the AST.
879
+ */
880
+ reverse(): OrderByItem {
881
+ return new OrderByItem(this.expr, this.dir === 'asc' ? 'desc' : 'asc');
882
+ }
860
883
  }
861
884
 
862
885
  export class JsonArrayAggExpr extends Expression {
@@ -1674,6 +1697,8 @@ export class InsertAst extends QueryAst {
1674
1697
  for (const value of Object.values(row)) {
1675
1698
  if (value.kind === 'param-ref' || value.kind === 'prepared-param-ref') {
1676
1699
  refs.push(value);
1700
+ } else if (value.kind === 'raw-expr') {
1701
+ refs.push(...value.collectParamRefs());
1677
1702
  }
1678
1703
  }
1679
1704
  }
@@ -1897,7 +1922,7 @@ export type AnyExpression =
1897
1922
  | RawExpr;
1898
1923
  export type AnyParamRef = ParamRef | PreparedParamRef;
1899
1924
  export type AnyInsertOnConflictAction = DoNothingConflictAction | DoUpdateSetConflictAction;
1900
- export type AnyInsertValue = ColumnRef | ParamRef | PreparedParamRef | DefaultValueExpr;
1925
+ export type AnyInsertValue = ColumnRef | ParamRef | PreparedParamRef | DefaultValueExpr | RawExpr;
1901
1926
  export type AnyOperationArg = AnyExpression | ParamRef | PreparedParamRef | LiteralExpr;
1902
1927
 
1903
1928
  export const queryAstKinds: ReadonlySet<string> = new Set<AnyQueryAst['kind']>([
@@ -10,7 +10,7 @@ import {
10
10
  /**
11
11
  * Derive the canonical {@link CodecRef} for a `(table, column)` pair against a {@link SqlStorage}. This is the build-time path every column-bound `ParamRef` / `ProjectionItem` uses to stamp its `codec` slot before the AST is handed to the runtime — the runtime resolver then materialises a memoised {@link import('@prisma-next/sql-relational-core/ast').Codec} for the same `CodecRef` via `forCodecRef`.
12
12
  *
13
- * Resolution rules over `storage.tables[table].columns[column]`:
13
+ * Resolution rules over namespace `entries.table[table].columns[column]`:
14
14
  *
15
15
  * - `typeRef` column → `{codecId, typeParams}` from `storage.types[typeRef]` (multiple columns sharing the typeRef share one ref → one memoised codec).
16
16
  * - inline `typeParams` column → `{codecId, typeParams}` from the column itself.
@@ -25,7 +25,7 @@ export function codecRefForStorageColumn(
25
25
  ): CodecRef | undefined {
26
26
  let tableDef: StorageTable | undefined;
27
27
  for (const ns of Object.values(storage.namespaces)) {
28
- const candidate = ns.tables[tableName] as StorageTable | undefined;
28
+ const candidate = ns.entries.table[tableName] as StorageTable | undefined;
29
29
  if (candidate !== undefined) {
30
30
  tableDef = candidate;
31
31
  break;
@@ -38,13 +38,11 @@ export function codecRefForStorageColumn(
38
38
  let instance: unknown = storage.types?.[columnDef.typeRef];
39
39
  if (!instance) {
40
40
  for (const ns of Object.values(storage.namespaces)) {
41
- const nsEnums = (ns as { enum?: Record<string, unknown> }).enum;
42
- if (nsEnums) {
43
- const nsEntry = nsEnums[columnDef.typeRef];
44
- if (nsEntry !== undefined) {
45
- instance = nsEntry;
46
- break;
47
- }
41
+ const typeSlot = (ns.entries as { type?: Record<string, unknown> }).type;
42
+ const nsEntry = typeSlot?.[columnDef.typeRef];
43
+ if (nsEntry !== undefined) {
44
+ instance = nsEntry;
45
+ break;
48
46
  }
49
47
  }
50
48
  }
@@ -0,0 +1,21 @@
1
+ import type { ColumnDefaultLiteralInputValue } from '@prisma-next/contract/types';
2
+ import type { DdlColumnDefault } from '../ast/ddl-types';
3
+ import { DdlColumn, FunctionColumnDefault, LiteralColumnDefault } from '../ast/ddl-types';
4
+
5
+ export interface DdlColumnOptions {
6
+ readonly notNull?: boolean;
7
+ readonly primaryKey?: boolean;
8
+ readonly default?: DdlColumnDefault;
9
+ }
10
+
11
+ export function lit(value: ColumnDefaultLiteralInputValue): LiteralColumnDefault {
12
+ return new LiteralColumnDefault(value);
13
+ }
14
+
15
+ export function fn(expression: string): FunctionColumnDefault {
16
+ return new FunctionColumnDefault(expression);
17
+ }
18
+
19
+ export function col(name: string, type: string, options?: DdlColumnOptions): DdlColumn {
20
+ return new DdlColumn({ name, type, ...options });
21
+ }
@@ -0,0 +1,17 @@
1
+ export {
2
+ CfConflictClause,
3
+ CfExpr,
4
+ CfInsertQuery,
5
+ CfSelectQuery,
6
+ CfUpdateQuery,
7
+ CfUpsertBuilder,
8
+ CfUpsertQuery,
9
+ type ColumnDescriptor,
10
+ type ColumnProxy,
11
+ type ColumnSchema,
12
+ type ExcludedProxy,
13
+ type TableHandle,
14
+ type TableInsertRow,
15
+ type TableSetValues,
16
+ table,
17
+ } from './table';