@minnowdb/core 0.0.1 → 0.1.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 (218) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -1
  3. package/dist/block-format/block.d.ts +46 -0
  4. package/dist/block-format/block.d.ts.map +1 -0
  5. package/dist/block-format/block.js +244 -0
  6. package/dist/block-format/block.js.map +1 -0
  7. package/dist/block-format/checksum.d.ts +7 -0
  8. package/dist/block-format/checksum.d.ts.map +1 -0
  9. package/dist/block-format/checksum.js +56 -0
  10. package/dist/block-format/checksum.js.map +1 -0
  11. package/dist/block-format/codecs.d.ts +24 -0
  12. package/dist/block-format/codecs.d.ts.map +1 -0
  13. package/dist/block-format/codecs.js +102 -0
  14. package/dist/block-format/codecs.js.map +1 -0
  15. package/dist/block-format/column.d.ts +8 -0
  16. package/dist/block-format/column.d.ts.map +1 -0
  17. package/dist/block-format/column.js +166 -0
  18. package/dist/block-format/column.js.map +1 -0
  19. package/dist/block-format/index.d.ts +7 -0
  20. package/dist/block-format/index.d.ts.map +1 -0
  21. package/dist/block-format/index.js +7 -0
  22. package/dist/block-format/index.js.map +1 -0
  23. package/dist/block-format/physical.d.ts +20 -0
  24. package/dist/block-format/physical.d.ts.map +1 -0
  25. package/dist/block-format/physical.js +439 -0
  26. package/dist/block-format/physical.js.map +1 -0
  27. package/dist/block-format/types.d.ts +93 -0
  28. package/dist/block-format/types.d.ts.map +1 -0
  29. package/dist/block-format/types.js +2 -0
  30. package/dist/block-format/types.js.map +1 -0
  31. package/dist/engine/artifact-cache.d.ts +22 -0
  32. package/dist/engine/artifact-cache.d.ts.map +1 -0
  33. package/dist/engine/artifact-cache.js +68 -0
  34. package/dist/engine/artifact-cache.js.map +1 -0
  35. package/dist/engine/batch.d.ts +28 -0
  36. package/dist/engine/batch.d.ts.map +1 -0
  37. package/dist/engine/batch.js +38 -0
  38. package/dist/engine/batch.js.map +1 -0
  39. package/dist/engine/buffered-writer.d.ts +43 -0
  40. package/dist/engine/buffered-writer.d.ts.map +1 -0
  41. package/dist/engine/buffered-writer.js +158 -0
  42. package/dist/engine/buffered-writer.js.map +1 -0
  43. package/dist/engine/catalog.d.ts +82 -0
  44. package/dist/engine/catalog.d.ts.map +1 -0
  45. package/dist/engine/catalog.js +47 -0
  46. package/dist/engine/catalog.js.map +1 -0
  47. package/dist/engine/client.d.ts +211 -0
  48. package/dist/engine/client.d.ts.map +1 -0
  49. package/dist/engine/client.js +538 -0
  50. package/dist/engine/client.js.map +1 -0
  51. package/dist/engine/coordinator.d.ts +17 -0
  52. package/dist/engine/coordinator.d.ts.map +1 -0
  53. package/dist/engine/coordinator.js +60 -0
  54. package/dist/engine/coordinator.js.map +1 -0
  55. package/dist/engine/database.d.ts +661 -0
  56. package/dist/engine/database.d.ts.map +1 -0
  57. package/dist/engine/database.js +10313 -0
  58. package/dist/engine/database.js.map +1 -0
  59. package/dist/engine/defaults.d.ts +33 -0
  60. package/dist/engine/defaults.d.ts.map +1 -0
  61. package/dist/engine/defaults.js +87 -0
  62. package/dist/engine/defaults.js.map +1 -0
  63. package/dist/engine/dsl/db.d.ts +137 -0
  64. package/dist/engine/dsl/db.d.ts.map +1 -0
  65. package/dist/engine/dsl/db.js +161 -0
  66. package/dist/engine/dsl/db.js.map +1 -0
  67. package/dist/engine/dsl/expression.d.ts +172 -0
  68. package/dist/engine/dsl/expression.d.ts.map +1 -0
  69. package/dist/engine/dsl/expression.js +397 -0
  70. package/dist/engine/dsl/expression.js.map +1 -0
  71. package/dist/engine/dsl/index.d.ts +8 -0
  72. package/dist/engine/dsl/index.d.ts.map +1 -0
  73. package/dist/engine/dsl/index.js +7 -0
  74. package/dist/engine/dsl/index.js.map +1 -0
  75. package/dist/engine/dsl/live-query.d.ts +45 -0
  76. package/dist/engine/dsl/live-query.d.ts.map +1 -0
  77. package/dist/engine/dsl/live-query.js +116 -0
  78. package/dist/engine/dsl/live-query.js.map +1 -0
  79. package/dist/engine/dsl/mutations.d.ts +123 -0
  80. package/dist/engine/dsl/mutations.d.ts.map +1 -0
  81. package/dist/engine/dsl/mutations.js +241 -0
  82. package/dist/engine/dsl/mutations.js.map +1 -0
  83. package/dist/engine/dsl/select-query-builder.d.ts +148 -0
  84. package/dist/engine/dsl/select-query-builder.d.ts.map +1 -0
  85. package/dist/engine/dsl/select-query-builder.js +377 -0
  86. package/dist/engine/dsl/select-query-builder.js.map +1 -0
  87. package/dist/engine/dsl/sql-tag.d.ts +46 -0
  88. package/dist/engine/dsl/sql-tag.d.ts.map +1 -0
  89. package/dist/engine/dsl/sql-tag.js +85 -0
  90. package/dist/engine/dsl/sql-tag.js.map +1 -0
  91. package/dist/engine/dsl/types.d.ts +133 -0
  92. package/dist/engine/dsl/types.d.ts.map +1 -0
  93. package/dist/engine/dsl/types.js +9 -0
  94. package/dist/engine/dsl/types.js.map +1 -0
  95. package/dist/engine/errors.d.ts +55 -0
  96. package/dist/engine/errors.d.ts.map +1 -0
  97. package/dist/engine/errors.js +81 -0
  98. package/dist/engine/errors.js.map +1 -0
  99. package/dist/engine/fts.d.ts +93 -0
  100. package/dist/engine/fts.d.ts.map +1 -0
  101. package/dist/engine/fts.js +273 -0
  102. package/dist/engine/fts.js.map +1 -0
  103. package/dist/engine/group-index.d.ts +32 -0
  104. package/dist/engine/group-index.d.ts.map +1 -0
  105. package/dist/engine/group-index.js +366 -0
  106. package/dist/engine/group-index.js.map +1 -0
  107. package/dist/engine/index.d.ts +13 -0
  108. package/dist/engine/index.d.ts.map +1 -0
  109. package/dist/engine/index.js +12 -0
  110. package/dist/engine/index.js.map +1 -0
  111. package/dist/engine/join-index.d.ts +12 -0
  112. package/dist/engine/join-index.d.ts.map +1 -0
  113. package/dist/engine/join-index.js +217 -0
  114. package/dist/engine/join-index.js.map +1 -0
  115. package/dist/engine/live.d.ts +86 -0
  116. package/dist/engine/live.d.ts.map +1 -0
  117. package/dist/engine/live.js +289 -0
  118. package/dist/engine/live.js.map +1 -0
  119. package/dist/engine/memory.d.ts +37 -0
  120. package/dist/engine/memory.d.ts.map +1 -0
  121. package/dist/engine/memory.js +119 -0
  122. package/dist/engine/memory.js.map +1 -0
  123. package/dist/engine/optimizer.d.ts +20 -0
  124. package/dist/engine/optimizer.d.ts.map +1 -0
  125. package/dist/engine/optimizer.js +1170 -0
  126. package/dist/engine/optimizer.js.map +1 -0
  127. package/dist/engine/query-cache.d.ts +10 -0
  128. package/dist/engine/query-cache.d.ts.map +1 -0
  129. package/dist/engine/query-cache.js +58 -0
  130. package/dist/engine/query-cache.js.map +1 -0
  131. package/dist/engine/query.d.ts +844 -0
  132. package/dist/engine/query.d.ts.map +1 -0
  133. package/dist/engine/query.js +7450 -0
  134. package/dist/engine/query.js.map +1 -0
  135. package/dist/engine/schema-wire.d.ts +92 -0
  136. package/dist/engine/schema-wire.d.ts.map +1 -0
  137. package/dist/engine/schema-wire.js +115 -0
  138. package/dist/engine/schema-wire.js.map +1 -0
  139. package/dist/engine/schema.d.ts +394 -0
  140. package/dist/engine/schema.d.ts.map +1 -0
  141. package/dist/engine/schema.js +709 -0
  142. package/dist/engine/schema.js.map +1 -0
  143. package/dist/engine/sort-keys.d.ts +36 -0
  144. package/dist/engine/sort-keys.d.ts.map +1 -0
  145. package/dist/engine/sort-keys.js +60 -0
  146. package/dist/engine/sort-keys.js.map +1 -0
  147. package/dist/engine/sql-json.d.ts +30 -0
  148. package/dist/engine/sql-json.d.ts.map +1 -0
  149. package/dist/engine/sql-json.js +120 -0
  150. package/dist/engine/sql-json.js.map +1 -0
  151. package/dist/engine/sql-semantics.d.ts +31 -0
  152. package/dist/engine/sql-semantics.d.ts.map +1 -0
  153. package/dist/engine/sql-semantics.js +121 -0
  154. package/dist/engine/sql-semantics.js.map +1 -0
  155. package/dist/engine/vector.d.ts +87 -0
  156. package/dist/engine/vector.d.ts.map +1 -0
  157. package/dist/engine/vector.js +4227 -0
  158. package/dist/engine/vector.js.map +1 -0
  159. package/dist/engine/worker-host.d.ts +48 -0
  160. package/dist/engine/worker-host.d.ts.map +1 -0
  161. package/dist/engine/worker-host.js +501 -0
  162. package/dist/engine/worker-host.js.map +1 -0
  163. package/dist/engine/worker.d.ts +2 -0
  164. package/dist/engine/worker.d.ts.map +1 -0
  165. package/dist/engine/worker.js +14 -0
  166. package/dist/engine/worker.js.map +1 -0
  167. package/dist/index.d.ts +2 -0
  168. package/dist/index.d.ts.map +1 -0
  169. package/dist/index.js +2 -0
  170. package/dist/index.js.map +1 -0
  171. package/dist/plan/index.d.ts +17 -0
  172. package/dist/plan/index.d.ts.map +1 -0
  173. package/dist/plan/index.js +17 -0
  174. package/dist/plan/index.js.map +1 -0
  175. package/dist/storage/fixture-shape.d.ts +42 -0
  176. package/dist/storage/fixture-shape.d.ts.map +1 -0
  177. package/dist/storage/fixture-shape.js +146 -0
  178. package/dist/storage/fixture-shape.js.map +1 -0
  179. package/dist/storage/index.d.ts +5 -0
  180. package/dist/storage/index.d.ts.map +1 -0
  181. package/dist/storage/index.js +5 -0
  182. package/dist/storage/index.js.map +1 -0
  183. package/dist/storage/indexeddb.d.ts +139 -0
  184. package/dist/storage/indexeddb.d.ts.map +1 -0
  185. package/dist/storage/indexeddb.js +3161 -0
  186. package/dist/storage/indexeddb.js.map +1 -0
  187. package/dist/storage/memory.d.ts +121 -0
  188. package/dist/storage/memory.d.ts.map +1 -0
  189. package/dist/storage/memory.js +1455 -0
  190. package/dist/storage/memory.js.map +1 -0
  191. package/dist/storage/snapshot.d.ts +108 -0
  192. package/dist/storage/snapshot.d.ts.map +1 -0
  193. package/dist/storage/snapshot.js +276 -0
  194. package/dist/storage/snapshot.js.map +1 -0
  195. package/dist/storage/types.d.ts +895 -0
  196. package/dist/storage/types.d.ts.map +1 -0
  197. package/dist/storage/types.js +1549 -0
  198. package/dist/storage/types.js.map +1 -0
  199. package/dist/testing/index.d.ts +76 -0
  200. package/dist/testing/index.d.ts.map +1 -0
  201. package/dist/testing/index.js +233 -0
  202. package/dist/testing/index.js.map +1 -0
  203. package/dist/testing/seeds.d.ts +11 -0
  204. package/dist/testing/seeds.d.ts.map +1 -0
  205. package/dist/testing/seeds.js +50 -0
  206. package/dist/testing/seeds.js.map +1 -0
  207. package/dist/transactions/index.d.ts +148 -0
  208. package/dist/transactions/index.d.ts.map +1 -0
  209. package/dist/transactions/index.js +662 -0
  210. package/dist/transactions/index.js.map +1 -0
  211. package/dist/worker-protocol/index.d.ts +84 -0
  212. package/dist/worker-protocol/index.d.ts.map +1 -0
  213. package/dist/worker-protocol/index.js +117 -0
  214. package/dist/worker-protocol/index.js.map +1 -0
  215. package/package.json +66 -16
  216. package/sql-feature-matrix.json +1275 -0
  217. package/index.d.ts +0 -1
  218. package/index.js +0 -1
@@ -0,0 +1,133 @@
1
+ import { type CompiledQuery, type Expression } from "../query.js";
2
+ import { type AnyTable, type InferRow, type SchemaDefinition } from "../schema.js";
3
+ /**
4
+ * Type foundation for the Kysely-style query builder. A database type `DB` maps table names to
5
+ * row types and is derived from the runtime schema DSL (`InferDatabase<typeof appSchema>`), so
6
+ * one schema declaration drives migration planning, insert validation, and builder autocomplete.
7
+ * A query context `TCtx` maps in-scope aliases to row types and evolves through `selectFrom` and
8
+ * joins; every column reference type below is resolved against it.
9
+ */
10
+ /** Flattens intersections so inferred row types read as one object. */
11
+ export type Simplify<T> = {
12
+ [K in keyof T]: T[K];
13
+ } & {};
14
+ /** Maps a schema's table names to their inferred row shapes. */
15
+ export type InferDatabase<TSchema extends SchemaDefinition<readonly AnyTable[]>> = Simplify<{
16
+ [TTable in TSchema["tables"][number] as TTable["name"]]: InferRow<TTable>;
17
+ }>;
18
+ export type AnyRow = Record<string, unknown>;
19
+ export type AnyContext = Record<string, AnyRow>;
20
+ /** `"users"` or `"users as u"`. */
21
+ export type TableExpression<DB> = (keyof DB & string) | `${keyof DB & string} as ${string}`;
22
+ export type ExtractTableAlias<TE extends string> = TE extends `${string} as ${infer TAlias}` ? TAlias : TE;
23
+ export type ExtractTableName<TE extends string> = TE extends `${infer TName} as ${string}` ? TName : TE;
24
+ export type NullableRow<TRow> = {
25
+ [K in keyof TRow]: TRow[K] | null;
26
+ };
27
+ /** The context after bringing a table (or aliased table) into scope. */
28
+ export type ContextWithTable<DB, TCtx, TE extends string> = TCtx & Record<ExtractTableAlias<TE>, DB[ExtractTableName<TE> & keyof DB]>;
29
+ /** The context after a LEFT JOIN: the joined table's columns widen with null. */
30
+ export type ContextWithLeftTable<DB, TCtx, TE extends string> = TCtx & Record<ExtractTableAlias<TE>, NullableRow<DB[ExtractTableName<TE> & keyof DB]>>;
31
+ /** Every column in scope, as a bare name or an alias-qualified `"a.column"`. */
32
+ export type ColumnReference<TCtx> = {
33
+ [TAlias in keyof TCtx & string]: (keyof TCtx[TAlias] & string) | `${TAlias}.${keyof TCtx[TAlias] & string}`;
34
+ }[keyof TCtx & string];
35
+ /**
36
+ * Only the columns whose (non-null) value type matches `TValue`, as bare or qualified names.
37
+ * Numeric and date functions constrain their column arguments with this, so `fn.sum("name")`
38
+ * on a string column is a compile error instead of a runtime surprise.
39
+ */
40
+ export type ColumnReferenceOf<TCtx, TValue> = {
41
+ [TAlias in keyof TCtx & string]: {
42
+ [TColumn in keyof TCtx[TAlias] & string]: NonNullable<TCtx[TAlias][TColumn]> extends TValue ? TColumn | `${TAlias}.${TColumn}` : never;
43
+ }[keyof TCtx[TAlias] & string];
44
+ }[keyof TCtx & string];
45
+ /** A join whose alias collides with one already in scope resolves to this instead of a builder. */
46
+ export interface DuplicateJoinAliasError<TMessage extends string> {
47
+ readonly duplicateJoinAlias: TMessage;
48
+ }
49
+ /**
50
+ * The result of a join: the builder when the alias is new, and a readable branded error type
51
+ * when the alias is already in scope. The guard lives in the return type (not the parameter)
52
+ * so it cannot interfere with inference of the table expression.
53
+ */
54
+ export type JoinResult<TCtx, TE extends string, TBuilder> = ExtractTableAlias<TE> extends keyof TCtx & string ? DuplicateJoinAliasError<`alias '${ExtractTableAlias<TE>}' is already used in this query`> : TBuilder;
55
+ /** The value type a reference resolves to; bare names union across matching tables. */
56
+ export type ReferencedValue<TCtx, TRef extends string> = TRef extends `${infer TAlias}.${infer TColumn}` ? TAlias extends keyof TCtx ? TColumn extends keyof TCtx[TAlias] ? TCtx[TAlias][TColumn] : never : never : {
57
+ [TAlias in keyof TCtx]: TRef extends keyof TCtx[TAlias] ? TCtx[TAlias][TRef] : never;
58
+ }[keyof TCtx];
59
+ /** A selectable string: a column reference, optionally aliased with `as`. */
60
+ export type StringSelection<TCtx> = ColumnReference<TCtx> | `${ColumnReference<TCtx>} as ${string}`;
61
+ /** An expression given an output name with `.as(alias)`. */
62
+ export interface AliasedExpression<out TValue, out TAlias extends string> {
63
+ readonly kind: "aliased-expression";
64
+ readonly alias: TAlias;
65
+ /** Materializes at compile time so subquery sources number under the shared sequence. */
66
+ readonly source: ExpressionSource;
67
+ /** Phantom output type; never materialized at runtime. */
68
+ readonly __value?: TValue;
69
+ }
70
+ export type Selection<TCtx> = StringSelection<TCtx> | AliasedExpression<unknown, string>;
71
+ export type SelectionOutputKey<S extends string> = S extends `${string} as ${infer TAlias}` ? TAlias : S extends `${string}.${infer TColumn}` ? TColumn : S;
72
+ type StringSelectionValue<TCtx, S extends string> = S extends `${infer TRef} as ${string}` ? ReferencedValue<TCtx, TRef> : ReferencedValue<TCtx, S>;
73
+ /** The output row contributed by one `select(...)` call. */
74
+ export type RowFromSelections<TCtx, TSel> = Simplify<{
75
+ [S in Extract<TSel, string> as SelectionOutputKey<S>]: StringSelectionValue<TCtx, S>;
76
+ } & {
77
+ [E in Extract<TSel, AliasedExpression<unknown, string>> as E["alias"]]: E extends AliasedExpression<infer TValue, string> ? TValue : never;
78
+ }>;
79
+ type UnionToIntersection<U> = (U extends unknown ? (member: U) => void : never) extends (member: infer I) => void ? I : never;
80
+ type IsUnion<T, U = T> = T extends unknown ? ([U] extends [T] ? false : true) : never;
81
+ type QualifiedColumnsRow<TCtx> = UnionToIntersection<{
82
+ [TAlias in keyof TCtx & string]: {
83
+ [TColumn in keyof TCtx[TAlias] & string as `${TAlias}.${TColumn}`]: TCtx[TAlias][TColumn];
84
+ };
85
+ }[keyof TCtx & string]>;
86
+ /**
87
+ * The `selectAll()` row: a single-source context keeps bare column names; a joined context
88
+ * qualifies every column as `"alias.column"`, exactly as the executor projects `SELECT *`.
89
+ */
90
+ export type AllColumnsRow<TCtx> = true extends IsUnion<keyof TCtx> ? Simplify<QualifiedColumnsRow<TCtx>> : TCtx[keyof TCtx];
91
+ /**
92
+ * True when the column's value carries the HasDefault flavor — the engine can fill it. The
93
+ * detector probes for the phantom key, which plain primitives never have; `any` (whose keyof is
94
+ * every key) is excluded first.
95
+ */
96
+ type IsGenerated<TValue> = 0 extends 1 & TValue ? false : "__minnowHasDefault" extends keyof NonNullable<TValue> ? true : false;
97
+ type OptionalInsertKey<TRow, K extends keyof TRow> = null extends TRow[K] ? true : IsGenerated<TRow[K]>;
98
+ /** Insert rows require non-nullable columns and may omit nullable or default-bearing ones. */
99
+ export type InsertRowFor<TRow> = Simplify<{
100
+ [K in keyof TRow as true extends OptionalInsertKey<TRow, K> ? never : K]: TRow[K];
101
+ } & {
102
+ [K in keyof TRow as true extends OptionalInsertKey<TRow, K> ? K : never]?: TRow[K] | undefined;
103
+ }>;
104
+ /** An undefined entry means "leave this column untouched", so spread-patches stay safe. */
105
+ export type UpdateChangesFor<TRow> = {
106
+ [K in keyof TRow]?: TRow[K] | undefined;
107
+ };
108
+ /**
109
+ * Compile-time services threaded through expression materialization: the shared derived-source
110
+ * sequence (so builder plans number sources exactly as parsed SQL does) and CTE resolution.
111
+ */
112
+ export interface CompileContext {
113
+ nextSequence: () => number;
114
+ /** Returns a fresh clone of a CTE body compiled earlier in this compile pass. */
115
+ cteFor: (name: string) => CompiledQuery | undefined;
116
+ }
117
+ /** An expression, either concrete or deferred until the compile context exists. */
118
+ export type ExpressionSource = Expression | ((context: CompileContext) => Expression);
119
+ export declare function materialize(source: ExpressionSource, context: CompileContext): Expression;
120
+ /** A sub-select usable as a derived table, subquery expression, or set-operation member. */
121
+ export interface BlockCompilable {
122
+ readonly kind: "dsl-select-builder";
123
+ compileBlock(context: CompileContext, label: string): CompiledQuery;
124
+ }
125
+ export declare function isBlockCompilable(value: unknown): value is BlockCompilable;
126
+ /** The `{ kind: "typed-query" }` envelope the engine's `run()` executes. */
127
+ export interface TypedQueryEnvelope<out TRow> {
128
+ readonly kind: "typed-query";
129
+ readonly plan: CompiledQuery;
130
+ readonly __row?: TRow;
131
+ }
132
+ export {};
133
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/engine/dsl/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEnF;;;;;;GAMG;AAEH,uEAAuE;AACvE,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC;AAExD,gEAAgE;AAChE,MAAM,MAAM,aAAa,CAAC,OAAO,SAAS,gBAAgB,CAAC,SAAS,QAAQ,EAAE,CAAC,IAAI,QAAQ,CAAC;KACzF,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC;CAC1E,CAAC,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEhD,mCAAmC;AACnC,MAAM,MAAM,eAAe,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,GA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C,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC;CACrE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAM1E;AAED,4EAA4E;AAC5E,MAAM,WAAW,kBAAkB,CAAC,GAAG,CAAC,IAAI;IAC1C,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;CACvB"}
@@ -0,0 +1,9 @@
1
+ export function materialize(source, context) {
2
+ return typeof source === "function" ? source(context) : source;
3
+ }
4
+ export function isBlockCompilable(value) {
5
+ return (typeof value === "object" &&
6
+ value !== null &&
7
+ value.kind === "dsl-select-builder");
8
+ }
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/engine/dsl/types.ts"],"names":[],"mappings":"AAkMA,MAAM,UAAU,WAAW,CAAC,MAAwB,EAAE,OAAuB;IAC3E,OAAO,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACjE,CAAC;AAQD,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACb,KAA4B,CAAC,IAAI,KAAK,oBAAoB,CAC5D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Typed engine errors, kept free of engine imports so the main-thread worker client can rehydrate
3
+ * them (name, fields, instanceof) without bundling the executor.
4
+ */
5
+ type ErrorValue = boolean | number | string | Date;
6
+ export declare class UniqueConstraintError extends Error {
7
+ readonly tableName: string;
8
+ readonly columnName: string;
9
+ readonly value: ErrorValue;
10
+ readonly name = "UniqueConstraintError";
11
+ constructor(tableName: string, columnName: string, value: ErrorValue);
12
+ }
13
+ export declare class MissingKeyError extends Error {
14
+ readonly tableName: string;
15
+ readonly columnName: string;
16
+ readonly value: ErrorValue;
17
+ readonly name = "MissingKeyError";
18
+ constructor(tableName: string, columnName: string, value: ErrorValue);
19
+ }
20
+ export declare class CompactionMemoryBudgetError extends Error {
21
+ readonly budgetBytes: number;
22
+ readonly minimumBytes: number;
23
+ readonly name = "CompactionMemoryBudgetError";
24
+ constructor(budgetBytes: number, minimumBytes: number);
25
+ }
26
+ export declare class CompactionWriteAmplificationError extends Error {
27
+ readonly outputBytes: number;
28
+ readonly maximumOutputBytes: number;
29
+ readonly name = "CompactionWriteAmplificationError";
30
+ constructor(outputBytes: number, maximumOutputBytes: number);
31
+ }
32
+ export declare class CompactionJobCancelledError extends Error {
33
+ readonly jobId: string;
34
+ readonly name = "CompactionJobCancelledError";
35
+ constructor(jobId: string);
36
+ }
37
+ /**
38
+ * SQL that failed to compile, located in the text the caller passed. `offset` and `length` are
39
+ * character positions into that exact string — leading whitespace included — so an editor can
40
+ * underline the token that failed without re-deriving the position from the message.
41
+ *
42
+ * `length` is 0 where the failure has no width: an empty statement, or a query that ended before
43
+ * the parser expected it to. Errors raised after parsing succeeds (plan optimization, execution)
44
+ * carry no position and stay plain `TypeError`s.
45
+ *
46
+ * It extends `TypeError` because that is what compilation failures threw before positions existed.
47
+ */
48
+ export declare class SqlCompileError extends TypeError {
49
+ readonly offset: number;
50
+ readonly length: number;
51
+ readonly name = "SqlCompileError";
52
+ constructor(message: string, offset: number, length: number);
53
+ }
54
+ export {};
55
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/engine/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAMnD,qBAAa,qBAAsB,SAAQ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EACd,MAAM,EAAE,MAAM;CAI1B"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Typed engine errors, kept free of engine imports so the main-thread worker client can rehydrate
3
+ * them (name, fields, instanceof) without bundling the executor.
4
+ */
5
+ function formatValue(value) {
6
+ return value instanceof Date ? value.toISOString() : String(value);
7
+ }
8
+ export class UniqueConstraintError extends Error {
9
+ tableName;
10
+ columnName;
11
+ value;
12
+ name = "UniqueConstraintError";
13
+ constructor(tableName, columnName, value) {
14
+ super(`Duplicate value for ${tableName}.${columnName}: ${formatValue(value)}`);
15
+ this.tableName = tableName;
16
+ this.columnName = columnName;
17
+ this.value = value;
18
+ }
19
+ }
20
+ export class MissingKeyError extends Error {
21
+ tableName;
22
+ columnName;
23
+ value;
24
+ name = "MissingKeyError";
25
+ constructor(tableName, columnName, value) {
26
+ super(`Missing value for ${tableName}.${columnName}: ${formatValue(value)}`);
27
+ this.tableName = tableName;
28
+ this.columnName = columnName;
29
+ this.value = value;
30
+ }
31
+ }
32
+ export class CompactionMemoryBudgetError extends Error {
33
+ budgetBytes;
34
+ minimumBytes;
35
+ name = "CompactionMemoryBudgetError";
36
+ constructor(budgetBytes, minimumBytes) {
37
+ super(`Compaction needs at least ${String(minimumBytes)} bytes of working memory; budget is ${String(budgetBytes)} bytes`);
38
+ this.budgetBytes = budgetBytes;
39
+ this.minimumBytes = minimumBytes;
40
+ }
41
+ }
42
+ export class CompactionWriteAmplificationError extends Error {
43
+ outputBytes;
44
+ maximumOutputBytes;
45
+ name = "CompactionWriteAmplificationError";
46
+ constructor(outputBytes, maximumOutputBytes) {
47
+ super(`Compaction output would use ${String(outputBytes)} stored bytes; limit is ${String(maximumOutputBytes)} bytes`);
48
+ this.outputBytes = outputBytes;
49
+ this.maximumOutputBytes = maximumOutputBytes;
50
+ }
51
+ }
52
+ export class CompactionJobCancelledError extends Error {
53
+ jobId;
54
+ name = "CompactionJobCancelledError";
55
+ constructor(jobId) {
56
+ super(`Compaction job cancelled: ${jobId}`);
57
+ this.jobId = jobId;
58
+ }
59
+ }
60
+ /**
61
+ * SQL that failed to compile, located in the text the caller passed. `offset` and `length` are
62
+ * character positions into that exact string — leading whitespace included — so an editor can
63
+ * underline the token that failed without re-deriving the position from the message.
64
+ *
65
+ * `length` is 0 where the failure has no width: an empty statement, or a query that ended before
66
+ * the parser expected it to. Errors raised after parsing succeeds (plan optimization, execution)
67
+ * carry no position and stay plain `TypeError`s.
68
+ *
69
+ * It extends `TypeError` because that is what compilation failures threw before positions existed.
70
+ */
71
+ export class SqlCompileError extends TypeError {
72
+ offset;
73
+ length;
74
+ name = "SqlCompileError";
75
+ constructor(message, offset, length) {
76
+ super(message);
77
+ this.offset = offset;
78
+ this.length = length;
79
+ }
80
+ }
81
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/engine/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,SAAS,WAAW,CAAC,KAAiB;IACpC,OAAO,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAInC;IACA;IACA;IALO,IAAI,GAAG,uBAAuB,CAAC;IAEjD,YACW,SAAiB,EACjB,UAAkB,EAClB,KAAiB;QAE1B,KAAK,CAAC,uBAAuB,SAAS,IAAI,UAAU,KAAK,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAJtE,cAAS,GAAT,SAAS,CAAQ;QACjB,eAAU,GAAV,UAAU,CAAQ;QAClB,UAAK,GAAL,KAAK,CAAY;IAG5B,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAI7B;IACA;IACA;IALO,IAAI,GAAG,iBAAiB,CAAC;IAE3C,YACW,SAAiB,EACjB,UAAkB,EAClB,KAAiB;QAE1B,KAAK,CAAC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;IAGzB,CAAC;CACF"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Full-text search primitives: the tokenizer, the query grammar, and the BM25 scorer.
3
+ *
4
+ * The tokenizer is deliberately hand-rolled rather than `Intl.Segmenter`: segmentation output
5
+ * must be identical across browsers, ICU versions, and time, because phase-2 persists tokens in
6
+ * a multi-tab shared index — an environment-varying tokenizer would silently split one logical
7
+ * index into two vocabularies. Any change to tokenization must bump `FTS_TOKENIZER_VERSION`;
8
+ * a persisted index stamped with another version reads as absent and rebuilds.
9
+ *
10
+ * The scorer takes only integers (term frequency, document length, document frequency, document
11
+ * count, total token count), so the row and columnar executors produce bit-identical scores no
12
+ * matter what order they accumulate in. Keep it that way: never feed it a running float.
13
+ */
14
+ export declare const FTS_TOKENIZER_VERSION = 1;
15
+ /** One parsed query term; `prefix` terms match any token they prefix. */
16
+ export interface FtsQueryTerm {
17
+ readonly term: string;
18
+ readonly prefix: boolean;
19
+ }
20
+ /**
21
+ * Corpus statistics for one (columns, query) signature — O(#query terms) integers. Every row of
22
+ * the corpus counts as a document (an all-null document has length 0): this definition is what
23
+ * lets a persisted index serve exact statistics without a scan, since the document count is
24
+ * just the table's row count. All producers — the row executor, the columnar scan, and the
25
+ * postings index — must share it, or BM25 scores drift between paths.
26
+ */
27
+ export interface FtsStats {
28
+ /** Every row of the corpus, including all-null documents. */
29
+ docCount: number;
30
+ /** Total tokens across all documents. */
31
+ totalTokens: number;
32
+ /** Documents containing each query term, aligned with the query's term order. */
33
+ dfByTerm: number[];
34
+ }
35
+ /** Tokenizes one cell's text: NFKC, locale-independent lowercase, letter/number runs. */
36
+ export declare function tokenize(text: string): string[];
37
+ /**
38
+ * Parses a query: whitespace-separated chunks, each tokenized with the document pipeline; a
39
+ * chunk ending in `*` marks its last produced token as a prefix term. Zero terms means the
40
+ * query matches nothing.
41
+ */
42
+ export declare function tokenizeQuery(query: string): FtsQueryTerm[];
43
+ export declare function termMatches(token: string, term: FtsQueryTerm): boolean;
44
+ /**
45
+ * Compile-time cap on query terms: the columnar fast path packs per-term presence into one
46
+ * 32-bit mask per dictionary entry.
47
+ */
48
+ export declare const FTS_MAX_QUERY_TERMS = 32;
49
+ /** Tokenized query terms with the same bounded caching scheme as the LIKE pattern cache. */
50
+ export declare function cachedQueryTerms(query: string): FtsQueryTerm[];
51
+ /** Compile-time validation shared by the SQL parser and the DSL expression builder. */
52
+ export declare function validateFtsQuery(query: string): void;
53
+ /** Bitmask of query terms present in a token list: bit i set means terms[i] matched. */
54
+ export declare function termsMask(tokens: readonly string[], terms: readonly FtsQueryTerm[]): number;
55
+ /** The all-terms-present mask; terms.length is capped at 32 so the shift stays in range. */
56
+ export declare function fullTermsMask(termCount: number): number;
57
+ /**
58
+ * Document-level MATCH truth over one row's rendered column values: every term must appear in
59
+ * some column (AND across terms, OR across columns). All columns null → SQL unknown (null);
60
+ * an empty query matches nothing.
61
+ */
62
+ export declare function ftsMatchTruth(terms: readonly FtsQueryTerm[], values: Iterable<unknown>): boolean | null;
63
+ /**
64
+ * Per-term frequencies of the query's terms in one token list, aligned with the term order.
65
+ * A document matches when every slot is non-zero.
66
+ */
67
+ export declare function termFrequencies(tokens: readonly string[], terms: readonly FtsQueryTerm[]): number[];
68
+ /**
69
+ * One term's BM25 contribution. Integer inputs only — see the module comment. `df` of zero
70
+ * contributes nothing (the term appears in no document, so no row scores on it).
71
+ */
72
+ export declare function bm25Score(tf: number, docLength: number, df: number, docCount: number, totalTokens: number): number;
73
+ /** Sums the contributions of every query term for one document. */
74
+ export declare function bm25DocumentScore(frequencies: readonly number[], docLength: number, stats: FtsStats): number;
75
+ /** Accumulates corpus statistics one document at a time; every producer feeds this. */
76
+ export declare class FtsStatsAccumulator {
77
+ #private;
78
+ constructor(terms: readonly FtsQueryTerm[]);
79
+ /** Adds one document; an all-null row contributes a document of length 0. */
80
+ addDocument(tokens: readonly string[]): void;
81
+ /** Adds one document from pre-aggregated counts (the dictionary-table producers). */
82
+ addDocumentCounts(termMask: number, length: number): void;
83
+ get stats(): FtsStats;
84
+ }
85
+ /**
86
+ * Document-level BM25 for one row's rendered column values: term frequencies and document
87
+ * length sum across columns (the document is the concatenation of its fields). All columns
88
+ * null → SQL null; a document containing no query term scores 0.
89
+ */
90
+ export declare function ftsBm25Row(terms: readonly FtsQueryTerm[], values: Iterable<unknown>, stats: FtsStats): number | null;
91
+ /** Renders one cell for the document, per column type. Booleans are excluded from documents. */
92
+ export declare function renderDocumentValue(value: unknown): string | undefined;
93
+ //# sourceMappingURL=fts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fts.d.ts","sourceRoot":"","sources":["../../src/engine/fts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAevC,yEAAyE;AACzE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAmCD,yFAAyF;AACzF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ/C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CAW3D;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAEtE;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAItC,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CAO9D;AAED,uFAAuF;AACvF,wBAAgB,gBAAgB,C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