effect-qb 0.14.0 → 0.15.0

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 (141) hide show
  1. package/dist/mysql.js +61270 -4259
  2. package/dist/postgres/metadata.js +176 -82
  3. package/dist/postgres.js +5903 -3316
  4. package/package.json +14 -1
  5. package/src/internal/aggregation-validation.ts +3 -3
  6. package/src/internal/case-analysis.d.ts +18 -0
  7. package/src/internal/case-analysis.ts +4 -4
  8. package/src/internal/coercion/analysis.d.ts +7 -0
  9. package/src/internal/{coercion-analysis.ts → coercion/analysis.ts} +3 -3
  10. package/src/internal/coercion/errors.d.ts +17 -0
  11. package/src/internal/{coercion-errors.ts → coercion/errors.ts} +1 -1
  12. package/src/internal/coercion/kind.d.ts +4 -0
  13. package/src/internal/{coercion-kind.ts → coercion/kind.ts} +2 -2
  14. package/src/internal/{coercion-normalize.ts → coercion/normalize.ts} +1 -1
  15. package/src/internal/coercion/rules.d.ts +6 -0
  16. package/src/internal/{coercion-rules.ts → coercion/rules.ts} +2 -2
  17. package/src/internal/column-state.d.ts +190 -0
  18. package/src/internal/column-state.ts +36 -47
  19. package/src/internal/column.ts +21 -305
  20. package/src/internal/datatypes/define.d.ts +17 -0
  21. package/src/internal/datatypes/define.ts +18 -4
  22. package/src/internal/datatypes/lookup.d.ts +44 -0
  23. package/src/internal/datatypes/lookup.ts +61 -152
  24. package/src/internal/datatypes/shape.d.ts +16 -0
  25. package/src/internal/datatypes/shape.ts +1 -1
  26. package/src/internal/derived-table.d.ts +4 -0
  27. package/src/internal/derived-table.ts +21 -16
  28. package/src/internal/dsl-mutation-runtime.ts +378 -0
  29. package/src/internal/dsl-plan-runtime.ts +387 -0
  30. package/src/internal/dsl-query-runtime.ts +160 -0
  31. package/src/internal/dsl-transaction-ddl-runtime.ts +263 -0
  32. package/src/internal/executor.ts +132 -31
  33. package/src/internal/expression-ast.ts +15 -5
  34. package/src/internal/grouping-key.d.ts +3 -0
  35. package/src/internal/grouping-key.ts +1 -1
  36. package/src/internal/implication-runtime.d.ts +15 -0
  37. package/src/internal/implication-runtime.ts +4 -4
  38. package/src/internal/json/ast.d.ts +30 -0
  39. package/src/internal/json/ast.ts +1 -1
  40. package/src/internal/json/errors.d.ts +8 -0
  41. package/src/internal/json/path.d.ts +75 -0
  42. package/src/internal/json/path.ts +1 -1
  43. package/src/internal/json/types.d.ts +62 -0
  44. package/src/internal/predicate/analysis.d.ts +20 -0
  45. package/src/internal/{predicate-analysis.ts → predicate/analysis.ts} +3 -3
  46. package/src/internal/predicate/atom.d.ts +28 -0
  47. package/src/internal/{predicate-branches.ts → predicate/branches.ts} +2 -2
  48. package/src/internal/predicate/context.d.ts +67 -0
  49. package/src/internal/{predicate-context.ts → predicate/context.ts} +8 -5
  50. package/src/internal/predicate/formula.d.ts +35 -0
  51. package/src/internal/{predicate-formula.ts → predicate/formula.ts} +1 -1
  52. package/src/internal/predicate/key.d.ts +11 -0
  53. package/src/internal/{predicate-key.ts → predicate/key.ts} +2 -2
  54. package/src/internal/{predicate-nnf.ts → predicate/nnf.ts} +2 -2
  55. package/src/internal/predicate/normalize.d.ts +53 -0
  56. package/src/internal/{predicate-normalize.ts → predicate/normalize.ts} +19 -19
  57. package/src/internal/predicate/runtime.d.ts +31 -0
  58. package/src/internal/{predicate-runtime.ts → predicate/runtime.ts} +9 -6
  59. package/src/internal/projection-alias.d.ts +13 -0
  60. package/src/internal/projections.d.ts +31 -0
  61. package/src/internal/projections.ts +1 -1
  62. package/src/internal/query-ast.d.ts +217 -0
  63. package/src/internal/query-ast.ts +1 -1
  64. package/src/internal/query-requirements.d.ts +20 -0
  65. package/src/internal/query.d.ts +775 -0
  66. package/src/internal/query.ts +389 -313
  67. package/src/internal/renderer.ts +7 -21
  68. package/src/internal/row-set.d.ts +53 -0
  69. package/src/internal/{plan.ts → row-set.ts} +11 -9
  70. package/src/internal/{runtime-normalize.ts → runtime/normalize.ts} +9 -31
  71. package/src/internal/{runtime-schema.ts → runtime/schema.ts} +13 -38
  72. package/src/internal/runtime/value.d.ts +22 -0
  73. package/src/internal/{runtime-value.ts → runtime/value.ts} +2 -2
  74. package/src/internal/scalar.d.ts +107 -0
  75. package/src/internal/scalar.ts +191 -0
  76. package/src/internal/schema-derivation.d.ts +105 -0
  77. package/src/internal/schema-expression.d.ts +18 -0
  78. package/src/internal/schema-expression.ts +38 -7
  79. package/src/internal/table-options.d.ts +94 -0
  80. package/src/internal/table-options.ts +8 -2
  81. package/src/internal/table.d.ts +173 -0
  82. package/src/internal/table.ts +32 -14
  83. package/src/mysql/column.ts +94 -18
  84. package/src/mysql/datatypes/index.ts +47 -7
  85. package/src/mysql/errors/generated.ts +57336 -0
  86. package/src/mysql/errors/index.ts +1 -0
  87. package/src/mysql/errors/normalize.ts +55 -53
  88. package/src/mysql/errors/types.ts +74 -0
  89. package/src/mysql/executor.ts +69 -7
  90. package/src/mysql/function/aggregate.ts +1 -5
  91. package/src/mysql/function/core.ts +1 -4
  92. package/src/mysql/function/index.ts +0 -1
  93. package/src/mysql/function/string.ts +1 -5
  94. package/src/mysql/function/temporal.ts +12 -15
  95. package/src/mysql/function/window.ts +1 -6
  96. package/src/{internal/mysql-dialect.ts → mysql/internal/dialect.ts} +1 -1
  97. package/src/{internal/mysql-query.ts → mysql/internal/dsl.ts} +1024 -2082
  98. package/src/{internal/mysql-renderer.ts → mysql/internal/renderer.ts} +6 -6
  99. package/src/mysql/internal/sql-expression-renderer.ts +1455 -0
  100. package/src/mysql/json.ts +2 -0
  101. package/src/mysql/query.ts +111 -91
  102. package/src/mysql/renderer.ts +1 -1
  103. package/src/mysql/table.ts +1 -1
  104. package/src/mysql.ts +6 -4
  105. package/src/postgres/cast.ts +11 -12
  106. package/src/postgres/column.ts +178 -46
  107. package/src/postgres/datatypes/index.d.ts +515 -0
  108. package/src/postgres/datatypes/index.ts +22 -13
  109. package/src/postgres/datatypes/spec.d.ts +412 -0
  110. package/src/postgres/errors/generated.ts +2636 -0
  111. package/src/postgres/errors/index.ts +1 -0
  112. package/src/postgres/errors/normalize.ts +47 -62
  113. package/src/postgres/errors/types.ts +92 -34
  114. package/src/postgres/executor.ts +37 -5
  115. package/src/postgres/function/aggregate.ts +1 -5
  116. package/src/postgres/function/core.ts +12 -6
  117. package/src/postgres/function/index.ts +0 -1
  118. package/src/postgres/function/string.ts +1 -5
  119. package/src/postgres/function/temporal.ts +12 -15
  120. package/src/postgres/function/window.ts +1 -6
  121. package/src/{internal/postgres-dialect.ts → postgres/internal/dialect.ts} +1 -1
  122. package/src/{internal/postgres-query.ts → postgres/internal/dsl.ts} +1085 -2089
  123. package/src/{internal/postgres-renderer.ts → postgres/internal/renderer.ts} +6 -6
  124. package/src/postgres/internal/schema-ddl.ts +108 -0
  125. package/src/{internal/postgres-schema-model.ts → postgres/internal/schema-model.ts} +12 -6
  126. package/src/{internal → postgres/internal}/sql-expression-renderer.ts +19 -17
  127. package/src/postgres/{function/json.ts → json.ts} +77 -85
  128. package/src/postgres/metadata.ts +2 -2
  129. package/src/postgres/query.ts +113 -89
  130. package/src/postgres/renderer.ts +3 -13
  131. package/src/postgres/schema-expression.ts +2 -1
  132. package/src/postgres/schema-management.ts +1 -1
  133. package/src/postgres/table.ts +12 -4
  134. package/src/postgres/type.ts +29 -2
  135. package/src/postgres.ts +6 -4
  136. package/src/internal/expression.ts +0 -327
  137. package/src/internal/schema-ddl.ts +0 -55
  138. package/src/mysql/function/json.ts +0 -4
  139. package/src/mysql/private/query.ts +0 -1
  140. package/src/postgres/private/query.ts +0 -1
  141. /package/src/internal/{predicate-atom.ts → predicate/atom.ts} +0 -0
@@ -1,32 +1,6 @@
1
- import type * as Expression from ".././expression.js"
2
- import type { mysqlDatatypeFamilies, mysqlDatatypeKinds } from "../../mysql/datatypes/spec.js"
3
- import type { postgresDatatypeFamilies, postgresDatatypeKinds } from "../../postgres/datatypes/spec.js"
1
+ import type * as Expression from "../scalar.js"
4
2
  import type { RuntimeOfTag, RuntimeTag } from "./shape.js"
5
3
 
6
- type KnownDialect = "postgres" | "mysql"
7
-
8
- type DialectKinds<Dialect extends KnownDialect> =
9
- Dialect extends "postgres" ? typeof postgresDatatypeKinds :
10
- typeof mysqlDatatypeKinds
11
-
12
- type DialectFamilies<Dialect extends KnownDialect> =
13
- Dialect extends "postgres" ? typeof postgresDatatypeFamilies :
14
- typeof mysqlDatatypeFamilies
15
-
16
- type StripParameterizedKind<Kind extends string> =
17
- Kind extends `${infer Base}(${string}`
18
- ? StripParameterizedKind<Base>
19
- : Kind
20
-
21
- type StripArrayKind<Kind extends string> =
22
- Kind extends `${infer Base}[]`
23
- ? StripArrayKind<Base>
24
- : Kind
25
-
26
- type BaseKind<Kind extends string> = StripArrayKind<StripParameterizedKind<Kind>>
27
-
28
- type IsArrayKind<Kind extends string> = Kind extends `${string}[]` ? true : false
29
-
30
4
  type ExactKindFamily =
31
5
  | "array"
32
6
  | "range"
@@ -35,101 +9,55 @@ type ExactKindFamily =
35
9
  | "enum"
36
10
  | "set"
37
11
 
38
- type KnownKindFamily<
39
- Dialect extends KnownDialect,
40
- Kind extends string
41
- > = IsArrayKind<Kind> extends true
42
- ? "array"
43
- : BaseKind<Kind> extends "null"
44
- ? "null"
45
- : BaseKind<Kind> extends keyof DialectKinds<Dialect>
46
- ? DialectKinds<Dialect>[BaseKind<Kind>] extends { readonly family: infer Family extends string }
47
- ? Family
48
- : never
49
- : `other:${Dialect}:${Kind}`
12
+ type BaseFamilyOf<Db extends Expression.DbType.Base<any, any>> =
13
+ Db extends { readonly family?: infer Family extends string }
14
+ ? Family
15
+ : Db["kind"] extends "null"
16
+ ? "null"
17
+ : `other:${Db["dialect"]}:${Db["kind"]}`
18
+
19
+ type BaseRuntimeTagOf<Db extends Expression.DbType.Base<any, any>> =
20
+ Db extends { readonly runtime?: infer Runtime extends RuntimeTag }
21
+ ? Runtime
22
+ : "unknown"
50
23
 
51
- type KnownKindRuntimeTag<
52
- Dialect extends KnownDialect,
53
- Kind extends string
54
- > = IsArrayKind<Kind> extends true
55
- ? "array"
56
- : BaseKind<Kind> extends "null"
57
- ? "null"
58
- : BaseKind<Kind> extends keyof DialectKinds<Dialect>
59
- ? DialectKinds<Dialect>[BaseKind<Kind>] extends { readonly runtime: infer Runtime extends RuntimeTag }
60
- ? Runtime
61
- : "unknown"
62
- : "unknown"
24
+ type BaseCompareGroupOf<Db extends Expression.DbType.Base<any, any>> =
25
+ Db extends { readonly compareGroup?: infer CompareGroup extends string }
26
+ ? CompareGroup
27
+ : BaseFamilyOf<Db>
63
28
 
64
- type FamilyCastTargets<
65
- Dialect extends KnownDialect,
66
- Family extends string
67
- > = Family extends keyof DialectFamilies<Dialect>
68
- ? DialectFamilies<Dialect>[Family] extends { readonly castTargets: readonly (infer CastTarget extends string)[] }
69
- ? CastTarget
29
+ type BaseCastTargetsOf<Db extends Expression.DbType.Base<any, any>> =
30
+ Db extends { readonly castTargets?: readonly (infer Target extends string)[] }
31
+ ? Target
70
32
  : never
71
- : never
72
33
 
73
- type FamilyHasTextualTrait<
74
- Dialect extends KnownDialect,
75
- Family extends string
76
- > = Family extends keyof DialectFamilies<Dialect>
77
- ? DialectFamilies<Dialect>[Family] extends { readonly traits: infer Traits }
34
+ type BaseHasTextualTrait<Db extends Expression.DbType.Base<any, any>> =
35
+ Db extends { readonly traits?: infer Traits }
78
36
  ? Traits extends { readonly textual: true }
79
37
  ? true
80
38
  : false
81
39
  : false
82
- : false
83
-
84
- type BaseFamilyOf<
85
- Dialect extends KnownDialect,
86
- Kind extends string
87
- > = Kind extends keyof DialectKinds<Dialect>
88
- ? DialectKinds<Dialect>[Kind] extends { readonly family: infer Family extends string }
89
- ? Family
90
- : never
91
- : `other:${Dialect}:${Kind}`
92
-
93
- type BaseRuntimeTagOf<
94
- Dialect extends KnownDialect,
95
- Kind extends string
96
- > = Kind extends keyof DialectKinds<Dialect>
97
- ? DialectKinds<Dialect>[Kind] extends { readonly runtime: infer Runtime extends RuntimeTag }
98
- ? Runtime
99
- : "unknown"
100
- : "unknown"
101
-
102
- type BaseCompareGroupOf<
103
- Dialect extends KnownDialect,
104
- Kind extends string
105
- > = BaseFamilyOf<Dialect, Kind> extends ExactKindFamily
106
- ? Kind
107
- : BaseFamilyOf<Dialect, Kind> extends keyof DialectFamilies<Dialect>
108
- ? DialectFamilies<Dialect>[BaseFamilyOf<Dialect, Kind>] extends { readonly compareGroup: infer CompareGroup extends string }
109
- ? CompareGroup
110
- : never
111
- : BaseFamilyOf<Dialect, Kind>
112
40
 
113
41
  export type FamilyOfDbType<Db extends Expression.DbType.Any> =
114
42
  Db extends Expression.DbType.Domain<any, infer Base extends Expression.DbType.Any, any>
115
43
  ? FamilyOfDbType<Base>
116
44
  : Db extends Expression.DbType.Array<any, any, any>
117
45
  ? "array"
118
- : Db extends Expression.DbType.Range<any, any, any>
119
- ? "range"
120
- : Db extends Expression.DbType.Multirange<any, any, any>
121
- ? "multirange"
122
- : Db extends Expression.DbType.Composite<any, any, any>
123
- ? "record"
124
- : Db extends Expression.DbType.Enum<any, any>
125
- ? "enum"
126
- : Db extends Expression.DbType.Set<any, any>
127
- ? "set"
128
- : Db extends Expression.DbType.Json<any, any>
129
- ? "json"
130
- : Db extends Expression.DbType.Base<infer Dialect extends KnownDialect, infer Kind extends string>
131
- ? BaseFamilyOf<Dialect, Kind>
132
- : "other:unknown:unknown"
46
+ : Db extends Expression.DbType.Range<any, any, any>
47
+ ? "range"
48
+ : Db extends Expression.DbType.Multirange<any, any, any>
49
+ ? "multirange"
50
+ : Db extends Expression.DbType.Composite<any, any, any>
51
+ ? "record"
52
+ : Db extends Expression.DbType.Enum<any, any>
53
+ ? "enum"
54
+ : Db extends Expression.DbType.Set<any, any>
55
+ ? "set"
56
+ : Db extends Expression.DbType.Json<any, any>
57
+ ? "json"
58
+ : Db extends Expression.DbType.Base<any, any>
59
+ ? BaseFamilyOf<Db>
60
+ : "other:unknown:unknown"
133
61
 
134
62
  export type CompareGroupOfDbType<Db extends Expression.DbType.Any> =
135
63
  Db extends Expression.DbType.Domain<any, infer Base extends Expression.DbType.Any, any>
@@ -140,17 +68,17 @@ export type CompareGroupOfDbType<Db extends Expression.DbType.Any> =
140
68
  ? Kind
141
69
  : Db extends Expression.DbType.Multirange<any, any, infer Kind extends string>
142
70
  ? Kind
143
- : Db extends Expression.DbType.Composite<any, any, infer Kind extends string>
71
+ : Db extends Expression.DbType.Composite<any, any, infer Kind extends string>
144
72
  ? Kind
145
73
  : Db extends Expression.DbType.Enum<any, infer Kind extends string>
146
74
  ? Kind
147
- : Db extends Expression.DbType.Set<any, infer Kind extends string>
148
- ? Kind
149
- : Db extends Expression.DbType.Json<any, any>
150
- ? never
151
- : Db extends Expression.DbType.Base<infer Dialect extends KnownDialect, infer Kind extends string>
152
- ? BaseCompareGroupOf<Dialect, Kind>
153
- : "other:unknown:unknown"
75
+ : Db extends Expression.DbType.Set<any, infer Kind extends string>
76
+ ? Kind
77
+ : Db extends Expression.DbType.Json<any, any>
78
+ ? never
79
+ : Db extends Expression.DbType.Base<any, any>
80
+ ? BaseCompareGroupOf<Db>
81
+ : "other:unknown:unknown"
154
82
 
155
83
  export type RuntimeOfDbType<Db extends Expression.DbType.Any> =
156
84
  Db extends Expression.DbType.Domain<any, infer Base extends Expression.DbType.Any, any>
@@ -159,17 +87,17 @@ export type RuntimeOfDbType<Db extends Expression.DbType.Any> =
159
87
  ? ReadonlyArray<RuntimeOfDbType<Element>>
160
88
  : Db extends Expression.DbType.Composite<any, infer Fields extends Record<string, Expression.DbType.Any>, any>
161
89
  ? { readonly [K in keyof Fields]: RuntimeOfDbType<Fields[K]> }
162
- : Db extends Expression.DbType.Range<any, any, any> | Expression.DbType.Multirange<any, any, any>
163
- ? unknown
164
- : Db extends Expression.DbType.Json<any, any>
165
- ? import("../runtime-value.js").JsonValue
90
+ : Db extends Expression.DbType.Range<any, any, any> | Expression.DbType.Multirange<any, any, any>
91
+ ? unknown
92
+ : Db extends Expression.DbType.Json<any, any>
93
+ ? import("../runtime/value.js").JsonValue
166
94
  : Db extends Expression.DbType.Enum<any, any> | Expression.DbType.Set<any, any>
167
- ? string
168
- : Db extends Expression.DbType.Base<infer Dialect extends KnownDialect, infer Kind extends string>
169
- ? BaseRuntimeTagOf<Dialect, Kind> extends infer Runtime extends RuntimeTag
170
- ? RuntimeOfTag<Runtime>
95
+ ? string
96
+ : Db extends Expression.DbType.Base<any, any>
97
+ ? BaseRuntimeTagOf<Db> extends infer Runtime extends RuntimeTag
98
+ ? RuntimeOfTag<Runtime>
99
+ : unknown
171
100
  : unknown
172
- : unknown
173
101
 
174
102
  export type CanCompareDbTypes<
175
103
  Left extends Expression.DbType.Any,
@@ -221,12 +149,8 @@ export type CanTextuallyCoerceDbType<
221
149
  ? true
222
150
  : Db extends Expression.DbType.Json<any, any>
223
151
  ? false
224
- : Db extends Expression.DbType.Base<infer D extends KnownDialect, infer Kind extends string>
225
- ? Kind extends keyof DialectKinds<D>
226
- ? FamilyHasTextualTrait<D, BaseFamilyOf<D, Kind>> extends true
227
- ? true
228
- : false
229
- : false
152
+ : Db extends Expression.DbType.Base<any, any>
153
+ ? BaseHasTextualTrait<Db>
230
154
  : false
231
155
  : false
232
156
 
@@ -252,29 +176,14 @@ export type CanCastDbType<
252
176
  | Expression.DbType.Enum<any, any>
253
177
  | Expression.DbType.Set<any, any>
254
178
  ? true
255
- : Source extends Expression.DbType.Base<infer SourceDialect extends KnownDialect, infer SourceKind extends string>
256
- ? Target extends Expression.DbType.Base<infer TargetDialect extends KnownDialect, infer TargetKind extends string>
257
- ? SourceDialect extends TargetDialect
258
- ? SourceKind extends keyof DialectKinds<SourceDialect>
259
- ? TargetKind extends keyof DialectKinds<TargetDialect>
260
- ? BaseFamilyOf<SourceDialect, SourceKind> extends ExactKindFamily
261
- ? BaseFamilyOf<SourceDialect, TargetKind> extends "text"
262
- ? FamilyCastTargets<SourceDialect, Extract<BaseFamilyOf<SourceDialect, SourceKind>, string>> extends infer Targets extends string
263
- ? "text" extends Targets
264
- ? true
265
- : false
266
- : false
267
- : false
268
- : BaseFamilyOf<SourceDialect, TargetKind> extends FamilyCastTargets<
269
- SourceDialect,
270
- Extract<BaseFamilyOf<SourceDialect, SourceKind>, string>
271
- >
272
- ? true
273
- : false
179
+ : Source extends Expression.DbType.Base<any, any>
180
+ ? Target extends Expression.DbType.Base<any, any>
181
+ ? BaseFamilyOf<Target> extends ExactKindFamily
182
+ ? false
183
+ : BaseFamilyOf<Target> extends BaseCastTargetsOf<Source>
184
+ ? true
274
185
  : false
275
- : false
276
186
  : false
277
187
  : false
278
- : false
279
188
  : false
280
189
  : false
@@ -0,0 +1,16 @@
1
+ import type { BigIntString, DecimalString, InstantString, JsonValue, LocalDateString, LocalDateTimeString, LocalTimeString, OffsetTimeString, YearString } from "../runtime/value.js";
2
+ export type RuntimeTag = "string" | "number" | "bigintString" | "boolean" | "json" | "localDate" | "localTime" | "offsetTime" | "localDateTime" | "instant" | "year" | "decimalString" | "bytes" | "array" | "record" | "unknown" | "null";
3
+ export type RuntimeOfTag<Tag extends RuntimeTag> = Tag extends "string" ? string : Tag extends "number" ? number : Tag extends "bigintString" ? BigIntString : Tag extends "boolean" ? boolean : Tag extends "json" ? JsonValue : Tag extends "localDate" ? LocalDateString : Tag extends "localTime" ? LocalTimeString : Tag extends "offsetTime" ? OffsetTimeString : Tag extends "localDateTime" ? LocalDateTimeString : Tag extends "instant" ? InstantString : Tag extends "year" ? YearString : Tag extends "decimalString" ? DecimalString : Tag extends "bytes" ? Uint8Array : Tag extends "array" ? ReadonlyArray<unknown> : Tag extends "record" ? Record<string, unknown> : Tag extends "null" ? null : unknown;
4
+ export interface DatatypeTraits {
5
+ readonly textual?: true;
6
+ readonly ordered?: true;
7
+ }
8
+ export interface DatatypeFamilySpec<CompareGroup extends string = string, CastTargets extends readonly string[] = readonly string[], Traits extends DatatypeTraits = DatatypeTraits> {
9
+ readonly compareGroup: CompareGroup;
10
+ readonly castTargets: CastTargets;
11
+ readonly traits: Traits;
12
+ }
13
+ export interface DatatypeKindSpec<Family extends string = string, Runtime extends RuntimeTag = RuntimeTag> {
14
+ readonly family: Family;
15
+ readonly runtime: Runtime;
16
+ }
@@ -8,7 +8,7 @@ import type {
8
8
  LocalTimeString,
9
9
  OffsetTimeString,
10
10
  YearString
11
- } from "../runtime-value.js"
11
+ } from "../runtime/value.js"
12
12
 
13
13
  export type RuntimeTag =
14
14
  | "string"
@@ -0,0 +1,4 @@
1
+ import { type CompletePlan, type CteSource, type DerivedSource, type LateralSource, type QueryPlan } from "./query.js";
2
+ export declare const makeDerivedSource: <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>, Alias extends string>(plan: CompletePlan<PlanValue>, alias: Alias) => DerivedSource<PlanValue, Alias>;
3
+ export declare const makeCteSource: <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>, Alias extends string>(plan: CompletePlan<PlanValue>, alias: Alias, recursive?: boolean) => CteSource<PlanValue, Alias>;
4
+ export declare const makeLateralSource: <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>, Alias extends string>(plan: PlanValue, alias: Alias) => LateralSource<PlanValue, Alias>;
@@ -1,7 +1,7 @@
1
1
  import { pipeArguments } from "effect/Pipeable"
2
2
 
3
- import * as Expression from "./expression.js"
4
- import * as Plan from "./plan.js"
3
+ import * as Expression from "./scalar.js"
4
+ import * as Plan from "./row-set.js"
5
5
  import {
6
6
  type CompletePlan,
7
7
  type CteSource,
@@ -22,6 +22,17 @@ const DerivedProto = {
22
22
  }
23
23
  }
24
24
 
25
+ const attachPipe = <Value extends object>(value: Value): Value => {
26
+ Object.defineProperty(value, "pipe", {
27
+ configurable: true,
28
+ writable: true,
29
+ value: function(this: unknown) {
30
+ return pipeArguments(value, arguments)
31
+ }
32
+ })
33
+ return value
34
+ }
35
+
25
36
  const setPath = (
26
37
  target: Record<string, unknown>,
27
38
  path: readonly string[],
@@ -45,7 +56,7 @@ const setPath = (
45
56
  const pathAlias = (path: readonly string[]): string => path.join("__")
46
57
 
47
58
  const reboundedColumns = <
48
- PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any>,
59
+ PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
49
60
  Alias extends string
50
61
  >(
51
62
  plan: PlanValue,
@@ -67,13 +78,7 @@ const reboundedColumns = <
67
78
  runtimeSchema: expression[Expression.TypeId].runtimeSchema,
68
79
  nullability: expression[Expression.TypeId].nullability,
69
80
  dialect: expression[Expression.TypeId].dialect,
70
- aggregation: "scalar",
71
- source: {
72
- tableName: alias,
73
- columnName: projection.alias,
74
- baseTableName: alias
75
- },
76
- sourceNullability: "propagate" as const,
81
+ kind: "scalar",
77
82
  dependencies: {
78
83
  [alias]: true
79
84
  } as Record<Alias, true>
@@ -87,14 +92,14 @@ const reboundedColumns = <
87
92
  }
88
93
 
89
94
  export const makeDerivedSource = <
90
- PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any>,
95
+ PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
91
96
  Alias extends string
92
97
  >(
93
98
  plan: CompletePlan<PlanValue>,
94
99
  alias: Alias
95
100
  ): DerivedSource<PlanValue, Alias> => {
96
101
  const columns = reboundedColumns(plan, alias)
97
- const derived = Object.create(DerivedProto) as Record<string, unknown>
102
+ const derived = attachPipe(Object.create(DerivedProto)) as Record<string, unknown>
98
103
  Object.assign(derived, columns)
99
104
  derived.kind = "derived"
100
105
  derived.name = alias
@@ -107,7 +112,7 @@ export const makeDerivedSource = <
107
112
  }
108
113
 
109
114
  export const makeCteSource = <
110
- PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any>,
115
+ PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
111
116
  Alias extends string
112
117
  >(
113
118
  plan: CompletePlan<PlanValue>,
@@ -115,7 +120,7 @@ export const makeCteSource = <
115
120
  recursive = false
116
121
  ): CteSource<PlanValue, Alias> => {
117
122
  const columns = reboundedColumns(plan, alias)
118
- const cte = Object.create(DerivedProto) as Record<string, unknown>
123
+ const cte = attachPipe(Object.create(DerivedProto)) as Record<string, unknown>
119
124
  Object.assign(cte, columns)
120
125
  cte.kind = "cte"
121
126
  cte.name = alias
@@ -129,14 +134,14 @@ export const makeCteSource = <
129
134
  }
130
135
 
131
136
  export const makeLateralSource = <
132
- PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any>,
137
+ PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>,
133
138
  Alias extends string
134
139
  >(
135
140
  plan: PlanValue,
136
141
  alias: Alias
137
142
  ): LateralSource<PlanValue, Alias> => {
138
143
  const columns = reboundedColumns(plan, alias)
139
- const lateral = Object.create(DerivedProto) as Record<string, unknown>
144
+ const lateral = attachPipe(Object.create(DerivedProto)) as Record<string, unknown>
140
145
  Object.assign(lateral, columns)
141
146
  lateral.kind = "lateral"
142
147
  lateral.name = alias