opfsql 0.0.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 (270) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +198 -0
  3. package/dist/binder/core/context.d.ts +15 -0
  4. package/dist/binder/core/errors.d.ts +4 -0
  5. package/dist/binder/core/helpers.d.ts +6 -0
  6. package/dist/binder/core/operators.d.ts +12 -0
  7. package/dist/binder/core/plan-utils.d.ts +4 -0
  8. package/dist/binder/core/scope.d.ts +34 -0
  9. package/dist/binder/core/type-check.d.ts +5 -0
  10. package/dist/binder/core/type-map.d.ts +8 -0
  11. package/dist/binder/core/utils/eval-constant.d.ts +4 -0
  12. package/dist/binder/core/utils/extract-columns.d.ts +4 -0
  13. package/dist/binder/core/utils/find-column.d.ts +4 -0
  14. package/dist/binder/core/utils/require-table.d.ts +3 -0
  15. package/dist/binder/expression/aggregate.d.ts +11 -0
  16. package/dist/binder/expression/between.d.ts +5 -0
  17. package/dist/binder/expression/case.d.ts +5 -0
  18. package/dist/binder/expression/cast.d.ts +5 -0
  19. package/dist/binder/expression/column-ref.d.ts +5 -0
  20. package/dist/binder/expression/comparison.d.ts +5 -0
  21. package/dist/binder/expression/conjunction.d.ts +5 -0
  22. package/dist/binder/expression/constant.d.ts +3 -0
  23. package/dist/binder/expression/function.d.ts +5 -0
  24. package/dist/binder/expression/index.d.ts +5 -0
  25. package/dist/binder/expression/operator.d.ts +5 -0
  26. package/dist/binder/expression/parameter.d.ts +4 -0
  27. package/dist/binder/expression/same-expression.d.ts +3 -0
  28. package/dist/binder/expression/star.d.ts +5 -0
  29. package/dist/binder/expression/subquery.d.ts +5 -0
  30. package/dist/binder/index.d.ts +30 -0
  31. package/dist/binder/statement/alter-table.d.ts +4 -0
  32. package/dist/binder/statement/create-index.d.ts +4 -0
  33. package/dist/binder/statement/create-table.d.ts +4 -0
  34. package/dist/binder/statement/cte.d.ts +16 -0
  35. package/dist/binder/statement/delete.d.ts +4 -0
  36. package/dist/binder/statement/drop.d.ts +3 -0
  37. package/dist/binder/statement/insert.d.ts +4 -0
  38. package/dist/binder/statement/query-node.d.ts +5 -0
  39. package/dist/binder/statement/select.d.ts +5 -0
  40. package/dist/binder/statement/set-operation.d.ts +5 -0
  41. package/dist/binder/statement/update.d.ts +4 -0
  42. package/dist/binder/table-ref/base-table.d.ts +5 -0
  43. package/dist/binder/table-ref/index.d.ts +5 -0
  44. package/dist/binder/table-ref/join.d.ts +6 -0
  45. package/dist/binder/table-ref/subquery.d.ts +5 -0
  46. package/dist/binder/tests/aggregates.test.d.ts +1 -0
  47. package/dist/binder/tests/binder.test.d.ts +1 -0
  48. package/dist/binder/tests/cte.test.d.ts +1 -0
  49. package/dist/binder/tests/ddl.test.d.ts +1 -0
  50. package/dist/binder/tests/dml.test.d.ts +1 -0
  51. package/dist/binder/tests/expressions.test.d.ts +1 -0
  52. package/dist/binder/tests/join.test.d.ts +1 -0
  53. package/dist/binder/tests/misc.test.d.ts +1 -0
  54. package/dist/binder/tests/select.test.d.ts +1 -0
  55. package/dist/binder/tests/subquery.test.d.ts +1 -0
  56. package/dist/binder/tests/test_helpers.d.ts +14 -0
  57. package/dist/binder/tests/union.test.d.ts +1 -0
  58. package/dist/binder/tests/utils.test.d.ts +1 -0
  59. package/dist/binder/types.d.ts +401 -0
  60. package/dist/engine/engine.d.ts +23 -0
  61. package/dist/engine/explain.d.ts +3 -0
  62. package/dist/engine/index.d.ts +3 -0
  63. package/dist/engine/session.d.ts +43 -0
  64. package/dist/engine/tests/engine.test.d.ts +1 -0
  65. package/dist/engine/tests/explain-format.test.d.ts +1 -0
  66. package/dist/engine/tests/explain.test.d.ts +1 -0
  67. package/dist/engine/tests/session.test.d.ts +1 -0
  68. package/dist/engine/types.d.ts +19 -0
  69. package/dist/executor/ddl/alter-drop.d.ts +5 -0
  70. package/dist/executor/ddl/create.d.ts +5 -0
  71. package/dist/executor/ddl/index.d.ts +2 -0
  72. package/dist/executor/ddl.d.ts +8 -0
  73. package/dist/executor/dml/delete.d.ts +5 -0
  74. package/dist/executor/dml/index.d.ts +3 -0
  75. package/dist/executor/dml/insert.d.ts +5 -0
  76. package/dist/executor/dml/update.d.ts +5 -0
  77. package/dist/executor/dml/utils/coerce.d.ts +3 -0
  78. package/dist/executor/dml/utils/index-maintenance.d.ts +5 -0
  79. package/dist/executor/dml/utils/scan.d.ts +16 -0
  80. package/dist/executor/dml.d.ts +8 -0
  81. package/dist/executor/errors.d.ts +4 -0
  82. package/dist/executor/evaluate/aggregate.d.ts +4 -0
  83. package/dist/executor/evaluate/between.d.ts +5 -0
  84. package/dist/executor/evaluate/case.d.ts +5 -0
  85. package/dist/executor/evaluate/cast.d.ts +5 -0
  86. package/dist/executor/evaluate/column-ref.d.ts +5 -0
  87. package/dist/executor/evaluate/comparison.d.ts +5 -0
  88. package/dist/executor/evaluate/compile.d.ts +11 -0
  89. package/dist/executor/evaluate/conjunction.d.ts +5 -0
  90. package/dist/executor/evaluate/context.d.ts +9 -0
  91. package/dist/executor/evaluate/function.d.ts +5 -0
  92. package/dist/executor/evaluate/functions/md5.d.ts +1 -0
  93. package/dist/executor/evaluate/functions/normalize-json.d.ts +8 -0
  94. package/dist/executor/evaluate/helpers.d.ts +14 -0
  95. package/dist/executor/evaluate/index.d.ts +6 -0
  96. package/dist/executor/evaluate/json-access.d.ts +7 -0
  97. package/dist/executor/evaluate/operator.d.ts +5 -0
  98. package/dist/executor/evaluate/parameter.d.ts +4 -0
  99. package/dist/executor/evaluate/subquery.d.ts +5 -0
  100. package/dist/executor/evaluate/utils/cast.d.ts +7 -0
  101. package/dist/executor/evaluate/utils/compare.d.ts +8 -0
  102. package/dist/executor/evaluate/utils/like.d.ts +2 -0
  103. package/dist/executor/evaluate/utils/serialize.d.ts +3 -0
  104. package/dist/executor/execute/index.d.ts +4 -0
  105. package/dist/executor/execute/result.d.ts +5 -0
  106. package/dist/executor/execute/select.d.ts +8 -0
  107. package/dist/executor/executor.d.ts +5 -0
  108. package/dist/executor/index.d.ts +3 -0
  109. package/dist/executor/operators/aggregate.d.ts +22 -0
  110. package/dist/executor/operators/cte.d.ts +37 -0
  111. package/dist/executor/operators/filter.d.ts +13 -0
  112. package/dist/executor/operators/index-min-max.d.ts +18 -0
  113. package/dist/executor/operators/index-scan.d.ts +22 -0
  114. package/dist/executor/operators/index-union-scan.d.ts +22 -0
  115. package/dist/executor/operators/join.d.ts +36 -0
  116. package/dist/executor/operators/limit.d.ts +13 -0
  117. package/dist/executor/operators/projection.d.ts +14 -0
  118. package/dist/executor/operators/scan.d.ts +29 -0
  119. package/dist/executor/operators/set.d.ts +22 -0
  120. package/dist/executor/operators/sort.d.ts +18 -0
  121. package/dist/executor/operators/utils.d.ts +10 -0
  122. package/dist/executor/planner/index.d.ts +5 -0
  123. package/dist/executor/planner/plan-aggregate.d.ts +5 -0
  124. package/dist/executor/planner/plan-cte.d.ts +6 -0
  125. package/dist/executor/planner/plan-filter.d.ts +4 -0
  126. package/dist/executor/planner/plan-get.d.ts +6 -0
  127. package/dist/executor/planner/plan-join.d.ts +5 -0
  128. package/dist/executor/planner/plan-limit.d.ts +4 -0
  129. package/dist/executor/planner/plan-order-by.d.ts +4 -0
  130. package/dist/executor/planner/plan-projection.d.ts +4 -0
  131. package/dist/executor/planner/plan-set.d.ts +5 -0
  132. package/dist/executor/planner/types.d.ts +12 -0
  133. package/dist/executor/planner.d.ts +5 -0
  134. package/dist/executor/resolve.d.ts +3 -0
  135. package/dist/executor/tests/compile.test.d.ts +1 -0
  136. package/dist/executor/tests/ddl-dml.test.d.ts +1 -0
  137. package/dist/executor/tests/evaluate.test.d.ts +1 -0
  138. package/dist/executor/tests/executor.test.d.ts +1 -0
  139. package/dist/executor/tests/functions.test.d.ts +1 -0
  140. package/dist/executor/tests/helpers.d.ts +34 -0
  141. package/dist/executor/tests/index-min-max.test.d.ts +1 -0
  142. package/dist/executor/tests/index-scan.test.d.ts +1 -0
  143. package/dist/executor/tests/index-union-scan.test.d.ts +1 -0
  144. package/dist/executor/tests/operators.test.d.ts +1 -0
  145. package/dist/executor/tests/planner.test.d.ts +1 -0
  146. package/dist/executor/tests/scan.test.d.ts +1 -0
  147. package/dist/executor/types.d.ts +39 -0
  148. package/dist/index.d.ts +3 -0
  149. package/dist/index.js +5 -0
  150. package/dist/optimizer/build_probe_side.d.ts +2 -0
  151. package/dist/optimizer/decorrelate_exists.d.ts +2 -0
  152. package/dist/optimizer/expression_rewriter.d.ts +2 -0
  153. package/dist/optimizer/filter_combiner.d.ts +13 -0
  154. package/dist/optimizer/filter_pullup.d.ts +2 -0
  155. package/dist/optimizer/filter_pushdown.d.ts +2 -0
  156. package/dist/optimizer/in_clause_rewriter.d.ts +2 -0
  157. package/dist/optimizer/index.d.ts +15 -0
  158. package/dist/optimizer/index_selection.d.ts +3 -0
  159. package/dist/optimizer/join_order.d.ts +2 -0
  160. package/dist/optimizer/limit_pushdown.d.ts +2 -0
  161. package/dist/optimizer/remove_unused_columns.d.ts +2 -0
  162. package/dist/optimizer/reorder_filter.d.ts +4 -0
  163. package/dist/optimizer/tests/build_probe_side.test.d.ts +1 -0
  164. package/dist/optimizer/tests/decorrelate_exists.test.d.ts +1 -0
  165. package/dist/optimizer/tests/expression_rewriter.test.d.ts +1 -0
  166. package/dist/optimizer/tests/filter_combiner.test.d.ts +1 -0
  167. package/dist/optimizer/tests/filter_pullup.test.d.ts +1 -0
  168. package/dist/optimizer/tests/filter_pushdown.test.d.ts +1 -0
  169. package/dist/optimizer/tests/full_pipeline.test.d.ts +1 -0
  170. package/dist/optimizer/tests/in_clause_rewriter.test.d.ts +1 -0
  171. package/dist/optimizer/tests/index_selection.test.d.ts +1 -0
  172. package/dist/optimizer/tests/join_order.test.d.ts +1 -0
  173. package/dist/optimizer/tests/limit_pushdown.test.d.ts +1 -0
  174. package/dist/optimizer/tests/optimizer.test.d.ts +1 -0
  175. package/dist/optimizer/tests/remove_unused_columns.test.d.ts +1 -0
  176. package/dist/optimizer/tests/reorder_filter.test.d.ts +1 -0
  177. package/dist/optimizer/tests/test_helpers.d.ts +27 -0
  178. package/dist/optimizer/tests/utils.test.d.ts +1 -0
  179. package/dist/optimizer/utils/collect_column_refs.d.ts +2 -0
  180. package/dist/optimizer/utils/expression_key.d.ts +7 -0
  181. package/dist/optimizer/utils/expression_references_table.d.ts +2 -0
  182. package/dist/optimizer/utils/expressions_equal.d.ts +1 -0
  183. package/dist/optimizer/utils/flatten_conjunction.d.ts +2 -0
  184. package/dist/optimizer/utils/flip_comparison.d.ts +2 -0
  185. package/dist/optimizer/utils/get_expression_tables.d.ts +2 -0
  186. package/dist/optimizer/utils/get_operator_tables.d.ts +2 -0
  187. package/dist/optimizer/utils/index.d.ts +23 -0
  188. package/dist/optimizer/utils/is_column_ref.d.ts +2 -0
  189. package/dist/optimizer/utils/is_comparison.d.ts +2 -0
  190. package/dist/optimizer/utils/is_conjunction.d.ts +2 -0
  191. package/dist/optimizer/utils/is_constant.d.ts +2 -0
  192. package/dist/optimizer/utils/is_foldable.d.ts +2 -0
  193. package/dist/optimizer/utils/is_numeric_type.d.ts +2 -0
  194. package/dist/optimizer/utils/is_operator.d.ts +2 -0
  195. package/dist/optimizer/utils/is_parameter.d.ts +2 -0
  196. package/dist/optimizer/utils/make_bool_constant.d.ts +2 -0
  197. package/dist/optimizer/utils/make_conjunction.d.ts +2 -0
  198. package/dist/optimizer/utils/make_constant.d.ts +2 -0
  199. package/dist/optimizer/utils/make_null_constant.d.ts +2 -0
  200. package/dist/optimizer/utils/map_expression.d.ts +2 -0
  201. package/dist/optimizer/utils/map_operator_expressions.d.ts +2 -0
  202. package/dist/optimizer/utils/negate_comparison.d.ts +2 -0
  203. package/dist/parser/index.d.ts +3 -0
  204. package/dist/parser/lexer.d.ts +24 -0
  205. package/dist/parser/parser/base.d.ts +17 -0
  206. package/dist/parser/parser/ddl.d.ts +5 -0
  207. package/dist/parser/parser/dml.d.ts +5 -0
  208. package/dist/parser/parser/expressions.d.ts +5 -0
  209. package/dist/parser/parser/index.d.ts +7 -0
  210. package/dist/parser/parser/select.d.ts +3 -0
  211. package/dist/parser/parser/tcl.d.ts +3 -0
  212. package/dist/parser/parser/type-parser.d.ts +3 -0
  213. package/dist/parser/tests/lexer.test.d.ts +1 -0
  214. package/dist/parser/tests/parser.test.d.ts +1 -0
  215. package/dist/parser/types.d.ts +482 -0
  216. package/dist/store/backend/memory-storage.d.ts +16 -0
  217. package/dist/store/backend/node-storage.d.ts +33 -0
  218. package/dist/store/backend/opfs-storage.d.ts +39 -0
  219. package/dist/store/btree/btree.d.ts +48 -0
  220. package/dist/store/btree/compare.d.ts +13 -0
  221. package/dist/store/btree/search-bounds.d.ts +15 -0
  222. package/dist/store/btree/types.d.ts +33 -0
  223. package/dist/store/cache.d.ts +17 -0
  224. package/dist/store/catalog.d.ts +24 -0
  225. package/dist/store/errors.d.ts +5 -0
  226. package/dist/store/index-btree/compare.d.ts +3 -0
  227. package/dist/store/index-btree/index-btree.d.ts +53 -0
  228. package/dist/store/index-btree/search-bounds.d.ts +7 -0
  229. package/dist/store/index-btree/types.d.ts +27 -0
  230. package/dist/store/index-expression.d.ts +5 -0
  231. package/dist/store/index-manager.d.ts +23 -0
  232. package/dist/store/index.d.ts +10 -0
  233. package/dist/store/memory-storage.d.ts +13 -0
  234. package/dist/store/opfs/opfs-storage.d.ts +15 -0
  235. package/dist/store/opfs-storage.d.ts +44 -0
  236. package/dist/store/page-manager.d.ts +19 -0
  237. package/dist/store/row-manager.d.ts +15 -0
  238. package/dist/store/session-store.d.ts +20 -0
  239. package/dist/store/storage/memory-storage.d.ts +11 -0
  240. package/dist/store/storage/opfs-storage.d.ts +15 -0
  241. package/dist/store/storage.d.ts +28 -0
  242. package/dist/store/table-btree.d.ts +48 -0
  243. package/dist/store/table-manager.d.ts +17 -0
  244. package/dist/store/tests/btree.test.d.ts +1 -0
  245. package/dist/store/tests/catalog.test.d.ts +1 -0
  246. package/dist/store/tests/compare.test.d.ts +1 -0
  247. package/dist/store/tests/index-btree.test.d.ts +1 -0
  248. package/dist/store/tests/index-expression.test.d.ts +1 -0
  249. package/dist/store/tests/index-manager.test.d.ts +1 -0
  250. package/dist/store/tests/lru-cache.test.d.ts +1 -0
  251. package/dist/store/tests/memory-storage.d.ts +15 -0
  252. package/dist/store/tests/opfs-storage.test.d.ts +1 -0
  253. package/dist/store/tests/page-manager.test.d.ts +1 -0
  254. package/dist/store/tests/row-manager.test.d.ts +1 -0
  255. package/dist/store/tests/search-bounds.test.d.ts +1 -0
  256. package/dist/store/tests/storage.test.d.ts +1 -0
  257. package/dist/store/tests/table-btree.test.d.ts +1 -0
  258. package/dist/store/tests/vacuum.test.d.ts +1 -0
  259. package/dist/store/tests/wal-storage.test.d.ts +1 -0
  260. package/dist/store/types.d.ts +75 -0
  261. package/dist/store/vacuum.d.ts +12 -0
  262. package/dist/store/wal/crc32.d.ts +1 -0
  263. package/dist/store/wal/file-handle.d.ts +34 -0
  264. package/dist/store/wal/wal-storage.d.ts +50 -0
  265. package/dist/types.d.ts +87 -0
  266. package/dist/worker/client.d.ts +36 -0
  267. package/dist/worker/index.d.ts +1 -0
  268. package/dist/worker/protocol.d.ts +59 -0
  269. package/dist/worker/worker.d.ts +1 -0
  270. package/package.json +55 -0
@@ -0,0 +1,482 @@
1
+ export declare enum TokenType {
2
+ INTEGER_LITERAL = 0,
3
+ FLOAT_LITERAL = 1,
4
+ STRING_LITERAL = 2,
5
+ BLOB_LITERAL = 3,
6
+ PARAMETER = 4,
7
+ IDENTIFIER = 5,
8
+ QUOTED_IDENTIFIER = 6,
9
+ EQUALS = 7,
10
+ NOT_EQUALS = 8,
11
+ LESS_THAN = 9,
12
+ LESS_THAN_EQUAL = 10,
13
+ GREATER_THAN = 11,
14
+ GREATER_THAN_EQUAL = 12,
15
+ PLUS = 13,
16
+ MINUS = 14,
17
+ STAR = 15,
18
+ SLASH = 16,
19
+ PERCENT = 17,
20
+ PIPE_PIPE = 18,
21
+ LEFT_PAREN = 19,
22
+ RIGHT_PAREN = 20,
23
+ LEFT_BRACKET = 21,
24
+ RIGHT_BRACKET = 22,
25
+ COMMA = 23,
26
+ SEMICOLON = 24,
27
+ DOT = 25,
28
+ SELECT = 26,
29
+ FROM = 27,
30
+ WHERE = 28,
31
+ JOIN = 29,
32
+ LEFT = 30,
33
+ RIGHT = 31,
34
+ INNER = 32,
35
+ OUTER = 33,
36
+ CROSS = 34,
37
+ ON = 35,
38
+ USING = 36,
39
+ AS = 37,
40
+ DISTINCT = 38,
41
+ ALL = 39,
42
+ GROUP = 40,
43
+ BY = 41,
44
+ HAVING = 42,
45
+ ORDER = 43,
46
+ ASC = 44,
47
+ DESC = 45,
48
+ NULLS = 46,
49
+ FIRST = 47,
50
+ LAST = 48,
51
+ LIMIT = 49,
52
+ OFFSET = 50,
53
+ UNION = 51,
54
+ INSERT = 52,
55
+ INTO = 53,
56
+ VALUES = 54,
57
+ UPDATE = 55,
58
+ SET = 56,
59
+ DELETE = 57,
60
+ CREATE = 58,
61
+ TABLE = 59,
62
+ INDEX = 60,
63
+ UNIQUE = 61,
64
+ IF = 62,
65
+ NOT = 63,
66
+ EXISTS = 64,
67
+ ALTER = 65,
68
+ ADD = 66,
69
+ DROP = 67,
70
+ COLUMN = 68,
71
+ BEGIN = 69,
72
+ COMMIT = 70,
73
+ ROLLBACK = 71,
74
+ TRANSACTION = 72,
75
+ WITH = 73,
76
+ AND = 74,
77
+ OR = 75,
78
+ IN = 76,
79
+ BETWEEN = 77,
80
+ LIKE = 78,
81
+ IS = 79,
82
+ NULL_KW = 80,
83
+ PRIMARY = 81,
84
+ KEY = 82,
85
+ FOREIGN = 83,
86
+ REFERENCES = 84,
87
+ DEFAULT = 85,
88
+ CASE = 86,
89
+ WHEN = 87,
90
+ THEN = 88,
91
+ ELSE = 89,
92
+ END = 90,
93
+ CAST = 91,
94
+ TRUE_KW = 92,
95
+ FALSE_KW = 93,
96
+ CONFLICT = 94,
97
+ DO = 95,
98
+ NOTHING = 96,
99
+ EXCLUDED = 97,
100
+ AUTOINCREMENT = 98,
101
+ EXPLAIN = 99,
102
+ INTEGER_KW = 100,
103
+ INT_KW = 101,
104
+ BIGINT_KW = 102,
105
+ SMALLINT_KW = 103,
106
+ REAL_KW = 104,
107
+ FLOAT_KW = 105,
108
+ DOUBLE_KW = 106,
109
+ TEXT_KW = 107,
110
+ VARCHAR_KW = 108,
111
+ CHAR_KW = 109,
112
+ BLOB_KW = 110,
113
+ BOOLEAN_KW = 111,
114
+ BOOL_KW = 112,
115
+ JSON_KW = 113,
116
+ EOF = 114
117
+ }
118
+ export interface Token {
119
+ type: TokenType;
120
+ value: string;
121
+ line: number;
122
+ column: number;
123
+ }
124
+ export declare enum LogicalTypeId {
125
+ INTEGER = "INTEGER",
126
+ BIGINT = "BIGINT",
127
+ SMALLINT = "SMALLINT",
128
+ FLOAT = "FLOAT",
129
+ DOUBLE = "DOUBLE",
130
+ VARCHAR = "VARCHAR",
131
+ BLOB = "BLOB",
132
+ BOOLEAN = "BOOLEAN",
133
+ JSON = "JSON"
134
+ }
135
+ export interface LogicalType {
136
+ id: LogicalTypeId;
137
+ }
138
+ export interface Value {
139
+ type: LogicalType;
140
+ is_null: boolean;
141
+ value: string | number | boolean | Uint8Array | Record<string, unknown> | unknown[] | null;
142
+ }
143
+ import type { JsonPathSegment } from '../types.js';
144
+ export type { JsonPathSegment };
145
+ export declare enum ExpressionClass {
146
+ COLUMN_REF = "COLUMN_REF",
147
+ CONSTANT = "CONSTANT",
148
+ PARAMETER = "PARAMETER",
149
+ COMPARISON = "COMPARISON",
150
+ CONJUNCTION = "CONJUNCTION",
151
+ OPERATOR = "OPERATOR",
152
+ BETWEEN = "BETWEEN",
153
+ FUNCTION = "FUNCTION",
154
+ SUBQUERY = "SUBQUERY",
155
+ CASE = "CASE",
156
+ CAST = "CAST",
157
+ STAR = "STAR"
158
+ }
159
+ export declare enum ExpressionType {
160
+ COMPARE_EQUAL = "COMPARE_EQUAL",
161
+ COMPARE_NOTEQUAL = "COMPARE_NOTEQUAL",
162
+ COMPARE_LESSTHAN = "COMPARE_LESSTHAN",
163
+ COMPARE_LESSTHANOREQUALTO = "COMPARE_LESSTHANOREQUALTO",
164
+ COMPARE_GREATERTHAN = "COMPARE_GREATERTHAN",
165
+ COMPARE_GREATERTHANOREQUALTO = "COMPARE_GREATERTHANOREQUALTO",
166
+ CONJUNCTION_AND = "CONJUNCTION_AND",
167
+ CONJUNCTION_OR = "CONJUNCTION_OR",
168
+ OPERATOR_NOT = "OPERATOR_NOT",
169
+ OPERATOR_IS_NULL = "OPERATOR_IS_NULL",
170
+ OPERATOR_IS_NOT_NULL = "OPERATOR_IS_NOT_NULL",
171
+ OPERATOR_IN = "OPERATOR_IN",
172
+ OPERATOR_NOT_IN = "OPERATOR_NOT_IN",
173
+ COMPARE_LIKE = "COMPARE_LIKE",
174
+ COMPARE_NOT_LIKE = "COMPARE_NOT_LIKE",
175
+ OPERATOR_ADD = "OPERATOR_ADD",
176
+ OPERATOR_SUBTRACT = "OPERATOR_SUBTRACT",
177
+ OPERATOR_MULTIPLY = "OPERATOR_MULTIPLY",
178
+ OPERATOR_DIVIDE = "OPERATOR_DIVIDE",
179
+ OPERATOR_MOD = "OPERATOR_MOD",
180
+ OPERATOR_NEGATE = "OPERATOR_NEGATE",
181
+ OPERATOR_CONCAT = "OPERATOR_CONCAT"
182
+ }
183
+ export interface ColumnRefExpression {
184
+ expression_class: ExpressionClass.COLUMN_REF;
185
+ alias: string | null;
186
+ column_names: string[];
187
+ path?: JsonPathSegment[];
188
+ }
189
+ export interface ConstantExpression {
190
+ expression_class: ExpressionClass.CONSTANT;
191
+ alias: string | null;
192
+ value: Value;
193
+ }
194
+ /** $1-based parameter placeholder. index is 0-based internally. */
195
+ export interface ParameterExpression {
196
+ expression_class: ExpressionClass.PARAMETER;
197
+ alias: string | null;
198
+ index: number;
199
+ }
200
+ export interface ComparisonExpression {
201
+ expression_class: ExpressionClass.COMPARISON;
202
+ alias: string | null;
203
+ type: ExpressionType;
204
+ left: ParsedExpression;
205
+ right: ParsedExpression;
206
+ }
207
+ export interface ConjunctionExpression {
208
+ expression_class: ExpressionClass.CONJUNCTION;
209
+ alias: string | null;
210
+ type: ExpressionType;
211
+ children: ParsedExpression[];
212
+ }
213
+ export interface OperatorExpression {
214
+ expression_class: ExpressionClass.OPERATOR;
215
+ alias: string | null;
216
+ type: ExpressionType;
217
+ children: ParsedExpression[];
218
+ }
219
+ export interface BetweenExpression {
220
+ expression_class: ExpressionClass.BETWEEN;
221
+ alias: string | null;
222
+ input: ParsedExpression;
223
+ lower: ParsedExpression;
224
+ upper: ParsedExpression;
225
+ }
226
+ export interface FunctionExpression {
227
+ expression_class: ExpressionClass.FUNCTION;
228
+ alias: string | null;
229
+ function_name: string;
230
+ children: ParsedExpression[];
231
+ distinct: boolean;
232
+ is_star: boolean;
233
+ }
234
+ export interface SubqueryExpression {
235
+ expression_class: ExpressionClass.SUBQUERY;
236
+ alias: string | null;
237
+ subquery_type: 'SCALAR' | 'EXISTS' | 'NOT_EXISTS' | 'ANY' | 'ALL';
238
+ subquery: SelectStatement;
239
+ child: ParsedExpression | null;
240
+ comparison_type?: ExpressionType;
241
+ }
242
+ export interface CaseExpression {
243
+ expression_class: ExpressionClass.CASE;
244
+ alias: string | null;
245
+ case_checks: Array<{
246
+ when_expr: ParsedExpression;
247
+ then_expr: ParsedExpression;
248
+ }>;
249
+ else_expr: ParsedExpression | null;
250
+ }
251
+ export interface CastExpression {
252
+ expression_class: ExpressionClass.CAST;
253
+ alias: string | null;
254
+ child: ParsedExpression;
255
+ cast_type: LogicalType;
256
+ }
257
+ export interface StarExpression {
258
+ expression_class: ExpressionClass.STAR;
259
+ alias: string | null;
260
+ table_name: string | null;
261
+ }
262
+ export type ParsedExpression = ColumnRefExpression | ConstantExpression | ParameterExpression | ComparisonExpression | ConjunctionExpression | OperatorExpression | BetweenExpression | FunctionExpression | SubqueryExpression | CaseExpression | CastExpression | StarExpression;
263
+ export declare enum TableRefType {
264
+ BASE_TABLE = "BASE_TABLE",
265
+ JOIN = "JOIN",
266
+ SUBQUERY = "SUBQUERY"
267
+ }
268
+ export declare enum JoinType {
269
+ INNER = "INNER",
270
+ LEFT = "LEFT",
271
+ RIGHT = "RIGHT",
272
+ CROSS = "CROSS"
273
+ }
274
+ export interface BaseTableRef {
275
+ type: TableRefType.BASE_TABLE;
276
+ table_name: string;
277
+ alias: string | null;
278
+ schema_name: string | null;
279
+ }
280
+ export interface JoinRef {
281
+ type: TableRefType.JOIN;
282
+ left: TableRef;
283
+ right: TableRef;
284
+ condition: ParsedExpression | null;
285
+ join_type: JoinType;
286
+ using_columns: string[];
287
+ }
288
+ export interface SubqueryRef {
289
+ type: TableRefType.SUBQUERY;
290
+ subquery: SelectStatement;
291
+ alias: string | null;
292
+ column_name_alias: string[];
293
+ }
294
+ export type TableRef = BaseTableRef | JoinRef | SubqueryRef;
295
+ export declare enum ResultModifierType {
296
+ ORDER_MODIFIER = "ORDER_MODIFIER",
297
+ LIMIT_MODIFIER = "LIMIT_MODIFIER",
298
+ DISTINCT_MODIFIER = "DISTINCT_MODIFIER"
299
+ }
300
+ export declare enum OrderType {
301
+ ASCENDING = "ASCENDING",
302
+ DESCENDING = "DESCENDING"
303
+ }
304
+ export declare enum OrderByNullType {
305
+ NULLS_FIRST = "NULLS_FIRST",
306
+ NULLS_LAST = "NULLS_LAST"
307
+ }
308
+ export interface OrderByNode {
309
+ type: OrderType;
310
+ null_order: OrderByNullType;
311
+ expression: ParsedExpression;
312
+ }
313
+ export interface OrderModifier {
314
+ type: ResultModifierType.ORDER_MODIFIER;
315
+ orders: OrderByNode[];
316
+ }
317
+ export interface LimitModifier {
318
+ type: ResultModifierType.LIMIT_MODIFIER;
319
+ limit: ParsedExpression | null;
320
+ offset: ParsedExpression | null;
321
+ }
322
+ export interface DistinctModifier {
323
+ type: ResultModifierType.DISTINCT_MODIFIER;
324
+ distinct_on_targets: ParsedExpression[];
325
+ }
326
+ export type ResultModifier = OrderModifier | LimitModifier | DistinctModifier;
327
+ export interface GroupByNode {
328
+ group_expressions: ParsedExpression[];
329
+ }
330
+ export interface CTENode {
331
+ query: SelectStatement;
332
+ aliases: string[];
333
+ }
334
+ export interface CTEMap {
335
+ map: Record<string, CTENode>;
336
+ recursive: boolean;
337
+ }
338
+ export interface SelectNode {
339
+ type: 'SELECT_NODE';
340
+ select_list: ParsedExpression[];
341
+ from_table: TableRef | null;
342
+ where_clause: ParsedExpression | null;
343
+ groups: GroupByNode;
344
+ having: ParsedExpression | null;
345
+ modifiers: ResultModifier[];
346
+ cte_map: CTEMap;
347
+ }
348
+ export declare enum StatementType {
349
+ SELECT_STATEMENT = "SELECT_STATEMENT",
350
+ INSERT_STATEMENT = "INSERT_STATEMENT",
351
+ UPDATE_STATEMENT = "UPDATE_STATEMENT",
352
+ DELETE_STATEMENT = "DELETE_STATEMENT",
353
+ CREATE_TABLE_STATEMENT = "CREATE_TABLE_STATEMENT",
354
+ CREATE_INDEX_STATEMENT = "CREATE_INDEX_STATEMENT",
355
+ ALTER_TABLE_STATEMENT = "ALTER_TABLE_STATEMENT",
356
+ DROP_STATEMENT = "DROP_STATEMENT",
357
+ TRANSACTION_STATEMENT = "TRANSACTION_STATEMENT",
358
+ EXPLAIN_STATEMENT = "EXPLAIN_STATEMENT"
359
+ }
360
+ export interface SelectStatement {
361
+ type: StatementType.SELECT_STATEMENT;
362
+ node: SelectNode | SetOperationNode;
363
+ }
364
+ export declare enum SetOperationType {
365
+ UNION = "UNION",
366
+ UNION_ALL = "UNION_ALL"
367
+ }
368
+ export interface SetOperationNode {
369
+ type: 'SET_OPERATION_NODE';
370
+ set_op_type: SetOperationType;
371
+ left: SelectNode | SetOperationNode;
372
+ right: SelectNode;
373
+ modifiers: ResultModifier[];
374
+ cte_map: CTEMap;
375
+ }
376
+ export interface SetOperationStatement {
377
+ type: StatementType.SELECT_STATEMENT;
378
+ node: SetOperationNode;
379
+ }
380
+ export interface ColumnDefinition {
381
+ name: string;
382
+ type: LogicalType;
383
+ is_primary_key: boolean;
384
+ is_not_null: boolean;
385
+ is_unique: boolean;
386
+ is_autoincrement: boolean;
387
+ default_value: ParsedExpression | null;
388
+ }
389
+ export interface ForeignKeyConstraint {
390
+ columns: string[];
391
+ ref_table: string;
392
+ ref_columns: string[];
393
+ }
394
+ export interface OnConflictUpdate {
395
+ type: 'UPDATE';
396
+ setClauses: UpdateSetClause[];
397
+ whereClause: ParsedExpression | null;
398
+ }
399
+ export interface OnConflictClause {
400
+ conflictTarget: string[] | null;
401
+ action: 'NOTHING' | OnConflictUpdate;
402
+ }
403
+ export interface InsertStatement {
404
+ type: StatementType.INSERT_STATEMENT;
405
+ table: string;
406
+ columns: string[];
407
+ values: ParsedExpression[][];
408
+ select_statement: SelectStatement | null;
409
+ onConflict: OnConflictClause | null;
410
+ }
411
+ export interface UpdateSetClause {
412
+ column: string;
413
+ value: ParsedExpression;
414
+ }
415
+ export interface UpdateStatement {
416
+ type: StatementType.UPDATE_STATEMENT;
417
+ table: string;
418
+ set_clauses: UpdateSetClause[];
419
+ where_clause: ParsedExpression | null;
420
+ }
421
+ export interface DeleteStatement {
422
+ type: StatementType.DELETE_STATEMENT;
423
+ table: string;
424
+ where_clause: ParsedExpression | null;
425
+ }
426
+ export interface CreateTableStatement {
427
+ type: StatementType.CREATE_TABLE_STATEMENT;
428
+ table: string;
429
+ if_not_exists: boolean;
430
+ columns: ColumnDefinition[];
431
+ primary_key: string[];
432
+ foreign_keys: ForeignKeyConstraint[];
433
+ }
434
+ export interface CreateIndexStatement {
435
+ type: StatementType.CREATE_INDEX_STATEMENT;
436
+ index_name: string;
437
+ table_name: string;
438
+ expressions: ParsedExpression[];
439
+ is_unique: boolean;
440
+ if_not_exists: boolean;
441
+ }
442
+ export declare enum AlterType {
443
+ ADD_COLUMN = "ADD_COLUMN",
444
+ DROP_COLUMN = "DROP_COLUMN"
445
+ }
446
+ export interface AlterTableStatement {
447
+ type: StatementType.ALTER_TABLE_STATEMENT;
448
+ table: string;
449
+ alter_type: AlterType;
450
+ column_def: ColumnDefinition | null;
451
+ column_name: string | null;
452
+ }
453
+ export declare enum DropType {
454
+ TABLE = "TABLE",
455
+ INDEX = "INDEX"
456
+ }
457
+ export interface DropStatement {
458
+ type: StatementType.DROP_STATEMENT;
459
+ drop_type: DropType;
460
+ name: string;
461
+ if_exists: boolean;
462
+ }
463
+ export declare enum TransactionType {
464
+ BEGIN = "BEGIN",
465
+ COMMIT = "COMMIT",
466
+ ROLLBACK = "ROLLBACK"
467
+ }
468
+ export interface TransactionStatement {
469
+ type: StatementType.TRANSACTION_STATEMENT;
470
+ transaction_type: TransactionType;
471
+ }
472
+ export interface ExplainStatement {
473
+ type: StatementType.EXPLAIN_STATEMENT;
474
+ statement: Statement;
475
+ }
476
+ export type Statement = SelectStatement | SetOperationStatement | InsertStatement | UpdateStatement | DeleteStatement | CreateTableStatement | CreateIndexStatement | AlterTableStatement | DropStatement | TransactionStatement | ExplainStatement;
477
+ export declare class ParseError extends Error {
478
+ line: number;
479
+ column: number;
480
+ token: Token;
481
+ constructor(message: string, line: number, column: number, token: Token);
482
+ }
@@ -0,0 +1,16 @@
1
+ import type { SyncIPageStorage } from "../types.js";
2
+ /**
3
+ * Test-only in-memory SyncIPageStorage. Uses structuredClone to mimic real storage
4
+ * (no shared references between stored and returned values).
5
+ */
6
+ export declare class MemoryPageStorage implements SyncIPageStorage {
7
+ private pages;
8
+ private nextPageId;
9
+ open(): Promise<void>;
10
+ close(): void;
11
+ readPage<T>(pageNo: number): T | null;
12
+ writePage(pageNo: number, value: unknown): void;
13
+ getNextPageId(): number;
14
+ writeHeader(nextPageId: number): void;
15
+ flush(): void;
16
+ }
@@ -0,0 +1,33 @@
1
+ import type { ISyncFileHandle } from "../wal/file-handle.js";
2
+ import type { SyncIPageStorage } from "../types.js";
3
+ export declare class NodeFileHandle implements ISyncFileHandle {
4
+ private fd;
5
+ constructor(filePath: string);
6
+ read(buffer: Uint8Array, options?: {
7
+ at?: number;
8
+ }): number;
9
+ write(buffer: Uint8Array, options?: {
10
+ at?: number;
11
+ }): number;
12
+ getSize(): number;
13
+ truncate(size: number): void;
14
+ flush(): void;
15
+ close(): void;
16
+ }
17
+ export declare class NodeSyncStorage implements SyncIPageStorage {
18
+ private readonly filePath;
19
+ private handle;
20
+ private pageSize;
21
+ private nextPageId;
22
+ constructor(filePath: string);
23
+ open(): Promise<void>;
24
+ close(): void;
25
+ readPage<T>(pageNo: number): T | null;
26
+ writePage(pageNo: number, value: unknown): void;
27
+ getNextPageId(): number;
28
+ writeHeader(nextPageId: number): void;
29
+ truncateToSize(): void;
30
+ flush(): void;
31
+ private initNewFile;
32
+ private readHeader;
33
+ }
@@ -0,0 +1,39 @@
1
+ import type { SyncIPageStorage } from "../types.js";
2
+ interface FileSystemSyncAccessHandle {
3
+ getSize(): number;
4
+ read(buffer: Uint8Array, options?: {
5
+ at?: number;
6
+ }): number;
7
+ write(buffer: Uint8Array, options?: {
8
+ at?: number;
9
+ }): number;
10
+ truncate(size: number): void;
11
+ flush(): void;
12
+ close(): void;
13
+ }
14
+ declare global {
15
+ interface FileSystemFileHandle {
16
+ createSyncAccessHandle(options?: {
17
+ mode?: "readwrite" | "read-only" | "readwrite-unsafe";
18
+ }): Promise<FileSystemSyncAccessHandle>;
19
+ }
20
+ }
21
+ export declare class OPFSSyncStorage implements SyncIPageStorage {
22
+ private readonly dbName;
23
+ private handle;
24
+ private pageSize;
25
+ private nextPageId;
26
+ constructor(dbName: string);
27
+ open(): Promise<void>;
28
+ close(): void;
29
+ readPage<T>(pageNo: number): T | null;
30
+ writePage(pageNo: number, value: unknown): void;
31
+ getNextPageId(): number;
32
+ writeHeader(nextPageId: number): void;
33
+ /** Shrink file to match nextPageId. Safe only after flush(). */
34
+ truncateToSize(): void;
35
+ flush(): void;
36
+ private initNewFile;
37
+ private readHeader;
38
+ }
39
+ export {};
@@ -0,0 +1,48 @@
1
+ import type { IPageManager, RowId } from '../types.js';
2
+ import type { IndexKey } from './types.js';
3
+ import { type SearchPredicate } from './search-bounds.js';
4
+ export type { SearchPredicate } from './search-bounds.js';
5
+ export declare class BTree {
6
+ private readonly indexName;
7
+ private readonly pm;
8
+ private readonly unique;
9
+ constructor(indexName: string, pm: IPageManager, unique: boolean);
10
+ insert(key: IndexKey, rowId: RowId): Promise<void>;
11
+ delete(key: IndexKey, rowId: RowId): Promise<void>;
12
+ search(predicates: SearchPredicate[], totalColumns?: number): Promise<RowId[]>;
13
+ bulkLoad(entries: Array<{
14
+ key: IndexKey;
15
+ rowId: RowId;
16
+ }>): Promise<void>;
17
+ drop(): Promise<void>;
18
+ private insertIntoLeaf;
19
+ private removeFromLeaf;
20
+ private rangeScan;
21
+ private pointLookup;
22
+ private findLeftmostLeaf;
23
+ private collectRange;
24
+ private isBelowLower;
25
+ private isAboveUpper;
26
+ private mergeEntries;
27
+ private buildLeaves;
28
+ private linkAndWriteLeaves;
29
+ private buildInternalLevels;
30
+ private splitLeaf;
31
+ private propagateSplit;
32
+ private splitInternal;
33
+ private createNewRoot;
34
+ private findLeafPath;
35
+ /** Find insertion point: first position where keys[pos] >= key. */
36
+ private bisectLeft;
37
+ /** Find child index: first position where key < keys[pos]. */
38
+ private bisectRight;
39
+ private metaKey;
40
+ private nodeKey;
41
+ private readMeta;
42
+ private writeMeta;
43
+ private readNode;
44
+ private writeNode;
45
+ private allocNodeId;
46
+ private createLeaf;
47
+ private initEmptyTree;
48
+ }
@@ -0,0 +1,13 @@
1
+ import type { IndexKey } from './types.js';
2
+ /**
3
+ * Compare two composite index keys lexicographically.
4
+ * NULL sorts LAST (greater than all non-null values).
5
+ * Two NULLs in the same position are considered equal.
6
+ */
7
+ export declare function compareIndexKeys(a: IndexKey, b: IndexKey): number;
8
+ /**
9
+ * Check if a key contains any NULL components.
10
+ * Used for UNIQUE constraint: rows with NULL in any indexed column
11
+ * are exempt from uniqueness checks (SQL standard).
12
+ */
13
+ export declare function keyHasNull(key: IndexKey): boolean;
@@ -0,0 +1,15 @@
1
+ import type { IndexKey } from './types.js';
2
+ export interface SearchPredicate {
3
+ columnPosition: number;
4
+ comparisonType: 'EQUAL' | 'LESS' | 'GREATER' | 'LESS_EQUAL' | 'GREATER_EQUAL';
5
+ value: string | number | boolean | null;
6
+ }
7
+ export interface ScanBounds {
8
+ lowerKey: IndexKey | null;
9
+ lowerInclusive: boolean;
10
+ upperKey: IndexKey | null;
11
+ upperInclusive: boolean;
12
+ exactKey: IndexKey | null;
13
+ prefixScan?: boolean;
14
+ }
15
+ export declare function computeBounds(predicates: SearchPredicate[], totalColumns?: number): ScanBounds;
@@ -0,0 +1,33 @@
1
+ import type { RowId } from '../types.js';
2
+ export type IndexKeyValue = string | number | boolean | null;
3
+ /** Composite key: one element per indexed column. */
4
+ export type IndexKey = IndexKeyValue[];
5
+ export interface BTreeLeafNode {
6
+ kind: 'leaf';
7
+ nodeId: number;
8
+ keys: IndexKey[];
9
+ /** rowIds[i] = array of RowId for keys[i]. Non-unique indexes may have multiple. */
10
+ rowIds: RowId[][];
11
+ /** Pointer to the next leaf for efficient range scans. */
12
+ nextLeafId: number | null;
13
+ }
14
+ export interface BTreeInternalNode {
15
+ kind: 'internal';
16
+ nodeId: number;
17
+ /** Separator keys. keys.length === children.length - 1. */
18
+ keys: IndexKey[];
19
+ /** Child node IDs. */
20
+ children: number[];
21
+ }
22
+ export type BTreeNode = BTreeLeafNode | BTreeInternalNode;
23
+ export interface BTreeMeta {
24
+ rootNodeId: number;
25
+ /** Tree height. 1 means root is a leaf. */
26
+ height: number;
27
+ /** Monotonically increasing node ID allocator. */
28
+ nextNodeId: number;
29
+ /** Total number of index entries. */
30
+ size: number;
31
+ }
32
+ /** Maximum keys per leaf node. Internal nodes hold ORDER-1 keys and ORDER children. */
33
+ export declare const ORDER = 100;
@@ -0,0 +1,17 @@
1
+ export interface ICache<K, V> {
2
+ get(key: K): V | undefined;
3
+ set(key: K, value: V): void;
4
+ delete(key: K): void;
5
+ has(key: K): boolean;
6
+ clear(): void;
7
+ }
8
+ export declare class LRUCache<K, V> implements ICache<K, V> {
9
+ private readonly capacity;
10
+ private readonly map;
11
+ constructor(capacity: number);
12
+ get(key: K): V | undefined;
13
+ set(key: K, value: V): void;
14
+ delete(key: K): void;
15
+ has(key: K): boolean;
16
+ clear(): void;
17
+ }