@prisma-next/sql-relational-core 0.3.0-pr.93.5 → 0.3.0-pr.94.2

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 (160) hide show
  1. package/dist/errors-BwxypN2Q.mjs +3 -0
  2. package/dist/errors-CLx1Ylq0.d.mts +2 -0
  3. package/dist/exports/ast.d.mts +123 -0
  4. package/dist/exports/ast.d.mts.map +1 -0
  5. package/dist/exports/ast.mjs +304 -0
  6. package/dist/exports/ast.mjs.map +1 -0
  7. package/dist/exports/errors.d.mts +2 -0
  8. package/dist/exports/errors.mjs +3 -0
  9. package/dist/exports/guards.d.mts +88 -0
  10. package/dist/exports/guards.d.mts.map +1 -0
  11. package/dist/exports/guards.mjs +3 -0
  12. package/dist/exports/operations-registry.d.mts +5 -0
  13. package/dist/exports/operations-registry.mjs +3 -0
  14. package/dist/exports/param.d.mts +5 -0
  15. package/dist/exports/param.mjs +3 -0
  16. package/dist/exports/plan.d.mts +2 -0
  17. package/dist/exports/plan.mjs +17 -0
  18. package/dist/exports/plan.mjs.map +1 -0
  19. package/dist/exports/query-lane-context.d.mts +2 -0
  20. package/dist/exports/query-lane-context.mjs +1 -0
  21. package/dist/exports/schema.d.mts +5 -0
  22. package/dist/exports/schema.mjs +4 -0
  23. package/dist/exports/types.d.mts +4 -0
  24. package/dist/exports/types.mjs +3 -0
  25. package/dist/guards-4T0IByJo.mjs +132 -0
  26. package/dist/guards-4T0IByJo.mjs.map +1 -0
  27. package/dist/index.d.mts +12 -0
  28. package/dist/index.mjs +12 -0
  29. package/dist/operations-registry-7R5KE2-5.mjs +152 -0
  30. package/dist/operations-registry-7R5KE2-5.mjs.map +1 -0
  31. package/dist/operations-registry-CIcn4f2P.d.mts +9 -0
  32. package/dist/operations-registry-CIcn4f2P.d.mts.map +1 -0
  33. package/dist/param-B4LzVPv2.d.mts +8 -0
  34. package/dist/param-B4LzVPv2.d.mts.map +1 -0
  35. package/dist/param-BFvNAaHR.mjs +14 -0
  36. package/dist/param-BFvNAaHR.mjs.map +1 -0
  37. package/dist/plan-9PvH-Tu3.d.mts +157 -0
  38. package/dist/plan-9PvH-Tu3.d.mts.map +1 -0
  39. package/dist/query-lane-context-wr_XXnB5.d.mts +143 -0
  40. package/dist/query-lane-context-wr_XXnB5.d.mts.map +1 -0
  41. package/dist/schema-BsY2EXAf.mjs +148 -0
  42. package/dist/schema-BsY2EXAf.mjs.map +1 -0
  43. package/dist/schema-Dse48uyP.d.mts +63 -0
  44. package/dist/schema-Dse48uyP.d.mts.map +1 -0
  45. package/dist/types-Bg2kUmUA.d.mts +359 -0
  46. package/dist/types-Bg2kUmUA.d.mts.map +1 -0
  47. package/dist/types-D_FRJvm0.mjs +18 -0
  48. package/dist/types-D_FRJvm0.mjs.map +1 -0
  49. package/package.json +28 -50
  50. package/src/ast/predicate.ts +3 -11
  51. package/src/ast/types.ts +23 -9
  52. package/src/exports/guards.ts +5 -0
  53. package/src/operations-registry.ts +112 -73
  54. package/src/schema.ts +40 -29
  55. package/src/types.ts +102 -52
  56. package/src/utils/guards.ts +88 -18
  57. package/dist/ast/adapter-types.d.ts +0 -28
  58. package/dist/ast/adapter-types.d.ts.map +0 -1
  59. package/dist/ast/codec-types.d.ts +0 -141
  60. package/dist/ast/codec-types.d.ts.map +0 -1
  61. package/dist/ast/common.d.ts +0 -7
  62. package/dist/ast/common.d.ts.map +0 -1
  63. package/dist/ast/delete.d.ts +0 -8
  64. package/dist/ast/delete.d.ts.map +0 -1
  65. package/dist/ast/driver-types.d.ts +0 -20
  66. package/dist/ast/driver-types.d.ts.map +0 -1
  67. package/dist/ast/insert.d.ts +0 -8
  68. package/dist/ast/insert.d.ts.map +0 -1
  69. package/dist/ast/join.d.ts +0 -6
  70. package/dist/ast/join.d.ts.map +0 -1
  71. package/dist/ast/order.d.ts +0 -6
  72. package/dist/ast/order.d.ts.map +0 -1
  73. package/dist/ast/predicate.d.ts +0 -4
  74. package/dist/ast/predicate.d.ts.map +0 -1
  75. package/dist/ast/select.d.ts +0 -18
  76. package/dist/ast/select.d.ts.map +0 -1
  77. package/dist/ast/types.d.ts +0 -118
  78. package/dist/ast/types.d.ts.map +0 -1
  79. package/dist/ast/update.d.ts +0 -9
  80. package/dist/ast/update.d.ts.map +0 -1
  81. package/dist/ast/util.d.ts +0 -2
  82. package/dist/ast/util.d.ts.map +0 -1
  83. package/dist/chunk-2F7DSEOU.js +0 -8
  84. package/dist/chunk-2F7DSEOU.js.map +0 -1
  85. package/dist/chunk-36WJWNHT.js +0 -1
  86. package/dist/chunk-36WJWNHT.js.map +0 -1
  87. package/dist/chunk-5N34PNVZ.js +0 -62
  88. package/dist/chunk-5N34PNVZ.js.map +0 -1
  89. package/dist/chunk-7I3EMQID.js +0 -16
  90. package/dist/chunk-7I3EMQID.js.map +0 -1
  91. package/dist/chunk-D4JLPIWO.js +0 -13
  92. package/dist/chunk-D4JLPIWO.js.map +0 -1
  93. package/dist/chunk-G52ENULI.js +0 -1
  94. package/dist/chunk-G52ENULI.js.map +0 -1
  95. package/dist/chunk-J6O2HVBM.js +0 -320
  96. package/dist/chunk-J6O2HVBM.js.map +0 -1
  97. package/dist/chunk-KYSP7L5C.js +0 -16
  98. package/dist/chunk-KYSP7L5C.js.map +0 -1
  99. package/dist/chunk-M23L3JHG.js +0 -159
  100. package/dist/chunk-M23L3JHG.js.map +0 -1
  101. package/dist/chunk-U7AXAUJA.js +0 -1
  102. package/dist/chunk-U7AXAUJA.js.map +0 -1
  103. package/dist/chunk-U7IAFPVU.js +0 -152
  104. package/dist/chunk-U7IAFPVU.js.map +0 -1
  105. package/dist/errors.d.ts +0 -2
  106. package/dist/errors.d.ts.map +0 -1
  107. package/dist/exports/ast.d.ts +0 -14
  108. package/dist/exports/ast.d.ts.map +0 -1
  109. package/dist/exports/ast.js +0 -46
  110. package/dist/exports/ast.js.map +0 -1
  111. package/dist/exports/errors.d.ts +0 -2
  112. package/dist/exports/errors.d.ts.map +0 -1
  113. package/dist/exports/errors.js +0 -9
  114. package/dist/exports/errors.js.map +0 -1
  115. package/dist/exports/guards.d.ts +0 -2
  116. package/dist/exports/guards.d.ts.map +0 -1
  117. package/dist/exports/guards.js +0 -21
  118. package/dist/exports/guards.js.map +0 -1
  119. package/dist/exports/operations-registry.d.ts +0 -2
  120. package/dist/exports/operations-registry.d.ts.map +0 -1
  121. package/dist/exports/operations-registry.js +0 -9
  122. package/dist/exports/operations-registry.js.map +0 -1
  123. package/dist/exports/param.d.ts +0 -3
  124. package/dist/exports/param.d.ts.map +0 -1
  125. package/dist/exports/param.js +0 -7
  126. package/dist/exports/param.js.map +0 -1
  127. package/dist/exports/plan.d.ts +0 -2
  128. package/dist/exports/plan.d.ts.map +0 -1
  129. package/dist/exports/plan.js +0 -7
  130. package/dist/exports/plan.js.map +0 -1
  131. package/dist/exports/query-lane-context.d.ts +0 -2
  132. package/dist/exports/query-lane-context.d.ts.map +0 -1
  133. package/dist/exports/query-lane-context.js +0 -2
  134. package/dist/exports/query-lane-context.js.map +0 -1
  135. package/dist/exports/schema.d.ts +0 -3
  136. package/dist/exports/schema.d.ts.map +0 -1
  137. package/dist/exports/schema.js +0 -14
  138. package/dist/exports/schema.js.map +0 -1
  139. package/dist/exports/types.d.ts +0 -2
  140. package/dist/exports/types.d.ts.map +0 -1
  141. package/dist/exports/types.js +0 -10
  142. package/dist/exports/types.js.map +0 -1
  143. package/dist/index.d.ts +0 -9
  144. package/dist/index.d.ts.map +0 -1
  145. package/dist/index.js +0 -81
  146. package/dist/index.js.map +0 -1
  147. package/dist/operations-registry.d.ts +0 -5
  148. package/dist/operations-registry.d.ts.map +0 -1
  149. package/dist/param.d.ts +0 -4
  150. package/dist/param.d.ts.map +0 -1
  151. package/dist/plan.d.ts +0 -23
  152. package/dist/plan.d.ts.map +0 -1
  153. package/dist/query-lane-context.d.ts +0 -16
  154. package/dist/query-lane-context.d.ts.map +0 -1
  155. package/dist/schema.d.ts +0 -63
  156. package/dist/schema.d.ts.map +0 -1
  157. package/dist/types.d.ts +0 -332
  158. package/dist/types.d.ts.map +0 -1
  159. package/dist/utils/guards.d.ts +0 -55
  160. package/dist/utils/guards.d.ts.map +0 -1
package/src/types.ts CHANGED
@@ -10,6 +10,8 @@ import type {
10
10
  BinaryOp,
11
11
  ColumnRef,
12
12
  Direction,
13
+ Expression,
14
+ ExpressionSource,
13
15
  OperationExpr,
14
16
  ParamRef,
15
17
  QueryAst,
@@ -22,13 +24,21 @@ export interface ParamPlaceholder {
22
24
  readonly name: string;
23
25
  }
24
26
 
27
+ /**
28
+ * ValueSource represents any value that can appear in a comparison or as an argument.
29
+ * This includes:
30
+ * - ParamPlaceholder: A parameter placeholder (e.g., `param('userId')`)
31
+ * - ExpressionSource: Something that can be converted to an Expression (ColumnBuilder, ExpressionBuilder)
32
+ */
33
+ export type ValueSource = ParamPlaceholder | ExpressionSource;
34
+
25
35
  export interface OrderBuilder<
26
- ColumnName extends string = string,
27
- ColumnMeta extends StorageColumn = StorageColumn,
28
- JsType = unknown,
36
+ _ColumnName extends string = string,
37
+ _ColumnMeta extends StorageColumn = StorageColumn,
38
+ _JsType = unknown,
29
39
  > {
30
40
  readonly kind: 'order';
31
- readonly expr: ColumnBuilder<ColumnName, ColumnMeta, JsType> | OperationExpr;
41
+ readonly expr: Expression;
32
42
  readonly dir: Direction;
33
43
  }
34
44
 
@@ -45,6 +55,7 @@ export function createOrderBuilder(
45
55
  /**
46
56
  * ColumnBuilder with optional operation methods based on the column's typeId.
47
57
  * When Operations is provided and the column's typeId matches, operation methods are included.
58
+ * Implements ExpressionSource to provide type-safe conversion to ColumnRef.
48
59
  */
49
60
  export type ColumnBuilder<
50
61
  ColumnName extends string = string,
@@ -56,20 +67,17 @@ export type ColumnBuilder<
56
67
  readonly table: string;
57
68
  readonly column: ColumnName;
58
69
  readonly columnMeta: ColumnMeta;
59
- eq(value: ParamPlaceholder | AnyColumnBuilderBase): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
60
- neq(
61
- value: ParamPlaceholder | AnyColumnBuilderBase,
62
- ): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
63
- gt(value: ParamPlaceholder | AnyColumnBuilderBase): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
64
- lt(value: ParamPlaceholder | AnyColumnBuilderBase): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
65
- gte(
66
- value: ParamPlaceholder | AnyColumnBuilderBase,
67
- ): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
68
- lte(
69
- value: ParamPlaceholder | AnyColumnBuilderBase,
70
- ): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
70
+ // Methods accept ValueSource (ParamPlaceholder or ExpressionSource)
71
+ eq(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
72
+ neq(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
73
+ gt(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
74
+ lt(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
75
+ gte(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
76
+ lte(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
71
77
  asc(): OrderBuilder<ColumnName, ColumnMeta, JsType>;
72
78
  desc(): OrderBuilder<ColumnName, ColumnMeta, JsType>;
79
+ /** Converts this column builder to a ColumnRef expression */
80
+ toExpr(): ColumnRef;
73
81
  // Helper property for type extraction (not used at runtime)
74
82
  readonly __jsType: JsType;
75
83
  } & (ColumnMeta['codecId'] extends string
@@ -84,14 +92,47 @@ export type ColumnBuilder<
84
92
  : Record<string, never>);
85
93
 
86
94
  export interface BinaryBuilder<
87
- ColumnName extends string = string,
88
- ColumnMeta extends StorageColumn = StorageColumn,
89
- JsType = unknown,
95
+ _ColumnName extends string = string,
96
+ _ColumnMeta extends StorageColumn = StorageColumn,
97
+ _JsType = unknown,
90
98
  > {
91
99
  readonly kind: 'binary';
92
100
  readonly op: BinaryOp;
93
- readonly left: ColumnBuilder<ColumnName, ColumnMeta, JsType> | OperationExpr;
94
- readonly right: ParamPlaceholder | AnyColumnBuilderBase;
101
+ readonly left: Expression;
102
+ readonly right: ValueSource;
103
+ }
104
+
105
+ // Forward declare AnyBinaryBuilder and AnyOrderBuilder for use in ExpressionBuilder
106
+ export type AnyBinaryBuilder = BinaryBuilder;
107
+ export type AnyOrderBuilder = OrderBuilder;
108
+
109
+ /**
110
+ * ExpressionBuilder represents the result of an operation (e.g., col.distance(...)).
111
+ * Unlike ColumnBuilder (which represents a column), ExpressionBuilder represents
112
+ * an operation expression and provides the same DSL methods for chaining.
113
+ *
114
+ * Implements ExpressionSource to provide type-safe conversion to OperationExpr.
115
+ */
116
+ export interface ExpressionBuilder<JsType = unknown> extends ExpressionSource {
117
+ readonly kind: 'expression';
118
+ readonly expr: OperationExpr;
119
+ readonly columnMeta: StorageColumn;
120
+
121
+ // Methods accept ValueSource (ParamPlaceholder or ExpressionSource)
122
+ eq(value: ValueSource): AnyBinaryBuilder;
123
+ neq(value: ValueSource): AnyBinaryBuilder;
124
+ gt(value: ValueSource): AnyBinaryBuilder;
125
+ lt(value: ValueSource): AnyBinaryBuilder;
126
+ gte(value: ValueSource): AnyBinaryBuilder;
127
+ lte(value: ValueSource): AnyBinaryBuilder;
128
+ asc(): AnyOrderBuilder;
129
+ desc(): AnyOrderBuilder;
130
+
131
+ /** Converts this expression builder to the underlying OperationExpr */
132
+ toExpr(): OperationExpr;
133
+
134
+ // Helper property for type extraction (not used at runtime)
135
+ readonly __jsType: JsType;
95
136
  }
96
137
 
97
138
  // Helper aliases for usage sites where the specific column parameters are irrelevant
@@ -108,14 +149,16 @@ export type AnyColumnBuilderBase = {
108
149
  readonly table: string;
109
150
  readonly column: string;
110
151
  readonly columnMeta: StorageColumn;
111
- eq(value: ParamPlaceholder | AnyColumnBuilderBase): AnyBinaryBuilder;
112
- neq(value: ParamPlaceholder | AnyColumnBuilderBase): AnyBinaryBuilder;
113
- gt(value: ParamPlaceholder | AnyColumnBuilderBase): AnyBinaryBuilder;
114
- lt(value: ParamPlaceholder | AnyColumnBuilderBase): AnyBinaryBuilder;
115
- gte(value: ParamPlaceholder | AnyColumnBuilderBase): AnyBinaryBuilder;
116
- lte(value: ParamPlaceholder | AnyColumnBuilderBase): AnyBinaryBuilder;
152
+ // Methods accept ValueSource (ParamPlaceholder or ExpressionSource)
153
+ eq(value: ValueSource): AnyBinaryBuilder;
154
+ neq(value: ValueSource): AnyBinaryBuilder;
155
+ gt(value: ValueSource): AnyBinaryBuilder;
156
+ lt(value: ValueSource): AnyBinaryBuilder;
157
+ gte(value: ValueSource): AnyBinaryBuilder;
158
+ lte(value: ValueSource): AnyBinaryBuilder;
117
159
  asc(): AnyOrderBuilder;
118
160
  desc(): AnyOrderBuilder;
161
+ toExpr(): ColumnRef;
119
162
  readonly __jsType: unknown;
120
163
  // Allow any operation methods (from conditional type)
121
164
  readonly [key: string]: unknown;
@@ -130,8 +173,12 @@ export type AnyColumnBuilder =
130
173
  any
131
174
  >
132
175
  | AnyColumnBuilderBase;
133
- export type AnyBinaryBuilder = BinaryBuilder<string, StorageColumn, unknown>;
134
- export type AnyOrderBuilder = OrderBuilder<string, StorageColumn, unknown>;
176
+
177
+ /**
178
+ * Union type for any builder that can produce an Expression.
179
+ * Used in DSL method signatures where either a column or operation result can be passed.
180
+ */
181
+ export type AnyExpressionSource = AnyColumnBuilder | ExpressionBuilder;
135
182
 
136
183
  export function isColumnBuilder(value: unknown): value is AnyColumnBuilder {
137
184
  return (
@@ -264,7 +311,7 @@ type OperationArgs<Args extends ReadonlyArray<ArgSpec>> = Args extends readonly
264
311
  : [];
265
312
 
266
313
  type ArgToType<Arg extends ArgSpec> = Arg extends { kind: 'typeId' }
267
- ? AnyColumnBuilder
314
+ ? AnyExpressionSource
268
315
  : Arg extends { kind: 'param' }
269
316
  ? ParamPlaceholder
270
317
  : Arg extends { kind: 'literal' }
@@ -273,25 +320,25 @@ type ArgToType<Arg extends ArgSpec> = Arg extends { kind: 'typeId' }
273
320
 
274
321
  /**
275
322
  * Maps operation return spec to return type.
276
- * - builtin types: ColumnBuilder with appropriate JsType (matches runtime behavior)
277
- * - typeId types: ColumnBuilder (for now, could be more specific in future)
323
+ * Operations return ExpressionBuilder, not ColumnBuilder, because the result
324
+ * represents an expression (OperationExpr) rather than a column reference.
278
325
  */
279
326
  type OperationReturn<
280
327
  Returns extends ReturnSpec,
281
- ColumnName extends string,
282
- ColumnMeta extends StorageColumn,
328
+ _ColumnName extends string,
329
+ _ColumnMeta extends StorageColumn,
283
330
  _JsType,
284
331
  > = Returns extends { kind: 'builtin'; type: infer T }
285
332
  ? T extends 'number'
286
- ? ColumnBuilder<ColumnName, ColumnMeta, number>
333
+ ? ExpressionBuilder<number>
287
334
  : T extends 'boolean'
288
- ? ColumnBuilder<ColumnName, ColumnMeta, boolean>
335
+ ? ExpressionBuilder<boolean>
289
336
  : T extends 'string'
290
- ? ColumnBuilder<ColumnName, ColumnMeta, string>
291
- : ColumnBuilder<ColumnName, ColumnMeta, unknown>
337
+ ? ExpressionBuilder<string>
338
+ : ExpressionBuilder<unknown>
292
339
  : Returns extends { kind: 'typeId' }
293
- ? AnyColumnBuilder
294
- : ColumnBuilder<ColumnName, ColumnMeta, unknown>;
340
+ ? ExpressionBuilder<unknown>
341
+ : ExpressionBuilder<unknown>;
295
342
 
296
343
  /**
297
344
  * Computes JavaScript type for a column at column creation time.
@@ -351,17 +398,18 @@ export type InferProjectionRow<P extends Record<string, AnyColumnBuilder>> = {
351
398
  };
352
399
 
353
400
  /**
354
- * Nested projection type - allows recursive nesting of ColumnBuilder or nested objects.
401
+ * Nested projection type - allows recursive nesting of ColumnBuilder, ExpressionBuilder, or nested objects.
355
402
  */
356
403
  export type NestedProjection = Record<
357
404
  string,
358
- | AnyColumnBuilder
405
+ | AnyExpressionSource
359
406
  | Record<
360
407
  string,
361
- | AnyColumnBuilder
408
+ | AnyExpressionSource
362
409
  | Record<
363
410
  string,
364
- AnyColumnBuilder | Record<string, AnyColumnBuilder | Record<string, AnyColumnBuilder>>
411
+ | AnyExpressionSource
412
+ | Record<string, AnyExpressionSource | Record<string, AnyExpressionSource>>
365
413
  >
366
414
  >
367
415
  >;
@@ -384,17 +432,19 @@ type ExtractIncludeType<
384
432
  * by looking up the include alias in the Includes type map.
385
433
  */
386
434
  export type InferNestedProjectionRow<
387
- P extends Record<string, AnyColumnBuilder | boolean | NestedProjection>,
435
+ P extends Record<string, AnyExpressionSource | boolean | NestedProjection>,
388
436
  CodecTypes extends Record<string, { readonly output: unknown }> = Record<string, never>,
389
437
  Includes extends Record<string, unknown> = Record<string, never>,
390
438
  > = {
391
- [K in keyof P]: P[K] extends AnyColumnBuilder
392
- ? ExtractJsTypeFromColumnBuilder<P[K]>
393
- : P[K] extends true
394
- ? Array<ExtractIncludeType<K & string, Includes>> // Include reference - infers Array<ChildShape> from Includes map
395
- : P[K] extends NestedProjection
396
- ? InferNestedProjectionRow<P[K], CodecTypes, Includes>
397
- : never;
439
+ [K in keyof P]: P[K] extends ExpressionBuilder<infer JsType>
440
+ ? JsType
441
+ : P[K] extends AnyColumnBuilder
442
+ ? ExtractJsTypeFromColumnBuilder<P[K]>
443
+ : P[K] extends true
444
+ ? Array<ExtractIncludeType<K & string, Includes>> // Include reference - infers Array<ChildShape> from Includes map
445
+ : P[K] extends NestedProjection
446
+ ? InferNestedProjectionRow<P[K], CodecTypes, Includes>
447
+ : never;
398
448
  };
399
449
 
400
450
  /**
@@ -1,16 +1,27 @@
1
1
  import type { StorageColumn } from '@prisma-next/sql-contract/types';
2
- import type { ColumnRef, LiteralExpr, OperationExpr, ParamRef } from '../ast/types';
3
- import type { AnyColumnBuilder, ParamPlaceholder } from '../types';
2
+ import type {
3
+ ColumnRef,
4
+ Expression,
5
+ ExpressionSource,
6
+ LiteralExpr,
7
+ OperationExpr,
8
+ ParamRef,
9
+ } from '../ast/types';
10
+ import type {
11
+ AnyColumnBuilder,
12
+ AnyExpressionSource,
13
+ ExpressionBuilder,
14
+ ParamPlaceholder,
15
+ ValueSource,
16
+ } from '../types';
4
17
 
5
18
  /**
6
- * Helper to extract columnMeta from a ColumnBuilder.
19
+ * Helper to extract columnMeta from a ColumnBuilder or ExpressionBuilder.
7
20
  * Returns StorageColumn if present, undefined otherwise.
8
- * AnyColumnBuilder is a union that includes types with columnMeta property,
9
- * so we can safely access it after checking for existence.
21
+ * Both ColumnBuilder and ExpressionBuilder have columnMeta property.
10
22
  */
11
- export function getColumnMeta(expr: AnyColumnBuilder): StorageColumn | undefined {
12
- // AnyColumnBuilder includes AnyColumnBuilderBase which has columnMeta: StorageColumn
13
- // and ColumnBuilder which has columnMeta: ColumnMeta extends StorageColumn
23
+ export function getColumnMeta(expr: AnyExpressionSource): StorageColumn | undefined {
24
+ // Both ColumnBuilder and ExpressionBuilder have columnMeta: StorageColumn
14
25
  // TypeScript should narrow the type after the 'in' check
15
26
  if ('columnMeta' in expr) {
16
27
  return expr.columnMeta;
@@ -66,15 +77,17 @@ export function collectColumnRefs(
66
77
  /**
67
78
  * Type predicate to check if an expression is an OperationExpr.
68
79
  */
69
- export function isOperationExpr(expr: AnyColumnBuilder | OperationExpr): expr is OperationExpr {
80
+ export function isOperationExpr(
81
+ expr: AnyExpressionSource | OperationExpr | Expression,
82
+ ): expr is OperationExpr {
70
83
  return typeof expr === 'object' && expr !== null && 'kind' in expr && expr.kind === 'operation';
71
84
  }
72
85
 
73
86
  /**
74
- * Helper to extract table and column from a ColumnBuilder or OperationExpr.
75
- * For OperationExpr, recursively unwraps to find the base ColumnRef.
87
+ * Helper to extract table and column from a ColumnBuilder, ExpressionBuilder, or OperationExpr.
88
+ * For ExpressionBuilder or OperationExpr, recursively unwraps to find the base ColumnRef.
76
89
  */
77
- export function getColumnInfo(expr: AnyColumnBuilder | OperationExpr): {
90
+ export function getColumnInfo(expr: AnyExpressionSource | OperationExpr): {
78
91
  table: string;
79
92
  column: string;
80
93
  } {
@@ -82,6 +95,10 @@ export function getColumnInfo(expr: AnyColumnBuilder | OperationExpr): {
82
95
  const baseCol = extractBaseColumnRef(expr);
83
96
  return { table: baseCol.table, column: baseCol.column };
84
97
  }
98
+ if (isExpressionBuilder(expr)) {
99
+ const baseCol = extractBaseColumnRef(expr.expr);
100
+ return { table: baseCol.table, column: baseCol.column };
101
+ }
85
102
  // expr is ColumnBuilder - TypeScript can't narrow properly
86
103
  const colBuilder = expr as unknown as { table: string; column: string };
87
104
  return { table: colBuilder.table, column: colBuilder.column };
@@ -99,18 +116,71 @@ export function isColumnBuilder(value: unknown): value is AnyColumnBuilder {
99
116
  );
100
117
  }
101
118
 
119
+ /**
120
+ * Type predicate to check if a value is an ExpressionBuilder.
121
+ */
122
+ export function isExpressionBuilder(value: unknown): value is ExpressionBuilder {
123
+ return (
124
+ typeof value === 'object' &&
125
+ value !== null &&
126
+ 'kind' in value &&
127
+ (value as { kind: unknown }).kind === 'expression'
128
+ );
129
+ }
130
+
131
+ /**
132
+ * Type predicate to check if a value is an ExpressionSource (has toExpr method).
133
+ */
134
+ export function isExpressionSource(value: unknown): value is ExpressionSource {
135
+ return (
136
+ typeof value === 'object' &&
137
+ value !== null &&
138
+ 'toExpr' in value &&
139
+ typeof (value as ExpressionSource).toExpr === 'function'
140
+ );
141
+ }
142
+
143
+ /**
144
+ * Converts any ExpressionSource to an Expression.
145
+ * This is the canonical way to get an AST Expression from a builder.
146
+ *
147
+ * @param source - A ColumnBuilder or ExpressionBuilder
148
+ * @returns The corresponding Expression (ColumnRef or OperationExpr)
149
+ */
150
+ export function toExpression(source: ExpressionSource): Expression {
151
+ return source.toExpr();
152
+ }
153
+
154
+ /**
155
+ * Converts an AnyExpressionSource to an Expression.
156
+ * Handles both ColumnBuilder and ExpressionBuilder.
157
+ *
158
+ * @param source - A ColumnBuilder or ExpressionBuilder
159
+ * @returns The corresponding Expression (ColumnRef or OperationExpr)
160
+ */
161
+ export function expressionFromSource(source: AnyExpressionSource): Expression {
162
+ return source.toExpr();
163
+ }
164
+
165
+ /**
166
+ * Type predicate to check if a value is a ValueSource.
167
+ * ValueSource is either a ParamPlaceholder or an ExpressionSource.
168
+ */
169
+ export function isValueSource(value: unknown): value is ValueSource {
170
+ return isParamPlaceholder(value) || isExpressionSource(value);
171
+ }
172
+
102
173
  /**
103
174
  * Extracts and returns an OperationExpr from a builder.
104
175
  * Returns the OperationExpr if the builder is an OperationExpr or has an _operationExpr property,
105
176
  * otherwise returns undefined.
106
177
  *
178
+ * @deprecated Use isExpressionBuilder() instead. This function exists for backward compatibility
179
+ * with code that uses the hidden _operationExpr property pattern.
180
+ *
107
181
  * @design-note: This function accesses the hidden `_operationExpr` property, which is a code smell.
108
- * The issue is that `executeOperation()` in relational-core returns a ColumnBuilder-shaped object
109
- * with a hidden `_operationExpr` property, creating coupling between lanes and relational-core
110
- * implementation details. A cleaner design would be to have operation results be a separate
111
- * type (e.g., `OperationResultBuilder`) that properly represents expression nodes rather than
112
- * pretending to be a ColumnBuilder. This would require refactoring the operation execution
113
- * system in relational-core to return proper expression types.
182
+ * The ExpressionBuilder type (introduced in the operation-expr-refactoring) provides a cleaner
183
+ * approach by explicitly representing operation results as a distinct type.
114
184
  */
115
185
  export function getOperationExpr(
116
186
  builder: AnyColumnBuilder | OperationExpr,
@@ -1,28 +0,0 @@
1
- import type { CodecRegistry } from './codec-types';
2
- export type AdapterTarget = string;
3
- export interface AdapterProfile<TTarget extends AdapterTarget = AdapterTarget> {
4
- readonly id: string;
5
- readonly target: TTarget;
6
- readonly capabilities: Record<string, unknown>;
7
- /**
8
- * Returns the adapter's default codec registry.
9
- * The registry contains codecs provided by the adapter for converting
10
- * between wire types and JavaScript types.
11
- */
12
- codecs(): CodecRegistry;
13
- }
14
- export interface LoweredPayload<TBody = unknown> {
15
- readonly profileId?: string;
16
- readonly body: TBody;
17
- readonly annotations?: Record<string, unknown>;
18
- }
19
- export interface LowererContext<TContract = unknown> {
20
- readonly contract: TContract;
21
- readonly params?: readonly unknown[];
22
- }
23
- export type Lowerer<Ast = unknown, TContract = unknown, TBody = unknown> = (ast: Ast, context: LowererContext<TContract>) => LoweredPayload<TBody>;
24
- export interface Adapter<Ast = unknown, TContract = unknown, TBody = unknown> {
25
- readonly profile: AdapterProfile;
26
- lower(ast: Ast, context: LowererContext<TContract>): LoweredPayload<TBody>;
27
- }
28
- //# sourceMappingURL=adapter-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adapter-types.d.ts","sourceRoot":"","sources":["../../src/ast/adapter-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,aAAa,GAAG,aAAa;IAC3E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C;;;;OAIG;IACH,MAAM,IAAI,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,cAAc,CAAC,KAAK,GAAG,OAAO;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,cAAc,CAAC,SAAS,GAAG,OAAO;IACjD,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CACtC;AAED,MAAM,MAAM,OAAO,CAAC,GAAG,GAAG,OAAO,EAAE,SAAS,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,IAAI,CACzE,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,KAC/B,cAAc,CAAC,KAAK,CAAC,CAAC;AAE3B,MAAM,WAAW,OAAO,CAAC,GAAG,GAAG,OAAO,EAAE,SAAS,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO;IAC1E,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;CAC5E"}
@@ -1,141 +0,0 @@
1
- import type { O } from 'ts-toolbelt';
2
- /**
3
- * Codec metadata for database-specific type information.
4
- * Used for schema introspection and verification.
5
- */
6
- export interface CodecMeta {
7
- readonly db?: {
8
- readonly sql?: {
9
- readonly postgres?: {
10
- readonly nativeType: string;
11
- };
12
- };
13
- };
14
- }
15
- /**
16
- * Codec interface for encoding/decoding values between wire format and JavaScript types.
17
- *
18
- * Codecs are pure, synchronous functions with no side effects or IO.
19
- * They provide deterministic conversion between database wire types and JS values.
20
- */
21
- export interface Codec<Id extends string = string, TWire = unknown, TJs = unknown> {
22
- /**
23
- * Namespaced codec identifier in format 'namespace/name@version'
24
- * Examples: 'pg/text@1', 'pg/uuid@1', 'pg/timestamptz@1'
25
- */
26
- readonly id: Id;
27
- /**
28
- * Contract scalar type IDs that this codec can handle.
29
- * Examples: ['text'], ['int4', 'float8'], ['timestamp', 'timestamptz']
30
- */
31
- readonly targetTypes: readonly string[];
32
- /**
33
- * Optional metadata for database-specific type information.
34
- * Used for schema introspection and verification.
35
- */
36
- readonly meta?: CodecMeta;
37
- /**
38
- * Decode a wire value (from database) to JavaScript type.
39
- * Must be synchronous and pure (no side effects).
40
- */
41
- decode(wire: TWire): TJs;
42
- /**
43
- * Encode a JavaScript value to wire format (for database).
44
- * Optional - if not provided, values pass through unchanged.
45
- * Must be synchronous and pure (no side effects).
46
- */
47
- encode?(value: TJs): TWire;
48
- }
49
- /**
50
- * Registry interface for codecs organized by ID and by contract scalar type.
51
- *
52
- * The registry allows looking up codecs by their namespaced ID or by the
53
- * contract scalar types they handle. Multiple codecs may handle the same
54
- * scalar type; ordering in byScalar reflects preference (adapter first,
55
- * then packs, then app overrides).
56
- */
57
- export interface CodecRegistry {
58
- get(id: string): Codec<string> | undefined;
59
- has(id: string): boolean;
60
- getByScalar(scalar: string): readonly Codec<string>[];
61
- getDefaultCodec(scalar: string): Codec<string> | undefined;
62
- register(codec: Codec<string>): void;
63
- [Symbol.iterator](): Iterator<Codec<string>>;
64
- values(): IterableIterator<Codec<string>>;
65
- }
66
- /**
67
- * Codec factory - creates a codec with typeId and encode/decode functions.
68
- */
69
- export declare function codec<Id extends string, TWire, TJs>(config: {
70
- typeId: Id;
71
- targetTypes: readonly string[];
72
- encode: (value: TJs) => TWire;
73
- decode: (wire: TWire) => TJs;
74
- meta?: CodecMeta;
75
- }): Codec<Id, TWire, TJs>;
76
- /**
77
- * Type helpers to extract codec types.
78
- */
79
- export type CodecId<T> = T extends Codec<infer Id, unknown, unknown> ? Id : T extends {
80
- readonly id: infer Id;
81
- } ? Id : never;
82
- export type CodecInput<T> = T extends Codec<string, unknown, infer JsT> ? JsT : never;
83
- export type CodecOutput<T> = T extends Codec<string, unknown, infer JsT> ? JsT : never;
84
- /**
85
- * Type helper to extract codec types from builder instance.
86
- */
87
- export type ExtractCodecTypes<ScalarNames extends {
88
- readonly [K in keyof ScalarNames]: Codec<string>;
89
- } = Record<never, never>> = {
90
- readonly [K in keyof ScalarNames as ScalarNames[K] extends Codec<infer Id, unknown, unknown> ? Id : never]: {
91
- readonly input: CodecInput<ScalarNames[K]>;
92
- readonly output: CodecOutput<ScalarNames[K]>;
93
- };
94
- };
95
- /**
96
- * Type helper to extract data type IDs from builder instance.
97
- * Uses ExtractCodecTypes which preserves literal types as keys.
98
- * Since ExtractCodecTypes<Record<K, ScalarNames[K]>> has exactly one key (the Id),
99
- * we extract it by creating a mapped type that uses the Id as both key and value,
100
- * then extract the value type. This preserves literal types.
101
- */
102
- export type ExtractDataTypes<ScalarNames extends {
103
- readonly [K in keyof ScalarNames]: Codec<string>;
104
- }> = {
105
- readonly [K in keyof ScalarNames]: {
106
- readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id;
107
- }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>];
108
- };
109
- /**
110
- * Builder interface for declaring codecs.
111
- */
112
- export interface CodecDefBuilder<ScalarNames extends {
113
- readonly [K in keyof ScalarNames]: Codec<string>;
114
- } = Record<never, never>> {
115
- readonly CodecTypes: ExtractCodecTypes<ScalarNames>;
116
- add<ScalarName extends string, CodecImpl extends Codec<string>>(scalarName: ScalarName, codecImpl: CodecImpl): CodecDefBuilder<O.Overwrite<ScalarNames, Record<ScalarName, CodecImpl>> & Record<ScalarName, CodecImpl>>;
117
- readonly codecDefinitions: {
118
- readonly [K in keyof ScalarNames]: {
119
- readonly typeId: ScalarNames[K] extends Codec<infer Id extends string, unknown, unknown> ? Id : never;
120
- readonly scalar: K;
121
- readonly codec: ScalarNames[K];
122
- readonly input: CodecInput<ScalarNames[K]>;
123
- readonly output: CodecOutput<ScalarNames[K]>;
124
- readonly jsType: CodecOutput<ScalarNames[K]>;
125
- };
126
- };
127
- readonly dataTypes: {
128
- readonly [K in keyof ScalarNames]: {
129
- readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id;
130
- }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>];
131
- };
132
- }
133
- /**
134
- * Create a new codec registry.
135
- */
136
- export declare function createCodecRegistry(): CodecRegistry;
137
- /**
138
- * Create a new codec definition builder.
139
- */
140
- export declare function defineCodecs(): CodecDefBuilder<Record<never, never>>;
141
- //# sourceMappingURL=codec-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codec-types.d.ts","sourceRoot":"","sources":["../../src/ast/codec-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAErC;;;GAGG;A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ACzB,QAAQ,EAAE,CAAC,IAAI,MAAM,WAAW,GAAG;YACjC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,GACpF,EAAE,GACF,KAAK,CAAC;YACV,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YACnB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;YAC/B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9C;KACF,CAAC;IAEF,QAAQ,CAAC,SAAS,EAAE;QAClB,QAAQ,EAAE,CAAC,IAAI,MAAM,WAAW,GAAG;YACjC,QAAQ,EAAE,EAAE,IAAI,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;SACxE,CAAC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACtD,CAAC;CACH;AAkHD;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAEnD;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,eAAe,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAEpE"}
@@ -1,7 +0,0 @@
1
- import type { ColumnRef, LiteralExpr, OperationExpr, ParamRef, TableRef } from './types';
2
- export declare function createTableRef(name: string): TableRef;
3
- export declare function createColumnRef(table: string, column: string): ColumnRef;
4
- export declare function createParamRef(index: number, name?: string): ParamRef;
5
- export declare function createOperationExpr(operation: OperationExpr): OperationExpr;
6
- export declare function createLiteralExpr(value: unknown): LiteralExpr;
7
- //# sourceMappingURL=common.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/ast/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGzF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAKrD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAMxE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,CAMrE;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,aAAa,GAAG,aAAa,CAE3E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAK7D"}
@@ -1,8 +0,0 @@
1
- import type { BinaryExpr, ColumnRef, DeleteAst, TableRef } from './types';
2
- export interface CreateDeleteAstOptions {
3
- readonly table: TableRef;
4
- readonly where: BinaryExpr;
5
- readonly returning?: ReadonlyArray<ColumnRef>;
6
- }
7
- export declare function createDeleteAst(options: CreateDeleteAstOptions): DeleteAst;
8
- //# sourceMappingURL=delete.d.ts.map
@@ -1 +0,0 @@
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,20 +0,0 @@
1
- export interface SqlExecuteRequest {
2
- readonly sql: string;
3
- readonly params?: readonly unknown[];
4
- }
5
- export interface SqlQueryResult<Row = Record<string, unknown>> {
6
- readonly rows: ReadonlyArray<Row>;
7
- readonly rowCount?: number | null;
8
- readonly [key: string]: unknown;
9
- }
10
- export interface SqlExplainResult<Row = Record<string, unknown>> {
11
- readonly rows: ReadonlyArray<Row>;
12
- }
13
- export interface SqlDriver {
14
- connect(): Promise<void>;
15
- execute<Row = Record<string, unknown>>(request: SqlExecuteRequest): AsyncIterable<Row>;
16
- explain?(request: SqlExecuteRequest): Promise<SqlExplainResult>;
17
- query<Row = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<SqlQueryResult<Row>>;
18
- close(): Promise<void>;
19
- }
20
- //# sourceMappingURL=driver-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"driver-types.d.ts","sourceRoot":"","sources":["../../src/ast/driver-types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,cAAc,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACvF,OAAO,CAAC,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChE,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAC1B,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
@@ -1,8 +0,0 @@
1
- import type { ColumnRef, InsertAst, ParamRef, TableRef } from './types';
2
- export interface CreateInsertAstOptions {
3
- readonly table: TableRef;
4
- readonly values: Record<string, ColumnRef | ParamRef>;
5
- readonly returning?: ReadonlyArray<ColumnRef>;
6
- }
7
- export declare function createInsertAst(options: CreateInsertAstOptions): InsertAst;
8
- //# sourceMappingURL=insert.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../src/ast/insert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxE,MAAM,WAAW,sBAAsB;IACrC,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,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAO1E"}