import { DataSource } from "../storage.mjs"; import { queryDimMetaKey, queryDimParquetKey } from "../entity-keys.mjs"; import { TenantCtx } from "@gscdump/contracts"; interface QueryDimRecord { query: string; /** Lexical canonical, never empty: NULL/'' folds to the raw query. */ query_canonical: string; /** Packed search-intent code (see `@gscdump/analysis` `encodeIntent`). */ intent_code: number; normalizer_version: number; intent_version: number; } /** JSON sidecar: versions + freshness, readable without decoding the parquet. */ interface QueryDimMeta { version: 1; builtAt: number; rowCount: number; normalizerVersion: number; intentVersion: number; } /** * Injected derivation. `engine` never imports `@gscdump/analysis`; the host * passes `normalizeQuery` / `classifyIntentCode` (e.g. `encodeIntent ∘ * classifyQueryIntent`) plus their version constants. */ interface QueryDimDeps { normalizeQuery: (query: string) => string; normalizerVersion: number; /** Returns the packed intent code for a raw query. */ classifyIntentCode: (query: string) => number; intentVersion: number; } /** * Pure: distinct raw queries → dimension records. De-dupes, drops empties, and * folds an empty/whitespace canonical back to the raw query so the dimension * is total for read-time joins. */ declare function buildQueryDimRecords(queries: Iterable, deps: QueryDimDeps): QueryDimRecord[]; interface QueryDimStore { parquetKey: (ctx: TenantCtx) => string; /** Write the parquet + JSON sidecar. Last-write-wins; no history. */ write: (ctx: TenantCtx, records: readonly QueryDimRecord[], builtAt: number) => Promise<{ parquetKey: string; rowCount: number; }>; /** Read the sidecar (versions + freshness), or null on first build. */ loadMeta: (ctx: TenantCtx) => Promise; /** Decode the dimension rows (test/inspection; reads JOIN the parquet by key). */ loadRecords: (ctx: TenantCtx) => Promise; } declare function createQueryDimStore({ dataSource }: { dataSource: DataSource; }): QueryDimStore; export { QueryDimDeps, QueryDimMeta, QueryDimRecord, QueryDimStore, buildQueryDimRecords, createQueryDimStore, queryDimMetaKey, queryDimParquetKey };