export declare const OPS: readonly ["eq", "neq", "in", "not_in", "gt", "gte", "lt", "lte", "between", "contains", "is_null", "not_null"]; export declare const AGG_FNS: readonly ["count", "count_distinct", "sum", "avg", "min", "max"]; export declare const BUCKETS: readonly ["day", "week", "month", "quarter", "year"]; export declare const SORT_DIRS: readonly ["asc", "desc"]; export declare const DEFAULT_ROW_CAP = 500; export declare const OFFSET_CAP = 10000; export declare const GROUP_BY_CAP = 3; export declare const STATEMENT_TIMEOUT_MS = 2000; export declare const RELATIVE_DATE_TOKENS: readonly ["@today", "@today-Nd", "@today+Nd", "@today-Nw", "@today+Nw", "@today-Nm", "@today+Nm", "@today-Ny", "@today+Ny", "@month_start", "@quarter_start", "@fy_start"]; export declare const REPORT_VIEW_GRAMMAR: { readonly operators: readonly [{ readonly op: "eq"; readonly value: "scalar"; }, { readonly op: "neq"; readonly value: "scalar"; }, { readonly op: "in"; readonly value: "array"; }, { readonly op: "not_in"; readonly value: "array"; }, { readonly op: "gt"; readonly value: "scalar"; }, { readonly op: "gte"; readonly value: "scalar"; }, { readonly op: "lt"; readonly value: "scalar"; }, { readonly op: "lte"; readonly value: "scalar"; }, { readonly op: "between"; readonly value: "[from, to]"; }, { readonly op: "contains"; readonly value: "bare string — wildcards escaped, compiled as ILIKE %value%. Do not send % or SQL LIKE syntax."; }, { readonly op: "is_null"; readonly value: "none"; }, { readonly op: "not_null"; readonly value: "none"; }]; readonly aggregates: readonly ["count", "count_distinct", "sum", "avg", "min", "max"]; readonly buckets: readonly ["day", "week", "month", "quarter", "year"]; readonly sort_dirs: readonly ["asc", "desc"]; readonly relative_dates: { readonly tokens: readonly ["@today", "@today-Nd", "@today+Nd", "@today-Nw", "@today+Nw", "@today-Nm", "@today+Nm", "@today-Ny", "@today+Ny", "@month_start", "@quarter_start", "@fy_start"]; readonly example: "@today-30d"; readonly timezone: "Asia/Kolkata"; readonly fy_anchor: "04-01"; readonly note: "Resolved server-side to an ISO calendar date in Asia/Kolkata. @fy_start is 1 April (Indian FY); in January–March that is last April. Do not compute today or period boundaries in the client."; }; readonly caller: { readonly tokens: readonly ["@me"]; readonly note: "Resolved server-side to the caller: user id on id-type columns, email on string columns. Incompatible columns return value_type_mismatch."; }; readonly rails: { readonly tenancy: "injected"; readonly limit_cap: 500; readonly group_by_cap: 3; readonly offset_cap: 10000; readonly statement_timeout_ms: 2000; }; readonly join: { readonly max: 1; readonly cardinality: "many_to_one"; readonly columns: "."; readonly semantics: "LEFT JOIN; unmatched rows yield nulls for .*"; readonly note: "Name a catalog-declared relationship from view_describe. Do not send ON conditions."; }; }; export type ReportViewOp = (typeof OPS)[number]; export type ReportViewAggFn = (typeof AGG_FNS)[number]; export type ReportViewBucket = (typeof BUCKETS)[number]; export type CatalogColumn = { name: string; display_name?: string; description?: string; semantic_type?: string; enum_map?: Record; format?: Record; filterable?: boolean; groupable?: boolean; aggregatable?: string[]; bucketable?: boolean; sensitive?: boolean; visibility?: boolean; }; export type CatalogView = { catalog_name: string; table_name: string; title?: string; description?: string; grain?: string; domain?: string; tenancy_column: string; user_scoped?: boolean; user_column?: string; view_kind?: 'view' | 'materialized'; row_cap: number; last_run_time?: Date | string | null; example_queries?: Array<{ q: string; dsl: ReportViewDsl; }>; suggested_visualizations?: unknown[]; columns: CatalogColumn[]; relationships?: CatalogRelationship[]; }; export type ReportViewFilter = { column?: string; op?: string; value?: unknown; }; export type ReportViewGroupBy = { column?: string; bucket?: string; }; export type ReportViewAggregate = { fn?: string; column?: string; as?: string; }; export type ReportViewSort = { by?: string; dir?: string; }; export type CatalogRelationship = { name: string; view: string; on: Record; when?: Record; cardinality: string; description?: string; target?: CatalogView; }; export type ReportViewDsl = { join?: string | string[]; columns?: string[]; filters?: ReportViewFilter[]; group_by?: ReportViewGroupBy[]; aggregates?: ReportViewAggregate[]; sort?: ReportViewSort[]; limit?: number; offset?: number; }; export type CompiledQuery = { sql: string; params: unknown[]; limit: number; offset: number; fetchLimit: number; output: Array<{ name: string; title: string; type: string; format?: Record; enum_map?: Record; }>; view: { name: string; grain?: string; table_name: string; refreshed_at: Date | string | null; live?: boolean; }; }; export declare class ReportViewQueryError extends Error { readonly code: string; constructor(code: string, message: string); } export type CompileOptions = { now?: Date; user?: { id: number; email?: string; }; }; export declare function compileReportViewQuery(view: CatalogView, dsl: ReportViewDsl, businessId: number, options?: CompileOptions): CompiledQuery; export declare function agentVisibleColumns(view: CatalogView): CatalogColumn[]; export declare function quoteIdent(name: string): string; export declare function resolveRelativeDate(value: unknown, now: Date): unknown; export declare function nearest(input: string, names: string[], n: number): string[]; export declare const ReportViewQueryCompiler: { compileReportViewQuery: typeof compileReportViewQuery; agentVisibleColumns: typeof agentVisibleColumns; quoteIdent: typeof quoteIdent; resolveRelativeDate: typeof resolveRelativeDate; nearest: typeof nearest; RELATIVE_DATE_TOKENS: readonly ["@today", "@today-Nd", "@today+Nd", "@today-Nw", "@today+Nw", "@today-Nm", "@today+Nm", "@today-Ny", "@today+Ny", "@month_start", "@quarter_start", "@fy_start"]; };