@prisma-next/sql-relational-core 0.3.0-dev.31 → 0.3.0-dev.33

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.
@@ -1,7 +1,7 @@
1
- import type { BinaryExpr, ColumnRef, DeleteAst, TableRef } from './types';
1
+ import type { ColumnRef, DeleteAst, TableRef, WhereExpr } from './types';
2
2
  export interface CreateDeleteAstOptions {
3
3
  readonly table: TableRef;
4
- readonly where: BinaryExpr;
4
+ readonly where: WhereExpr;
5
5
  readonly returning?: ReadonlyArray<ColumnRef>;
6
6
  }
7
7
  export declare function createDeleteAst(options: CreateDeleteAstOptions): DeleteAst;
@@ -1 +1 @@
1
- {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/ast/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAG1E,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAO1E"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/ast/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAO1E"}
@@ -1,4 +1,5 @@
1
- import type { BinaryExpr, BinaryOp, ExistsExpr, Expression, ParamRef, SelectAst } from './types';
1
+ import type { BinaryExpr, BinaryOp, ExistsExpr, Expression, NullCheckExpr, ParamRef, SelectAst } from './types';
2
2
  export declare function createBinaryExpr(op: BinaryOp, left: Expression, right: Expression | ParamRef): BinaryExpr;
3
3
  export declare function createExistsExpr(not: boolean, subquery: SelectAst): ExistsExpr;
4
+ export declare function createNullCheckExpr(expr: Expression, isNull: boolean): NullCheckExpr;
4
5
  //# sourceMappingURL=predicate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../src/ast/predicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEjG,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,UAAU,GAAG,QAAQ,GAC3B,UAAU,CAOZ;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,GAAG,UAAU,CAM9E"}
1
+ {"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../src/ast/predicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,QAAQ,EACR,SAAS,EACV,MAAM,SAAS,CAAC;AAEjB,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,UAAU,GAAG,QAAQ,GAC3B,UAAU,CAOZ;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,GAAG,UAAU,CAM9E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,GAAG,aAAa,CAMpF"}
@@ -1,4 +1,4 @@
1
- import type { BinaryExpr, ColumnRef, Direction, ExistsExpr, IncludeAst, IncludeRef, JoinAst, OperationExpr, SelectAst, TableRef } from './types';
1
+ import type { ColumnRef, Direction, IncludeAst, IncludeRef, JoinAst, OperationExpr, SelectAst, TableRef, WhereExpr } from './types';
2
2
  export interface CreateSelectAstOptions {
3
3
  readonly from: TableRef;
4
4
  readonly joins?: ReadonlyArray<JoinAst>;
@@ -7,7 +7,7 @@ export interface CreateSelectAstOptions {
7
7
  alias: string;
8
8
  expr: ColumnRef | IncludeRef | OperationExpr;
9
9
  }>;
10
- readonly where?: BinaryExpr | ExistsExpr;
10
+ readonly where?: WhereExpr;
11
11
  readonly orderBy?: ReadonlyArray<{
12
12
  expr: ColumnRef | OperationExpr;
13
13
  dir: Direction;
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/ast/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,aAAa,EACb,SAAS,EACT,QAAQ,EACT,MAAM,SAAS,CAAC;AAGjB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAC9B,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,aAAa,CAAC;KAC9C,CAAC,CAAC;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,SAAS,GAAG,aAAa,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACtF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAW1E"}
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/ast/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,OAAO,EACP,aAAa,EACb,SAAS,EACT,QAAQ,EACR,SAAS,EACV,MAAM,SAAS,CAAC;AAGjB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAC9B,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,aAAa,CAAC;KAC9C,CAAC,CAAC;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,SAAS,GAAG,aAAa,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACtF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAW1E"}
@@ -53,6 +53,19 @@ export interface ExistsExpr {
53
53
  readonly not: boolean;
54
54
  readonly subquery: SelectAst;
55
55
  }
56
+ /**
57
+ * Unary expression for IS NULL / IS NOT NULL checks.
58
+ * Used in WHERE clauses to check for null values.
59
+ */
60
+ export interface NullCheckExpr {
61
+ readonly kind: 'nullCheck';
62
+ readonly expr: Expression;
63
+ readonly isNull: boolean;
64
+ }
65
+ /**
66
+ * Union type for WHERE clause expressions.
67
+ */
68
+ export type WhereExpr = BinaryExpr | ExistsExpr | NullCheckExpr;
56
69
  export type JoinOnExpr = {
57
70
  readonly kind: 'eqCol';
58
71
  readonly left: ColumnRef;
@@ -74,7 +87,7 @@ export interface IncludeAst {
74
87
  readonly child: {
75
88
  readonly table: TableRef;
76
89
  readonly on: JoinOnExpr;
77
- readonly where?: BinaryExpr | ExistsExpr;
90
+ readonly where?: WhereExpr;
78
91
  readonly orderBy?: ReadonlyArray<{
79
92
  expr: Expression;
80
93
  dir: Direction;
@@ -95,7 +108,7 @@ export interface SelectAst {
95
108
  alias: string;
96
109
  expr: Expression | IncludeRef | LiteralExpr;
97
110
  }>;
98
- readonly where?: BinaryExpr | ExistsExpr;
111
+ readonly where?: WhereExpr;
99
112
  readonly orderBy?: ReadonlyArray<{
100
113
  expr: Expression;
101
114
  dir: Direction;
@@ -112,13 +125,13 @@ export interface UpdateAst {
112
125
  readonly kind: 'update';
113
126
  readonly table: TableRef;
114
127
  readonly set: Record<string, ColumnRef | ParamRef>;
115
- readonly where: BinaryExpr;
128
+ readonly where: WhereExpr;
116
129
  readonly returning?: ReadonlyArray<ColumnRef>;
117
130
  }
118
131
  export interface DeleteAst {
119
132
  readonly kind: 'delete';
120
133
  readonly table: TableRef;
121
- readonly where: BinaryExpr;
134
+ readonly where: WhereExpr;
122
135
  readonly returning?: ReadonlyArray<ColumnRef>;
123
136
  }
124
137
  export type QueryAst = SelectAst | InsertAst | UpdateAst | DeleteAst;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ast/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,E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AQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IACtD,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChD"}
@@ -1,8 +1,8 @@
1
- import type { BinaryExpr, ColumnRef, ParamRef, TableRef, UpdateAst } from './types';
1
+ import type { ColumnRef, ParamRef, TableRef, UpdateAst, WhereExpr } from './types';
2
2
  export interface CreateUpdateAstOptions {
3
3
  readonly table: TableRef;
4
4
  readonly set: Record<string, ColumnRef | ParamRef>;
5
- readonly where: BinaryExpr;
5
+ readonly where: WhereExpr;
6
6
  readonly returning?: ReadonlyArray<ColumnRef>;
7
7
  }
8
8
  export declare function createUpdateAst(options: CreateUpdateAstOptions): UpdateAst;
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/ast/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAQ1E"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/ast/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGnF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAQ1E"}
@@ -85,6 +85,28 @@ var ColumnBuilderImpl = class {
85
85
  dir: "desc"
86
86
  });
87
87
  }
88
+ /**
89
+ * Creates an IS NULL check for this column.
90
+ * Available on all columns at runtime, but typed to only be visible on nullable columns.
91
+ */
92
+ isNull() {
93
+ return Object.freeze({
94
+ kind: "nullCheck",
95
+ expr: this.toExpr(),
96
+ isNull: true
97
+ });
98
+ }
99
+ /**
100
+ * Creates an IS NOT NULL check for this column.
101
+ * Available on all columns at runtime, but typed to only be visible on nullable columns.
102
+ */
103
+ isNotNull() {
104
+ return Object.freeze({
105
+ kind: "nullCheck",
106
+ expr: this.toExpr(),
107
+ isNull: false
108
+ });
109
+ }
88
110
  };
89
111
  var TableBuilderImpl = class {
90
112
  kind = "table";
@@ -168,4 +190,4 @@ export {
168
190
  TableBuilderImpl,
169
191
  schema
170
192
  };
171
- //# sourceMappingURL=chunk-YXD25S5I.js.map
193
+ //# sourceMappingURL=chunk-4WKZQIDS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts"],"sourcesContent":["import type { OperationRegistry } from '@prisma-next/operations';\nimport { planInvalid } from '@prisma-next/plan';\nimport type {\n ExtractCodecTypes,\n ExtractOperationTypes,\n SqlContract,\n SqlStorage,\n StorageColumn,\n} from '@prisma-next/sql-contract/types';\nimport type { BinaryOp, ColumnRef, ExpressionSource, TableRef } from './ast/types';\nimport { attachOperationsToColumnBuilder } from './operations-registry';\nimport type { QueryLaneContext } from './query-lane-context';\nimport type {\n BinaryBuilder,\n CodecTypes as CodecTypesType,\n ColumnBuilder,\n ComputeColumnJsType,\n NullCheckBuilder,\n OperationTypeSignature,\n OperationTypes,\n OrderBuilder,\n ParamPlaceholder,\n} from './types';\n\ntype TableColumns<Table extends { columns: Record<string, StorageColumn> }> = Table['columns'];\n\ntype ColumnBuilders<\n Contract extends SqlContract<SqlStorage>,\n TableName extends string,\n Columns extends Record<string, StorageColumn>,\n CodecTypes extends CodecTypesType,\n Operations extends OperationTypes,\n> = {\n readonly [K in keyof Columns]: ColumnBuilder<\n K & string,\n Columns[K],\n ComputeColumnJsType<Contract, TableName, K & string, Columns[K], CodecTypes>,\n Operations\n >;\n};\n\nexport class ColumnBuilderImpl<\n ColumnName extends string,\n ColumnMeta extends StorageColumn,\n JsType = unknown,\n> implements ExpressionSource\n{\n readonly kind = 'column' as const;\n\n constructor(\n readonly table: string,\n readonly column: ColumnName,\n private readonly storageColumn: ColumnMeta,\n ) {}\n\n get columnMeta(): ColumnMeta {\n return this.storageColumn;\n }\n\n // Type-level helper property (not used at runtime)\n get __jsType(): JsType {\n return undefined as unknown as JsType;\n }\n\n /**\n * Converts this column builder to a ColumnRef expression.\n * This is the canonical way to get an AST node from a builder.\n */\n toExpr(): ColumnRef {\n return Object.freeze({\n kind: 'col' as const,\n table: this.table,\n column: this.column,\n });\n }\n\n private createBinaryBuilder(\n op: BinaryOp,\n value: ParamPlaceholder | ExpressionSource,\n ): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n if (value == null) {\n throw planInvalid(\n 'Parameter placeholder or expression source required for column comparison',\n );\n }\n // Check for ExpressionSource first (has toExpr method)\n if ('toExpr' in value && typeof value.toExpr === 'function') {\n return Object.freeze({\n kind: 'binary' as const,\n op,\n left: this.toExpr(),\n right: value,\n }) as BinaryBuilder<ColumnName, ColumnMeta, JsType>;\n }\n // Must be a ParamPlaceholder\n if ('kind' in value && value.kind === 'param-placeholder') {\n return Object.freeze({\n kind: 'binary' as const,\n op,\n left: this.toExpr(),\n right: value,\n }) as BinaryBuilder<ColumnName, ColumnMeta, JsType>;\n }\n throw planInvalid('Parameter placeholder or expression source required for column comparison');\n }\n\n eq(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('eq', value);\n }\n\n neq(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('neq', value);\n }\n\n gt(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('gt', value);\n }\n\n lt(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('lt', value);\n }\n\n gte(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('gte', value);\n }\n\n lte(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('lte', value);\n }\n\n asc(): OrderBuilder<ColumnName, ColumnMeta, JsType> {\n return Object.freeze({\n kind: 'order' as const,\n expr: this.toExpr(),\n dir: 'asc' as const,\n }) as OrderBuilder<ColumnName, ColumnMeta, JsType>;\n }\n\n desc(): OrderBuilder<ColumnName, ColumnMeta, JsType> {\n return Object.freeze({\n kind: 'order' as const,\n expr: this.toExpr(),\n dir: 'desc' as const,\n }) as OrderBuilder<ColumnName, ColumnMeta, JsType>;\n }\n\n /**\n * Creates an IS NULL check for this column.\n * Available on all columns at runtime, but typed to only be visible on nullable columns.\n */\n isNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType> {\n return Object.freeze({\n kind: 'nullCheck' as const,\n expr: this.toExpr(),\n isNull: true,\n }) as NullCheckBuilder<ColumnName, ColumnMeta, JsType>;\n }\n\n /**\n * Creates an IS NOT NULL check for this column.\n * Available on all columns at runtime, but typed to only be visible on nullable columns.\n */\n isNotNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType> {\n return Object.freeze({\n kind: 'nullCheck' as const,\n expr: this.toExpr(),\n isNull: false,\n }) as NullCheckBuilder<ColumnName, ColumnMeta, JsType>;\n }\n}\n\nexport class TableBuilderImpl<\n Contract extends SqlContract<SqlStorage>,\n TableName extends string,\n Columns extends Record<string, StorageColumn>,\n CodecTypes extends CodecTypesType,\n Operations extends OperationTypes,\n> implements TableRef\n{\n readonly kind = 'table' as const;\n readonly columns: ColumnBuilders<Contract, TableName, Columns, CodecTypes, Operations>;\n private readonly _name: TableName;\n\n constructor(\n name: TableName,\n columns: ColumnBuilders<Contract, TableName, Columns, CodecTypes, Operations>,\n ) {\n this._name = name;\n this.columns = columns;\n }\n\n get name(): string {\n return this._name;\n }\n}\n\nfunction buildColumns<\n Contract extends SqlContract<SqlStorage>,\n TableName extends keyof Contract['storage']['tables'] & string,\n CodecTypes extends CodecTypesType,\n Operations extends OperationTypes,\n>(\n tableName: TableName,\n storage: SqlStorage,\n _contract: Contract,\n operationRegistry?: OperationRegistry,\n contractCapabilities?: Record<string, Record<string, boolean>>,\n): ColumnBuilders<\n Contract,\n TableName,\n Contract['storage']['tables'][TableName]['columns'],\n CodecTypes,\n Operations\n> {\n const table = storage.tables[tableName];\n\n if (!table) {\n throw planInvalid(`Unknown table ${tableName}`);\n }\n\n type Columns = Contract['storage']['tables'][TableName]['columns'];\n const tableColumns = table.columns as Columns;\n\n const result = {} as {\n [K in keyof Columns]: ColumnBuilder<\n K & string,\n Columns[K],\n ComputeColumnJsType<Contract, TableName, K & string, Columns[K], CodecTypes>,\n Operations\n >;\n };\n\n const assignColumn = <ColumnKey extends keyof Columns & string>(\n columnName: ColumnKey,\n columnDef: Columns[ColumnKey],\n ) => {\n type JsType = ComputeColumnJsType<\n Contract,\n TableName,\n ColumnKey,\n Columns[ColumnKey],\n CodecTypes\n >;\n\n const columnBuilder = new ColumnBuilderImpl<ColumnKey, Columns[ColumnKey], JsType>(\n tableName,\n columnName,\n columnDef,\n );\n\n const builderWithOps = attachOperationsToColumnBuilder<\n ColumnKey,\n Columns[ColumnKey],\n JsType,\n Operations\n >(\n columnBuilder as unknown as ColumnBuilder<\n ColumnKey,\n Columns[ColumnKey],\n JsType,\n Record<string, never>\n >,\n columnDef,\n operationRegistry,\n contractCapabilities,\n );\n\n (result as Record<string, unknown>)[columnName] = builderWithOps;\n };\n\n for (const columnName of Object.keys(tableColumns) as Array<keyof Columns & string>) {\n const columnDef = tableColumns[columnName];\n if (!columnDef) continue;\n assignColumn(columnName, columnDef);\n }\n\n return result as ColumnBuilders<Contract, TableName, Columns, CodecTypes, Operations>;\n}\n\n/**\n * Creates a Proxy that enables accessing table columns directly on the table object,\n * in addition to the standard `table.columns.columnName` syntax.\n *\n * This allows both access patterns:\n * - `tables.user.columns.id` (standard access)\n * - `tables.user.id` (convenience access via proxy)\n *\n * The proxy intercepts property access and routes column name lookups to\n * `table.columns[prop]`, while preserving direct access to table properties\n * like `name`, `kind`, and `columns`.\n */\nfunction createTableProxy<\n Contract extends SqlContract<SqlStorage>,\n TableName extends string,\n Columns extends Record<string, StorageColumn>,\n CodecTypes extends CodecTypesType,\n Operations extends OperationTypes,\n>(\n table: TableBuilderImpl<Contract, TableName, Columns, CodecTypes, Operations>,\n): TableBuilderImpl<Contract, TableName, Columns, CodecTypes, Operations> {\n return new Proxy(table, {\n get(target, prop) {\n if (prop === 'name' || prop === 'kind' || prop === 'columns') {\n return Reflect.get(target, prop);\n }\n if (typeof prop === 'string' && prop in target.columns) {\n return target.columns[prop as keyof typeof target.columns];\n }\n return undefined;\n },\n });\n}\n\ntype ExtractSchemaTables<\n Contract extends SqlContract<SqlStorage>,\n CodecTypes extends CodecTypesType,\n Operations extends OperationTypes,\n> = {\n readonly [TableName in keyof Contract['storage']['tables']]: TableBuilderImpl<\n Contract,\n TableName & string,\n TableColumns<Contract['storage']['tables'][TableName]>,\n CodecTypes,\n Operations\n > &\n TableRef;\n};\n\n/**\n * Extracts the types registry shape from a contract.\n * Each key is a type name from storage.types, and the value preserves the\n * literal type from the contract (including codecId, nativeType, and typeParams).\n * Returns an empty object type {} when storage.types is undefined.\n */\ntype ExtractSchemaTypes<Contract extends SqlContract<SqlStorage>> =\n Contract['storage']['types'] extends infer Types\n ? Types extends Record<string, unknown>\n ? { readonly [TypeName in keyof Types]: Types[TypeName] }\n : Record<string, never>\n : Record<string, never>;\n\nexport type SchemaHandle<\n Contract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>,\n CodecTypes extends CodecTypesType = CodecTypesType,\n Operations extends OperationTypes = Record<string, never>,\n> = {\n readonly tables: ExtractSchemaTables<Contract, CodecTypes, Operations>;\n /**\n * Initialized type helpers from storage.types.\n * Each entry corresponds to a named type instance in the contract's storage.types.\n */\n readonly types: ExtractSchemaTypes<Contract>;\n};\n\ntype SchemaReturnType<Contract extends SqlContract<SqlStorage>> = SchemaHandle<\n Contract,\n ExtractCodecTypes<Contract>,\n ToOperationTypes<ExtractOperationTypes<Contract>>\n>;\n\ntype NormalizeOperationTypes<T> = {\n [TypeId in keyof T]: {\n [Method in keyof T[TypeId]]: T[TypeId][Method] extends OperationTypeSignature\n ? T[TypeId][Method]\n : OperationTypeSignature;\n };\n};\n\ntype ToOperationTypes<T> = T extends OperationTypes ? T : NormalizeOperationTypes<T>;\n\n/**\n * Creates a schema handle for building SQL queries.\n *\n * @param context - Query lane context containing contract, codec and operation registries\n * @returns A schema handle with typed table builders and type helpers\n *\n * @example\n * ```typescript\n * const schemaHandle = schema<Contract>(context);\n * const userTable = schemaHandle.tables.user;\n * const vectorType = schemaHandle.types.Vector1536;\n * ```\n */\nexport function schema<Contract extends SqlContract<SqlStorage>>(\n context: QueryLaneContext<Contract>,\n): SchemaReturnType<Contract> {\n const contract = context.contract;\n const storage = contract.storage;\n type CodecTypes = ExtractCodecTypes<Contract>;\n type Operations = ToOperationTypes<ExtractOperationTypes<Contract>>;\n const tables = {} as ExtractSchemaTables<Contract, CodecTypes, Operations>;\n const contractCapabilities = contract.capabilities;\n\n const operationRegistry = context.operations;\n\n for (const tableName of Object.keys(storage.tables) as Array<\n keyof Contract['storage']['tables'] & string\n >) {\n const columns = buildColumns<Contract, typeof tableName, CodecTypes, Operations>(\n tableName,\n storage,\n contract,\n operationRegistry,\n contractCapabilities,\n );\n const table = new TableBuilderImpl<\n Contract,\n typeof tableName & string,\n Contract['storage']['tables'][typeof tableName]['columns'],\n CodecTypes,\n Operations\n >(tableName, columns);\n const proxiedTable = createTableProxy<\n Contract,\n typeof tableName & string,\n Contract['storage']['tables'][typeof tableName]['columns'],\n CodecTypes,\n Operations\n >(table);\n (tables as Record<string, unknown>)[tableName] = Object.freeze(\n proxiedTable,\n ) as ExtractSchemaTables<Contract, CodecTypes, Operations>[typeof tableName];\n }\n\n // Get type helpers from context (populated by createRuntimeContext)\n const types = (context.types ?? {}) as ExtractSchemaTypes<Contract>;\n\n return Object.freeze({ tables, types }) as SchemaReturnType<Contract>;\n}\n\nexport type { ColumnBuilderImpl as Column, TableBuilderImpl as Table };\n"],"mappings":";;;;;AACA,SAAS,mBAAmB;AAwCrB,IAAM,oBAAN,MAKP;AAAA,EAGE,YACW,OACA,QACQ,eACjB;AAHS;AACA;AACQ;AAAA,EAChB;AAAA,EANM,OAAO;AAAA,EAQhB,IAAI,aAAyB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,WAAmB;AACrB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAoB;AAClB,WAAO,OAAO,OAAO;AAAA,MACnB,MAAM;AAAA,MACN,OAAO,KAAK;AAAA,MACZ,QAAQ,KAAK;AAAA,IACf,CAAC;AAAA,EACH;AAAA,EAEQ,oBACN,IACA,OAC+C;AAC/C,QAAI,SAAS,MAAM;AACjB,YAAM;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AAEA,QAAI,YAAY,SAAS,OAAO,MAAM,WAAW,YAAY;AAC3D,aAAO,OAAO,OAAO;AAAA,QACnB,MAAM;AAAA,QACN;AAAA,QACA,MAAM,KAAK,OAAO;AAAA,QAClB,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAEA,QAAI,UAAU,SAAS,MAAM,SAAS,qBAAqB;AACzD,aAAO,OAAO,OAAO;AAAA,QACnB,MAAM;AAAA,QACN;AAAA,QACA,MAAM,KAAK,OAAO;AAAA,QAClB,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AACA,UAAM,YAAY,2EAA2E;AAAA,EAC/F;AAAA,EAEA,G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Q,IAAI,iBAMhB,WAAW,OAAO;AACpB,UAAM,eAAe,iBAMnB,KAAK;AACP,IAAC,OAAmC,SAAS,IAAI,OAAO;AAAA,MACtD;AAAA,IACF;AAAA,EACF;AAGA,QAAM,QAAS,QAAQ,SAAS,CAAC;AAEjC,SAAO,OAAO,OAAO,EAAE,QAAQ,MAAM,CAAC;AACxC;","names":[]}
@@ -10,4 +10,4 @@ export {
10
10
  createOrderBuilder,
11
11
  isColumnBuilder
12
12
  };
13
- //# sourceMappingURL=chunk-2BWK6XEY.js.map
13
+ //# sourceMappingURL=chunk-HAUHWBE7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n ResultType as CoreResultType,\n ExecutionPlan,\n PlanRefs,\n} from '@prisma-next/contract/types';\nimport type { ArgSpec, ReturnSpec } from '@prisma-next/operations';\nimport type { SqlContract, SqlStorage, StorageColumn } from '@prisma-next/sql-contract/types';\nimport type { SqlLoweringSpec } from '@prisma-next/sql-operations';\nimport type {\n BinaryOp,\n ColumnRef,\n Direction,\n Expression,\n ExpressionSource,\n OperationExpr,\n ParamRef,\n QueryAst,\n} from './ast/types';\nimport type { SqlQueryPlan } from './plan';\nimport type { QueryLaneContext } from './query-lane-context';\n\nexport interface ParamPlaceholder {\n readonly kind: 'param-placeholder';\n readonly name: string;\n}\n\n/**\n * ValueSource represents any value that can appear in a comparison or as an argument.\n * This includes:\n * - ParamPlaceholder: A parameter placeholder (e.g., `param('userId')`)\n * - ExpressionSource: Something that can be converted to an Expression (ColumnBuilder, ExpressionBuilder)\n */\nexport type ValueSource = ParamPlaceholder | ExpressionSource;\n\nexport interface OrderBuilder<\n _ColumnName extends string = string,\n _ColumnMeta extends StorageColumn = StorageColumn,\n _JsType = unknown,\n> {\n readonly kind: 'order';\n readonly expr: Expression;\n readonly dir: Direction;\n}\n\n/**\n * Creates an OrderBuilder for use in orderBy clauses.\n */\nexport function createOrderBuilder(\n expr: AnyColumnBuilder | OperationExpr,\n dir: Direction,\n): AnyOrderBuilder {\n return { kind: 'order', expr, dir } as AnyOrderBuilder;\n}\n\n/**\n * ColumnBuilder with optional operation methods based on the column's typeId.\n * When Operations is provided and the column's typeId matches, operation methods are included.\n * Implements ExpressionSource to provide type-safe conversion to ColumnRef.\n *\n * For nullable columns (ColumnMeta['nullable'] extends true), includes isNull() and isNotNull() methods.\n */\nexport type ColumnBuilder<\n ColumnName extends string = string,\n ColumnMeta extends StorageColumn = StorageColumn,\n JsType = unknown,\n Operations extends OperationTypes = Record<string, never>,\n> = {\n readonly kind: 'column';\n readonly table: string;\n readonly column: ColumnName;\n readonly columnMeta: ColumnMeta;\n // Methods accept ValueSource (ParamPlaceholder or ExpressionSource)\n eq(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;\n neq(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;\n gt(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;\n lt(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;\n gte(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;\n lte(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;\n asc(): OrderBuilder<ColumnName, ColumnMeta, JsType>;\n desc(): OrderBuilder<ColumnName, ColumnMeta, JsType>;\n /** Converts this column builder to a ColumnRef expression */\n toExpr(): ColumnRef;\n // Helper property for type extraction (not used at runtime)\n readonly __jsType: JsType;\n} & (ColumnMeta['codecId'] extends string\n ? ColumnMeta['codecId'] extends keyof Operations\n ? OperationMethods<\n OperationsForTypeId<ColumnMeta['codecId'] & string, Operations>,\n ColumnName,\n StorageColumn,\n JsType\n >\n : Record<string, never>\n : Record<string, never>) &\n (ColumnMeta['nullable'] extends true\n ? NullableMethods<ColumnName, ColumnMeta, JsType>\n : Record<string, never>);\n\nexport interface BinaryBuilder<\n _ColumnName extends string = string,\n _ColumnMeta extends StorageColumn = StorageColumn,\n _JsType = unknown,\n> {\n readonly kind: 'binary';\n readonly op: BinaryOp;\n readonly left: Expression;\n readonly right: ValueSource;\n}\n\n/**\n * Builder for IS NULL / IS NOT NULL checks.\n * Used to build unary null check expressions in WHERE clauses.\n */\nexport interface NullCheckBuilder<\n _ColumnName extends string = string,\n _ColumnMeta extends StorageColumn = StorageColumn,\n _JsType = unknown,\n> {\n readonly kind: 'nullCheck';\n readonly expr: Expression;\n readonly isNull: boolean;\n}\n\n/**\n * Union type for unary builders (currently just NullCheckBuilder).\n * Extensible for future unary operators.\n */\nexport type UnaryBuilder = NullCheckBuilder;\n\n// Forward declare AnyBinaryBuilder and AnyOrderBuilder for use in ExpressionBuilder\nexport type AnyBinaryBuilder = BinaryBuilder;\nexport type AnyOrderBuilder = OrderBuilder;\nexport type AnyUnaryBuilder = UnaryBuilder;\n\n/**\n * Methods available only on nullable columns.\n * These are conditionally added to ColumnBuilder when ColumnMeta['nullable'] is true.\n * Note: Index signature is required for compatibility with AnyColumnBuilderBase's index signature.\n */\nexport interface NullableMethods<\n ColumnName extends string = string,\n ColumnMeta extends StorageColumn = StorageColumn,\n JsType = unknown,\n> {\n /** Creates an IS NULL check for this column */\n isNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType>;\n /** Creates an IS NOT NULL check for this column */\n isNotNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType>;\n /** Index signature for compatibility with AnyColumnBuilderBase */\n readonly [key: string]: unknown;\n}\n\n/**\n * ExpressionBuilder represents the result of an operation (e.g., col.distance(...)).\n * Unlike ColumnBuilder (which represents a column), ExpressionBuilder represents\n * an operation expression and provides the same DSL methods for chaining.\n *\n * Implements ExpressionSource to provide type-safe conversion to OperationExpr.\n */\nexport interface ExpressionBuilder<JsType = unknown> extends ExpressionSource {\n readonly kind: 'expression';\n readonly expr: OperationExpr;\n readonly columnMeta: StorageColumn;\n\n // Methods accept ValueSource (ParamPlaceholder or ExpressionSource)\n eq(value: ValueSource): AnyBinaryBuilder;\n neq(value: ValueSource): AnyBinaryBuilder;\n gt(value: ValueSource): AnyBinaryBuilder;\n lt(value: ValueSource): AnyBinaryBuilder;\n gte(value: ValueSource): AnyBinaryBuilder;\n lte(value: ValueSource): AnyBinaryBuilder;\n asc(): AnyOrderBuilder;\n desc(): AnyOrderBuilder;\n\n /** Converts this expression builder to the underlying OperationExpr */\n toExpr(): OperationExpr;\n\n // Helper property for type extraction (not used at runtime)\n readonly __jsType: JsType;\n}\n\n// Helper aliases for usage sites where the specific column parameters are irrelevant\n// Accepts any ColumnBuilder regardless of its Operations parameter\n// Note: We use `any` here because TypeScript's variance rules don't allow us to express\n// \"any type that extends OperationTypes\" in a way that works for assignment.\n// Contract-specific OperationTypes (e.g., PgVectorOperationTypes) are not assignable\n// to the base OperationTypes in generic parameter position, even though they extend it structurally.\n// Helper type that accepts any ColumnBuilder regardless of its generic parameters\n// This is needed because conditional types in ColumnBuilder create incompatible intersection types\n// when Operations differs, even though structurally they're compatible\nexport type AnyColumnBuilderBase = {\n readonly kind: 'column';\n readonly table: string;\n readonly column: string;\n readonly columnMeta: StorageColumn;\n // Methods accept ValueSource (ParamPlaceholder or ExpressionSource)\n eq(value: ValueSource): AnyBinaryBuilder;\n neq(value: ValueSource): AnyBinaryBuilder;\n gt(value: ValueSource): AnyBinaryBuilder;\n lt(value: ValueSource): AnyBinaryBuilder;\n gte(value: ValueSource): AnyBinaryBuilder;\n lte(value: ValueSource): AnyBinaryBuilder;\n asc(): AnyOrderBuilder;\n desc(): AnyOrderBuilder;\n toExpr(): ColumnRef;\n readonly __jsType: unknown;\n // Optional nullable methods (present when columnMeta.nullable is true)\n isNull?(): AnyUnaryBuilder;\n isNotNull?(): AnyUnaryBuilder;\n // Allow any operation methods (from conditional type)\n readonly [key: string]: unknown;\n};\n\nexport type AnyColumnBuilder =\n | ColumnBuilder<\n string,\n StorageColumn,\n unknown,\n // biome-ignore lint/suspicious/noExplicitAny: AnyColumnBuilder must accept column builders with any operation types\n any\n >\n | AnyColumnBuilderBase;\n\n/**\n * Union type for any builder that can produce an Expression.\n * Used in DSL method signatures where either a column or operation result can be passed.\n */\nexport type AnyExpressionSource = AnyColumnBuilder | ExpressionBuilder;\n\nexport function isColumnBuilder(value: unknown): value is AnyColumnBuilder {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'kind' in value &&\n (value as { kind: unknown }).kind === 'column'\n );\n}\n\nexport interface JoinOnBuilder {\n eqCol(left: AnyColumnBuilder, right: AnyColumnBuilder): JoinOnPredicate;\n}\n\nexport interface JoinOnPredicate {\n readonly kind: 'join-on';\n readonly left: AnyColumnBuilder;\n readonly right: AnyColumnBuilder;\n}\n\nexport type Expr = ColumnRef | ParamRef;\n\n/**\n * Helper type to extract codec output type from CodecTypes.\n * Returns never if the codecId is not found in CodecTypes.\n */\ntype ExtractCodecOutputType<\n CodecId extends string,\n CodecTypes extends Record<string, { readonly output: unknown }>,\n> = CodecId extends keyof CodecTypes\n ? CodecTypes[CodecId] extends { readonly output: infer Output }\n ? Output\n : never\n : never;\n\n/**\n * Extracts the model name for a given table from the contract mappings.\n */\ntype ExtractTableToModel<\n Contract extends SqlContract<SqlStorage>,\n TableName extends string,\n> = Contract['mappings'] extends {\n readonly tableToModel: infer TableToModel;\n}\n ? TableToModel extends Record<string, string>\n ? TableName extends keyof TableToModel\n ? TableToModel[TableName]\n : never\n : never\n : never;\n\n/**\n * Extracts the field name for a given table column from the contract mappings.\n */\ntype ExtractColumnToField<\n Contract extends SqlContract<SqlStorage>,\n TableName extends string,\n ColumnName extends string,\n> = Contract['mappings'] extends {\n readonly columnToField: infer ColumnToField;\n}\n ? ColumnToField extends Record<string, Record<string, string>>\n ? TableName extends keyof ColumnToField\n ? ColumnName extends keyof ColumnToField[TableName]\n ? ColumnToField[TableName][ColumnName]\n : never\n : never\n : never\n : never;\n\n/**\n * Extracts the field value type from a model's fields.\n */\ntype ExtractFieldValue<\n Contract extends SqlContract<SqlStorage>,\n ModelName extends string,\n FieldName extends string,\n> = Contract['models'] extends infer Models\n ? Models extends Record<string, unknown>\n ? ModelName extends keyof Models\n ? Models[ModelName] extends { readonly fields: infer Fields }\n ? Fields extends Record<string, unknown>\n ? FieldName extends keyof Fields\n ? Fields[FieldName]\n : never\n : never\n : never\n : never\n : never\n : never;\n\n/**\n * Extracts the JavaScript type for a column from model mappings if available.\n * Returns `never` if the column maps to a ModelField object (which indicates\n * a relation that should fall through to codec-based type resolution).\n *\n * The check for ModelField uses `Exclude<keyof FieldValue, 'column'> extends never`\n * to ensure we only skip pure `{ column: string }` marker objects, not richer\n * object types that happen to include a `column` property.\n */\ntype ExtractColumnJsTypeFromModels<\n Contract extends SqlContract<SqlStorage>,\n TableName extends string,\n ColumnName extends string,\n> = ExtractTableToModel<Contract, TableName> extends infer ModelName\n ? ModelName extends string\n ? ExtractColumnToField<Contract, TableName, ColumnName> extends infer FieldName\n ? FieldName extends string\n ? ExtractFieldValue<Contract, ModelName, FieldName> extends infer FieldValue\n ? FieldValue extends { readonly column: string }\n ? Exclude<keyof FieldValue, 'column'> extends never\n ? never\n : FieldValue\n : FieldValue\n : never\n : never\n : never\n : never\n : never;\n\n/**\n * Resolves type params for a column from either:\n * - inline `columnMeta.typeParams`, or\n * - `columnMeta.typeRef` (resolving into `contract.storage.types[typeRef].typeParams`).\n */\ntype ResolveColumnTypeParams<\n Contract extends SqlContract<SqlStorage>,\n ColumnMeta extends StorageColumn,\n> = ColumnMeta extends { typeParams: infer Params }\n ? Params extends object\n ? Params\n : undefined\n : ColumnMeta extends { typeRef: infer TypeRef extends string }\n ? Contract['storage'] extends { types: infer Types }\n ? Types extends Record<string, unknown>\n ? TypeRef extends keyof Types\n ? Types[TypeRef] extends { typeParams: infer Params }\n ? Params extends object\n ? Params\n : undefined\n : undefined\n : undefined\n : undefined\n : undefined\n : undefined;\n\n/**\n * If a codec entry exposes a type-level parameterized output surface, compute the output type\n * for a specific params object. Falls back to `never` if not supported.\n *\n * This enables lane typing to incorporate `columnMeta.typeParams` without branching on codec IDs\n * in core lane code.\n */\ntype ExtractParameterizedCodecOutputType<\n CodecId extends string,\n Params,\n CodecTypes extends Record<string, { readonly output: unknown }>,\n> = CodecId extends keyof CodecTypes\n ? CodecTypes[CodecId] extends { readonly parameterizedOutput: infer Fn }\n ? Fn extends (params: Params) => infer Out\n ? Out\n : never\n : never\n : never;\n\n/**\n * Type-level operation signature.\n * Represents an operation at the type level, similar to OperationSignature at runtime.\n */\nexport type OperationTypeSignature = {\n readonly args: ReadonlyArray<ArgSpec>;\n readonly returns: ReturnSpec;\n readonly lowering: SqlLoweringSpec;\n readonly capabilities?: ReadonlyArray<string>;\n};\n\n/**\n * Type-level operation registry.\n * Maps typeId → operations, where operations is a record of method name → operation signature.\n *\n * Example:\n * ```typescript\n * type MyOperations: OperationTypes = {\n * 'pg/vector@1': {\n * cosineDistance: {\n * args: [{ kind: 'typeId'; type: 'pg/vector@1' }];\n * returns: { kind: 'builtin'; type: 'number' };\n * lowering: { targetFamily: 'sql'; strategy: 'function'; template: '...' };\n * };\n * };\n * };\n * ```\n */\nexport type OperationTypes = Record<string, Record<string, OperationTypeSignature>>;\n\n/**\n * CodecTypes represents a map of typeId to codec definitions.\n * Each codec definition must have an `output` property indicating the JavaScript type.\n *\n * Example:\n * ```typescript\n * type MyCodecTypes: CodecTypes = {\n * 'pg/int4@1': { output: number };\n * 'pg/text@1': { output: string };\n * };\n * ```\n */\nexport type CodecTypes = Record<string, { readonly output: unknown }>;\n\n/**\n * Extracts operations for a given typeId from the operation registry.\n * Returns an empty record if the typeId is not found.\n *\n * @example\n * ```typescript\n * type Ops = OperationsForTypeId<'pg/vector@1', MyOperations>;\n * // Ops = { cosineDistance: { ... }, l2Distance: { ... } }\n * ```\n */\nexport type OperationsForTypeId<\n TypeId extends string,\n Operations extends OperationTypes,\n> = Operations extends Record<string, never>\n ? Record<string, never>\n : TypeId extends keyof Operations\n ? Operations[TypeId]\n : Record<string, never>;\n\n/**\n * Maps operation signatures to method signatures on ColumnBuilder.\n * Each operation becomes a method that returns a ColumnBuilder or BinaryBuilder\n * based on the return type.\n */\ntype OperationMethods<\n Ops extends Record<string, OperationTypeSignature>,\n ColumnName extends string,\n ColumnMeta extends StorageColumn,\n JsType,\n> = {\n [K in keyof Ops]: Ops[K] extends OperationTypeSignature\n ? (\n ...args: OperationArgs<Ops[K]['args']>\n ) => OperationReturn<Ops[K]['returns'], ColumnName, ColumnMeta, JsType>\n : never;\n};\n\n/**\n * Maps operation argument specs to TypeScript argument types.\n * - typeId args: ColumnBuilder (accepts base columns or operation results)\n * - param args: ParamPlaceholder\n * - literal args: unknown (could be more specific in future)\n */\ntype OperationArgs<Args extends ReadonlyArray<ArgSpec>> = Args extends readonly [\n infer First,\n ...infer Rest,\n]\n ? First extends ArgSpec\n ? [ArgToType<First>, ...(Rest extends ReadonlyArray<ArgSpec> ? OperationArgs<Rest> : [])]\n : []\n : [];\n\ntype ArgToType<Arg extends ArgSpec> = Arg extends { kind: 'typeId' }\n ? AnyExpressionSource\n : Arg extends { kind: 'param' }\n ? ParamPlaceholder\n : Arg extends { kind: 'literal' }\n ? unknown\n : never;\n\n/**\n * Maps operation return spec to return type.\n * Operations return ExpressionBuilder, not ColumnBuilder, because the result\n * represents an expression (OperationExpr) rather than a column reference.\n */\ntype OperationReturn<\n Returns extends ReturnSpec,\n _ColumnName extends string,\n _ColumnMeta extends StorageColumn,\n _JsType,\n> = Returns extends { kind: 'builtin'; type: infer T }\n ? T extends 'number'\n ? ExpressionBuilder<number>\n : T extends 'boolean'\n ? ExpressionBuilder<boolean>\n : T extends 'string'\n ? ExpressionBuilder<string>\n : ExpressionBuilder<unknown>\n : Returns extends { kind: 'typeId' }\n ? ExpressionBuilder<unknown>\n : ExpressionBuilder<unknown>;\n\n/**\n * Computes JavaScript type for a column at column creation time.\n *\n * Type inference:\n * - Read columnMeta.codecId as typeId string literal\n * - Look up CodecTypes[typeId].output\n * - Apply nullability: nullable ? Output | null : Output\n */\ntype ColumnMetaTypeId<ColumnMeta> = ColumnMeta extends { codecId: infer CodecId extends string }\n ? CodecId\n : ColumnMeta extends { type: infer TypeId extends string }\n ? TypeId\n : never;\n\nexport type ComputeColumnJsType<\n Contract extends SqlContract<SqlStorage>,\n TableName extends string,\n ColumnName extends string,\n ColumnMeta extends StorageColumn,\n CodecTypes extends Record<string, { readonly output: unknown }>,\n> = ExtractColumnJsTypeFromModels<Contract, TableName, ColumnName> extends infer FromModels\n ? [FromModels] extends [never]\n ? ColumnMeta extends { nullable: infer Nullable }\n ? ColumnMetaTypeId<ColumnMeta> extends infer TypeId\n ? TypeId extends string\n ? ResolveColumnTypeParams<Contract, ColumnMeta> extends infer Params\n ? Params extends object\n ? ExtractParameterizedCodecOutputType<\n TypeId,\n Params,\n CodecTypes\n > extends infer ParamOutput\n ? [ParamOutput] extends [never]\n ? ExtractCodecOutputType<TypeId, CodecTypes> extends infer CodecOutput\n ? [CodecOutput] extends [never]\n ? unknown // Codec not found in CodecTypes\n : Nullable extends true\n ? CodecOutput | null\n : CodecOutput\n : unknown\n : Nullable extends true\n ? ParamOutput | null\n : ParamOutput\n : unknown\n : ExtractCodecOutputType<TypeId, CodecTypes> extends infer CodecOutput\n ? [CodecOutput] extends [never]\n ? unknown // Codec not found in CodecTypes\n : Nullable extends true\n ? CodecOutput | null\n : CodecOutput\n : unknown\n : unknown\n : unknown\n : unknown\n : unknown\n : FromModels\n : unknown;\n\n/**\n * Infers Row type from a projection object.\n * Maps Record<string, ColumnBuilder> to Record<string, JSType>\n *\n * Extracts the pre-computed JsType from each ColumnBuilder in the projection.\n */\n/**\n * Extracts the inferred JsType carried by a ColumnBuilder.\n */\ntype ExtractJsTypeFromColumnBuilder<CB extends AnyColumnBuilder> =\n CB extends ColumnBuilder<\n infer _ColumnName extends string,\n infer _ColumnMeta extends StorageColumn,\n infer JsType,\n infer _Ops\n >\n ? JsType\n : never;\n\nexport type InferProjectionRow<P extends Record<string, AnyColumnBuilder>> = {\n [K in keyof P]: ExtractJsTypeFromColumnBuilder<P[K]>;\n};\n\n/**\n * Nested projection type - allows recursive nesting of ColumnBuilder, ExpressionBuilder, or nested objects.\n */\nexport type NestedProjection = Record<\n string,\n | AnyExpressionSource\n | Record<\n string,\n | AnyExpressionSource\n | Record<\n string,\n | AnyExpressionSource\n | Record<string, AnyExpressionSource | Record<string, AnyExpressionSource>>\n >\n >\n>;\n\n/**\n * Helper type to extract include type from Includes map.\n * Returns the value type if K is a key of Includes, otherwise returns unknown.\n */\ntype ExtractIncludeType<\n K extends string,\n Includes extends Record<string, unknown>,\n> = K extends keyof Includes ? Includes[K] : unknown;\n\n/**\n * Infers Row type from a nested projection object.\n * Recursively maps Record<string, ColumnBuilder | boolean | NestedProjection> to nested object types.\n *\n * Extracts the pre-computed JsType from each ColumnBuilder at leaves.\n * When a value is `true`, it represents an include reference and infers `Array<ChildShape>`\n * by looking up the include alias in the Includes type map.\n */\nexport type InferNestedProjectionRow<\n P extends Record<string, AnyExpressionSource | boolean | NestedProjection>,\n CodecTypes extends Record<string, { readonly output: unknown }> = Record<string, never>,\n Includes extends Record<string, unknown> = Record<string, never>,\n> = {\n [K in keyof P]: P[K] extends ExpressionBuilder<infer JsType>\n ? JsType\n : P[K] extends AnyColumnBuilder\n ? ExtractJsTypeFromColumnBuilder<P[K]>\n : P[K] extends true\n ? Array<ExtractIncludeType<K & string, Includes>> // Include reference - infers Array<ChildShape> from Includes map\n : P[K] extends NestedProjection\n ? InferNestedProjectionRow<P[K], CodecTypes, Includes>\n : never;\n};\n\n/**\n * Infers Row type from a tuple of ColumnBuilders used in returning() clause.\n * Extracts column name and JsType from each ColumnBuilder and creates a Record.\n */\nexport type InferReturningRow<Columns extends readonly AnyColumnBuilder[]> =\n Columns extends readonly [infer First, ...infer Rest]\n ? First extends ColumnBuilder<\n infer Name,\n infer _Meta,\n infer JsType,\n infer _Ops extends OperationTypes\n >\n ? Name extends string\n ? Rest extends readonly AnyColumnBuilder[]\n ? { [K in Name]: JsType } & InferReturningRow<Rest>\n : { [K in Name]: JsType }\n : never\n : never\n : Record<string, never>;\n\n/**\n * Utility type to check if a contract has the required capabilities for includeMany.\n * Requires both `lateral` and `jsonAgg` to be `true` in the contract's capabilities for the target.\n * Capabilities are nested by target: `{ [target]: { lateral: true, jsonAgg: true } }`\n */\nexport type HasIncludeManyCapabilities<TContract extends SqlContract<SqlStorage>> =\n TContract extends { capabilities: infer C; target: infer T }\n ? T extends string\n ? C extends Record<string, Record<string, boolean>>\n ? C extends { [K in T]: infer TargetCaps }\n ? TargetCaps extends { lateral: true; jsonAgg: true }\n ? true\n : false\n : false\n : false\n : false\n : false;\n\n/**\n * SQL-specific Plan type that refines the ast field to use QueryAst.\n * This is the type used by SQL query builders.\n */\nexport type SqlPlan<Row = unknown> = ExecutionPlan<Row, QueryAst>;\n\n/**\n * Helper types for extracting contract structure.\n */\nexport type TablesOf<TContract> = TContract extends {\n storage: { tables: infer U };\n}\n ? U\n : never;\n\nexport type TableKey<TContract> = Extract<keyof TablesOf<TContract>, string>;\n\n// Common types for contract.d.ts generation (SQL-specific)\n// These types are used by emitted contract.d.ts files to provide type-safe DSL/ORM types\n\n/**\n * Unique symbol for metadata property to avoid collisions with user-defined properties\n */\nexport declare const META: unique symbol;\n\n/**\n * Extracts metadata from a type that has a META property\n */\nexport type Meta<T extends { [META]: unknown }> = T[typeof META];\n\n/**\n * Metadata interface for table definitions\n */\nexport interface TableMetadata<Name extends string> {\n name: Name;\n}\n\n/**\n * Metadata interface for model definitions\n */\nexport interface ModelMetadata<Name extends string> {\n name: Name;\n}\n\n/**\n * Base interface for table definitions with metadata\n * Used in contract.d.ts to define storage-level table types\n */\nexport interface TableDef<Name extends string> {\n readonly [META]: TableMetadata<Name>;\n}\n\n/**\n * Base interface for model definitions with metadata\n * Used in contract.d.ts to define application-level model types\n */\nexport interface ModelDef<Name extends string> {\n readonly [META]: ModelMetadata<Name>;\n}\n\nexport type ColumnsOf<\n TContract,\n K extends TableKey<TContract>,\n> = K extends keyof TablesOf<TContract>\n ? TablesOf<TContract>[K] extends { columns: infer C }\n ? C\n : never\n : never;\n\nexport interface RawTemplateOptions {\n readonly refs?: PlanRefs;\n readonly annotations?: Record<string, unknown>;\n readonly projection?: ReadonlyArray<string>;\n}\n\nexport interface RawFunctionOptions extends RawTemplateOptions {\n readonly params: ReadonlyArray<unknown>;\n}\n\nexport type RawTemplateFactory = (\n strings: TemplateStringsArray,\n ...values: readonly unknown[]\n) => ExecutionPlan;\n\nexport interface RawFactory extends RawTemplateFactory {\n (text: string, options: RawFunctionOptions): ExecutionPlan;\n with(options: RawTemplateOptions): RawTemplateFactory;\n}\n\nexport type { RuntimeError } from '@prisma-next/plan';\n\nexport interface BuildParamsMap {\n readonly [name: string]: unknown;\n}\n\nexport interface BuildOptions {\n readonly params?: BuildParamsMap;\n}\n\nexport interface SqlBuilderOptions<\n TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>,\n> {\n readonly context: QueryLaneContext<TContract>;\n}\n\n/**\n * SQL-specific ResultType that works with both Plan and SqlQueryPlan.\n * This extends the core ResultType to also handle SqlQueryPlan.\n * Example: `type Row = ResultType<typeof plan>`\n */\nexport type ResultType<P> = P extends SqlQueryPlan<infer R> ? R : CoreResultType<P>;\n"],"mappings":";AA+CO,SAAS,mBACd,MACA,KACiB;AACjB,SAAO,EAAE,MAAM,SAAS,MAAM,IAAI;AACpC;AAiLO,SAAS,gBAAgB,OAA2C;AACzE,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAA4B,SAAS;AAE1C;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isColumnBuilder
3
- } from "./chunk-2BWK6XEY.js";
3
+ } from "./chunk-HAUHWBE7.js";
4
4
 
5
5
  // src/ast/codec-types.ts
6
6
  var CodecRegistryImpl = class {
@@ -264,6 +264,13 @@ function createExistsExpr(not, subquery) {
264
264
  subquery
265
265
  };
266
266
  }
267
+ function createNullCheckExpr(expr, isNull) {
268
+ return {
269
+ kind: "nullCheck",
270
+ expr,
271
+ isNull
272
+ };
273
+ }
267
274
 
268
275
  // src/ast/select.ts
269
276
  function createSelectAst(options) {
@@ -313,8 +320,9 @@ export {
313
320
  createOrderByItem,
314
321
  createBinaryExpr,
315
322
  createExistsExpr,
323
+ createNullCheckExpr,
316
324
  createSelectAst,
317
325
  isOperationExpr,
318
326
  createUpdateAst
319
327
  };
320
- //# sourceMappingURL=chunk-HV334QHG.js.map
328
+ //# sourceMappingURL=chunk-RVHFGDZ6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ast/codec-types.ts","../src/ast/util.ts","../src/ast/common.ts","../src/ast/delete.ts","../src/ast/insert.ts","../src/ast/join.ts","../src/ast/order.ts","../src/ast/predicate.ts","../src/ast/select.ts","../src/ast/types.ts","../src/ast/update.ts"],"sourcesContent":["import type { O } from 'ts-toolbelt';\n\n/**\n * Codec metadata for database-specific type information.\n * Used for schema introspection and verification.\n */\nexport interface CodecMeta {\n readonly db?: {\n readonly sql?: {\n readonly postgres?: {\n readonly nativeType: string; // e.g. 'integer', 'text', 'vector', 'timestamp with time zone'\n };\n };\n };\n}\n\n/**\n * Codec interface for encoding/decoding values between wire format and JavaScript types.\n *\n * Codecs are pure, synchronous functions with no side effects or IO.\n * They provide deterministic conversion between database wire types and JS values.\n */\nexport interface Codec<Id extends string = string, TWire = unknown, TJs = unknown> {\n /**\n * Namespaced codec identifier in format 'namespace/name@version'\n * Examples: 'pg/text@1', 'pg/uuid@1', 'pg/timestamptz@1'\n */\n readonly id: Id;\n\n /**\n * Contract scalar type IDs that this codec can handle.\n * Examples: ['text'], ['int4', 'float8'], ['timestamp', 'timestamptz']\n */\n readonly targetTypes: readonly string[];\n\n /**\n * Optional metadata for database-specific type information.\n * Used for schema introspection and verification.\n */\n readonly meta?: CodecMeta;\n\n /**\n * Decode a wire value (from database) to JavaScript type.\n * Must be synchronous and pure (no side effects).\n */\n decode(wire: TWire): TJs;\n\n /**\n * Encode a JavaScript value to wire format (for database).\n * Optional - if not provided, values pass through unchanged.\n * Must be synchronous and pure (no side effects).\n */\n encode?(value: TJs): TWire;\n}\n\n/**\n * Registry interface for codecs organized by ID and by contract scalar type.\n *\n * The registry allows looking up codecs by their namespaced ID or by the\n * contract scalar types they handle. Multiple codecs may handle the same\n * scalar type; ordering in byScalar reflects preference (adapter first,\n * then packs, then app overrides).\n */\nexport interface CodecRegistry {\n get(id: string): Codec<string> | undefined;\n has(id: string): boolean;\n getByScalar(scalar: string): readonly Codec<string>[];\n getDefaultCodec(scalar: string): Codec<string> | undefined;\n register(codec: Codec<string>): void;\n [Symbol.iterator](): Iterator<Codec<string>>;\n values(): IterableIterator<Codec<string>>;\n}\n\n/**\n * Implementation of CodecRegistry.\n */\nclass CodecRegistryImpl implements CodecRegistry {\n private readonly _byId = new Map<string, Codec<string>>();\n private readonly _byScalar = new Map<string, Codec<string>[]>();\n\n /**\n * Map-like interface for codec lookup by ID.\n * Example: registry.get('pg/text@1')\n */\n get(id: string): Codec<string> | undefined {\n return this._byId.get(id);\n }\n\n /**\n * Check if a codec with the given ID is registered.\n */\n has(id: string): boolean {\n return this._byId.has(id);\n }\n\n /**\n * Get all codecs that handle a given scalar type.\n * Returns an empty frozen array if no codecs are found.\n * Example: registry.getByScalar('text') → [codec1, codec2, ...]\n */\n getByScalar(scalar: string): readonly Codec<string>[] {\n return this._byScalar.get(scalar) ?? Object.freeze([]);\n }\n\n /**\n * Get the default codec for a scalar type (first registered codec).\n * Returns undefined if no codec handles this scalar type.\n */\n getDefaultCodec(scalar: string): Codec<string> | undefined {\n const _codecs = this._byScalar.get(scalar);\n return _codecs?.[0];\n }\n\n /**\n * Register a codec in the registry.\n * Throws an error if a codec with the same ID is already registered.\n *\n * @param codec - The codec to register\n * @throws Error if a codec with the same ID already exists\n */\n register(codec: Codec<string>): void {\n if (this._byId.has(codec.id)) {\n throw new Error(`Codec with ID '${codec.id}' is already registered`);\n }\n\n this._byId.set(codec.id, codec);\n\n // Update byScalar mapping\n for (const scalarType of codec.targetTypes) {\n const existing = this._byScalar.get(scalarType);\n if (existing) {\n existing.push(codec);\n } else {\n this._byScalar.set(scalarType, [codec]);\n }\n }\n }\n\n /**\n * Returns an iterator over all registered codecs.\n * Useful for iterating through codecs from another registry.\n */\n *[Symbol.iterator](): Iterator<Codec<string>> {\n for (const codec of this._byId.values()) {\n yield codec;\n }\n }\n\n /**\n * Returns an iterable of all registered codecs.\n */\n values(): IterableIterator<Codec<string>> {\n return this._byId.values();\n }\n}\n\n/**\n * Codec factory - creates a codec with typeId and encode/decode functions.\n */\nexport function codec<Id extends string, TWire, TJs>(config: {\n typeId: Id;\n targetTypes: readonly string[];\n encode: (value: TJs) => TWire;\n decode: (wire: TWire) => TJs;\n meta?: CodecMeta;\n}): Codec<Id, TWire, TJs> {\n return {\n id: config.typeId,\n targetTypes: config.targetTypes,\n ...(config.meta ? { meta: config.meta } : {}),\n encode: config.encode,\n decode: config.decode,\n };\n}\n\n/**\n * Type helpers to extract codec types.\n */\nexport type CodecId<T> =\n T extends Codec<infer Id, unknown, unknown>\n ? Id\n : T extends { readonly id: infer Id }\n ? Id\n : never;\nexport type CodecInput<T> = T extends Codec<string, unknown, infer JsT> ? JsT : never;\nexport type CodecOutput<T> = T extends Codec<string, unknown, infer JsT> ? JsT : never;\n\n/**\n * Type helper to extract codec types from builder instance.\n */\nexport type ExtractCodecTypes<\n ScalarNames extends { readonly [K in keyof ScalarNames]: Codec<string> } = Record<never, never>,\n> = {\n readonly [K in keyof ScalarNames as ScalarNames[K] extends Codec<infer Id, unknown, unknown>\n ? Id\n : never]: {\n readonly input: CodecInput<ScalarNames[K]>;\n readonly output: CodecOutput<ScalarNames[K]>;\n };\n};\n\n/**\n * Type helper to extract data type IDs from builder instance.\n * Uses ExtractCodecTypes which preserves literal types as keys.\n * Since ExtractCodecTypes<Record<K, ScalarNames[K]>> has exactly one key (the Id),\n * we extract it by creating a mapped type that uses the Id as both key and value,\n * then extract the value type. This preserves literal types.\n */\nexport type ExtractDataTypes<\n ScalarNames extends { readonly [K in keyof ScalarNames]: Codec<string> },\n> = {\n readonly [K in keyof ScalarNames]: {\n readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id;\n }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>];\n};\n\n/**\n * Builder interface for declaring codecs.\n */\nexport interface CodecDefBuilder<\n ScalarNames extends { readonly [K in keyof ScalarNames]: Codec<string> } = Record<never, never>,\n> {\n readonly CodecTypes: ExtractCodecTypes<ScalarNames>;\n\n add<ScalarName extends string, CodecImpl extends Codec<string>>(\n scalarName: ScalarName,\n codecImpl: CodecImpl,\n ): CodecDefBuilder<\n O.Overwrite<ScalarNames, Record<ScalarName, CodecImpl>> & Record<ScalarName, CodecImpl>\n >;\n\n readonly codecDefinitions: {\n readonly [K in keyof ScalarNames]: {\n readonly typeId: ScalarNames[K] extends Codec<infer Id extends string, unknown, unknown>\n ? Id\n : never;\n readonly scalar: K;\n readonly codec: ScalarNames[K];\n readonly input: CodecInput<ScalarNames[K]>;\n readonly output: CodecOutput<ScalarNames[K]>;\n readonly jsType: CodecOutput<ScalarNames[K]>;\n };\n };\n\n readonly dataTypes: {\n readonly [K in keyof ScalarNames]: {\n readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id;\n }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>];\n };\n}\n\n/**\n * Implementation of CodecDefBuilder.\n */\nclass CodecDefBuilderImpl<\n ScalarNames extends { readonly [K in keyof ScalarNames]: Codec<string> } = Record<never, never>,\n> implements CodecDefBuilder<ScalarNames>\n{\n private readonly _codecs: ScalarNames;\n\n public readonly CodecTypes: ExtractCodecTypes<ScalarNames>;\n public readonly dataTypes: {\n readonly [K in keyof ScalarNames]: {\n readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id;\n }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>];\n };\n\n constructor(codecs: ScalarNames) {\n this._codecs = codecs;\n\n // Populate CodecTypes from codecs\n const codecTypes: Record<string, { readonly input: unknown; readonly output: unknown }> = {};\n for (const [, codecImpl] of Object.entries(this._codecs)) {\n const codecImplTyped = codecImpl as Codec<string>;\n codecTypes[codecImplTyped.id] = {\n input: undefined as unknown as CodecInput<typeof codecImplTyped>,\n output: undefined as unknown as CodecOutput<typeof codecImplTyped>,\n };\n }\n this.CodecTypes = codecTypes as ExtractCodecTypes<ScalarNames>;\n\n // Populate dataTypes from codecs - extract id property from each codec\n // Build object preserving keys from ScalarNames\n // Type assertion is safe because we know ScalarNames structure matches the return type\n // biome-ignore lint/suspicious/noExplicitAny: dynamic codec mapping requires any\n const dataTypes = {} as any;\n for (const key in this._codecs) {\n if (Object.hasOwn(this._codecs, key)) {\n const codec = this._codecs[key] as Codec<string>;\n dataTypes[key] = codec.id;\n }\n }\n this.dataTypes = dataTypes as {\n readonly [K in keyof ScalarNames]: {\n readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id;\n }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>];\n };\n }\n\n add<ScalarName extends string, CodecImpl extends Codec<string>>(\n scalarName: ScalarName,\n codecImpl: CodecImpl,\n ): CodecDefBuilder<\n O.Overwrite<ScalarNames, Record<ScalarName, CodecImpl>> & Record<ScalarName, CodecImpl>\n > {\n return new CodecDefBuilderImpl({\n ...this._codecs,\n [scalarName]: codecImpl,\n } as O.Overwrite<ScalarNames, Record<ScalarName, CodecImpl>> & Record<ScalarName, CodecImpl>);\n }\n\n /**\n * Derive codecDefinitions structure.\n */\n get codecDefinitions(): {\n readonly [K in keyof ScalarNames]: {\n readonly typeId: ScalarNames[K] extends Codec<infer Id, unknown, unknown> ? Id : never;\n readonly scalar: K;\n readonly codec: ScalarNames[K];\n readonly input: CodecInput<ScalarNames[K]>;\n readonly output: CodecOutput<ScalarNames[K]>;\n readonly jsType: CodecOutput<ScalarNames[K]>;\n };\n } {\n const result: Record<\n string,\n {\n typeId: string;\n scalar: string;\n codec: Codec;\n input: unknown;\n output: unknown;\n jsType: unknown;\n }\n > = {};\n\n for (const [scalarName, codecImpl] of Object.entries(this._codecs)) {\n const codec = codecImpl as Codec<string>;\n result[scalarName] = {\n typeId: codec.id,\n scalar: scalarName,\n codec: codec,\n input: undefined as unknown as CodecInput<typeof codec>,\n output: undefined as unknown as CodecOutput<typeof codec>,\n jsType: undefined as unknown as CodecOutput<typeof codec>,\n };\n }\n\n return result as {\n readonly [K in keyof ScalarNames]: {\n readonly typeId: ScalarNames[K] extends Codec<infer Id extends string, unknown, unknown>\n ? Id\n : never;\n readonly scalar: K;\n readonly codec: ScalarNames[K];\n readonly input: CodecInput<ScalarNames[K]>;\n readonly output: CodecOutput<ScalarNames[K]>;\n readonly jsType: CodecOutput<ScalarNames[K]>;\n };\n };\n }\n}\n\n/**\n * Create a new codec registry.\n */\nexport function createCodecRegistry(): CodecRegistry {\n return new CodecRegistryImpl();\n}\n\n/**\n * Create a new codec definition builder.\n */\nexport function defineCodecs(): CodecDefBuilder<Record<never, never>> {\n return new CodecDefBuilderImpl({});\n}\n","export 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","import type { ColumnRef, LiteralExpr, OperationExpr, ParamRef, TableRef } from './types';\nimport { compact } from './util';\n\nexport function createTableRef(name: string): TableRef {\n return {\n kind: 'table',\n name,\n };\n}\n\nexport function createColumnRef(table: string, column: string): ColumnRef {\n return {\n kind: 'col',\n table,\n column,\n };\n}\n\nexport function createParamRef(index: number, name?: string): ParamRef {\n return compact({\n kind: 'param',\n index,\n name,\n }) as ParamRef;\n}\n\nexport function createOperationExpr(operation: OperationExpr): OperationExpr {\n return operation;\n}\n\nexport function createLiteralExpr(value: unknown): LiteralExpr {\n return {\n kind: 'literal',\n value,\n };\n}\n","import type { ColumnRef, DeleteAst, TableRef, WhereExpr } from './types';\nimport { compact } from './util';\n\nexport interface CreateDeleteAstOptions {\n readonly table: TableRef;\n readonly where: WhereExpr;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport function createDeleteAst(options: CreateDeleteAstOptions): DeleteAst {\n return compact({\n kind: 'delete',\n table: options.table,\n where: options.where,\n returning: options.returning,\n }) as DeleteAst;\n}\n","import type { ColumnRef, InsertAst, ParamRef, TableRef } from './types';\nimport { compact } from './util';\n\nexport interface CreateInsertAstOptions {\n readonly table: TableRef;\n readonly values: Record<string, ColumnRef | ParamRef>;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport function createInsertAst(options: CreateInsertAstOptions): InsertAst {\n return compact({\n kind: 'insert',\n table: options.table,\n values: options.values,\n returning: options.returning,\n }) as InsertAst;\n}\n","import { planInvalid } from '@prisma-next/plan';\nimport type { AnyColumnBuilder, JoinOnBuilder, JoinOnPredicate } from '../types';\nimport { isColumnBuilder } from '../types';\nimport type { ColumnRef, JoinAst, JoinOnExpr, TableRef } from './types';\n\nexport function createJoin(\n joinType: 'inner' | 'left' | 'right' | 'full',\n table: TableRef,\n on: JoinOnExpr,\n): JoinAst {\n return {\n kind: 'join',\n joinType,\n table,\n on,\n };\n}\n\nexport function createJoinOnExpr(left: ColumnRef, right: ColumnRef): JoinOnExpr {\n return {\n kind: 'eqCol',\n left,\n right,\n };\n}\n\nclass JoinOnBuilderImpl implements JoinOnBuilder {\n eqCol(left: AnyColumnBuilder, right: AnyColumnBuilder): JoinOnPredicate {\n if (!left || !isColumnBuilder(left)) {\n throw planInvalid('Join ON left operand must be a column');\n }\n\n if (!right || !isColumnBuilder(right)) {\n throw planInvalid('Join ON right operand must be a column');\n }\n\n // TypeScript can't narrow ColumnBuilder properly, so we assert\n const leftCol = left as unknown as { table: string; column: string };\n const rightCol = right as unknown as { table: string; column: string };\n if (leftCol.table === rightCol.table) {\n throw planInvalid('Self-joins are not supported in MVP');\n }\n\n return {\n kind: 'join-on',\n left: left as AnyColumnBuilder,\n right: right as AnyColumnBuilder,\n };\n }\n}\n\nexport function createJoinOnBuilder(): JoinOnBuilder {\n return new JoinOnBuilderImpl();\n}\n","import type { ColumnRef, Direction, OperationExpr } from './types';\n\nexport function createOrderByItem(\n expr: ColumnRef | OperationExpr,\n dir: 'asc' | 'desc',\n): { expr: ColumnRef | OperationExpr; dir: Direction } {\n return {\n expr,\n dir,\n };\n}\n","import type {\n BinaryExpr,\n BinaryOp,\n ExistsExpr,\n Expression,\n NullCheckExpr,\n ParamRef,\n SelectAst,\n} from './types';\n\nexport function createBinaryExpr(\n op: BinaryOp,\n left: Expression,\n right: Expression | ParamRef,\n): BinaryExpr {\n return {\n kind: 'bin',\n op,\n left,\n right,\n };\n}\n\nexport function createExistsExpr(not: boolean, subquery: SelectAst): ExistsExpr {\n return {\n kind: 'exists',\n not,\n subquery,\n };\n}\n\nexport function createNullCheckExpr(expr: Expression, isNull: boolean): NullCheckExpr {\n return {\n kind: 'nullCheck',\n expr,\n isNull,\n };\n}\n","import type {\n ColumnRef,\n Direction,\n IncludeAst,\n IncludeRef,\n JoinAst,\n OperationExpr,\n SelectAst,\n TableRef,\n WhereExpr,\n} from './types';\nimport { compact } from './util';\n\nexport interface CreateSelectAstOptions {\n readonly from: TableRef;\n readonly joins?: ReadonlyArray<JoinAst>;\n readonly includes?: ReadonlyArray<IncludeAst>;\n readonly project: ReadonlyArray<{\n alias: string;\n expr: ColumnRef | IncludeRef | OperationExpr;\n }>;\n readonly where?: WhereExpr;\n readonly orderBy?: ReadonlyArray<{ expr: ColumnRef | OperationExpr; dir: Direction }>;\n readonly limit?: number;\n}\n\nexport function createSelectAst(options: CreateSelectAstOptions): SelectAst {\n return compact({\n kind: 'select',\n from: options.from,\n joins: options.joins,\n includes: options.includes,\n project: options.project,\n where: options.where,\n orderBy: options.orderBy,\n limit: options.limit,\n }) as SelectAst;\n}\n","import type { ReturnSpec } from '@prisma-next/operations';\nimport type { SqlLoweringSpec } from '@prisma-next/sql-operations';\n\n// SQL-specific AST types and supporting types\n// These types are needed by adapters and runtime for SQL query execution\n\nexport type Direction = 'asc' | 'desc';\n\nexport interface TableRef {\n readonly kind: 'table';\n readonly name: string;\n}\n\nexport interface ColumnRef {\n readonly kind: 'col';\n readonly table: string;\n readonly column: string;\n}\n\nexport interface ParamRef {\n readonly kind: 'param';\n readonly index: number;\n readonly name?: string;\n}\n\nexport interface LiteralExpr {\n readonly kind: 'literal';\n readonly value: unknown;\n}\n\nexport interface OperationExpr {\n readonly kind: 'operation';\n readonly method: string;\n readonly forTypeId: string;\n readonly self: Expression;\n readonly args: ReadonlyArray<Expression | ParamRef | LiteralExpr>;\n readonly returns: ReturnSpec;\n readonly lowering: SqlLoweringSpec;\n}\n\n/**\n * Unified expression type - the canonical AST representation for column references\n * and operation expressions. This is what all builders convert to via toExpr().\n */\nexport type Expression = ColumnRef | OperationExpr;\n\n/**\n * Interface for any builder that can produce an Expression.\n * Implemented by ColumnBuilder and ExpressionBuilder.\n */\nexport interface ExpressionSource {\n toExpr(): Expression;\n}\n\nexport function isOperationExpr(expr: Expression): expr is OperationExpr {\n return expr.kind === 'operation';\n}\n\nexport type BinaryOp = 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte';\n\nexport interface BinaryExpr {\n readonly kind: 'bin';\n readonly op: BinaryOp;\n readonly left: Expression;\n readonly right: Expression | ParamRef;\n}\n\nexport interface ExistsExpr {\n readonly kind: 'exists';\n readonly not: boolean;\n readonly subquery: SelectAst;\n}\n\n/**\n * Unary expression for IS NULL / IS NOT NULL checks.\n * Used in WHERE clauses to check for null values.\n */\nexport interface NullCheckExpr {\n readonly kind: 'nullCheck';\n readonly expr: Expression;\n readonly isNull: boolean;\n}\n\n/**\n * Union type for WHERE clause expressions.\n */\nexport type WhereExpr = BinaryExpr | ExistsExpr | NullCheckExpr;\n\nexport type JoinOnExpr = {\n readonly kind: 'eqCol';\n readonly left: ColumnRef;\n readonly right: ColumnRef;\n};\n\nexport interface JoinAst {\n readonly kind: 'join';\n readonly joinType: 'inner' | 'left' | 'right' | 'full';\n readonly table: TableRef;\n readonly on: JoinOnExpr;\n}\n\nexport interface IncludeRef {\n readonly kind: 'includeRef';\n readonly alias: string;\n}\n\nexport interface IncludeAst {\n readonly kind: 'includeMany';\n readonly alias: string;\n readonly child: {\n readonly table: TableRef;\n readonly on: JoinOnExpr;\n readonly where?: WhereExpr;\n readonly orderBy?: ReadonlyArray<{ expr: Expression; dir: Direction }>;\n readonly limit?: number;\n readonly project: ReadonlyArray<{ alias: string; expr: Expression }>;\n };\n}\n\nexport interface SelectAst {\n readonly kind: 'select';\n readonly from: TableRef;\n readonly joins?: ReadonlyArray<JoinAst>;\n readonly includes?: ReadonlyArray<IncludeAst>;\n readonly project: ReadonlyArray<{\n alias: string;\n expr: Expression | IncludeRef | LiteralExpr;\n }>;\n readonly where?: WhereExpr;\n readonly orderBy?: ReadonlyArray<{ expr: Expression; dir: Direction }>;\n readonly limit?: number;\n}\n\nexport interface InsertAst {\n readonly kind: 'insert';\n readonly table: TableRef;\n readonly values: Record<string, ColumnRef | ParamRef>;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport interface UpdateAst {\n readonly kind: 'update';\n readonly table: TableRef;\n readonly set: Record<string, ColumnRef | ParamRef>;\n readonly where: WhereExpr;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport interface DeleteAst {\n readonly kind: 'delete';\n readonly table: TableRef;\n readonly where: WhereExpr;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport type QueryAst = SelectAst | InsertAst | UpdateAst | DeleteAst;\n\nexport interface LoweredStatement {\n readonly sql: string;\n readonly params: readonly unknown[];\n readonly annotations?: Record<string, unknown>;\n}\n","import type { ColumnRef, ParamRef, TableRef, UpdateAst, WhereExpr } from './types';\nimport { compact } from './util';\n\nexport interface CreateUpdateAstOptions {\n readonly table: TableRef;\n readonly set: Record<string, ColumnRef | ParamRef>;\n readonly where: WhereExpr;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport function createUpdateAst(options: CreateUpdateAstOptions): UpdateAst {\n return compact({\n kind: 'update',\n table: options.table,\n set: options.set,\n where: options.where,\n returning: options.returning,\n }) as UpdateAst;\n}\n"],"mappings":";;;;;AA4EA,IAAM,oBAAN,MAAiD;AAAA,EAC9B,QAAQ,oBAAI,IAA2B;AAAA,EACvC,YAAY,oBAAI,IAA6B;AAAA;AAAA;AAAA;AAAA;AAAA,EAM9D,IAAI,IAAuC;AACzC,WAAO,KAAK,MAAM,IAAI,EAAE;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,IAAqB;AACvB,WAAO,KAAK,MAAM,IAAI,EAAE;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAY,QAA0C;AACpD,WAAO,KAAK,UAAU,IAAI,MAAM,KAAK,OAAO,OAAO,CAAC,CAAC;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAgB,QAA2C;AACzD,UAAM,UAAU,KAAK,UAAU,IAAI,MAAM;AACzC,WAAO,UAAU,CAAC;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,SAASA,QAA4B;AACnC,QAAI,KAAK,MAAM,IAAIA,OAAM,EAAE,GAAG;AAC5B,YAAM,IAAI,MAAM,kBAAkBA,OAAM,EAAE,yBAAyB;AAAA,IACrE;AAEA,SAAK,MAAM,IAAIA,OAAM,IAAIA,MAAK;AAG9B,eAAW,cAAcA,OAAM,aAAa;AAC1C,YAAM,WAAW,KAAK,UAAU,IAAI,UAAU;AAC9C,UAAI,UAAU;AACZ,iBAAS,KAAKA,MAAK;AAAA,MACrB,OAAO;AACL,aAAK,UAAU,IAAI,YAAY,CAACA,MAAK,CAAC;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,EAAE,OAAO,QAAQ,IAA6B;AAC5C,eAAWA,UAAS,KAAK,MAAM,OAAO,GAAG;AACvC,Y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MAAM,QAAQ;AAAA,IACd,OAAO,QAAQ;AAAA,IACf,UAAU,QAAQ;AAAA,IAClB,SAAS,QAAQ;AAAA,IACjB,OAAO,QAAQ;AAAA,IACf,SAAS,QAAQ;AAAA,IACjB,OAAO,QAAQ;AAAA,EACjB,CAAC;AACH;;;ACiBO,SAAS,gBAAgB,MAAyC;AACvE,SAAO,KAAK,SAAS;AACvB;;;AC9CO,SAAS,gBAAgB,SAA4C;AAC1E,SAAO,QAAQ;AAAA,IACb,MAAM;AAAA,IACN,OAAO,QAAQ;AAAA,IACf,KAAK,QAAQ;AAAA,IACb,OAAO,QAAQ;AAAA,IACf,WAAW,QAAQ;AAAA,EACrB,CAAC;AACH;","names":["codec"]}
@@ -11,6 +11,7 @@ import {
11
11
  createJoinOnBuilder,
12
12
  createJoinOnExpr,
13
13
  createLiteralExpr,
14
+ createNullCheckExpr,
14
15
  createOperationExpr,
15
16
  createOrderByItem,
16
17
  createParamRef,
@@ -19,8 +20,8 @@ import {
19
20
  createUpdateAst,
20
21
  defineCodecs,
21
22
  isOperationExpr
22
- } from "../chunk-HV334QHG.js";
23
- import "../chunk-2BWK6XEY.js";
23
+ } from "../chunk-RVHFGDZ6.js";
24
+ import "../chunk-HAUHWBE7.js";
24
25
  export {
25
26
  codec,
26
27
  compact,
@@ -34,6 +35,7 @@ export {
34
35
  createJoinOnBuilder,
35
36
  createJoinOnExpr,
36
37
  createLiteralExpr,
38
+ createNullCheckExpr,
37
39
  createOperationExpr,
38
40
  createOrderByItem,
39
41
  createParamRef,
@@ -2,7 +2,7 @@ import {
2
2
  ColumnBuilderImpl,
3
3
  TableBuilderImpl,
4
4
  schema
5
- } from "../chunk-YXD25S5I.js";
5
+ } from "../chunk-4WKZQIDS.js";
6
6
  import "../chunk-3F4RFQIB.js";
7
7
  import "../chunk-2MAKNVCP.js";
8
8
  export {
@@ -2,7 +2,7 @@ import "../chunk-36WJWNHT.js";
2
2
  import {
3
3
  createOrderBuilder,
4
4
  isColumnBuilder
5
- } from "../chunk-2BWK6XEY.js";
5
+ } from "../chunk-HAUHWBE7.js";
6
6
  export {
7
7
  createOrderBuilder,
8
8
  isColumnBuilder
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  ColumnBuilderImpl,
4
4
  TableBuilderImpl,
5
5
  schema
6
- } from "./chunk-YXD25S5I.js";
6
+ } from "./chunk-4WKZQIDS.js";
7
7
  import {
8
8
  param
9
9
  } from "./chunk-7I3EMQID.js";
@@ -30,6 +30,7 @@ import {
30
30
  createJoinOnBuilder,
31
31
  createJoinOnExpr,
32
32
  createLiteralExpr,
33
+ createNullCheckExpr,
33
34
  createOperationExpr,
34
35
  createOrderByItem,
35
36
  createParamRef,
@@ -38,11 +39,11 @@ import {
38
39
  createUpdateAst,
39
40
  defineCodecs,
40
41
  isOperationExpr
41
- } from "./chunk-HV334QHG.js";
42
+ } from "./chunk-RVHFGDZ6.js";
42
43
  import {
43
44
  createOrderBuilder,
44
45
  isColumnBuilder
45
- } from "./chunk-2BWK6XEY.js";
46
+ } from "./chunk-HAUHWBE7.js";
46
47
  import {
47
48
  augmentDescriptorWithColumnMeta
48
49
  } from "./chunk-KYSP7L5C.js";
@@ -63,6 +64,7 @@ export {
63
64
  createJoinOnBuilder,
64
65
  createJoinOnExpr,
65
66
  createLiteralExpr,
67
+ createNullCheckExpr,
66
68
  createOperationExpr,
67
69
  createOrderBuilder,
68
70
  createOrderByItem,
package/dist/schema.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ExtractCodecTypes, ExtractOperationTypes, SqlContract, SqlStorage, StorageColumn } from '@prisma-next/sql-contract/types';
2
2
  import type { ColumnRef, ExpressionSource, TableRef } from './ast/types';
3
3
  import type { QueryLaneContext } from './query-lane-context';
4
- import type { BinaryBuilder, CodecTypes as CodecTypesType, ColumnBuilder, ComputeColumnJsType, OperationTypeSignature, OperationTypes, OrderBuilder, ParamPlaceholder } from './types';
4
+ import type { BinaryBuilder, CodecTypes as CodecTypesType, ColumnBuilder, ComputeColumnJsType, NullCheckBuilder, OperationTypeSignature, OperationTypes, OrderBuilder, ParamPlaceholder } from './types';
5
5
  type TableColumns<Table extends {
6
6
  columns: Record<string, StorageColumn>;
7
7
  }> = Table['columns'];
@@ -30,6 +30,16 @@ export declare class ColumnBuilderImpl<ColumnName extends string, ColumnMeta ext
30
30
  lte(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
31
31
  asc(): OrderBuilder<ColumnName, ColumnMeta, JsType>;
32
32
  desc(): OrderBuilder<ColumnName, ColumnMeta, JsType>;
33
+ /**
34
+ * Creates an IS NULL check for this column.
35
+ * Available on all columns at runtime, but typed to only be visible on nullable columns.
36
+ */
37
+ isNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType>;
38
+ /**
39
+ * Creates an IS NOT NULL check for this column.
40
+ * Available on all columns at runtime, but typed to only be visible on nullable columns.
41
+ */
42
+ isNotNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType>;
33
43
  }
34
44
  export declare class TableBuilderImpl<Contract extends SqlContract<SqlStorage>, TableName extends string, Columns extends Record<string, StorageColumn>, CodecTypes extends CodecTypesType, Operations extends OperationTypes> implements TableRef {
35
45
  readonly kind: "table";
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACX,UAAU,EACV,aAAa,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAY,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EACV,aAAa,EACb,UAAU,IAAI,cAAc,EAC5B,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,gBAAgB,EACjB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