import { DatabaseSync } from "node:sqlite"; import type { Corpus } from "./types.ts"; /** * Compile a corpus into a single SQLite file. * * SQLite comes with Node, so this needs no native module, no compiler on the * machine, and no install step that can fail. Full-text search comes with it * too, which is why searching a rulebook here costs nothing to set up. * * The whole build runs inside one transaction. A build that fails half way * leaves no file a reader could mistake for a complete one. */ /** * The shape of the compiled database, as a number the reader can compare. * * `corpus.db` is a build artefact and is not in version control, so an upgraded * package meets a database an older package wrote. Version 1 held no rulings * table, and the first question then failed with `no such table: rulings`, which * names neither the cause nor the cure. * * Bump this whenever a table, an index, or a column changes. `SqliteStore.open` * refuses an older number and says which command rebuilds the file. * * This is NOT `SCHEMA_VERSION` in `schema.ts`. That one versions the JSON a * corpus author writes, and the two move for different reasons: rulings arrived * as an optional file, so the JSON format stayed at 2 while this went to 3. */ export declare const DB_SCHEMA_VERSION = 3; /** Column weights for rule ranking, highest first. */ declare const RULE_WEIGHTS: { number: number; title: number; content: number; example: number; }; declare const CARD_WEIGHTS: { name: number; type: number; text: number; }; declare const TERM_WEIGHTS: { term: number; aliases: number; definition: number; }; /** * A ruling is found by its question far more often than by its answer. * * A reader asks nearly the words somebody already asked, so the question column * carries the match. The answer is long and repeats common rules vocabulary, so * weighting it highly would rank every ruling about a popular mechanic above the * one ruling that answers the question in front of you. */ declare const RULING_WEIGHTS: { question: number; cards: number; topic: number; answer: number; }; export type BuildOptions = { /** Where to write. Use ":memory:" for a database that never touches the disk. */ path: string; }; /** * Write `corpus` to a SQLite database and return the open handle. * * Any database already at `path` is replaced. The caller owns the handle and * must close it. `SqliteStore.open` is the ordinary way to read one back. */ export declare function buildDatabase(corpus: Corpus, options: BuildOptions): DatabaseSync; export { CARD_WEIGHTS, RULE_WEIGHTS, RULING_WEIGHTS, TERM_WEIGHTS }; //# sourceMappingURL=build.d.ts.map