UNPKG

staticql

Version:

Type-safe query engine for static content including Markdown, YAML, JSON, and more.

67 lines (66 loc) 2.35 kB
import { Indexer } from "./Indexer.js"; import { QueryBuilder } from "./QueryBuilder.js"; import { SourceConfig, SourceConfigResolver, SourceRecord } from "./SourceConfigResolver.js"; import { StorageRepository } from "./repository/StorageRepository.js"; import { Validator } from "./validator/Validator.js"; import { LoggerProvider } from "./logger/LoggerProvider.js"; import { ParserOptions } from "./parser/index.js"; /** * Initialization options for StaticQL. */ /** * Initialization options for StaticQL. */ export interface StaticQLInitOptions { /** Validator for content schema */ validator?: Validator; /** Logger for debug/info/warning output */ logger?: LoggerProvider; /** * Parsers registry to override or extend default parsers * (e.g. CSV, XML, custom formats). */ parsers?: Record<string, (options: ParserOptions) => any>; } /** * Configuration for StaticQL. */ export interface StaticQLConfig { sources: Record<string, SourceConfig>; } /** * The core class for querying structured static content. */ export declare class StaticQL { private config; private repository; private sourceConfigResolver; private options; private validator; private logger; constructor(config: StaticQLConfig, repository: StorageRepository, sourceConfigResolver: SourceConfigResolver, options?: StaticQLInitOptions); /** * Creates a type-safe QueryBuilder for the specified source. * * @param sourceName - Name of the source. * @returns A new QueryBuilder instance. */ from<T extends SourceRecord, TIndexKey extends string = keyof {}>(sourceName: string): QueryBuilder<T, TIndexKey>; /** * Saves index files for all sources * to the configured output directory. * * @param customIndexers - Optional custom indexer callbacks for _custom indexes. * @throws If writing to the storage fails. */ saveIndexes(customIndexers?: Record<string, (value: any, record?: SourceRecord) => any>): Promise<void>; /** * Returns the configuration object used by StaticQL. */ getConfig(): StaticQLConfig; /** * Returns an Indexer instance. * Useful for incremental index updates. */ getIndexer(customIndexers?: Record<string, (value: any, record?: SourceRecord) => any>): Indexer; }