/**
 * athena gateway types
 *
 * type definitions for the athena gateway api client and react hook
 */
type AthenaGatewayMethod = 'POST' | 'PUT' | 'DELETE';
type AthenaGatewayEndpointPath = '/gateway/fetch' | '/gateway/insert' | '/gateway/update' | '/gateway/delete';
type AthenaCountOption = 'exact' | 'planned' | 'estimated';
type AthenaConditionValue = string | number | boolean | null;
type AthenaConditionArrayValue = Array<AthenaConditionValue>;
type AthenaConditionOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'contains' | 'containedBy' | 'not' | 'or';
interface AthenaGatewayCondition {
    column?: string;
    operator: AthenaConditionOperator;
    value?: AthenaConditionValue | AthenaConditionArrayValue | string;
}
interface AthenaFetchPayload {
    view_name?: string;
    table_name?: string;
    columns?: string[] | string;
    conditions?: AthenaGatewayCondition[];
    limit?: number;
    offset?: number;
    current_page?: number;
    page_size?: number;
    total_pages?: number;
    strip_nulls?: boolean;
    group_by?: string;
    time_granularity?: 'day' | 'hour' | 'minute';
    aggregation_column?: string;
    aggregation_strategy?: 'cumulative_sum';
    aggregation_dedup?: boolean;
}
interface AthenaInsertPayload {
    table_name: string;
    insert_body: Record<string, unknown> | Record<string, unknown>[];
    update_body?: Record<string, unknown>;
    columns?: string[] | string;
    count?: AthenaCountOption;
    head?: boolean;
    default_to_null?: boolean;
    on_conflict?: string | string[];
}
interface AthenaDeletePayload {
    table_name: string;
    resource_id?: string;
    columns?: string[] | string;
    conditions?: AthenaGatewayCondition[];
}
interface AthenaUpdatePayload extends AthenaFetchPayload {
    update_body?: Record<string, unknown>;
}
interface AthenaGatewayBaseOptions {
    baseUrl?: string;
    client?: string;
    apiKey?: string;
    stripNulls?: boolean;
    supabaseUrl?: string;
    supabaseKey?: string;
    publishEvent?: string;
    headers?: Record<string, string>;
    /** optional user context injected as gateway request headers */
    userId?: string | null;
    companyId?: string | null;
    organizationId?: string | null;
}
interface AthenaGatewayHookConfig extends AthenaGatewayBaseOptions {
}
interface AthenaGatewayCallOptions extends AthenaGatewayBaseOptions {
    count?: AthenaCountOption;
    head?: boolean;
    defaultToNull?: boolean;
    onConflict?: string | string[];
    updateBody?: Record<string, unknown>;
}
interface AthenaGatewayResponse<T = unknown> {
    ok: boolean;
    status: number;
    data: T | null;
    error?: string;
    raw: unknown;
}
interface AthenaGatewayResponseLog extends AthenaGatewayResponse {
    timestamp: string;
}
interface AthenaGatewayCallLog {
    endpoint: AthenaGatewayEndpointPath;
    method: AthenaGatewayMethod;
    payload: unknown;
    headers: Record<string, string>;
    timestamp: string;
}
interface AthenaGatewayHookResult {
    fetchGateway: <T = unknown>(payload: AthenaFetchPayload, options?: AthenaGatewayCallOptions) => Promise<AthenaGatewayResponse<T>>;
    insertGateway: <T = unknown>(payload: AthenaInsertPayload, options?: AthenaGatewayCallOptions) => Promise<AthenaGatewayResponse<T>>;
    updateGateway: <T = unknown>(payload: AthenaUpdatePayload, options?: AthenaGatewayCallOptions) => Promise<AthenaGatewayResponse<T>>;
    deleteGateway: <T = unknown>(payload: AthenaDeletePayload, options?: AthenaGatewayCallOptions) => Promise<AthenaGatewayResponse<T>>;
    isLoading: boolean;
    error: string | null;
    lastRequest: AthenaGatewayCallLog | null;
    lastResponse: AthenaGatewayResponseLog | null;
    baseUrl: string;
}

export type { AthenaGatewayCallOptions as A, AthenaConditionValue as a, AthenaConditionArrayValue as b, AthenaConditionOperator as c, AthenaDeletePayload as d, AthenaFetchPayload as e, AthenaGatewayBaseOptions as f, AthenaGatewayCallLog as g, AthenaGatewayCondition as h, AthenaGatewayEndpointPath as i, AthenaGatewayHookConfig as j, AthenaGatewayHookResult as k, AthenaGatewayMethod as l, AthenaGatewayResponse as m, AthenaGatewayResponseLog as n, AthenaInsertPayload as o, AthenaUpdatePayload as p };
