@prisma-next/sql-relational-core 0.3.0-pr.99.6 → 0.3.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 (163) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +20 -6
  3. package/dist/codec-types-DcEITed4.d.mts +144 -0
  4. package/dist/codec-types-DcEITed4.d.mts.map +1 -0
  5. package/dist/errors-Cs52upp3.d.mts +8 -0
  6. package/dist/errors-Cs52upp3.d.mts.map +1 -0
  7. package/dist/errors-D3xmG4h-.mjs +35 -0
  8. package/dist/errors-D3xmG4h-.mjs.map +1 -0
  9. package/dist/exports/ast.d.mts +158 -0
  10. package/dist/exports/ast.d.mts.map +1 -0
  11. package/dist/exports/ast.mjs +1358 -0
  12. package/dist/exports/ast.mjs.map +1 -0
  13. package/dist/exports/errors.d.mts +5 -0
  14. package/dist/exports/errors.mjs +3 -0
  15. package/dist/exports/plan.d.mts +2 -0
  16. package/dist/exports/plan.mjs +17 -0
  17. package/dist/exports/plan.mjs.map +1 -0
  18. package/dist/exports/query-lane-context.d.mts +3 -0
  19. package/dist/exports/query-lane-context.mjs +1 -0
  20. package/dist/exports/types.d.mts +4 -0
  21. package/dist/exports/types.mjs +1 -0
  22. package/dist/index.d.mts +11 -0
  23. package/dist/index.mjs +7 -0
  24. package/dist/plan-5qUWdlJM.d.mts +28 -0
  25. package/dist/plan-5qUWdlJM.d.mts.map +1 -0
  26. package/dist/query-lane-context-UlR8vOkd.d.mts +89 -0
  27. package/dist/query-lane-context-UlR8vOkd.d.mts.map +1 -0
  28. package/dist/types-CLCtwVWx.d.mts +485 -0
  29. package/dist/types-CLCtwVWx.d.mts.map +1 -0
  30. package/dist/types-V1qiC5DO.d.mts +200 -0
  31. package/dist/types-V1qiC5DO.d.mts.map +1 -0
  32. package/package.json +29 -51
  33. package/src/ast/adapter-types.ts +11 -0
  34. package/src/ast/codec-types.ts +101 -53
  35. package/src/ast/driver-types.ts +20 -3
  36. package/src/ast/sql-codecs.ts +142 -0
  37. package/src/ast/types.ts +1678 -88
  38. package/src/errors.ts +47 -1
  39. package/src/exports/ast.ts +1 -8
  40. package/src/index.ts +0 -3
  41. package/src/plan.ts +4 -4
  42. package/src/query-lane-context.ts +74 -11
  43. package/src/types.ts +102 -404
  44. package/dist/ast/adapter-types.d.ts +0 -28
  45. package/dist/ast/adapter-types.d.ts.map +0 -1
  46. package/dist/ast/codec-types.d.ts +0 -141
  47. package/dist/ast/codec-types.d.ts.map +0 -1
  48. package/dist/ast/common.d.ts +0 -7
  49. package/dist/ast/common.d.ts.map +0 -1
  50. package/dist/ast/delete.d.ts +0 -8
  51. package/dist/ast/delete.d.ts.map +0 -1
  52. package/dist/ast/driver-types.d.ts +0 -20
  53. package/dist/ast/driver-types.d.ts.map +0 -1
  54. package/dist/ast/insert.d.ts +0 -8
  55. package/dist/ast/insert.d.ts.map +0 -1
  56. package/dist/ast/join.d.ts +0 -6
  57. package/dist/ast/join.d.ts.map +0 -1
  58. package/dist/ast/order.d.ts +0 -6
  59. package/dist/ast/order.d.ts.map +0 -1
  60. package/dist/ast/predicate.d.ts +0 -4
  61. package/dist/ast/predicate.d.ts.map +0 -1
  62. package/dist/ast/select.d.ts +0 -18
  63. package/dist/ast/select.d.ts.map +0 -1
  64. package/dist/ast/types.d.ts +0 -130
  65. package/dist/ast/types.d.ts.map +0 -1
  66. package/dist/ast/update.d.ts +0 -9
  67. package/dist/ast/update.d.ts.map +0 -1
  68. package/dist/ast/util.d.ts +0 -2
  69. package/dist/ast/util.d.ts.map +0 -1
  70. package/dist/chunk-2BWK6XEY.js +0 -13
  71. package/dist/chunk-2BWK6XEY.js.map +0 -1
  72. package/dist/chunk-2F7DSEOU.js +0 -8
  73. package/dist/chunk-2F7DSEOU.js.map +0 -1
  74. package/dist/chunk-2MAKNVCP.js +0 -86
  75. package/dist/chunk-2MAKNVCP.js.map +0 -1
  76. package/dist/chunk-36WJWNHT.js +0 -1
  77. package/dist/chunk-36WJWNHT.js.map +0 -1
  78. package/dist/chunk-3F4RFQIB.js +0 -169
  79. package/dist/chunk-3F4RFQIB.js.map +0 -1
  80. package/dist/chunk-7I3EMQID.js +0 -16
  81. package/dist/chunk-7I3EMQID.js.map +0 -1
  82. package/dist/chunk-G52ENULI.js +0 -1
  83. package/dist/chunk-G52ENULI.js.map +0 -1
  84. package/dist/chunk-HV334QHG.js +0 -320
  85. package/dist/chunk-HV334QHG.js.map +0 -1
  86. package/dist/chunk-KYSP7L5C.js +0 -16
  87. package/dist/chunk-KYSP7L5C.js.map +0 -1
  88. package/dist/chunk-U7AXAUJA.js +0 -1
  89. package/dist/chunk-U7AXAUJA.js.map +0 -1
  90. package/dist/chunk-YXD25S5I.js +0 -171
  91. package/dist/chunk-YXD25S5I.js.map +0 -1
  92. package/dist/errors.d.ts +0 -2
  93. package/dist/errors.d.ts.map +0 -1
  94. package/dist/exports/ast.d.ts +0 -14
  95. package/dist/exports/ast.d.ts.map +0 -1
  96. package/dist/exports/ast.js +0 -46
  97. package/dist/exports/ast.js.map +0 -1
  98. package/dist/exports/errors.d.ts +0 -2
  99. package/dist/exports/errors.d.ts.map +0 -1
  100. package/dist/exports/errors.js +0 -9
  101. package/dist/exports/errors.js.map +0 -1
  102. package/dist/exports/guards.d.ts +0 -2
  103. package/dist/exports/guards.d.ts.map +0 -1
  104. package/dist/exports/guards.js +0 -31
  105. package/dist/exports/guards.js.map +0 -1
  106. package/dist/exports/operations-registry.d.ts +0 -2
  107. package/dist/exports/operations-registry.d.ts.map +0 -1
  108. package/dist/exports/operations-registry.js +0 -9
  109. package/dist/exports/operations-registry.js.map +0 -1
  110. package/dist/exports/param.d.ts +0 -3
  111. package/dist/exports/param.d.ts.map +0 -1
  112. package/dist/exports/param.js +0 -7
  113. package/dist/exports/param.js.map +0 -1
  114. package/dist/exports/plan.d.ts +0 -2
  115. package/dist/exports/plan.d.ts.map +0 -1
  116. package/dist/exports/plan.js +0 -7
  117. package/dist/exports/plan.js.map +0 -1
  118. package/dist/exports/query-lane-context.d.ts +0 -2
  119. package/dist/exports/query-lane-context.d.ts.map +0 -1
  120. package/dist/exports/query-lane-context.js +0 -2
  121. package/dist/exports/query-lane-context.js.map +0 -1
  122. package/dist/exports/schema.d.ts +0 -3
  123. package/dist/exports/schema.d.ts.map +0 -1
  124. package/dist/exports/schema.js +0 -13
  125. package/dist/exports/schema.js.map +0 -1
  126. package/dist/exports/types.d.ts +0 -2
  127. package/dist/exports/types.d.ts.map +0 -1
  128. package/dist/exports/types.js +0 -10
  129. package/dist/exports/types.js.map +0 -1
  130. package/dist/index.d.ts +0 -9
  131. package/dist/index.d.ts.map +0 -1
  132. package/dist/index.js +0 -81
  133. package/dist/index.js.map +0 -1
  134. package/dist/operations-registry.d.ts +0 -5
  135. package/dist/operations-registry.d.ts.map +0 -1
  136. package/dist/param.d.ts +0 -4
  137. package/dist/param.d.ts.map +0 -1
  138. package/dist/plan.d.ts +0 -23
  139. package/dist/plan.d.ts.map +0 -1
  140. package/dist/query-lane-context.d.ts +0 -27
  141. package/dist/query-lane-context.d.ts.map +0 -1
  142. package/dist/schema.d.ts +0 -83
  143. package/dist/schema.d.ts.map +0 -1
  144. package/dist/types.d.ts +0 -371
  145. package/dist/types.d.ts.map +0 -1
  146. package/dist/utils/guards.d.ts +0 -82
  147. package/dist/utils/guards.d.ts.map +0 -1
  148. package/src/ast/common.ts +0 -36
  149. package/src/ast/delete.ts +0 -17
  150. package/src/ast/insert.ts +0 -17
  151. package/src/ast/join.ts +0 -54
  152. package/src/ast/order.ts +0 -11
  153. package/src/ast/predicate.ts +0 -22
  154. package/src/ast/select.ts +0 -39
  155. package/src/ast/update.ts +0 -19
  156. package/src/exports/guards.ts +0 -15
  157. package/src/exports/operations-registry.ts +0 -1
  158. package/src/exports/param.ts +0 -2
  159. package/src/exports/schema.ts +0 -6
  160. package/src/operations-registry.ts +0 -276
  161. package/src/param.ts +0 -15
  162. package/src/schema.ts +0 -406
  163. package/src/utils/guards.ts +0 -193
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2026] [Prisma Data, Inc]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -24,7 +24,9 @@ Provide shared relational primitives (schema builders, column builders, paramete
24
24
  - **Column Builders**: Provides column accessors with operation methods attached based on column typeId
25
25
  - **Parameter Helpers**: Creates parameter placeholders for query building
26
26
  - **Operations Registry**: Attaches registered operations as methods on column builders
27
+ - **Execution Context Types**: Defines the context shape used by query lanes
27
28
  - **Type Definitions**: Defines TypeScript types for column builders, operations, and projections
29
+ - **Codec Registry Types**: Defines codec interfaces and base SQL codec definitions
28
30
 
29
31
  **Non-goals:**
30
32
  - Query DSL construction (sql-lane)
@@ -42,6 +44,7 @@ flowchart TD
42
44
  PARAM[Parameter Helpers]
43
45
  OPS[Operations Registry]
44
46
  TYPES[Type Definitions]
47
+ AST[AST Types]
45
48
  end
46
49
 
47
50
  subgraph "Consumers"
@@ -59,6 +62,8 @@ flowchart TD
59
62
  OPS --> ORM
60
63
  TYPES --> SQL
61
64
  TYPES --> ORM
65
+ AST --> SQL
66
+ AST --> ORM
62
67
  ```
63
68
 
64
69
  ## Components
@@ -86,6 +91,16 @@ flowchart TD
86
91
  - Defines `SqlQueryPlan<Row>` interface for SQL query plans produced by lanes before lowering
87
92
  - Provides `augmentDescriptorWithColumnMeta(descriptors, columnMeta)` helper to update ParamDescriptor with `codecId` and `nativeType` from column metadata
88
93
 
94
+ ### AST Surface (`ast/*` via `exports/ast.ts`)
95
+ - Query roots: `SelectAst`, `InsertAst`, `UpdateAst`, `DeleteAst`
96
+ - Expressions: `ColumnRef`, `ParamRef`, `LiteralExpr`, `OperationExpr`, `ListExpression`
97
+ - Predicates: `BinaryExpr` (ops: `eq`, `neq`, `gt`, `lt`, `gte`, `lte`, `like`, `ilike`, `in`, `notIn`), `AndExpr`, `OrExpr`, `ExistsExpr`, `NullCheckExpr`
98
+ - Lane-agnostic filter interop: `WhereArg` and `ToWhereExpr` for passing filter payloads without lane-specific types
99
+ - Joins: `JoinAst`, `JoinOnExpr` (eqCol or WhereExpr)
100
+ - Inserts: `InsertAst.rows` is row-based and uses `InsertValue` cells (`ColumnRef`, `ParamRef`, or the insert-only `DefaultValueExpr` sentinel for SQL `DEFAULT`) for batched inserts
101
+ - `SelectAst.selectAllIntent` — preserves select-all intent when normalized to explicit columns
102
+ - `DeleteAst.where` and `UpdateAst.where` optional for mutation-without-WHERE lint support
103
+
89
104
  ### Type Definitions (`types.ts`)
90
105
  - Defines TypeScript types for column builders, operations, projections
91
106
  - Provides type inference utilities for extracting JavaScript types from codec types (e.g., `ExtractJsTypeFromColumnBuilder`)
@@ -95,14 +110,12 @@ flowchart TD
95
110
  ## Dependencies
96
111
 
97
112
  - **`@prisma-next/contract`**: Core contract types
98
- - **`@prisma-next/plan`**: Plan error helpers (`planInvalid`, `planUnsupported`) and `RuntimeError` type
99
- - **`@prisma-next/runtime`**: Runtime context types (TODO: Slice 6 will clean this up)
113
+ - **`@prisma-next/operations`**: Operation registry used by schema builders
100
114
  - **`@prisma-next/sql-contract`**: SQL contract types (via `@prisma-next/sql-contract/types`)
115
+ - **`arktype`**: Parameter schema typing for codec definitions
101
116
 
102
117
  **Note**: This package does not depend on specific adapters (e.g., `@prisma-next/adapter-postgres`). Test fixtures define `CodecTypes` inline to remain adapter-agnostic and avoid cyclic dependencies.
103
118
 
104
- **Note**: Error helpers (`planInvalid`, `planUnsupported`) and the `RuntimeError` type are imported from `@prisma-next/plan` (core ring) rather than being defined locally. This ensures target-agnostic error handling.
105
-
106
119
  ## Package Structure
107
120
 
108
121
  This package follows the standard `exports/` directory pattern:
@@ -112,7 +125,8 @@ This package follows the standard `exports/` directory pattern:
112
125
  - `src/exports/types.ts` - Re-exports type definitions
113
126
  - `src/exports/operations-registry.ts` - Re-exports operations registry
114
127
  - `src/exports/plan.ts` - Re-exports plan types and helpers
115
- - `src/exports/errors.ts` - Re-exports error helpers (from `@prisma-next/plan`)
128
+ - `src/exports/ast.ts` - Re-exports SQL AST types
129
+ - `src/exports/errors.ts` - Re-exports error helpers (`planInvalid`, `planUnsupported`)
116
130
  - `src/index.ts` - Main entry point that re-exports from `exports/`
117
131
 
118
132
  This enables subpath imports like `@prisma-next/sql-relational-core/schema`, `@prisma-next/sql-relational-core/param`, `@prisma-next/sql-relational-core/plan`, etc.
@@ -120,7 +134,7 @@ This enables subpath imports like `@prisma-next/sql-relational-core/schema`, `@p
120
134
  ## Related Subsystems
121
135
 
122
136
  - **[Query Lanes](../../../../docs/architecture%20docs/subsystems/3.%20Query%20Lanes.md)**: Detailed subsystem specification
123
- - **[Runtime & Plugin Framework](../../../../docs/architecture%20docs/subsystems/4.%20Runtime%20&%20Plugin%20Framework.md)**: Plan execution
137
+ - **[Runtime & Middleware Framework](../../../../docs/architecture%20docs/subsystems/4.%20Runtime%20&%20Middleware%20Framework.md)**: Plan execution
124
138
 
125
139
  ## Related ADRs
126
140
 
@@ -0,0 +1,144 @@
1
+ import { Type } from "arktype";
2
+ import { JsonValue } from "@prisma-next/contract/types";
3
+ import { Codec, CodecTrait, CodecTrait as CodecTrait$1 } from "@prisma-next/framework-components/codec";
4
+ import { O } from "ts-toolbelt";
5
+
6
+ //#region src/ast/codec-types.d.ts
7
+
8
+ /**
9
+ * Descriptor for parameterized codecs that require type parameter validation.
10
+ * Shared between adapter (compile-time) and runtime layers to avoid duplication.
11
+ *
12
+ * @template TParams - The shape of the type parameters (e.g., `{ length: number }`)
13
+ * @template THelper - The type returned by the optional `init` hook
14
+ */
15
+ interface CodecParamsDescriptor<TParams = Record<string, unknown>, THelper = unknown> {
16
+ /** The codec ID this descriptor applies to (e.g., 'pg/vector@1') */
17
+ readonly codecId: string;
18
+ /**
19
+ * Arktype schema for validating typeParams.
20
+ * Used to validate both storage.types entries and inline column typeParams.
21
+ */
22
+ readonly paramsSchema: Type<TParams>;
23
+ /**
24
+ * Optional init hook called during runtime context creation.
25
+ * Receives validated params and returns a helper object to be stored in context.types.
26
+ * If not provided, the validated params are stored directly.
27
+ */
28
+ readonly init?: (params: TParams) => THelper;
29
+ }
30
+ /**
31
+ * Codec metadata for database-specific type information.
32
+ * Used for schema introspection and verification.
33
+ */
34
+ interface CodecMeta {
35
+ readonly db?: {
36
+ readonly sql?: {
37
+ readonly postgres?: {
38
+ readonly nativeType: string;
39
+ };
40
+ };
41
+ };
42
+ }
43
+ /**
44
+ * SQL codec interface — extends the framework base with SQL-specific fields.
45
+ *
46
+ * Codecs are pure, synchronous functions with no side effects or IO.
47
+ * They provide deterministic conversion between database wire types and JS values,
48
+ * and between JS values and contract JSON.
49
+ */
50
+ interface Codec$1<Id$1 extends string = string, TTraits$1 extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TJs = unknown, TParams = Record<string, unknown>, THelper = unknown> extends Codec<Id$1, TTraits$1, TWire, TJs> {
51
+ readonly meta?: CodecMeta;
52
+ readonly paramsSchema?: Type<TParams>;
53
+ readonly init?: (params: TParams) => THelper;
54
+ }
55
+ /**
56
+ * Registry interface for codecs organized by ID and by contract scalar type.
57
+ *
58
+ * The registry allows looking up codecs by their namespaced ID or by the
59
+ * contract scalar types they handle. Multiple codecs may handle the same
60
+ * scalar type; ordering in byScalar reflects preference (adapter first,
61
+ * then packs, then app overrides).
62
+ */
63
+ interface CodecRegistry {
64
+ get(id: string): Codec$1<string> | undefined;
65
+ has(id: string): boolean;
66
+ getByScalar(scalar: string): readonly Codec$1<string>[];
67
+ getDefaultCodec(scalar: string): Codec$1<string> | undefined;
68
+ register(codec: Codec$1<string>): void;
69
+ /** Returns true if the codec with this ID has the given trait. */
70
+ hasTrait(codecId: string, trait: CodecTrait): boolean;
71
+ /** Returns all traits for a codec, or an empty array if not found. */
72
+ traitsOf(codecId: string): readonly CodecTrait[];
73
+ [Symbol.iterator](): Iterator<Codec$1<string>>;
74
+ values(): IterableIterator<Codec$1<string>>;
75
+ }
76
+ /**
77
+ * Codec factory - creates a codec with typeId and encode/decode functions.
78
+ * Provides identity defaults for encodeJson/decodeJson when not supplied.
79
+ */
80
+ declare function codec<Id$1 extends string, const TTraits$1 extends readonly CodecTrait[], TWire, TJs, TParams = Record<string, unknown>, THelper = unknown>(config: {
81
+ typeId: Id$1;
82
+ targetTypes: readonly string[];
83
+ encode: (value: TJs) => TWire;
84
+ decode: (wire: TWire) => TJs;
85
+ encodeJson?: (value: TJs) => JsonValue;
86
+ decodeJson?: (json: JsonValue) => TJs;
87
+ meta?: CodecMeta;
88
+ paramsSchema?: Type<TParams>;
89
+ init?: (params: TParams) => THelper;
90
+ traits?: TTraits$1;
91
+ renderOutputType?: (typeParams: Record<string, unknown>) => string | undefined;
92
+ }): Codec$1<Id$1, TTraits$1, TWire, TJs, TParams, THelper>;
93
+ /**
94
+ * Type helpers to extract codec types.
95
+ */
96
+ type CodecId<T> = T extends Codec$1<infer Id> ? Id : T extends {
97
+ readonly id: infer Id;
98
+ } ? Id : never;
99
+ type CodecInput<T> = T extends Codec$1<string, readonly CodecTrait[], unknown, infer JsT> ? JsT : never;
100
+ type CodecOutput<T> = T extends Codec$1<string, readonly CodecTrait[], unknown, infer JsT> ? JsT : never;
101
+ type CodecTraits<T> = T extends Codec$1<string, infer TTraits> ? TTraits[number] & CodecTrait : never;
102
+ /**
103
+ * Type helper to extract codec types from builder instance.
104
+ */
105
+ type ExtractCodecTypes<ScalarNames extends { readonly [K in keyof ScalarNames]: Codec$1<string> } = Record<never, never>> = { readonly [K in keyof ScalarNames as ScalarNames[K] extends Codec$1<infer Id> ? Id : never]: {
106
+ readonly input: CodecInput<ScalarNames[K]>;
107
+ readonly output: CodecOutput<ScalarNames[K]>;
108
+ readonly traits: CodecTraits<ScalarNames[K]>;
109
+ } };
110
+ /**
111
+ * Type helper to extract data type IDs from builder instance.
112
+ * Uses ExtractCodecTypes which preserves literal types as keys.
113
+ * Since ExtractCodecTypes<Record<K, ScalarNames[K]>> has exactly one key (the Id),
114
+ * we extract it by creating a mapped type that uses the Id as both key and value,
115
+ * then extract the value type. This preserves literal types.
116
+ */
117
+ type ExtractDataTypes<ScalarNames extends { readonly [K in keyof ScalarNames]: Codec$1<string> }> = { readonly [K in keyof ScalarNames]: { readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>] };
118
+ /**
119
+ * Builder interface for declaring codecs.
120
+ */
121
+ interface CodecDefBuilder<ScalarNames extends { readonly [K in keyof ScalarNames]: Codec$1<string> } = Record<never, never>> {
122
+ readonly CodecTypes: ExtractCodecTypes<ScalarNames>;
123
+ add<ScalarName extends string, CodecImpl extends Codec$1<string>>(scalarName: ScalarName, codecImpl: CodecImpl): CodecDefBuilder<O.Overwrite<ScalarNames, Record<ScalarName, CodecImpl>> & Record<ScalarName, CodecImpl>>;
124
+ readonly codecDefinitions: { readonly [K in keyof ScalarNames]: {
125
+ readonly typeId: ScalarNames[K] extends Codec$1<infer Id extends string> ? Id : never;
126
+ readonly scalar: K;
127
+ readonly codec: ScalarNames[K];
128
+ readonly input: CodecInput<ScalarNames[K]>;
129
+ readonly output: CodecOutput<ScalarNames[K]>;
130
+ readonly jsType: CodecOutput<ScalarNames[K]>;
131
+ } };
132
+ readonly dataTypes: { readonly [K in keyof ScalarNames]: { readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>] };
133
+ }
134
+ /**
135
+ * Create a new codec registry.
136
+ */
137
+ declare function createCodecRegistry(): CodecRegistry;
138
+ /**
139
+ * Create a new codec definition builder.
140
+ */
141
+ declare function defineCodecs(): CodecDefBuilder<Record<never, never>>;
142
+ //#endregion
143
+ export { CodecMeta as a, CodecRegistry as c, ExtractCodecTypes as d, ExtractDataTypes as f, defineCodecs as h, CodecInput as i, CodecTrait$1 as l, createCodecRegistry as m, CodecDefBuilder as n, CodecOutput as o, codec as p, CodecId as r, CodecParamsDescriptor as s, Codec$1 as t, CodecTraits as u };
144
+ //# sourceMappingURL=codec-types-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B,SAAA,MAAA,EAKN,WALM,CAKM,CALN,CAAA,SAKiB,OALjB,CAAA,KAAA,YAAA,MAAA,CAAA,GAAA,EAAA,GAAA,KAAA;IAAvB,SAAA,MAAA,EAMiB,CANjB;IAA+D,SAAA,KAAA,EAO/C,WAP+C,CAOnC,CAPmC,CAAA;IAAY,SAAA,KAAA,EAQ3D,UAR2D,CAQhD,WARgD,CAQpC,CARoC,CAAA,CAAA;IAAnB,SAAA,MAAA,EASvC,WATuC,CAS3B,WAT2B,CASf,CATe,CAAA,CAAA;IADzD,SAAA,MAAA,EAWkB,WAXlB,CAW8B,WAX9B,CAW0C,CAX1C,CAAA,CAAA;EAKoB,CAAA,EACF;EAAY,SAAA,SAAA,EAAA,iBAAW,MAUrB,WAVqB,GAAA,kBACvB,MAUK,iBAVL,CAUuB,MAVvB,CAU8B,CAV9B,EAUiC,WAVjC,CAU6C,CAV7C,CAAA,CAAA,CAAA,GAUoD,EAVpD,EACD,CAAA,MAUV,iBAVU,CAUQ,MAVR,CAUe,CAVf,EAUkB,WAVlB,CAU8B,CAV9B,CAAA,CAAA,CAAA,CAAA,EAAY;;;;;AAEa,iBAiI/B,mBAAA,CAAA,CAjI+B,EAiIR,aAjIQ;;;;AACxB,iBAuIP,YAAA,CAAA,CAvIO,EAuIS,eAvIT,CAuIyB,MAvIzB,CAAA,KAAA,EAAA,KAAA,CAAA,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { b as RuntimeError } from "./types-V1qiC5DO.mjs";
2
+
3
+ //#region src/errors.d.ts
4
+ declare function planInvalid(message: string, details?: Record<string, unknown>, hints?: readonly string[], docs?: readonly string[]): RuntimeError;
5
+ declare function planUnsupported(message: string, details?: Record<string, unknown>, hints?: readonly string[], docs?: readonly string[]): RuntimeError;
6
+ //#endregion
7
+ export { planUnsupported as n, planInvalid as t };
8
+ //# sourceMappingURL=errors-Cs52upp3.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-Cs52upp3.d.mts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;iBAEgB,WAAA,4BAEJ,+EAGT;iBAkBa,eAAA,4BAEJ,+EAGT"}
@@ -0,0 +1,35 @@
1
+ //#region src/errors.ts
2
+ function planInvalid(message, details, hints, docs) {
3
+ const error = new Error(message);
4
+ Object.defineProperty(error, "name", {
5
+ value: "RuntimeError",
6
+ configurable: true
7
+ });
8
+ return Object.assign(error, {
9
+ code: "PLAN.INVALID",
10
+ category: "PLAN",
11
+ severity: "error",
12
+ details,
13
+ hints,
14
+ docs
15
+ });
16
+ }
17
+ function planUnsupported(message, details, hints, docs) {
18
+ const error = new Error(message);
19
+ Object.defineProperty(error, "name", {
20
+ value: "RuntimeError",
21
+ configurable: true
22
+ });
23
+ return Object.assign(error, {
24
+ code: "PLAN.UNSUPPORTED",
25
+ category: "PLAN",
26
+ severity: "error",
27
+ details,
28
+ hints,
29
+ docs
30
+ });
31
+ }
32
+
33
+ //#endregion
34
+ export { planUnsupported as n, planInvalid as t };
35
+ //# sourceMappingURL=errors-D3xmG4h-.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-D3xmG4h-.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import type { RuntimeError } from './types';\n\nexport function planInvalid(\n message: string,\n details?: Record<string, unknown>,\n hints?: readonly string[],\n docs?: readonly string[],\n): RuntimeError {\n const error = new Error(message) as RuntimeError;\n\n Object.defineProperty(error, 'name', {\n value: 'RuntimeError',\n configurable: true,\n });\n\n return Object.assign(error, {\n code: 'PLAN.INVALID',\n category: 'PLAN' as const,\n severity: 'error' as const,\n details,\n hints,\n docs,\n });\n}\n\nexport function planUnsupported(\n message: string,\n details?: Record<string, unknown>,\n hints?: readonly string[],\n docs?: readonly string[],\n): RuntimeError {\n const error = new Error(message) as RuntimeError;\n\n Object.defineProperty(error, 'name', {\n value: 'RuntimeError',\n configurable: true,\n });\n\n return Object.assign(error, {\n code: 'PLAN.UNSUPPORTED',\n category: 'PLAN' as const,\n severity: 'error' as const,\n details,\n hints,\n docs,\n });\n}\n"],"mappings":";AAEA,SAAgB,YACd,SACA,SACA,OACA,MACc;CACd,MAAM,QAAQ,IAAI,MAAM,QAAQ;AAEhC,QAAO,eAAe,OAAO,QAAQ;EACnC,OAAO;EACP,cAAc;EACf,CAAC;AAEF,QAAO,OAAO,OAAO,OAAO;EAC1B,MAAM;EACN,UAAU;EACV,UAAU;EACV;EACA;EACA;EACD,CAAC;;AAGJ,SAAgB,gBACd,SACA,SACA,OACA,MACc;CACd,MAAM,QAAQ,IAAI,MAAM,QAAQ;AAEhC,QAAO,eAAe,OAAO,QAAQ;EACnC,OAAO;EACP,cAAc;EACf,CAAC;AAEF,QAAO,OAAO,OAAO,OAAO;EAC1B,MAAM;EACN,UAAU;EACV,UAAU;EACV;EACA;EACA;EACD,CAAC"}
@@ -0,0 +1,158 @@
1
+ import { a as CodecMeta, c as CodecRegistry, d as ExtractCodecTypes, f as ExtractDataTypes, h as defineCodecs, i as CodecInput, l as CodecTrait, m as createCodecRegistry, n as CodecDefBuilder, o as CodecOutput, p as codec, r as CodecId, s as CodecParamsDescriptor, t as Codec, u as CodecTraits } from "../codec-types-DcEITed4.mjs";
2
+ import { $ as ToWhereExpr, A as InsertOnConflict, B as NotExpr, C as ExistsExpr, D as ExpressionSource, E as ExpressionRewriter, F as JsonObjectEntry, G as ParamRef, H as OperationExpr, I as JsonObjectExpr, J as SelectAst, K as ProjectionExpr, L as ListExpression, M as JoinAst, N as JoinOnExpr, O as IdentifierRef, P as JsonArrayAggExpr, Q as TableSource, R as LiteralExpr, S as EqColJoinOn, T as ExpressionFolder, U as OrExpr, V as NullCheckExpr, W as OrderByItem, X as SubqueryExpr, Y as SelectAstOptions, Z as TableRef, _ as DeleteAst, a as AndExpr, at as whereExprKinds, b as DoNothingConflictAction, c as AnyInsertOnConflictAction, d as AnyQueryAst, et as UpdateAst, f as AstRewriter, g as DefaultValueExpr, h as ColumnRef, i as AggregateOpFn, it as queryAstKinds, j as InsertValue, k as InsertAst, l as AnyInsertValue, m as BinaryOp, n as AggregateExpr, nt as isQueryAst, o as AnyExpression, p as BinaryExpr, q as ProjectionItem, r as AggregateFn, rt as isWhereExpr, s as AnyFromSource, t as AggregateCountFn, tt as WhereArg, u as AnyOperationArg, v as DerivedTableSource, w as ExprVisitor, x as DoUpdateSetConflictAction, y as Direction, z as LoweredStatement } from "../types-CLCtwVWx.mjs";
3
+
4
+ //#region src/ast/adapter-types.d.ts
5
+ type AdapterTarget = string;
6
+ interface MarkerStatement {
7
+ readonly sql: string;
8
+ readonly params: readonly unknown[];
9
+ }
10
+ interface AdapterProfile<TTarget extends AdapterTarget = AdapterTarget> {
11
+ readonly id: string;
12
+ readonly target: TTarget;
13
+ readonly capabilities: Record<string, unknown>;
14
+ /**
15
+ * Returns the adapter's default codec registry.
16
+ * The registry contains codecs provided by the adapter for converting
17
+ * between wire types and JavaScript types.
18
+ */
19
+ codecs(): CodecRegistry;
20
+ /**
21
+ * Returns the SQL statement to read the contract marker from the database.
22
+ * Each adapter provides target-specific SQL (e.g. schema-qualified table names,
23
+ * parameter placeholder style).
24
+ */
25
+ readMarkerStatement(): MarkerStatement;
26
+ }
27
+ interface LoweredPayload<TBody = unknown> {
28
+ readonly profileId?: string;
29
+ readonly body: TBody;
30
+ readonly annotations?: Record<string, unknown>;
31
+ }
32
+ interface LowererContext<TContract = unknown> {
33
+ readonly contract: TContract;
34
+ readonly params?: readonly unknown[];
35
+ }
36
+ type Lowerer<Ast = unknown, TContract = unknown, TBody = unknown> = (ast: Ast, context: LowererContext<TContract>) => LoweredPayload<TBody>;
37
+ interface Adapter<Ast = unknown, TContract = unknown, TBody = unknown> {
38
+ readonly profile: AdapterProfile;
39
+ lower(ast: Ast, context: LowererContext<TContract>): LoweredPayload<TBody>;
40
+ }
41
+ //#endregion
42
+ //#region src/ast/driver-types.d.ts
43
+ interface SqlExecuteRequest {
44
+ readonly sql: string;
45
+ readonly params?: readonly unknown[];
46
+ }
47
+ interface SqlQueryResult<Row = Record<string, unknown>> {
48
+ readonly rows: ReadonlyArray<Row>;
49
+ readonly rowCount?: number | null;
50
+ readonly [key: string]: unknown;
51
+ }
52
+ interface SqlExplainResult<Row = Record<string, unknown>> {
53
+ readonly rows: ReadonlyArray<Row>;
54
+ }
55
+ type SqlDriverState = 'unbound' | 'connected' | 'closed';
56
+ interface SqlDriver<TBinding = void> extends SqlQueryable {
57
+ readonly state?: SqlDriverState;
58
+ connect(binding: TBinding): Promise<void>;
59
+ acquireConnection(): Promise<SqlConnection>;
60
+ close(): Promise<void>;
61
+ }
62
+ interface SqlConnection extends SqlQueryable {
63
+ beginTransaction(): Promise<SqlTransaction>;
64
+ release(): Promise<void>;
65
+ }
66
+ interface SqlTransaction extends SqlQueryable {
67
+ commit(): Promise<void>;
68
+ rollback(): Promise<void>;
69
+ }
70
+ interface SqlQueryable {
71
+ execute<Row = Record<string, unknown>>(request: SqlExecuteRequest): AsyncIterable<Row>;
72
+ explain?(request: SqlExecuteRequest): Promise<SqlExplainResult>;
73
+ query<Row = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<SqlQueryResult<Row>>;
74
+ }
75
+ //#endregion
76
+ //#region src/ast/sql-codecs.d.ts
77
+ declare const SQL_CHAR_CODEC_ID: "sql/char@1";
78
+ declare const SQL_VARCHAR_CODEC_ID: "sql/varchar@1";
79
+ declare const SQL_INT_CODEC_ID: "sql/int@1";
80
+ declare const SQL_FLOAT_CODEC_ID: "sql/float@1";
81
+ declare const SQL_TEXT_CODEC_ID: "sql/text@1";
82
+ declare const SQL_TIMESTAMP_CODEC_ID: "sql/timestamp@1";
83
+ declare const codecs: CodecDefBuilder<{
84
+ char: Codec<"sql/char@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
85
+ varchar: Codec<"sql/varchar@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
86
+ int: Codec<"sql/int@1", readonly ["equality", "order", "numeric"], number, number, Record<string, unknown>, unknown>;
87
+ float: Codec<"sql/float@1", readonly ["equality", "order", "numeric"], number, number, Record<string, unknown>, unknown>;
88
+ text: Codec<"sql/text@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
89
+ } & Record<"timestamp", Codec<"sql/timestamp@1", readonly ["equality", "order"], string, string, {
90
+ precision?: number;
91
+ }, unknown>>>;
92
+ declare const sqlCodecDefinitions: {
93
+ readonly char: {
94
+ readonly typeId: "sql/char@1";
95
+ readonly scalar: "char";
96
+ readonly codec: Codec<"sql/char@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
97
+ readonly input: string;
98
+ readonly output: string;
99
+ readonly jsType: string;
100
+ };
101
+ readonly varchar: {
102
+ readonly typeId: "sql/varchar@1";
103
+ readonly scalar: "varchar";
104
+ readonly codec: Codec<"sql/varchar@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
105
+ readonly input: string;
106
+ readonly output: string;
107
+ readonly jsType: string;
108
+ };
109
+ readonly int: {
110
+ readonly typeId: "sql/int@1";
111
+ readonly scalar: "int";
112
+ readonly codec: Codec<"sql/int@1", readonly ["equality", "order", "numeric"], number, number, Record<string, unknown>, unknown>;
113
+ readonly input: number;
114
+ readonly output: number;
115
+ readonly jsType: number;
116
+ };
117
+ readonly float: {
118
+ readonly typeId: "sql/float@1";
119
+ readonly scalar: "float";
120
+ readonly codec: Codec<"sql/float@1", readonly ["equality", "order", "numeric"], number, number, Record<string, unknown>, unknown>;
121
+ readonly input: number;
122
+ readonly output: number;
123
+ readonly jsType: number;
124
+ };
125
+ readonly text: {
126
+ readonly typeId: "sql/text@1";
127
+ readonly scalar: "text";
128
+ readonly codec: Codec<"sql/text@1", readonly ["equality", "order", "textual"], string, string, Record<string, unknown>, unknown>;
129
+ readonly input: string;
130
+ readonly output: string;
131
+ readonly jsType: string;
132
+ };
133
+ readonly timestamp: {
134
+ readonly typeId: "sql/timestamp@1";
135
+ readonly scalar: "timestamp";
136
+ readonly codec: Codec<"sql/timestamp@1", readonly ["equality", "order"], string, string, {
137
+ precision?: number;
138
+ }, unknown>;
139
+ readonly input: string;
140
+ readonly output: string;
141
+ readonly jsType: string;
142
+ };
143
+ };
144
+ declare const sqlDataTypes: {
145
+ readonly char: "sql/char@1";
146
+ readonly varchar: "sql/varchar@1";
147
+ readonly int: "sql/int@1";
148
+ readonly float: "sql/float@1";
149
+ readonly text: "sql/text@1";
150
+ readonly timestamp: "sql/timestamp@1";
151
+ };
152
+ type SqlCodecTypes = typeof codecs.CodecTypes;
153
+ //#endregion
154
+ //#region src/ast/util.d.ts
155
+ declare function compact<T extends Record<string, unknown>>(o: T): T;
156
+ //#endregion
157
+ export { Adapter, AdapterProfile, AdapterTarget, AggregateCountFn, AggregateExpr, AggregateFn, AggregateOpFn, AndExpr, AnyExpression, AnyFromSource, AnyInsertOnConflictAction, AnyInsertValue, AnyOperationArg, AnyQueryAst, AstRewriter, BinaryExpr, BinaryOp, Codec, CodecDefBuilder, CodecId, CodecInput, CodecMeta, CodecOutput, CodecParamsDescriptor, CodecRegistry, CodecTrait, CodecTraits, ColumnRef, DefaultValueExpr, DeleteAst, DerivedTableSource, Direction, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExistsExpr, ExprVisitor, ExpressionFolder, ExpressionRewriter, ExpressionSource, ExtractCodecTypes, ExtractDataTypes, IdentifierRef, InsertAst, InsertOnConflict, InsertValue, JoinAst, JoinOnExpr, JsonArrayAggExpr, JsonObjectEntry, JsonObjectExpr, ListExpression, LiteralExpr, LoweredPayload, LoweredStatement, Lowerer, LowererContext, MarkerStatement, NotExpr, NullCheckExpr, OperationExpr, OrExpr, OrderByItem, ParamRef, ProjectionExpr, ProjectionItem, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_TIMESTAMP_CODEC_ID, SQL_VARCHAR_CODEC_ID, SelectAst, SelectAstOptions, SqlCodecTypes, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlQueryResult, SqlQueryable, SqlTransaction, SubqueryExpr, TableRef, TableSource, ToWhereExpr, UpdateAst, WhereArg, codec, compact, createCodecRegistry, defineCodecs, isQueryAst, isWhereExpr, queryAstKinds, sqlCodecDefinitions, sqlDataTypes, whereExprKinds };
158
+ //# sourceMappingURL=ast.d.mts.map