import { Table } from "apache-arrow"; //#region src/react/hooks/types.d.ts /** * Supported response formats for analytics queries. * * "JSON" and "ARROW" are legacy aliases kept for backwards compatibility * with appkit/appkit-ui < 0.33.0 — safe to remove once no consumer is on * a pre-0.33.0 version. */ type AnalyticsFormat = "JSON_ARRAY" | "ARROW_STREAM" /** @deprecated Use "JSON_ARRAY". Safe to remove once no consumer is on appkit-ui < 0.33.0. */ | "JSON" /** @deprecated Use "ARROW_STREAM". Safe to remove once no consumer is on appkit-ui < 0.33.0. */ | "ARROW"; /** * Typed Arrow Table - preserves row type information for type inference. * At runtime this is just a regular Arrow Table, but TypeScript knows the row schema. * * @example * ```typescript * type MyTable = TypedArrowTable<{ id: string; value: number }>; * // Can access table.getChild("id") knowing it exists * ``` */ interface TypedArrowTable = Record> extends Table { /** * Phantom type marker for row schema. * Not used at runtime - only for TypeScript type inference. */ readonly __rowType?: TRow; } /** Options for configuring an analytics SSE query */ interface UseAnalyticsQueryOptions { /** Response format - "JSON_ARRAY" returns typed arrays, "ARROW_STREAM" returns TypedArrowTable */ format?: F; /** Maximum size of serialized parameters in bytes */ maxParametersSize?: number; /** Whether to automatically start the query when the hook is mounted. Default is true. */ autoStart?: boolean; } /** * SQL warehouse lifecycle state surfaced by `useAnalyticsQuery`. * Mirrors the states emitted by the analytics plugin (which mirror the * Databricks SQL SDK `sql.State`). */ type WarehouseState = "RUNNING" | "STARTING" | "STOPPED" | "STOPPING" | "DELETED" | "DELETING"; /** * Snapshot of warehouse readiness streamed by the analytics route before the * SQL result. Useful for rendering "warehouse starting…" affordances during * cold starts instead of a frozen spinner. * * Note: the SDK's `health.summary` is intentionally NOT included on the wire * — it's free-form operator-oriented diagnostic text (cluster IDs, capacity * reasons, internal RPC errors) that must not reach end users; it stays in * server-side telemetry only. */ interface WarehouseStatus { state: WarehouseState; /** Milliseconds elapsed since the route began waiting for the warehouse. */ elapsedMs: number; } /** Result state returned by useAnalyticsQuery */ interface UseAnalyticsQueryResult { /** Latest query result data */ data: T | null; /** Loading state of the query */ loading: boolean; /** Error state of the query */ error: string | null; /** * Latest warehouse status emitted by the server while waiting for the SQL * warehouse to reach RUNNING. `null` until the first status event arrives; * remains `null` for cache hits where the server skips the readiness check. */ warehouseStatus: WarehouseStatus | null; } /** * Query Registry for type-safe analytics queries. * Extend this interface via module augmentation to get full type inference: * * @example * ```typescript * // shared/appkit-types/analytics.d.ts * declare module "@databricks/appkit-ui/react" { * interface QueryRegistry { * apps_list: { * name: "apps_list"; * parameters: { startDate: string; endDate: string; aggregationLevel: string }; * result: Array<{ id: string; name: string }>; * }; * } * } * ``` */ interface QueryRegistry { [key: string]: { name: string; parameters: Record; result: unknown[]; }; } /** Gets only literal keys from a registry (excludes index signature) */ type AugmentedRegistry = keyof { [K in keyof T as string extends K ? never : K]: T[K] }; /** Resolves to registry keys if defined, otherwise string */ type QueryKey = AugmentedRegistry extends never ? string : AugmentedRegistry; /** * Infers result type from QueryRegistry[K]["result"] * Returns the JSON array type for the query. */ type InferResult = K extends AugmentedRegistry ? QueryRegistry[K] extends { result: infer R; } ? R : T : T; /** * Infers the row type from a query result array. * Used for TypedArrowTable row typing. */ type InferRowType = K extends AugmentedRegistry ? QueryRegistry[K] extends { result: Array; } ? R extends Record ? R : Record : Record : Record; /** * Conditionally infers result type based on format. * - JSON format: Returns the typed array from QueryRegistry * - ARROW format: Returns TypedArrowTable with row type preserved */ type InferResultByFormat = F extends "ARROW_STREAM" | "ARROW" ? TypedArrowTable> : InferResult; /** * Infers parameters type from QueryRegistry[K]["parameters"] */ type InferParams = K extends AugmentedRegistry ? QueryRegistry[K] extends { parameters: infer P; } ? P : Record : Record; interface PluginRegistry { [key: string]: Record; } /** * Serving endpoint registry for type-safe alias names. * Extend this interface via module augmentation to get alias autocomplete: * * @example * ```typescript * // Auto-generated by appKitServingTypesPlugin() * declare module "@databricks/appkit-ui/react" { * interface ServingEndpointRegistry { * llm: { request: {...}; response: {...}; chunk: {...} }; * } * } * ``` */ interface ServingEndpointRegistry {} /** Resolves to registry keys if populated, otherwise string */ type ServingAlias = AugmentedRegistry extends never ? string : AugmentedRegistry; /** Infers chunk type from registry when alias is a known key */ type InferServingChunk = K extends AugmentedRegistry ? ServingEndpointRegistry[K] extends { chunk: infer C; } ? C : unknown : unknown; /** Infers response type from registry when alias is a known key */ type InferServingResponse = K extends AugmentedRegistry ? ServingEndpointRegistry[K] extends { response: infer R; } ? R : unknown : unknown; /** Infers request type from registry when alias is a known key */ type InferServingRequest = K extends AugmentedRegistry ? ServingEndpointRegistry[K] extends { request: infer Req; } ? Req : Record : Record; //#endregion export { AnalyticsFormat, InferParams, InferResultByFormat, InferRowType, InferServingChunk, InferServingRequest, InferServingResponse, PluginRegistry, QueryKey, QueryRegistry, ServingAlias, ServingEndpointRegistry, TypedArrowTable, UseAnalyticsQueryOptions, UseAnalyticsQueryResult, WarehouseState, WarehouseStatus }; //# sourceMappingURL=types.d.ts.map