import { type ClickHouseClient, type ClickHouseClientConfigOptions } from "@clickhouse/client"; /** * Construction options for {@link createFjallClickHouseClient}. * * Every field is optional. `url` falls back to `process.env.CLICKHOUSE_URL`; * `caCert` falls back to `process.env.CLICKHOUSE_CA_CERT`. Empty strings * are treated identically to `undefined` on both — dev compose without a * CA cert injected boots transparently in plaintext, while prod ECS * containers receive the CA PEM via the secret-block on `secretsImport` * and run on `https://`. */ export interface CreateFjallClickHouseClientOptions { /** Defaults to env CLICKHOUSE_URL. Empty/undefined throws. */ readonly url?: string; /** * Defaults to env CLICKHOUSE_CA_CERT (PEM string injected by the ECS * `secrets:` block from `ClickHouseDatabase.tlsCaSecret`). Absent/empty * disables the `tls:` config (plaintext fallback for dev compose). */ readonly caCert?: string; readonly username?: string; readonly password?: string; /** Optional database name override. */ readonly database?: string; /** Merged over {@link WIRE_FORMAT_CLICKHOUSE_SETTINGS}; caller keys win. */ readonly clickhouse_settings?: ClickHouseClientConfigOptions["clickhouse_settings"]; readonly compression?: ClickHouseClientConfigOptions["compression"]; readonly request_timeout?: number; readonly max_open_connections?: number; readonly keep_alive?: ClickHouseClientConfigOptions["keep_alive"]; } /** * The Fjall wire-format contract, applied to every client this factory * builds: DateTime/DateTime64 columns serialise as RFC3339 instants with a * timezone designator (`2026-08-23T01:23:45.678Z`), so consumers may * `new Date(value)` any timestamp the server returns — no bespoke parser. * Inputs stay tolerant (`best_effort` accepts both the ISO shape and the * legacy `YYYY-MM-DD hh:mm:ss` form). * * Asymmetry to know: typed query PARAMETERS (`{x:DateTime64(3)}`) are bound * by a separate parser that rejects a trailing `Z` regardless of * `date_time_input_format` — keep formatting bind parameters without the * designator (ClickHouse 26.3, verified). * * Caller-supplied `clickhouse_settings` spread AFTER these, so a caller can * override either setting deliberately. */ export declare const WIRE_FORMAT_CLICKHOUSE_SETTINGS: { readonly date_time_output_format: "iso"; readonly date_time_input_format: "best_effort"; }; /** * Sync factory wrapping `@clickhouse/client`'s `createClient`. No AWS SDK * call, no `await`, no module-level cache — the CA PEM is already on * `process.env` when the container's user code runs because ECS resolves * the `secrets:` block during container bring-up. * * `tls.ca_cert` MUST be a `Buffer` per the `@clickhouse/client` contract. * Passing a raw string type-checks (the field accepts `Buffer | string` * structurally) but the underlying TLS stack silently skips the * trust-store add and the handshake fails downstream. Wrap explicitly * with `Buffer.from(pem, "utf8")`. */ export declare function createFjallClickHouseClient(opts?: CreateFjallClickHouseClientOptions): ClickHouseClient;