@crvouga/sqlite-mem 0.1.0 → 0.2.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.
- package/AGENTS.md +156 -0
- package/COMPATIBILITY-AUDIT.md +7 -9
- package/COMPATIBILITY.md +4 -3
- package/README.md +152 -14
- package/compat/coverage.json +797 -512
- package/compat/requirements.json +1 -1
- package/dist/api/database.d.ts +90 -12
- package/dist/api/statement.d.ts +74 -17
- package/dist/ast/nodes.d.ts +11 -2
- package/dist/constraints/check.d.ts +5 -6
- package/dist/errors/index.d.ts +25 -1
- package/dist/executor/attach.d.ts +3 -4
- package/dist/executor/ddl.d.ts +3 -4
- package/dist/executor/dml.d.ts +4 -4
- package/dist/executor/env.d.ts +9 -11
- package/dist/executor/execute.d.ts +3 -4
- package/dist/executor/pragma.d.ts +3 -4
- package/dist/executor/result.d.ts +9 -5
- package/dist/executor/select.d.ts +4 -5
- package/dist/executor/simple-select.d.ts +3 -4
- package/dist/executor/triggers.d.ts +6 -7
- package/dist/executor/vtable.d.ts +5 -6
- package/dist/expressions/context.d.ts +5 -5
- package/dist/expressions/equals.d.ts +3 -0
- package/dist/expressions/eval.d.ts +9 -4
- package/dist/expressions/index.d.ts +3 -4
- package/dist/expressions/like.d.ts +13 -3
- package/dist/functions/aggregate.d.ts +1 -2
- package/dist/functions/datetime.d.ts +1 -2
- package/dist/functions/extensions.d.ts +1 -2
- package/dist/functions/index.d.ts +8 -9
- package/dist/functions/json.d.ts +3 -4
- package/dist/functions/math.d.ts +1 -2
- package/dist/functions/registry.d.ts +5 -6
- package/dist/functions/scalar.d.ts +2 -3
- package/dist/functions/table-valued.d.ts +3 -4
- package/dist/functions/window.d.ts +1 -2
- package/dist/index.d.ts +33 -12
- package/dist/index.js +900 -120
- package/dist/index.js.map +4 -4
- package/dist/indexes/index.d.ts +17 -4
- package/dist/json/index.d.ts +7 -8
- package/dist/json/jsonb.d.ts +1 -2
- package/dist/json/ops.d.ts +8 -3
- package/dist/json/parse.d.ts +2 -3
- package/dist/json/path.d.ts +1 -2
- package/dist/json/stringify.d.ts +1 -2
- package/dist/json/tvf.d.ts +1 -2
- package/dist/json/types.d.ts +0 -1
- package/dist/lexer/tokenize.d.ts +7 -1
- package/dist/parser/index.d.ts +11 -5
- package/dist/parser/parser.d.ts +3 -3
- package/dist/planner/access.d.ts +13 -6
- package/dist/planner/index.d.ts +1 -2
- package/dist/runtime/clock.d.ts +8 -2
- package/dist/runtime/index.d.ts +3 -4
- package/dist/runtime/options.d.ts +5 -4
- package/dist/runtime/prng.d.ts +12 -1
- package/dist/schema/catalog.d.ts +2 -3
- package/dist/serialization/codec.d.ts +17 -2
- package/dist/serialization/index.d.ts +1 -2
- package/dist/storage/database-state.d.ts +16 -8
- package/dist/storage/index.d.ts +6 -7
- package/dist/storage/row.d.ts +1 -2
- package/dist/storage/table.d.ts +8 -4
- package/dist/transactions/manager.d.ts +2 -3
- package/dist/types/collation.d.ts +1 -2
- package/dist/types/strict.d.ts +6 -0
- package/dist/types/value.d.ts +30 -2
- package/dist/vtable/fts/options.d.ts +0 -1
- package/dist/vtable/fts/porter.d.ts +0 -1
- package/dist/vtable/fts/query.d.ts +0 -1
- package/dist/vtable/fts/table.d.ts +5 -6
- package/dist/vtable/fts/tokenize.d.ts +1 -2
- package/dist/vtable/fts5.d.ts +1 -2
- package/dist/vtable/index.d.ts +2 -3
- package/dist/vtable/modules.d.ts +2 -3
- package/package.json +14 -7
- package/compat/gate-report.json +0 -424
- package/dist/api/database.d.ts.map +0 -1
- package/dist/api/statement.d.ts.map +0 -1
- package/dist/ast/nodes.d.ts.map +0 -1
- package/dist/constraints/check.d.ts.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/executor/attach.d.ts.map +0 -1
- package/dist/executor/ddl.d.ts.map +0 -1
- package/dist/executor/dml.d.ts.map +0 -1
- package/dist/executor/env.d.ts.map +0 -1
- package/dist/executor/execute.d.ts.map +0 -1
- package/dist/executor/pragma.d.ts.map +0 -1
- package/dist/executor/result.d.ts.map +0 -1
- package/dist/executor/select.d.ts.map +0 -1
- package/dist/executor/simple-select.d.ts.map +0 -1
- package/dist/executor/triggers.d.ts.map +0 -1
- package/dist/executor/vtable.d.ts.map +0 -1
- package/dist/expressions/context.d.ts.map +0 -1
- package/dist/expressions/eval.d.ts.map +0 -1
- package/dist/expressions/index.d.ts.map +0 -1
- package/dist/expressions/like.d.ts.map +0 -1
- package/dist/functions/aggregate.d.ts.map +0 -1
- package/dist/functions/datetime.d.ts.map +0 -1
- package/dist/functions/extensions.d.ts.map +0 -1
- package/dist/functions/index.d.ts.map +0 -1
- package/dist/functions/json.d.ts.map +0 -1
- package/dist/functions/math.d.ts.map +0 -1
- package/dist/functions/registry.d.ts.map +0 -1
- package/dist/functions/scalar.d.ts.map +0 -1
- package/dist/functions/table-valued.d.ts.map +0 -1
- package/dist/functions/window.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/indexes/index.d.ts.map +0 -1
- package/dist/json/index.d.ts.map +0 -1
- package/dist/json/jsonb.d.ts.map +0 -1
- package/dist/json/ops.d.ts.map +0 -1
- package/dist/json/parse.d.ts.map +0 -1
- package/dist/json/path.d.ts.map +0 -1
- package/dist/json/stringify.d.ts.map +0 -1
- package/dist/json/tvf.d.ts.map +0 -1
- package/dist/json/types.d.ts.map +0 -1
- package/dist/lexer/tokenize.d.ts.map +0 -1
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/parser/parser.d.ts.map +0 -1
- package/dist/planner/access.d.ts.map +0 -1
- package/dist/planner/index.d.ts.map +0 -1
- package/dist/runtime/clock.d.ts.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/options.d.ts.map +0 -1
- package/dist/runtime/prng.d.ts.map +0 -1
- package/dist/schema/catalog.d.ts.map +0 -1
- package/dist/serialization/codec.d.ts.map +0 -1
- package/dist/serialization/index.d.ts.map +0 -1
- package/dist/storage/database-state.d.ts.map +0 -1
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/row.d.ts.map +0 -1
- package/dist/storage/table.d.ts.map +0 -1
- package/dist/transactions/manager.d.ts.map +0 -1
- package/dist/types/collation.d.ts.map +0 -1
- package/dist/types/value.d.ts.map +0 -1
- package/dist/vtable/fts/options.d.ts.map +0 -1
- package/dist/vtable/fts/porter.d.ts.map +0 -1
- package/dist/vtable/fts/query.d.ts.map +0 -1
- package/dist/vtable/fts/table.d.ts.map +0 -1
- package/dist/vtable/fts/tokenize.d.ts.map +0 -1
- package/dist/vtable/fts5.d.ts.map +0 -1
- package/dist/vtable/index.d.ts.map +0 -1
- package/dist/vtable/modules.d.ts.map +0 -1
package/dist/indexes/index.d.ts
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
import type { Rowid } from "../storage/row.
|
|
2
|
-
import { type SqlValue } from "../types/value.
|
|
1
|
+
import type { Rowid } from "../storage/row.js";
|
|
2
|
+
import { type SqlValue } from "../types/value.js";
|
|
3
3
|
export declare class IndexStore {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
private entries;
|
|
6
|
-
|
|
6
|
+
private keyValues;
|
|
7
|
+
private sortedKeys;
|
|
8
|
+
frozen: boolean;
|
|
9
|
+
constructor(name?: string, entries?: ReadonlyMap<string, readonly Rowid[]>, keyValues?: ReadonlyMap<string, readonly SqlValue[]>);
|
|
7
10
|
checkUnique(values: readonly SqlValue[], rowid?: Rowid): void;
|
|
8
11
|
insert(values: readonly SqlValue[], rowid: Rowid, unique?: boolean): void;
|
|
9
12
|
lookup(values: readonly SqlValue[]): readonly Rowid[];
|
|
13
|
+
/** Leftmost prefix match: INDEX(a,b) used for WHERE a = ?. */
|
|
14
|
+
lookupPrefix(values: readonly SqlValue[]): readonly Rowid[];
|
|
15
|
+
/**
|
|
16
|
+
* Ordered scan of rowids for a single-column comparison.
|
|
17
|
+
* `op` applies to the first key component.
|
|
18
|
+
*/
|
|
19
|
+
rangeLookup(op: ">" | ">=" | "<" | "<=" | "between", bound: SqlValue, bound2?: SqlValue): readonly Rowid[];
|
|
20
|
+
orderedRowids(desc?: boolean): readonly Rowid[];
|
|
10
21
|
remove(values: readonly SqlValue[], rowid?: Rowid): boolean;
|
|
11
22
|
clear(): void;
|
|
12
23
|
clone(): IndexStore;
|
|
24
|
+
freeze(): void;
|
|
13
25
|
get size(): number;
|
|
26
|
+
private orderedKeys;
|
|
27
|
+
private assertMutable;
|
|
14
28
|
}
|
|
15
29
|
export declare function serializeIndexKey(values: readonly SqlValue[]): string | null;
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/json/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export { decodeJsonb, encodeJsonb, jsonbToText, looksLikeJsonb, textToJsonb, walkJsonbTree, } from "./jsonb.
|
|
2
|
-
export { ensureJson, extractOne, jsonArrowPath, jsonNodeToSql, mutateJson, patchJson, removeJson, sqlToJsonInput, sqlValueToJsonNode, toJsonbBlob, toJsonText, wrapJsonError, } from "./ops.
|
|
3
|
-
export { isValidJsonText, JsonParseError, jsonErrorPosition, parseJsonText } from "./parse.
|
|
4
|
-
export { parseJsonPath, pathGet } from "./path.
|
|
5
|
-
export { jsonQuoteString, prettyJson, stringifyJson } from "./stringify.
|
|
6
|
-
export { jsonEachRows, jsonTreeRows } from "./tvf.
|
|
7
|
-
export type { JsonNode, JsonTypeName } from "./types.
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { decodeJsonb, encodeJsonb, jsonbToText, looksLikeJsonb, textToJsonb, walkJsonbTree, } from "./jsonb.js";
|
|
2
|
+
export { arrayInsertJson, ensureJson, extractOne, jsonArrowPath, jsonNodeToSql, mutateJson, patchJson, removeJson, sqlToJsonInput, sqlValueToJsonNode, toJsonbBlob, toJsonText, wrapJsonError, } from "./ops.js";
|
|
3
|
+
export { isValidJsonText, JsonParseError, jsonErrorPosition, parseJsonText } from "./parse.js";
|
|
4
|
+
export { parseJsonPath, pathGet } from "./path.js";
|
|
5
|
+
export { jsonQuoteString, prettyJson, stringifyJson } from "./stringify.js";
|
|
6
|
+
export { jsonEachRows, jsonTreeRows } from "./tvf.js";
|
|
7
|
+
export type { JsonNode, JsonTypeName } from "./types.js";
|
package/dist/json/jsonb.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JsonNode } from "./types.
|
|
1
|
+
import type { JsonNode } from "./types.js";
|
|
2
2
|
/** JSONB element types (low nibble). */
|
|
3
3
|
export declare const JB: {
|
|
4
4
|
readonly NULL: 0;
|
|
@@ -40,4 +40,3 @@ export interface JsonbWalkEntry {
|
|
|
40
40
|
export declare function walkJsonbTree(blob: Uint8Array): JsonbWalkEntry[];
|
|
41
41
|
export declare function jsonbToText(blob: Uint8Array): string;
|
|
42
42
|
export declare function textToJsonb(text: string): Uint8Array;
|
|
43
|
-
//# sourceMappingURL=jsonb.d.ts.map
|
package/dist/json/ops.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SqlJsonText, type SqlValue } from "../types/value.
|
|
2
|
-
import { type JsonNode } from "./types.
|
|
1
|
+
import { SqlJsonText, type SqlValue } from "../types/value.js";
|
|
2
|
+
import { type JsonNode } from "./types.js";
|
|
3
3
|
export declare function sqlToJsonInput(value: SqlValue): JsonNode;
|
|
4
4
|
export declare function trySqlToJsonInput(value: SqlValue): JsonNode | null;
|
|
5
5
|
/** VALUE arg for insert/set/array/object — literal unless JSON subtype / JSONB. */
|
|
@@ -8,6 +8,12 @@ export declare function jsonNodeToSql(node: JsonNode, mode: "sql" | "json" | "js
|
|
|
8
8
|
export declare function jsonArrowPath(right: SqlValue): string;
|
|
9
9
|
export declare function extractOne(root: JsonNode, path: string): JsonNode | undefined;
|
|
10
10
|
export type MutateMode = "insert" | "replace" | "set";
|
|
11
|
+
/**
|
|
12
|
+
* json_array_insert / jsonb_array_insert — like json_replace, but PATH must end
|
|
13
|
+
* with an array index and the value is spliced in (existing elements shift right).
|
|
14
|
+
* https://www.sqlite.org/json1.html#jarrins
|
|
15
|
+
*/
|
|
16
|
+
export declare function arrayInsertJson(root: JsonNode, path: string, value: JsonNode): JsonNode;
|
|
11
17
|
export declare function mutateJson(root: JsonNode, path: string, value: JsonNode, mode: MutateMode): JsonNode;
|
|
12
18
|
export declare function removeJson(root: JsonNode, path: string): JsonNode;
|
|
13
19
|
/** RFC7396-ish JSON Merge Patch as implemented by SQLite json_patch. */
|
|
@@ -16,4 +22,3 @@ export declare function wrapJsonError(e: unknown): never;
|
|
|
16
22
|
export declare function ensureJson(value: SqlValue): JsonNode;
|
|
17
23
|
export declare function toJsonbBlob(value: SqlValue): Uint8Array;
|
|
18
24
|
export declare function toJsonText(value: SqlValue): SqlJsonText;
|
|
19
|
-
//# sourceMappingURL=ops.d.ts.map
|
package/dist/json/parse.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SqliteError } from "../errors/index.
|
|
2
|
-
import type { JsonNode } from "./types.
|
|
1
|
+
import { SqliteError } from "../errors/index.js";
|
|
2
|
+
import type { JsonNode } from "./types.js";
|
|
3
3
|
export declare class JsonParseError extends Error {
|
|
4
4
|
readonly position: number;
|
|
5
5
|
constructor(message: string, position: number);
|
|
@@ -11,4 +11,3 @@ export declare function parseJsonText(input: string, options?: {
|
|
|
11
11
|
export declare function jsonErrorPosition(input: string): number;
|
|
12
12
|
export declare function isValidJsonText(input: string, flags?: number): boolean;
|
|
13
13
|
export declare function malformedJsonError(position?: number): SqliteError;
|
|
14
|
-
//# sourceMappingURL=parse.d.ts.map
|
package/dist/json/path.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JsonNode } from "./types.
|
|
1
|
+
import type { JsonNode } from "./types.js";
|
|
2
2
|
export type PathStep = {
|
|
3
3
|
kind: "root";
|
|
4
4
|
} | {
|
|
@@ -24,4 +24,3 @@ export interface PathParent {
|
|
|
24
24
|
}
|
|
25
25
|
/** Locate parent container for the final path step (for mutate). */
|
|
26
26
|
export declare function pathParent(root: JsonNode, steps: PathStep[]): PathParent | null;
|
|
27
|
-
//# sourceMappingURL=path.d.ts.map
|
package/dist/json/stringify.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { JsonNode } from "./types.
|
|
1
|
+
import type { JsonNode } from "./types.js";
|
|
2
2
|
export declare function stringifyJson(node: JsonNode): string;
|
|
3
3
|
export declare function jsonQuoteString(value: string): string;
|
|
4
4
|
export declare function prettyJson(node: JsonNode, indent?: string): string;
|
|
5
|
-
//# sourceMappingURL=stringify.d.ts.map
|
package/dist/json/tvf.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SqlValue } from "../types/value.
|
|
1
|
+
import type { SqlValue } from "../types/value.js";
|
|
2
2
|
export interface JsonTvfRow {
|
|
3
3
|
key: SqlValue;
|
|
4
4
|
value: SqlValue;
|
|
@@ -11,4 +11,3 @@ export interface JsonTvfRow {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function jsonEachRows(json: SqlValue, path?: SqlValue): JsonTvfRow[];
|
|
13
13
|
export declare function jsonTreeRows(json: SqlValue, path?: SqlValue): JsonTvfRow[];
|
|
14
|
-
//# sourceMappingURL=tvf.d.ts.map
|
package/dist/json/types.d.ts
CHANGED
|
@@ -27,4 +27,3 @@ export type JsonNode = {
|
|
|
27
27
|
export type JsonTypeName = "null" | "true" | "false" | "integer" | "real" | "text" | "array" | "object";
|
|
28
28
|
export declare function jsonTypeName(node: JsonNode): JsonTypeName;
|
|
29
29
|
export declare function cloneJson(node: JsonNode): JsonNode;
|
|
30
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/lexer/tokenize.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/** Lexer token kind: keywords, literals, operators, and punctuation. */
|
|
1
2
|
export type TokenKind = "EOF" | "IDENT" | "STRING" | "NUMBER" | "BLOB" | "PARAM_POS" | "PARAM_NAMED" | "DOT" | "COMMA" | "SEMI" | "LPAREN" | "RPAREN" | "PLUS" | "MINUS" | "STAR" | "SLASH" | "PERCENT" | "EQ" | "EQEQ" | "NE" | "LT" | "LE" | "GT" | "GE" | "CONCAT" | "AMP" | "PIPE" | "LSHIFT" | "RSHIFT" | "JSON_ARROW" | "JSON_ARROW2" | "TILDE" | "ABORT" | "ACTION" | "ADD" | "AFTER" | "ALL" | "ALTER" | "ANALYZE" | "AND" | "AS" | "ASC" | "ATTACH" | "AUTOINCREMENT" | "BEFORE" | "BEGIN" | "BETWEEN" | "BY" | "CASCADE" | "CASE" | "CAST" | "CHECK" | "COLLATE" | "COLUMN" | "COMMIT" | "CONFLICT" | "CONSTRAINT" | "CREATE" | "CROSS" | "CURRENT" | "CURRENT_DATE" | "CURRENT_TIME" | "CURRENT_TIMESTAMP" | "DATABASE" | "DEFAULT" | "DEFERRABLE" | "DEFERRED" | "DELETE" | "DESC" | "DETACH" | "DISTINCT" | "DO" | "DROP" | "EACH" | "ELSE" | "END" | "ESCAPE" | "EXCEPT" | "EXCLUDE" | "EXCLUSIVE" | "EXISTS" | "EXPLAIN" | "FAIL" | "FILTER" | "FIRST" | "FOLLOWING" | "FOR" | "FOREIGN" | "FROM" | "FULL" | "GENERATED" | "GLOB" | "GROUP" | "GROUPS" | "HAVING" | "IF" | "IGNORE" | "IMMEDIATE" | "IN" | "INDEX" | "INDEXED" | "INITIALLY" | "INNER" | "INSERT" | "INSTEAD" | "INTERSECT" | "INTO" | "IS" | "ISNULL" | "JOIN" | "KEY" | "LAST" | "LEFT" | "LIKE" | "LIMIT" | "MATCH" | "MATERIALIZED" | "NATURAL" | "NO" | "NOT" | "NOTHING" | "NOTNULL" | "NULL" | "NULLS" | "OF" | "OFFSET" | "ON" | "OR" | "ORDER" | "OTHERS" | "OUTER" | "OVER" | "PARTITION" | "PLAN" | "PRAGMA" | "PRECEDING" | "PRIMARY" | "QUERY" | "RAISE" | "RANGE" | "RECURSIVE" | "REFERENCES" | "REGEXP" | "REINDEX" | "RELEASE" | "RENAME" | "REPLACE" | "RESTRICT" | "RETURNING" | "RIGHT" | "ROLLBACK" | "ROW" | "ROWS" | "SAVEPOINT" | "SELECT" | "SET" | "TABLE" | "TEMP" | "TEMPORARY" | "THEN" | "TIES" | "TO" | "TRANSACTION" | "TRIGGER" | "UNBOUNDED" | "UNION" | "UNIQUE" | "UPDATE" | "USING" | "VACUUM" | "VALUES" | "VIEW" | "VIRTUAL" | "WHEN" | "WHERE" | "WINDOW" | "WITH" | "WITHOUT";
|
|
3
|
+
/** A single lexer token from {@link tokenize}. */
|
|
2
4
|
export interface Token {
|
|
3
5
|
kind: TokenKind;
|
|
4
6
|
value: string;
|
|
@@ -12,6 +14,10 @@ export interface Token {
|
|
|
12
14
|
start: number;
|
|
13
15
|
end: number;
|
|
14
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Lex `input` into SQLite tokens (keywords, literals, operators, parameters).
|
|
19
|
+
*
|
|
20
|
+
* @param input - SQL source text.
|
|
21
|
+
*/
|
|
15
22
|
export declare function tokenize(input: string): Token[];
|
|
16
23
|
export declare function isKeyword(kind: TokenKind): boolean;
|
|
17
|
-
//# sourceMappingURL=tokenize.d.ts.map
|
package/dist/parser/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type { Statement } from "../ast/nodes.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
1
|
+
import type { Statement as ParsedStatement } from "../ast/nodes.js";
|
|
2
|
+
/** Parsed SQL statement AST (`SELECT`, `INSERT`, `CREATE TABLE`, …). */
|
|
3
|
+
export type { Statement as ParsedStatement } from "../ast/nodes.js";
|
|
4
|
+
export { parseTokens } from "./parser.js";
|
|
5
|
+
/**
|
|
6
|
+
* Tokenize `sql` and parse every semicolon-separated statement.
|
|
7
|
+
*
|
|
8
|
+
* @param sql - SQLite SQL text.
|
|
9
|
+
* @returns AST statements in source order.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parse(sql: string): ParsedStatement[];
|
package/dist/parser/parser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Expr, SelectStmt, Statement } from "../ast/nodes.
|
|
2
|
-
import type { Token } from "../lexer/tokenize.
|
|
1
|
+
import type { Expr, SelectStmt, Statement } from "../ast/nodes.js";
|
|
2
|
+
import type { Token } from "../lexer/tokenize.js";
|
|
3
3
|
export declare class Parser {
|
|
4
4
|
private readonly tokens;
|
|
5
5
|
private pos;
|
|
@@ -67,6 +67,7 @@ export declare class Parser {
|
|
|
67
67
|
private parseConflictAction;
|
|
68
68
|
private parseFkAction;
|
|
69
69
|
private parseFkActions;
|
|
70
|
+
private parseDeferrable;
|
|
70
71
|
private parseOrConflict;
|
|
71
72
|
private parseCreateIndex;
|
|
72
73
|
private parseCreateView;
|
|
@@ -101,4 +102,3 @@ export declare class Parser {
|
|
|
101
102
|
private parseFrameBound;
|
|
102
103
|
}
|
|
103
104
|
export declare function parseTokens(tokens: Token[]): Statement[];
|
|
104
|
-
//# sourceMappingURL=parser.d.ts.map
|
package/dist/planner/access.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Expr, FromItem, TableRef } from "../ast/nodes.
|
|
2
|
-
import type { ExecutionEnv } from "../executor/env.
|
|
3
|
-
import type { Row } from "../storage/row.
|
|
4
|
-
import type { Table } from "../storage/table.
|
|
5
|
-
import type { SqlValue } from "../types/value.
|
|
1
|
+
import type { Expr, FromItem, TableRef } from "../ast/nodes.js";
|
|
2
|
+
import type { ExecutionEnv } from "../executor/env.js";
|
|
3
|
+
import type { Row } from "../storage/row.js";
|
|
4
|
+
import type { Table } from "../storage/table.js";
|
|
5
|
+
import type { SqlValue } from "../types/value.js";
|
|
6
6
|
export interface ConstEquality {
|
|
7
7
|
table: string | null;
|
|
8
8
|
column: string;
|
|
@@ -10,6 +10,10 @@ export interface ConstEquality {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function conjunctions(expr: Expr): Expr[];
|
|
12
12
|
export declare function equalityAgainstConst(expr: Expr): ConstEquality | null;
|
|
13
|
+
export declare function equalityAgainstExpr(expr: Expr): {
|
|
14
|
+
expr: Expr;
|
|
15
|
+
valueExpr: Expr;
|
|
16
|
+
} | null;
|
|
13
17
|
export declare function whereFullyCovered(where: Expr, coveredColumns: Set<string>, alias: string, tableName: string): boolean;
|
|
14
18
|
export interface TableRowLookup {
|
|
15
19
|
table: Table;
|
|
@@ -21,6 +25,10 @@ export interface TableRowLookup {
|
|
|
21
25
|
/** Look up rows for a simple `FROM table WHERE ...` using PK, a covering equality index, or an automatic hash. */
|
|
22
26
|
export declare function tryIndexedTableRows(from: FromItem, where: Expr, env: ExecutionEnv): TableRowLookup | null;
|
|
23
27
|
export declare function lookupTableRows(from: TableRef, where: Expr, env: ExecutionEnv): TableRowLookup | null;
|
|
28
|
+
export declare function tryIndexedOrder(from: FromItem, order: {
|
|
29
|
+
expr: Expr;
|
|
30
|
+
dir: "ASC" | "DESC";
|
|
31
|
+
}, env: ExecutionEnv, limit?: number): TableRowLookup | null;
|
|
24
32
|
export interface JoinProbe {
|
|
25
33
|
table: Table;
|
|
26
34
|
alias: string;
|
|
@@ -40,4 +48,3 @@ export interface JoinEqualityKeys {
|
|
|
40
48
|
}
|
|
41
49
|
export declare function tryJoinEqualityKeys(right: FromItem, on: Expr | null, env?: ExecutionEnv): JoinEqualityKeys | null;
|
|
42
50
|
export declare function tryJoinProbe(right: FromItem, on: Expr | null, env: ExecutionEnv): JoinProbe | null;
|
|
43
|
-
//# sourceMappingURL=access.d.ts.map
|
package/dist/planner/index.d.ts
CHANGED
package/dist/runtime/clock.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
/** Fixed reference instant used when callers do not supply a clock. */
|
|
1
|
+
/** Fixed reference instant used when callers do not supply a clock (`2000-01-01T00:00:00.000Z`). */
|
|
2
2
|
export declare const DEFAULT_NOW: Date;
|
|
3
|
+
/** Function that returns the current instant for `date('now')` and related builtins. */
|
|
3
4
|
export type Clock = () => Date;
|
|
5
|
+
/**
|
|
6
|
+
* Clock that always returns a copy of `instant` (default {@link DEFAULT_NOW}).
|
|
7
|
+
*
|
|
8
|
+
* @throws {RangeError} If `instant` is an invalid `Date`.
|
|
9
|
+
*/
|
|
4
10
|
export declare function fixedClock(instant?: Date): Clock;
|
|
11
|
+
/** Normalize a `Date`, {@link Clock}, or `undefined` into a {@link Clock}. */
|
|
5
12
|
export declare function resolveClock(now?: Date | Clock): Clock;
|
|
6
|
-
//# sourceMappingURL=clock.d.ts.map
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { type Clock, DEFAULT_NOW, fixedClock, resolveClock } from "./clock.
|
|
2
|
-
export { type DatabaseOptions, DEFAULT_DATABASE_SEED } from "./options.
|
|
3
|
-
export { deriveSeed, Prng } from "./prng.
|
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { type Clock, DEFAULT_NOW, fixedClock, resolveClock } from "./clock.js";
|
|
2
|
+
export { type DatabaseOptions, DEFAULT_DATABASE_SEED } from "./options.js";
|
|
3
|
+
export { deriveSeed, Prng } from "./prng.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { Clock } from "./clock.
|
|
2
|
-
import type { Prng } from "./prng.
|
|
1
|
+
import type { Clock } from "./clock.js";
|
|
2
|
+
import type { Prng } from "./prng.js";
|
|
3
|
+
/** Options for {@link Database} construction. All fields are optional. */
|
|
3
4
|
export interface DatabaseOptions {
|
|
4
5
|
/**
|
|
5
6
|
* Seed for deterministic `random()` (and any other PRNG-backed builtins).
|
|
6
|
-
* Defaults to `1
|
|
7
|
+
* Defaults to {@link DEFAULT_DATABASE_SEED} (`1`).
|
|
7
8
|
*/
|
|
8
9
|
seed?: number | bigint;
|
|
9
10
|
/**
|
|
@@ -15,5 +16,5 @@ export interface DatabaseOptions {
|
|
|
15
16
|
/** Optional pre-built PRNG (takes precedence over `seed`). */
|
|
16
17
|
prng?: Prng;
|
|
17
18
|
}
|
|
19
|
+
/** Default {@link DatabaseOptions.seed} when constructing a {@link Database}. */
|
|
18
20
|
export declare const DEFAULT_DATABASE_SEED = 1;
|
|
19
|
-
//# sourceMappingURL=options.d.ts.map
|
package/dist/runtime/prng.d.ts
CHANGED
|
@@ -4,17 +4,28 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare class Prng {
|
|
6
6
|
private state;
|
|
7
|
+
/**
|
|
8
|
+
* @param seed - Engine seed. `0` is replaced with a non-zero constant.
|
|
9
|
+
*/
|
|
7
10
|
constructor(seed?: number | bigint);
|
|
8
11
|
/** Next unsigned 64-bit value. */
|
|
9
12
|
nextU64(): bigint;
|
|
10
13
|
/** SQLite `random()` style signed 64-bit integer in [-2^63+1, 2^63-1]. */
|
|
11
14
|
nextSqliteRandom(): bigint;
|
|
15
|
+
/** Next float in `[0, 1)` from 53 bits of {@link nextU64}. */
|
|
12
16
|
nextFloat(): number;
|
|
17
|
+
/**
|
|
18
|
+
* Next integer in `[min, max]` (inclusive).
|
|
19
|
+
*
|
|
20
|
+
* @throws {RangeError} If `max < min`.
|
|
21
|
+
*/
|
|
13
22
|
nextInt(min: number, max: number): number;
|
|
14
23
|
/** Current unsigned 64-bit engine state (for snapshot / transaction rollback). */
|
|
15
24
|
getState(): bigint;
|
|
25
|
+
/** Restore unsigned 64-bit engine state from {@link getState}. */
|
|
16
26
|
setState(state: bigint): void;
|
|
27
|
+
/** Independent copy with the same engine state. */
|
|
17
28
|
clone(): Prng;
|
|
18
29
|
}
|
|
30
|
+
/** FNV-1a hash of `parts` as a signed 32-bit seed (for tests and custom PRNGs). */
|
|
19
31
|
export declare function deriveSeed(...parts: Array<number | string | bigint>): number;
|
|
20
|
-
//# sourceMappingURL=prng.d.ts.map
|
package/dist/schema/catalog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DatabaseState } from "../storage/database-state.
|
|
2
|
-
import { Table } from "../storage/table.
|
|
1
|
+
import type { DatabaseState } from "../storage/database-state.js";
|
|
2
|
+
import { Table } from "../storage/table.js";
|
|
3
3
|
export type SchemaObjectType = "table" | "index" | "view" | "trigger";
|
|
4
4
|
export interface SchemaCatalogRow {
|
|
5
5
|
type: SchemaObjectType;
|
|
@@ -12,4 +12,3 @@ export declare function schemaCatalogRows(state: DatabaseState): SchemaCatalogRo
|
|
|
12
12
|
export declare function buildSchemaCatalog(state: DatabaseState, name?: string): Table;
|
|
13
13
|
export declare function buildSqliteSchema(state: DatabaseState): Table;
|
|
14
14
|
export declare function buildSqliteMaster(state: DatabaseState): Table;
|
|
15
|
-
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import { DatabaseState } from "../storage/database-state.
|
|
1
|
+
import { DatabaseState } from "../storage/database-state.js";
|
|
2
|
+
/** PRNG + clock captured alongside schema/rows in a v2 snapshot. */
|
|
2
3
|
export interface SnapshotRuntime {
|
|
4
|
+
/** Unsigned 64-bit {@link Prng} state. */
|
|
3
5
|
prngState: bigint;
|
|
6
|
+
/** Clock instant as milliseconds since Unix epoch. */
|
|
4
7
|
nowMs: number;
|
|
5
8
|
}
|
|
9
|
+
/** Result of {@link decodeDatabaseState}. */
|
|
6
10
|
export interface DecodedSnapshot {
|
|
11
|
+
/** Restored catalog and table data. */
|
|
7
12
|
state: DatabaseState;
|
|
13
|
+
/** Present for v2 snapshots; `null` for v1 (schema/rows only). */
|
|
8
14
|
runtime: SnapshotRuntime | null;
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Encode catalog, rows, and runtime into a sqlite-mem snapshot blob (not a `.sqlite` file).
|
|
18
|
+
*
|
|
19
|
+
* Prefer {@link Database.snapshot} unless you are serializing engine state directly.
|
|
20
|
+
*/
|
|
10
21
|
export declare function encodeDatabaseState(state: DatabaseState, runtime: SnapshotRuntime): Uint8Array;
|
|
22
|
+
/**
|
|
23
|
+
* Decode a blob from {@link encodeDatabaseState} / {@link Database.snapshot}.
|
|
24
|
+
*
|
|
25
|
+
* @throws {SqliteError} If the magic, version, or payload is invalid.
|
|
26
|
+
*/
|
|
11
27
|
export declare function decodeDatabaseState(snapshot: Uint8Array): DecodedSnapshot;
|
|
12
|
-
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { type DecodedSnapshot, decodeDatabaseState, encodeDatabaseState, type SnapshotRuntime, } from "./codec.
|
|
2
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { type DecodedSnapshot, decodeDatabaseState, encodeDatabaseState, type SnapshotRuntime, } from "./codec.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { CreateIndexStmt, CreateTableStmt, CreateViewStmt, CreateVirtualTableStmt, Expr, IndexedColumn, SelectStmt } from "../ast/nodes.
|
|
2
|
-
import { IndexStore } from "../indexes/index.
|
|
3
|
-
import { Fts5VirtualTable } from "../vtable/fts5.
|
|
4
|
-
import { BytecodeVirtualTable, DbStatVirtualTable, FtsVocabVirtualTable, RTreeVirtualTable, TablesUsedVirtualTable } from "../vtable/modules.
|
|
5
|
-
import type { Rowid } from "./row.
|
|
6
|
-
import { Table } from "./table.
|
|
1
|
+
import type { CreateIndexStmt, CreateTableStmt, CreateViewStmt, CreateVirtualTableStmt, Expr, IndexedColumn, SelectStmt } from "../ast/nodes.js";
|
|
2
|
+
import { IndexStore } from "../indexes/index.js";
|
|
3
|
+
import { Fts5VirtualTable } from "../vtable/fts5.js";
|
|
4
|
+
import { BytecodeVirtualTable, DbStatVirtualTable, FtsVocabVirtualTable, RTreeVirtualTable, TablesUsedVirtualTable } from "../vtable/modules.js";
|
|
5
|
+
import type { Rowid } from "./row.js";
|
|
6
|
+
import { Table } from "./table.js";
|
|
7
7
|
export type AnyVirtualTable = Fts5VirtualTable | RTreeVirtualTable | DbStatVirtualTable | BytecodeVirtualTable | TablesUsedVirtualTable | FtsVocabVirtualTable;
|
|
8
8
|
export interface ViewInfo {
|
|
9
9
|
name: string;
|
|
@@ -28,10 +28,11 @@ export interface TriggerInfo {
|
|
|
28
28
|
when: Expr | null;
|
|
29
29
|
forEachRow: boolean;
|
|
30
30
|
/** Statements in the trigger body (already parsed). */
|
|
31
|
-
body: import("../ast/nodes.
|
|
31
|
+
body: import("../ast/nodes.js").Statement[];
|
|
32
32
|
updateColumns: string[] | null;
|
|
33
33
|
originalSql: string | null;
|
|
34
34
|
}
|
|
35
|
+
/** In-memory catalog: tables, indexes, views, triggers, and mutation counters. */
|
|
35
36
|
export declare class DatabaseState {
|
|
36
37
|
tables: Map<string, Table>;
|
|
37
38
|
virtualTables: Map<string, AnyVirtualTable>;
|
|
@@ -74,6 +75,14 @@ export declare class DatabaseState {
|
|
|
74
75
|
dropTriggersForTable(tableName: string): void;
|
|
75
76
|
recordChange(count: number, lastInsertRowid?: Rowid): void;
|
|
76
77
|
clone(): DatabaseState;
|
|
78
|
+
/** Share table/index objects with the live state. Callers must freeze first. */
|
|
79
|
+
cloneShallow(): DatabaseState;
|
|
80
|
+
freezeShared(): void;
|
|
81
|
+
thawShared(): void;
|
|
82
|
+
getWritableTable(name: string): Table;
|
|
83
|
+
ensureWritableTable(table: Table): Table;
|
|
84
|
+
getWritableIndex(name: string): IndexInfo;
|
|
85
|
+
ensureWritableIndex(index: IndexInfo): IndexInfo;
|
|
77
86
|
replaceWith(state: DatabaseState, options?: {
|
|
78
87
|
adopt?: boolean;
|
|
79
88
|
}): void;
|
|
@@ -83,4 +92,3 @@ export declare function splitQualifiedName(name: string): {
|
|
|
83
92
|
schema: string | null;
|
|
84
93
|
bare: string;
|
|
85
94
|
};
|
|
86
|
-
//# sourceMappingURL=database-state.d.ts.map
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export type { IndexInfo, ViewInfo } from "./database-state.
|
|
2
|
-
export { DatabaseState } from "./database-state.
|
|
3
|
-
export type { Row, Rowid, RowValues } from "./row.
|
|
4
|
-
export { cloneRow, normalizeColumnName, rowValues } from "./row.
|
|
5
|
-
export type { ColumnInfo, InsertRow, TableOptions } from "./table.
|
|
6
|
-
export { makeColumnInfo, Table } from "./table.
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export type { IndexInfo, ViewInfo } from "./database-state.js";
|
|
2
|
+
export { DatabaseState } from "./database-state.js";
|
|
3
|
+
export type { Row, Rowid, RowValues } from "./row.js";
|
|
4
|
+
export { cloneRow, normalizeColumnName, rowValues } from "./row.js";
|
|
5
|
+
export type { ColumnInfo, InsertRow, TableOptions } from "./table.js";
|
|
6
|
+
export { makeColumnInfo, Table } from "./table.js";
|
package/dist/storage/row.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SqlValue } from "../types/value.
|
|
1
|
+
import type { SqlValue } from "../types/value.js";
|
|
2
2
|
export type Rowid = number | bigint;
|
|
3
3
|
export interface Row {
|
|
4
4
|
rowid: Rowid;
|
|
@@ -8,4 +8,3 @@ export type RowValues = Map<string, SqlValue> | ReadonlyMap<string, SqlValue> |
|
|
|
8
8
|
export declare function normalizeColumnName(name: string): string;
|
|
9
9
|
export declare function rowValues(values: RowValues): Map<string, SqlValue>;
|
|
10
10
|
export declare function cloneRow(row: Row): Row;
|
|
11
|
-
//# sourceMappingURL=row.d.ts.map
|
package/dist/storage/table.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Expr, TableConstraint } from "../ast/nodes.
|
|
2
|
-
import type { Affinity, SqlValue } from "../types/value.
|
|
3
|
-
import type { Row, Rowid, RowValues } from "./row.
|
|
1
|
+
import type { Expr, TableConstraint } from "../ast/nodes.js";
|
|
2
|
+
import type { Affinity, SqlValue } from "../types/value.js";
|
|
3
|
+
import type { Row, Rowid, RowValues } from "./row.js";
|
|
4
4
|
export interface ColumnInfo {
|
|
5
5
|
name: string;
|
|
6
6
|
/** Cached `name.toLowerCase()` for hot-path lookups. */
|
|
@@ -35,6 +35,7 @@ export interface TableOptions {
|
|
|
35
35
|
indexes?: string[];
|
|
36
36
|
originalSql?: string | null;
|
|
37
37
|
withoutRowid?: boolean;
|
|
38
|
+
strict?: boolean;
|
|
38
39
|
}
|
|
39
40
|
export declare class Table {
|
|
40
41
|
name: string;
|
|
@@ -45,11 +46,13 @@ export declare class Table {
|
|
|
45
46
|
indexes: string[];
|
|
46
47
|
originalSql: string | null;
|
|
47
48
|
withoutRowid: boolean;
|
|
49
|
+
strict: boolean;
|
|
48
50
|
/** Clustered PK key string → row for WITHOUT ROWID tables. */
|
|
49
51
|
clusteredRows: Map<string, Row>;
|
|
50
52
|
private scanCache;
|
|
51
53
|
/** Lazy covering hashes: column nameLower → serializeIndexKey → rowids. */
|
|
52
54
|
private equalityHashes;
|
|
55
|
+
frozen: boolean;
|
|
53
56
|
constructor(name: string, columns: ColumnInfo[], options?: TableOptions);
|
|
54
57
|
integerPkColumn(): ColumnInfo | undefined;
|
|
55
58
|
get(rowid: Rowid): Row | undefined;
|
|
@@ -73,6 +76,8 @@ export declare class Table {
|
|
|
73
76
|
delete(rowid: Rowid): boolean;
|
|
74
77
|
scan(): Iterable<Row>;
|
|
75
78
|
clone(): Table;
|
|
79
|
+
freeze(): void;
|
|
80
|
+
private assertMutable;
|
|
76
81
|
/** Rebuild clustered storage after snapshot decode or bulk load. */
|
|
77
82
|
rebuildClusteredRows(): void;
|
|
78
83
|
private prepareValues;
|
|
@@ -87,4 +92,3 @@ export declare class Table {
|
|
|
87
92
|
private advanceNextRowid;
|
|
88
93
|
}
|
|
89
94
|
export declare function makeColumnInfo(name: string, typeName: string | null, options?: Partial<Omit<ColumnInfo, "name" | "nameLower" | "typeName" | "affinity">>): ColumnInfo;
|
|
90
|
-
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Prng } from "../runtime/prng.
|
|
2
|
-
import type { DatabaseState } from "../storage/database-state.
|
|
1
|
+
import type { Prng } from "../runtime/prng.js";
|
|
2
|
+
import type { DatabaseState } from "../storage/database-state.js";
|
|
3
3
|
export declare class TransactionManager {
|
|
4
4
|
readonly state: DatabaseState;
|
|
5
5
|
readonly prng: Prng;
|
|
@@ -17,4 +17,3 @@ export declare class TransactionManager {
|
|
|
17
17
|
private findSavepoint;
|
|
18
18
|
private requireTransaction;
|
|
19
19
|
}
|
|
20
|
-
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type SqlValue } from "./value.
|
|
1
|
+
import { type SqlValue } from "./value.js";
|
|
2
2
|
export type BuiltinCollation = "BINARY" | "NOCASE" | "RTRIM";
|
|
3
3
|
export declare function normalizeForCollation(value: SqlValue, name: string): SqlValue;
|
|
4
4
|
export declare function compareWithCollation(a: SqlValue, b: SqlValue, name: string): number | null;
|
|
5
|
-
//# sourceMappingURL=collation.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type SqlValue } from "./value.js";
|
|
2
|
+
export declare function isStrictTypeName(typeName: string | null | undefined): boolean;
|
|
3
|
+
export declare function applyStrictValue(value: SqlValue, typeName: string, table: string, column: string): SqlValue;
|
|
4
|
+
export declare function unknownStrictType(table: string, column: string, typeName: string): never;
|
|
5
|
+
/** SQLite reports INT for the integer storage class in STRICT errors. */
|
|
6
|
+
export declare function strictStorageLabel(value: SqlValue): string;
|
package/dist/types/value.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/** SQLite storage
|
|
1
|
+
/** SQLite storage class of a {@link SqlValue} (`null` / `integer` / `real` / `text` / `blob`). */
|
|
2
2
|
export type StorageClass = "null" | "integer" | "real" | "text" | "blob";
|
|
3
3
|
/** Integer-valued REAL that must not collapse to the integer storage class. */
|
|
4
4
|
export declare class SqlReal {
|
|
5
|
+
/** IEEE float payload (`-0` already canonicalized to `+0`). */
|
|
5
6
|
readonly value: number;
|
|
6
7
|
constructor(value: number);
|
|
7
8
|
valueOf(): number;
|
|
@@ -9,6 +10,7 @@ export declare class SqlReal {
|
|
|
9
10
|
}
|
|
10
11
|
/** SQLite JSON subtype (74 / 'J') — text that nested JSON APIs treat as JSON, not a string. */
|
|
11
12
|
export declare const JSON_SUBTYPE = 74;
|
|
13
|
+
/** TEXT value with SQLite JSON subtype 74 — nested JSON APIs treat it as JSON, not a string. */
|
|
12
14
|
export declare class SqlJsonText {
|
|
13
15
|
readonly value: string;
|
|
14
16
|
readonly subtype = 74;
|
|
@@ -16,37 +18,63 @@ export declare class SqlJsonText {
|
|
|
16
18
|
valueOf(): string;
|
|
17
19
|
toString(): string;
|
|
18
20
|
}
|
|
21
|
+
/** A SQLite value: NULL, integer/real, text, blob, or a typed REAL/JSON wrapper. */
|
|
19
22
|
export type SqlValue = null | number | bigint | string | Uint8Array | SqlReal | SqlJsonText;
|
|
23
|
+
/**
|
|
24
|
+
* A value as it appears in query result rows.
|
|
25
|
+
* {@link SqlReal} and {@link SqlJsonText} wrappers are unwrapped at the JS API surface.
|
|
26
|
+
*/
|
|
27
|
+
export type QueryValue = null | number | bigint | string | Uint8Array;
|
|
28
|
+
/** A result row keyed by column name. Duplicate SELECT names keep the last value. */
|
|
29
|
+
export type QueryRow = Record<string, QueryValue>;
|
|
30
|
+
/**
|
|
31
|
+
* Values accepted by bind slots (`?`, `?NNN`, `:name`, `@name`, `$name`).
|
|
32
|
+
* Booleans become integer 0/1; {@link ArrayBuffer} is copied as a BLOB.
|
|
33
|
+
*/
|
|
34
|
+
export type BindValue = SqlValue | boolean | ArrayBuffer;
|
|
35
|
+
/** Column type affinity from a declared type name (SQLite affinity rules). */
|
|
20
36
|
export type Affinity = "TEXT" | "NUMERIC" | "INTEGER" | "REAL" | "BLOB";
|
|
21
37
|
/** Canonicalize IEEE `-0` to `+0` for cross-runtime determinism. */
|
|
22
38
|
export declare function canonicalizeNumber(value: number): number;
|
|
39
|
+
/** Wrap `value` as {@link SqlReal} so it stays REAL even when it is an integer. */
|
|
23
40
|
export declare function asSqlReal(value: number): SqlReal;
|
|
41
|
+
/** `true` when `value` is a {@link SqlReal} wrapper. */
|
|
24
42
|
export declare function isSqlReal(value: SqlValue): value is SqlReal;
|
|
43
|
+
/** `true` when `value` is a {@link SqlJsonText} wrapper. */
|
|
25
44
|
export declare function isSqlJsonText(value: SqlValue): value is SqlJsonText;
|
|
45
|
+
/** Wrap `value` as {@link SqlJsonText} (JSON subtype 74). */
|
|
26
46
|
export declare function asSqlJsonText(value: string): SqlJsonText;
|
|
27
47
|
/** Strip ephemeral JSON subtype for table storage / non-JSON contexts. */
|
|
28
48
|
export declare function unwrapSqlValue(value: SqlValue): SqlValue;
|
|
29
49
|
export declare function subtypeOf(value: SqlValue): number;
|
|
30
50
|
export declare function numberValueOf(value: number | bigint | SqlReal): number;
|
|
51
|
+
/** SQLite storage class of `value` (`null` / `integer` / `real` / `text` / `blob`). */
|
|
31
52
|
export declare function storageClassOf(value: SqlValue): StorageClass;
|
|
53
|
+
/** SQLite `typeof()` string for `value`. */
|
|
32
54
|
export declare function typeofSql(value: SqlValue): string;
|
|
33
55
|
/** Determine column affinity from a declared type name (SQLite rules). */
|
|
34
56
|
export declare function affinityFromTypeName(typeName: string | null | undefined): Affinity;
|
|
57
|
+
/** Apply column {@link Affinity} conversion rules to `value`. */
|
|
35
58
|
export declare function applyAffinity(value: SqlValue, affinity: Affinity): SqlValue;
|
|
59
|
+
/** Parse `value` as a number, or `null` when it is not numeric. */
|
|
36
60
|
export declare function coerceToNumber(value: SqlValue): number | null;
|
|
61
|
+
/** Truncate `value` toward zero as an integer, or `null` when it is not numeric. */
|
|
37
62
|
export declare function toInteger(value: SqlValue): number | bigint | null;
|
|
63
|
+
/** SQLite `=` / `IS` equality for two non-NULL values (`NULL = NULL` is false here). */
|
|
38
64
|
export declare function sqlValueEquals(a: SqlValue, b: SqlValue): boolean;
|
|
39
65
|
/**
|
|
40
66
|
* SQLite comparison for ORDER BY / inequalities.
|
|
41
67
|
* Returns -1, 0, 1, or null if either side is NULL (SQL NULL).
|
|
42
68
|
*/
|
|
43
69
|
export declare function compareSql(a: SqlValue, b: SqlValue): number | null;
|
|
70
|
+
/** UTF-8 encode `s` (SQLite TEXT → BLOB). */
|
|
44
71
|
export declare function utf8Encode(s: string): Uint8Array;
|
|
72
|
+
/** UTF-8 decode `b` (SQLite BLOB → TEXT). */
|
|
45
73
|
export declare function utf8Decode(b: Uint8Array): string;
|
|
74
|
+
/** Deep-copy blobs and REAL/JSON wrappers; primitives are returned as-is. */
|
|
46
75
|
export declare function cloneSqlValue(v: SqlValue): SqlValue;
|
|
47
76
|
/**
|
|
48
77
|
* SQLite boolean truthiness (WHERE / HAVING / CASE / AND / OR / NOT).
|
|
49
78
|
* Non-NULL values are cast to numeric; non-numeric text/blob become 0 (false).
|
|
50
79
|
*/
|
|
51
80
|
export declare function isTruthySql(v: SqlValue): boolean | null;
|
|
52
|
-
//# sourceMappingURL=value.d.ts.map
|
|
@@ -37,4 +37,3 @@ export type FtsQueryNode = {
|
|
|
37
37
|
export declare function parseFts5Query(input: string): FtsQueryNode;
|
|
38
38
|
/** FTS3/4 query parser (ENABLE_FTS3_PARENTHESIS style). */
|
|
39
39
|
export declare function parseFts3Query(input: string): FtsQueryNode;
|
|
40
|
-
//# sourceMappingURL=query.d.ts.map
|