@minnowdb/core 0.1.0 → 0.1.1

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 (34) hide show
  1. package/README.md +29 -18
  2. package/package.json +1 -1
  3. package/dist/engine/dsl/db.d.ts +0 -137
  4. package/dist/engine/dsl/db.d.ts.map +0 -1
  5. package/dist/engine/dsl/db.js +0 -161
  6. package/dist/engine/dsl/db.js.map +0 -1
  7. package/dist/engine/dsl/expression.d.ts +0 -172
  8. package/dist/engine/dsl/expression.d.ts.map +0 -1
  9. package/dist/engine/dsl/expression.js +0 -397
  10. package/dist/engine/dsl/expression.js.map +0 -1
  11. package/dist/engine/dsl/index.d.ts +0 -8
  12. package/dist/engine/dsl/index.d.ts.map +0 -1
  13. package/dist/engine/dsl/index.js +0 -7
  14. package/dist/engine/dsl/index.js.map +0 -1
  15. package/dist/engine/dsl/live-query.d.ts +0 -45
  16. package/dist/engine/dsl/live-query.d.ts.map +0 -1
  17. package/dist/engine/dsl/live-query.js +0 -116
  18. package/dist/engine/dsl/live-query.js.map +0 -1
  19. package/dist/engine/dsl/mutations.d.ts +0 -123
  20. package/dist/engine/dsl/mutations.d.ts.map +0 -1
  21. package/dist/engine/dsl/mutations.js +0 -241
  22. package/dist/engine/dsl/mutations.js.map +0 -1
  23. package/dist/engine/dsl/select-query-builder.d.ts +0 -148
  24. package/dist/engine/dsl/select-query-builder.d.ts.map +0 -1
  25. package/dist/engine/dsl/select-query-builder.js +0 -377
  26. package/dist/engine/dsl/select-query-builder.js.map +0 -1
  27. package/dist/engine/dsl/sql-tag.d.ts +0 -46
  28. package/dist/engine/dsl/sql-tag.d.ts.map +0 -1
  29. package/dist/engine/dsl/sql-tag.js +0 -85
  30. package/dist/engine/dsl/sql-tag.js.map +0 -1
  31. package/dist/engine/dsl/types.d.ts +0 -133
  32. package/dist/engine/dsl/types.d.ts.map +0 -1
  33. package/dist/engine/dsl/types.js +0 -9
  34. package/dist/engine/dsl/types.js.map +0 -1
package/README.md CHANGED
@@ -1,28 +1,39 @@
1
1
  # @minnowdb/core
2
2
 
3
- Columnar SQL engine for the browser: real SQL over immutable snapshots, durable on IndexedDB,
4
- with no WebAssembly to download. Runs in a worker (`MinnowDatabase`) or on the main thread through
5
- an RPC proxy (`MinnowDatabaseClient`); the API is identical over both.
3
+ Columnar SQL engine for the browser: real SQL over immutable snapshots, durable on IndexedDB, with
4
+ no WebAssembly to download. It runs in the thread that constructs it (`MinnowDatabase`), or in a
5
+ worker with a main-thread client that mirrors it call for call (`MinnowDatabaseClient`).
6
+
7
+ **[minnowdb.com](https://minnowdb.com)** — documentation, a live playground, and benchmarks you
8
+ run yourself.
6
9
 
7
10
  ```bash
8
11
  npm install @minnowdb/core
9
12
  ```
10
13
 
11
- - **One schema, everything typed** — `table()`, `column`, and `schema()` drive migrations,
12
- autocomplete, row types, insert validation, and live subscriptions.
13
- - **SQL is the contract** every statement compiles through the same plan assembly, and the
14
- supported surface ships as a checked-in feature matrix
15
- (`@minnowdb/core/sql-feature-matrix.json`). The optional `@minnowdb/client` adds a typed builder
16
- over the same published primitives.
17
- - **Full-text search** — `MATCH` / BM25 on any column, no index DDL.
18
- - **Live queries** `.live()` subscriptions that update across tabs.
19
- - **Durable browser storage** — compressed columnar blocks on IndexedDB, atomic multi-tab
20
- commits, snapshot reads, compaction and GC.
21
- - **Subpath exports** — `/storage`, `/client`, `/worker`, `/transactions`, `/block-format`,
22
- `/testing`.
23
-
24
- Quick start, guides, benchmark results, contributor workflows, and the complete API reference live
25
- in the [Minnow docs](https://minnowdb.com/docs/) — the single source of truth.
14
+ - **SQL is the contract** — parser, planner, optimizer, and a vectorized executor written here,
15
+ with no SQLite or DuckDB underneath. The supported surface ships as a checked-in feature matrix
16
+ (`@minnowdb/core/sql-feature-matrix.json`) that the engine is tested against.
17
+ - **One schema, in TypeScript** `table()`, `column`, and `schema()` declare tables once and
18
+ `migrate()` evolves them without rewriting stored data.
19
+ - **Full-text search** `MATCH` / BM25 on any column, with no index DDL to write.
20
+ - **Live queries** — `liveQueries()` hands back a set whose subscribers get a fresh result after
21
+ any commit that could have changed it, across tabs.
22
+ - **Durable browser storage** — compressed columnar blocks on IndexedDB, atomic multi-tab commits,
23
+ snapshot reads, compaction and GC.
24
+ - **Bounded memory** — execution works in batches under a budget you set and spills to storage
25
+ rather than failing.
26
+ - **Subpath exports** — `/storage`, `/client`, `/worker`, `/worker-protocol`, `/transactions`,
27
+ `/plan`, `/block-format`, `/testing`.
28
+
29
+ Guides, the API reference, and the SQL feature matrix live in the
30
+ [docs](https://minnowdb.com/docs/), which are the single source of truth. Building with an agent?
31
+ [minnowdb.com/agent-rules.md](https://minnowdb.com/agent-rules.md) is a short rules file to drop
32
+ into an `AGENTS.md`, and [llms.txt](https://minnowdb.com/llms.txt) indexes the documentation in
33
+ markdown.
34
+
35
+ Every `@minnowdb` package shares a major version and moves independently inside it, so install
36
+ them on the same major. See [Versioning](https://minnowdb.com/docs/reference/versioning/).
26
37
 
27
38
  ## License
28
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minnowdb/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A columnar SQL engine that runs entirely in the browser: real SQL over immutable snapshots, durable on IndexedDB, with no WebAssembly to download.",
5
5
  "license": "MIT",
6
6
  "author": "Eric Wilhite",
@@ -1,137 +0,0 @@
1
- import { type CompiledQuery, type CompiledStatement, type QueryResult, type QueryRow, type QueryValue } from "../query.js";
2
- import { type AnyTable, type SchemaDefinition } from "../schema.js";
3
- import { type LiveSubscriptionHandle } from "./live-query.js";
4
- import { DeleteQueryBuilder, InsertQueryBuilder, UpdateQueryBuilder } from "./mutations.js";
5
- import { SelectQueryBuilder, type AliasedSelectQuery, type CteDefinition } from "./select-query-builder.js";
6
- import { type AnyRow, type ContextWithTable, type InferDatabase, type TableExpression } from "./types.js";
7
- /**
8
- * The Kysely-style facade. `Minnow<DB>` wraps either the in-worker `MinnowDatabase` or the
9
- * main-thread `MinnowDatabaseClient` (both satisfy `DslDriver` structurally) and hands out
10
- * typed builders: `selectFrom`, `insertInto`, `updateTable`, `deleteFrom`, `with`, and live
11
- * queries through the builders' `.live()`. `DB` is derived from the runtime schema with
12
- * `InferDatabase<typeof appSchema>`; migrations stay on the driver (`driver.migrate(schema)`).
13
- */
14
- export interface DriverLiveSet {
15
- subscribe(query: string | {
16
- kind: "typed-query";
17
- plan: CompiledQuery;
18
- }, options: {
19
- onChange(result: QueryResult): void;
20
- onError?(error: unknown): void;
21
- onComplete?(): void;
22
- }): Promise<LiveSubscriptionHandle>;
23
- close(): void | Promise<void>;
24
- }
25
- export interface DslLiveOptions {
26
- /** BroadcastChannel name for cross-tab commit hints (worker client). */
27
- channelName?: string;
28
- pollIntervalMs?: number;
29
- }
30
- /** The slice of MinnowDatabase / MinnowDatabaseClient the facade drives. */
31
- export interface DslDriver {
32
- run<TRow>(query: {
33
- kind: "typed-query";
34
- plan: CompiledQuery;
35
- __row?: TRow;
36
- }): Promise<TRow[]>;
37
- insertBatch(tableName: string, rows: ReadonlyArray<Readonly<Record<string, QueryValue>>>): Promise<{
38
- rowCount: number;
39
- generatedColumns?: Record<string, QueryValue[]>;
40
- }>;
41
- upsertBatch(tableName: string, rows: ReadonlyArray<Readonly<Record<string, QueryValue>>>): Promise<{
42
- rowCount: number;
43
- generatedColumns?: Record<string, QueryValue[]>;
44
- }>;
45
- runStatement(statement: CompiledStatement, options?: {
46
- returning?: readonly string[] | "*";
47
- }): Promise<{
48
- kind: string;
49
- rowCount?: number;
50
- returnedRows?: QueryRow[];
51
- }>;
52
- execute(sql: string, params?: readonly QueryValue[]): Promise<{
53
- kind: string;
54
- result?: {
55
- rows: QueryRow[];
56
- };
57
- }>;
58
- liveQueries(options?: DslLiveOptions): DriverLiveSet;
59
- }
60
- export interface MinnowOptions {
61
- /**
62
- * The runtime schema the database was migrated with. Inserts then pad omitted nullable
63
- * columns with null (the engine's batch API takes every column); without it, an insert must
64
- * list every column itself.
65
- */
66
- schema?: SchemaDefinition<readonly AnyTable[]>;
67
- /** Options for the shared live-query set behind `.live()`; created lazily on first use. */
68
- live?: DslLiveOptions;
69
- }
70
- type EmptyContext = Record<never, AnyRow>;
71
- /**
72
- * Creates the typed facade. The recommended form names the database type once, so every hover,
73
- * error, and emitted declaration prints `Minnow<DB>` instead of the fully expanded schema —
74
- * which matters as soon as the schema has more than a table or two:
75
- *
76
- * ```ts
77
- * interface DB extends InferDatabase<typeof appSchema> {}
78
- * const db = createMinnow<DB>(database, { schema: appSchema });
79
- * ```
80
- *
81
- * Without the type argument, `DB` is inferred from the runtime schema value — fine for
82
- * scratch code and small scripts, at the cost of expanded types in tooling:
83
- *
84
- * ```ts
85
- * const db = createMinnow(database, { schema: appSchema });
86
- * ```
87
- */
88
- export declare function createMinnow<TTables extends readonly AnyTable[]>(driver: DslDriver, options: Omit<MinnowOptions, "schema"> & {
89
- schema: SchemaDefinition<TTables>;
90
- }): Minnow<InferDatabase<SchemaDefinition<TTables>>>;
91
- export declare function createMinnow<DB>(driver: DslDriver, options?: MinnowOptions): Minnow<DB>;
92
- interface SharedLiveSet {
93
- set?: DriverLiveSet | undefined;
94
- }
95
- /** One db.search hit: the owning table, the row (without the score alias), and its BM25 score. */
96
- export interface SearchHit<DB> {
97
- table: keyof DB & string;
98
- row: Record<string, QueryValue>;
99
- score: number;
100
- }
101
- export declare class Minnow<in out DB> {
102
- #private;
103
- constructor(driver: DslDriver, options?: MinnowOptions, ctes?: readonly CteDefinition[], liveBox?: SharedLiveSet);
104
- /**
105
- * The driver this facade was created with — the `MinnowDatabase` or `MinnowDatabaseClient`
106
- * behind it. Tools handed only the facade (devtools, inspectors, schema browsers) reach the
107
- * catalog and the raw SQL entry points through here; application code should keep its own
108
- * reference to the driver rather than reaching back through the facade.
109
- */
110
- get driver(): DslDriver;
111
- selectFrom<TE extends TableExpression<DB>>(table: TE): SelectQueryBuilder<DB, ContextWithTable<DB, EmptyContext, TE>, EmptyContext>;
112
- selectFrom<TDerivedRow extends AnyRow, TAlias extends string>(derived: AliasedSelectQuery<TDerivedRow, TAlias>): SelectQueryBuilder<DB, Record<TAlias, TDerivedRow>, EmptyContext>;
113
- insertInto<TTable extends keyof DB & string>(table: TTable): InsertQueryBuilder<DB, TTable>;
114
- updateTable<TTable extends keyof DB & string>(table: TTable): UpdateQueryBuilder<DB, TTable>;
115
- deleteFrom<TTable extends keyof DB & string>(table: TTable): DeleteQueryBuilder<DB, TTable>;
116
- /**
117
- * Declares a common table expression usable in `selectFrom`/joins of queries created from the
118
- * returned facade, exactly as SQL `WITH name AS (...)`.
119
- */
120
- with<TName extends string, TCteCtx, TCteRow extends AnyRow>(name: TName, factory: (creator: Minnow<DB>) => SelectQueryBuilder<DB, TCteCtx, TCteRow>): Minnow<DB & Record<TName, TCteRow>>;
121
- /**
122
- * Zero-ceremony document search across tables: every searched table (all schema tables by
123
- * default; `options.tables` narrows the set) runs a MATCH(*)-filtered, BM25-ordered scan,
124
- * and the per-table hits merge into one relevance-ranked list. The facade must be created
125
- * with `{ schema }` — the per-table column lists come from it.
126
- */
127
- search(query: string, options?: {
128
- tables?: ReadonlyArray<keyof DB & string>;
129
- limit?: number;
130
- }): Promise<Array<SearchHit<DB>>>;
131
- /** @internal Raw-SQL escape hatch used by the `sql` template tag. */
132
- $executeRaw(sqlText: string, params?: readonly QueryValue[]): Promise<QueryRow[]>;
133
- /** Closes the shared live-query set, if one was created. */
134
- close(): Promise<void>;
135
- }
136
- export {};
137
- //# sourceMappingURL=db.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../../src/engine/dsl/db.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,gBAAgB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- import { DeleteQueryBuilder, InsertQueryBuilder, UpdateQueryBuilder, } from "./mutations.js";
2
- import { isAliasedSelectQuery, parseTableExpression, SelectQueryBuilder, } from "./select-query-builder.js";
3
- export function createMinnow(driver, options = {}) {
4
- return new Minnow(driver, options);
5
- }
6
- export class Minnow {
7
- #driver;
8
- #options;
9
- #ctes;
10
- #liveBox;
11
- constructor(driver, options = {}, ctes = [], liveBox = {}) {
12
- this.#driver = driver;
13
- this.#options = options;
14
- this.#ctes = ctes;
15
- this.#liveBox = liveBox;
16
- }
17
- /**
18
- * The driver this facade was created with — the `MinnowDatabase` or `MinnowDatabaseClient`
19
- * behind it. Tools handed only the facade (devtools, inspectors, schema browsers) reach the
20
- * catalog and the raw SQL entry points through here; application code should keep its own
21
- * reference to the driver rather than reaching back through the facade.
22
- */
23
- get driver() {
24
- return this.#driver;
25
- }
26
- #liveServices() {
27
- return {
28
- subscribe: async (query, handlers) => {
29
- this.#liveBox.set ??= this.#driver.liveQueries(this.#options.live ?? {});
30
- return this.#liveBox.set.subscribe(query, handlers);
31
- },
32
- };
33
- }
34
- #services() {
35
- return {
36
- run: (query) => this.#driver.run(query),
37
- live: this.#liveServices(),
38
- };
39
- }
40
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return --
41
- the implementation signature erases the context; the overloads above carry precise types. */
42
- selectFrom(table) {
43
- if (isAliasedSelectQuery(table)) {
44
- return SelectQueryBuilder.create({ kind: "derived", builder: table.builder, alias: table.alias }, this.#ctes, this.#services());
45
- }
46
- const { table: name, alias } = parseTableExpression(table);
47
- return SelectQueryBuilder.create({ kind: "table", table: name, alias }, this.#ctes, this.#services());
48
- }
49
- /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return */
50
- #mutationServices() {
51
- const schemaTables = this.#options.schema?.tables;
52
- return {
53
- insertBatch: (tableName, rows) => this.#driver.insertBatch(tableName, rows),
54
- upsertBatch: (tableName, rows) => this.#driver.upsertBatch(tableName, rows),
55
- runStatement: (statement, options) => this.#driver.runStatement(statement, options),
56
- tableColumns: (tableName) => {
57
- const definition = schemaTables?.find(({ name }) => name === tableName);
58
- return definition === undefined ? undefined : Object.keys(definition.columns);
59
- },
60
- columnDefaultFns: (tableName) => {
61
- const definition = schemaTables?.find(({ name }) => name === tableName);
62
- if (definition === undefined)
63
- return undefined;
64
- let fns;
65
- for (const [name, columnDefinition] of Object.entries(definition.columns)) {
66
- const fill = columnDefinition.defaultFn;
67
- if (fill !== undefined)
68
- (fns ??= {})[name] = fill;
69
- }
70
- return fns;
71
- },
72
- };
73
- }
74
- insertInto(table) {
75
- return new InsertQueryBuilder(this.#mutationServices(), table);
76
- }
77
- updateTable(table) {
78
- return new UpdateQueryBuilder(this.#mutationServices(), table);
79
- }
80
- deleteFrom(table) {
81
- return new DeleteQueryBuilder(this.#mutationServices(), table);
82
- }
83
- /**
84
- * Declares a common table expression usable in `selectFrom`/joins of queries created from the
85
- * returned facade, exactly as SQL `WITH name AS (...)`.
86
- */
87
- with(name, factory) {
88
- const builder = factory(this);
89
- return new Minnow(this.#driver, this.#options, [...this.#ctes, { name, builder }], this.#liveBox);
90
- }
91
- /**
92
- * Zero-ceremony document search across tables: every searched table (all schema tables by
93
- * default; `options.tables` narrows the set) runs a MATCH(*)-filtered, BM25-ordered scan,
94
- * and the per-table hits merge into one relevance-ranked list. The facade must be created
95
- * with `{ schema }` — the per-table column lists come from it.
96
- */
97
- async search(query, options = {}) {
98
- const schemaTables = this.#options.schema?.tables;
99
- if (schemaTables === undefined) {
100
- throw new TypeError("search() needs the table columns: create the facade with { schema }");
101
- }
102
- const tableNames = options.tables ?? schemaTables.map(({ name }) => name);
103
- const limit = options.limit ?? 10;
104
- const perTable = await Promise.all(tableNames.map(async (tableName) => {
105
- const definition = schemaTables.find(({ name }) => name === tableName);
106
- if (definition === undefined) {
107
- throw new TypeError(`search() needs the table's schema: ${tableName}`);
108
- }
109
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any --
110
- per-table column lists are only known at runtime; hits erase the row type anyway. */
111
- const builder = this.selectFrom(tableName);
112
- // The score is selected under an internal alias so hits can rank across tables, then
113
- // stripped from the row; user-facing rows never carry a synthetic column. The alias
114
- // grows parentheses until it collides with no real column name.
115
- const columnNames = Object.keys(definition.columns);
116
- let scoreAlias = "(search score)";
117
- while (columnNames.includes(scoreAlias))
118
- scoreAlias = `(${scoreAlias})`;
119
- let rows;
120
- try {
121
- rows = await builder
122
- .select((eb) => [...columnNames, eb.fn.bm25("*", query).as(scoreAlias)])
123
- .search(query)
124
- .limit(limit)
125
- .execute();
126
- }
127
- catch (error) {
128
- // A schema can list tables that don't exist yet or hold nothing searchable; those
129
- // tables simply contribute no hits. Anything else is a real failure.
130
- const message = error instanceof Error ? error.message : "";
131
- if (message.startsWith("Table not found:") ||
132
- message.startsWith("Unknown table:") ||
133
- message.includes("no searchable columns")) {
134
- return [];
135
- }
136
- throw error;
137
- }
138
- return rows.map((row) => {
139
- const { [scoreAlias]: score, ...rest } = row;
140
- return { table: tableName, row: rest, score: typeof score === "number" ? score : 0 };
141
- });
142
- }));
143
- return perTable
144
- .flat()
145
- .sort((left, right) => right.score - left.score)
146
- .slice(0, limit);
147
- }
148
- /** @internal Raw-SQL escape hatch used by the `sql` template tag. */
149
- async $executeRaw(sqlText, params) {
150
- const result = await this.#driver.execute(sqlText, params);
151
- return result.result?.rows ?? [];
152
- }
153
- /** Closes the shared live-query set, if one was created. */
154
- async close() {
155
- const set = this.#liveBox.set;
156
- this.#liveBox.set = undefined;
157
- if (set !== undefined)
158
- await set.close();
159
- }
160
- }
161
- //# sourceMappingURL=db.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db.js","sourceRoot":"","sources":["../../../src/engine/dsl/db.ts"],"names":[],"mappings":"AASA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GAEnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,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C,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,qEAAqE;IACrE,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,MAA8B;QAC/D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;IACnC,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,KAAK;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,SAAS,CAAC;QAC9B,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;IAC3C,CAAC;CACF"}
@@ -1,172 +0,0 @@
1
- import { type AggregateName, type Expression, type QueryValue, type WindowFunctionName } from "../query.js";
2
- import { type AliasedExpression, type BlockCompilable, type ColumnReference, type ColumnReferenceOf, type ContextWithTable, type ExpressionSource, type ReferencedValue, type TableExpression } from "./types.js";
3
- import type { SelectQueryBuilder } from "./select-query-builder.js";
4
- /**
5
- * Kysely-style expression building. `eb(lhs, op, rhs)` plus `eb.and/or/not/fn/case/exists/...`
6
- * assemble the same Expression trees the SQL parser produces — string left-hand sides are column
7
- * references, right-hand sides are values (use `eb.ref` to compare columns). Everything holds an
8
- * ExpressionSource so subqueries compile under the enclosing query's shared derived-source
9
- * sequence, keeping builder plans byte-identical to parsed SQL.
10
- */
11
- export type SqlBool = boolean;
12
- export type ComparisonOperatorToken = "=" | "!=" | "<>" | ">" | ">=" | "<" | "<=";
13
- export type LikeOperatorToken = "like" | "not like";
14
- export type InOperatorToken = "in" | "not in";
15
- export type IsOperatorToken = "is" | "is not";
16
- export type ArithmeticOperatorToken = "+" | "-" | "*" | "/";
17
- export type BinaryOperatorToken = ComparisonOperatorToken | LikeOperatorToken | InOperatorToken | IsOperatorToken | ArithmeticOperatorToken;
18
- export declare class ExpressionWrapper<out TValue> {
19
- readonly source: ExpressionSource;
20
- readonly kind: "dsl-expression";
21
- constructor(source: ExpressionSource);
22
- /** Names this expression's output column, as SQL `AS alias` does. */
23
- as<TAlias extends string>(alias: TAlias): AliasedExpression<TValue, TAlias>;
24
- }
25
- export declare function isExpressionWrapper(value: unknown): value is ExpressionWrapper<unknown>;
26
- /**
27
- * A subquery usable where a scalar `TValue` is expected: its row must be a single column whose
28
- * value fits. Only the value side is checked structurally — the builder's `DB`/context do not
29
- * matter here, hence the `any`s.
30
- */
31
- export type ScalarSubquery<TValue> = SelectQueryBuilder<any, any, Record<string, TValue | null>>;
32
- /** A value operand: a literal, a wrapped expression, or a scalar subquery of the same type. */
33
- export type ValueOperand<TValue> = TValue | null | ExpressionWrapper<TValue | null> | ScalarSubquery<TValue>;
34
- type ArithmeticOperand<TCtx> = ColumnReferenceOf<TCtx, number> | number | ExpressionWrapper<number | null>;
35
- export declare function literalExpression(value: unknown): Expression;
36
- /** Shared with the query builders: `lhs op rhs` where lhs is a reference and rhs a value. */
37
- export declare function buildBinaryCondition(lhs: unknown, operator: string, rhs: unknown): ExpressionSource;
38
- interface OverClauseState {
39
- partitionBy: ExpressionSource[];
40
- orderBy: Array<{
41
- source: ExpressionSource;
42
- direction: "asc" | "desc";
43
- }>;
44
- }
45
- export declare class OverBuilder<in out TCtx> {
46
- private readonly state;
47
- constructor(state?: OverClauseState);
48
- partitionBy(...references: ReadonlyArray<ColumnReference<TCtx> | ExpressionWrapper<unknown>>): OverBuilder<TCtx>;
49
- orderBy(reference: ColumnReference<TCtx> | ExpressionWrapper<unknown>, direction?: "asc" | "desc"): OverBuilder<TCtx>;
50
- /** @internal */
51
- get clause(): OverClauseState;
52
- }
53
- type OverConfigure<TCtx> = (over: OverBuilder<TCtx>) => OverBuilder<TCtx>;
54
- /** A ranking window function; SQL requires OVER, so only `.over()` yields an expression. */
55
- export declare class WindowFunctionBuilder<in out TCtx> {
56
- private readonly name;
57
- constructor(name: WindowFunctionName);
58
- over(configure?: OverConfigure<TCtx>): ExpressionWrapper<number>;
59
- }
60
- export declare class AggregateExpressionWrapper<in out TCtx, out TValue> extends ExpressionWrapper<TValue> {
61
- private readonly name;
62
- private readonly argument;
63
- private readonly isDistinct;
64
- constructor(name: AggregateName, argument: ExpressionSource, isDistinct?: boolean);
65
- /** COUNT(DISTINCT e); the engine restricts DISTINCT to COUNT over one scalar argument. */
66
- distinct(): AggregateExpressionWrapper<TCtx, TValue>;
67
- /** Turns the aggregate into a window over the given partition and ordering. */
68
- over(configure?: OverConfigure<TCtx>): ExpressionWrapper<TValue>;
69
- }
70
- /** A COALESCE argument: a column reference or any wrapped expression. */
71
- type CoalesceArg<TCtx> = ColumnReference<TCtx> | ExpressionWrapper<unknown>;
72
- type CoalesceArgValue<TCtx, TArg> = TArg extends ExpressionWrapper<infer TValue> ? TValue : TArg extends string ? ReferencedValue<TCtx, TArg> : never;
73
- /**
74
- * The union of the operand value types; null stays only when the final fallback is itself
75
- * nullable, matching COALESCE's first-non-null semantics.
76
- */
77
- type CoalesceValue<TCtx, TArgs extends readonly unknown[]> = TArgs extends readonly [
78
- ...unknown[],
79
- infer TLast
80
- ] ? Exclude<CoalesceArgValue<TCtx, TArgs[number]>, null> | Extract<CoalesceArgValue<TCtx, TLast>, null> : CoalesceArgValue<TCtx, TArgs[number]>;
81
- export interface FunctionModule<in out TCtx> {
82
- /** COUNT(argument); counts non-null values. */
83
- count(reference: ColumnReference<TCtx> | ExpressionWrapper<unknown>): AggregateExpressionWrapper<TCtx, number>;
84
- /** COUNT(*). */
85
- countAll(): AggregateExpressionWrapper<TCtx, number>;
86
- sum(reference: ColumnReferenceOf<TCtx, number> | ExpressionWrapper<number | null>): AggregateExpressionWrapper<TCtx, number | null>;
87
- avg(reference: ColumnReferenceOf<TCtx, number> | ExpressionWrapper<number | null>): AggregateExpressionWrapper<TCtx, number | null>;
88
- min<TRef extends ColumnReference<TCtx>>(reference: TRef): AggregateExpressionWrapper<TCtx, ReferencedValue<TCtx, TRef & string> | null>;
89
- min<TValue>(expression: ExpressionWrapper<TValue>): AggregateExpressionWrapper<TCtx, TValue | null>;
90
- max<TRef extends ColumnReference<TCtx>>(reference: TRef): AggregateExpressionWrapper<TCtx, ReferencedValue<TCtx, TRef & string> | null>;
91
- max<TValue>(expression: ExpressionWrapper<TValue>): AggregateExpressionWrapper<TCtx, TValue | null>;
92
- round(value: ArithmeticOperand<TCtx>, digits?: number): ExpressionWrapper<number | null>;
93
- coalesce<TArgs extends readonly [CoalesceArg<TCtx>, ...Array<CoalesceArg<TCtx>>]>(...values: TArgs): ExpressionWrapper<CoalesceValue<TCtx, TArgs>>;
94
- dateTrunc(unit: "year" | "month" | "day" | "hour" | "minute" | "second", value: ColumnReferenceOf<TCtx, Date> | Date | ExpressionWrapper<Date | null>): ExpressionWrapper<Date | null>;
95
- /**
96
- * Document-level BM25 relevance of the query against the listed columns ("*" = every
97
- * non-boolean column of the scanned table), compiling to the same node as SQL
98
- * `BM25(col, ...) AGAINST 'query'`. 0 when no term matches; null when every column is null.
99
- */
100
- bm25(columns: "*" | ReadonlyArray<ColumnReferenceOf<TCtx, string | number | Date> & string>, query: string): ExpressionWrapper<number | null>;
101
- }
102
- /** Shared by eb.match and fn.bm25: validates and assembles the full-text plan node. */
103
- export declare function buildFtsExpression(op: "match" | "bm25", columns: "*" | readonly string[], query: string): Expression;
104
- interface CaseBranch {
105
- when: ExpressionSource;
106
- then: ExpressionSource;
107
- }
108
- export declare class CaseThenBuilder<in out TCtx, out TValue> {
109
- private readonly branches;
110
- private readonly pendingWhen;
111
- constructor(branches: readonly CaseBranch[], pendingWhen: ExpressionSource);
112
- then<TNext extends QueryValue>(value: TNext | ExpressionWrapper<TNext>): CaseBuilder<TCtx, TValue | TNext>;
113
- }
114
- export declare class CaseBuilder<in out TCtx, out TValue = never> {
115
- private readonly branches;
116
- constructor(branches?: readonly CaseBranch[]);
117
- when(condition: ExpressionWrapper<SqlBool>): CaseThenBuilder<TCtx, TValue>;
118
- when<TRef extends ColumnReference<TCtx>>(lhs: TRef, operator: ComparisonOperatorToken | LikeOperatorToken, rhs: ValueOperand<ReferencedValue<TCtx, TRef & string>>): CaseThenBuilder<TCtx, TValue>;
119
- else<TNext extends QueryValue>(value: TNext | ExpressionWrapper<TNext>): CaseEndBuilder<TValue | TNext>;
120
- end(): ExpressionWrapper<TValue | null>;
121
- }
122
- export declare class CaseEndBuilder<out TValue> {
123
- private readonly branches;
124
- private readonly otherwise;
125
- constructor(branches: readonly CaseBranch[], otherwise: ExpressionSource);
126
- end(): ExpressionWrapper<TValue>;
127
- }
128
- export interface ExpressionBuilder<in out DB, in out TCtx> {
129
- /** Compares a column (or expression) to a value; string left-hand sides are references. */
130
- <TRef extends ColumnReference<TCtx> & string>(lhs: TRef, operator: ComparisonOperatorToken, rhs: ValueOperand<ReferencedValue<TCtx, TRef>>): ExpressionWrapper<SqlBool>;
131
- (lhs: ExpressionWrapper<unknown>, operator: ComparisonOperatorToken, rhs: QueryValue | ExpressionWrapper<unknown> | ScalarSubquery<unknown>): ExpressionWrapper<SqlBool>;
132
- (lhs: ColumnReference<TCtx> | ExpressionWrapper<string | null>, operator: LikeOperatorToken, rhs: string | ExpressionWrapper<string | null>): ExpressionWrapper<SqlBool>;
133
- <TRef extends ColumnReference<TCtx> & string>(lhs: TRef, operator: InOperatorToken, rhs: ReadonlyArray<ReferencedValue<TCtx, TRef> | ExpressionWrapper<unknown>> | ScalarSubquery<ReferencedValue<TCtx, TRef>>): ExpressionWrapper<SqlBool>;
134
- (lhs: ColumnReference<TCtx> | ExpressionWrapper<unknown>, operator: IsOperatorToken, rhs: null): ExpressionWrapper<SqlBool>;
135
- (lhs: ArithmeticOperand<TCtx>, operator: ArithmeticOperatorToken, rhs: ArithmeticOperand<TCtx>): ExpressionWrapper<number>;
136
- /** ANDs conditions left to right. */
137
- and(conditions: ReadonlyArray<ExpressionWrapper<SqlBool>>): ExpressionWrapper<SqlBool>;
138
- /** ORs conditions left to right. */
139
- or(conditions: ReadonlyArray<ExpressionWrapper<SqlBool>>): ExpressionWrapper<SqlBool>;
140
- not(condition: ExpressionWrapper<SqlBool>): ExpressionWrapper<SqlBool>;
141
- /** `lhs BETWEEN lower AND upper`, desugared exactly as the parser does. */
142
- between<TRef extends ColumnReference<TCtx>>(reference: TRef | ExpressionWrapper<unknown>, lower: ValueOperand<ReferencedValue<TCtx, TRef & string>>, upper: ValueOperand<ReferencedValue<TCtx, TRef & string>>): ExpressionWrapper<SqlBool>;
143
- notBetween<TRef extends ColumnReference<TCtx>>(reference: TRef | ExpressionWrapper<unknown>, lower: ValueOperand<ReferencedValue<TCtx, TRef & string>>, upper: ValueOperand<ReferencedValue<TCtx, TRef & string>>): ExpressionWrapper<SqlBool>;
144
- exists(subquery: BlockCompilable): ExpressionWrapper<SqlBool>;
145
- /**
146
- * Document-level full-text MATCH, compiling to the same node as SQL
147
- * `MATCH(col, ...) AGAINST 'query'`: every query term must appear in some listed column
148
- * ("*" searches every non-boolean column of the scanned table); a term ending in `*`
149
- * matches prefixes. Rows whose listed columns are all null are unknown, like LIKE on null.
150
- */
151
- match(columns: "*" | ReadonlyArray<ColumnReferenceOf<TCtx, string | number | Date> & string>, query: string): ExpressionWrapper<SqlBool>;
152
- /** A column reference as an expression, for the rare value-position column comparison. */
153
- ref<TRef extends ColumnReference<TCtx>>(reference: TRef): ExpressionWrapper<ReferencedValue<TCtx, TRef & string>>;
154
- /** A literal value as an expression. */
155
- val<TValue extends QueryValue>(value: TValue): ExpressionWrapper<TValue>;
156
- /** Arithmetic negation. */
157
- neg(value: ArithmeticOperand<TCtx>): ExpressionWrapper<number>;
158
- case(): CaseBuilder<TCtx>;
159
- rowNumber(): WindowFunctionBuilder<TCtx>;
160
- rank(): WindowFunctionBuilder<TCtx>;
161
- denseRank(): WindowFunctionBuilder<TCtx>;
162
- /** Starts a correlated or uncorrelated subquery over the database plus the outer scope. */
163
- selectFrom<TE extends TableExpression<DB>>(table: TE): SelectQueryBuilder<DB, ContextWithTable<DB, TCtx, TE>, Record<never, unknown>>;
164
- fn: FunctionModule<TCtx>;
165
- }
166
- /**
167
- * Creates the callable expression builder. The subquery factory is injected by the select
168
- * builder module, which owns both sides of that recursion.
169
- */
170
- export declare function createExpressionBuilder<DB, TCtx>(createSubquery: (table: string) => unknown): ExpressionBuilder<DB, TCtx>;
171
- export {};
172
- //# sourceMappingURL=expression.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expression.d.ts","sourceRoot":"","sources":["../../../src/engine/dsl/expression.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,UAAU,EAEf,KAAK,UAAU,EACf,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAEtB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;;;GAMG;AAEH,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC;AAE9B,MAAM,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;AAClF,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,UAAU,CAAC;AACpD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,QAAQ,CAAC;AAC9C,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,QAAQ,CAAC;AAC9C,MAAM,MAAM,uBAAuB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAE5D,MAAM,MAAM,mBAAmB,GAC3B,uBAAuB,GACvB,iBAAiB,GACjB,eAAe,GACf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