import { SQL } from "drizzle-orm"; /** * Structural subset of `ResolvedWindow` from `@gscdump/engine/period`. * Inlined here to avoid the cross-module type import in this leaf module; * any object with `start`/`end` strings (and optional `days`) satisfies it. */ interface ResolvedWindow { start: string; end: string; days?: number; } interface ScopedRunnerOptions { siteId?: string; window?: ResolvedWindow; /** Inclusive lower bound for `date`. Ignored if `window` is supplied. */ startDate?: string; /** Inclusive upper bound for `date`. Ignored if `window` is supplied. */ endDate?: string; /** * Temporal granularity. `'day'` (default) filters on `table.date`. `'hour'` * filters on `table.hour` when the table exposes that column (e.g. * `hourly_pages`); falls back to date filtering otherwise. */ grain?: 'day' | 'hour'; } interface TableScope { wherePredicates: SQL[]; window?: ResolvedWindow; siteId?: string; } declare function mergeScope(scope: TableScope, ...extra: SQL[]): SQL | undefined; /** * Bind `buildTableScope` + `mergeScope` to a specific drizzle schema. Engine * adapters (`engine-sqlite`, `engine-duckdb-wasm`) call this once at module load and * re-export the returned `scopeFor` / `mergeScope` so consumers get a typed * `keyof Schema` table parameter without each adapter re-implementing the * pass-through wrapper. */ declare function createScopedHelpers>>(schema: S): { scopeFor: (table: keyof S, opts: ScopedRunnerOptions) => TableScope; mergeScope: typeof mergeScope; }; export { ResolvedWindow, ScopedRunnerOptions, TableScope, createScopedHelpers, mergeScope };