import { Row } from "../storage.mjs"; import { ResolverAdapter } from "../resolver/types.mjs"; import { AnalysisQuerySource } from "./source-types.mjs"; import { EngineError } from "../errors.mjs"; import "../contracts.mjs"; interface AttachedTableRunner { /** * Run a query with positional (`?`) bound parameters. Return objects keyed * by column name. BIGINT → number coercion is applied by the source factory * (see `coerceRows`); runners only need to handle DATE → ISO string (or * let the analyzer reducer normalize via `num(v)`/`str(v)`). */ query: (sql: string, params?: unknown[], signal?: AbortSignal) => Promise; } interface AttachedTableSourceOptions { /** Schema name the exported DuckDB file was attached under — e.g. `gsc`. */ schema: string; /** * Abort in-flight queries when the caller no longer cares about the * result. Every `runner.query` call receives the same signal. */ signal?: AbortSignal; /** * List of table names actually attached to this connection. When provided, * `executeSql` short-circuits with a specific "table not attached" error * if the SQL plan references a table that isn't in this list — letting * callers (e.g. the analytics layer) route to cloud fallback without * paying the SQL execution cost. Omit to disable the check. */ attachedTables?: readonly string[]; /** * Dialect adapter surfaced on the source for analyzers that compose SQL * from a `BuilderState` at plan-build time (e.g. `data-query`, * `data-detail`). Attached-table sources execute pg-flavored DuckDB SQL, * so callers should pass `pgResolverAdapter` here. */ adapter?: ResolverAdapter; } declare class AttachedTableMissingError extends Error { readonly missing: readonly string[]; readonly engineError: EngineError; constructor(missing: readonly string[]); } declare function createAttachedTableSource(runner: AttachedTableRunner, options: AttachedTableSourceOptions): AnalysisQuerySource; export { AttachedTableMissingError, AttachedTableRunner, AttachedTableSourceOptions, createAttachedTableSource };