/** * tRPC Client Factory * * Creates a type-safe tRPC client for communicating with the Compliance API. * Uses httpBatchLink for efficient request batching. */ import { type Locale } from "@artu-ai/shared"; /** * Supported API versions */ export type APIVersion = "v1"; /** * SDK Environment - determines data isolation */ export type SDKEnvironment = "test" | "live"; /** * Configuration for creating a tRPC client */ export type TRPCAuthMode = "apiKey" | "cookie"; export interface TRPCAPIKeyAuthConfig { mode?: "apiKey"; apiKey: string; } export interface TRPCCookieAuthConfig { mode: "cookie"; credentials?: "include" | "omit" | "same-origin"; /** * Custom headers to include with each request. * Useful for server-side cookie forwarding in Next.js. * * @example * ```typescript * // Forward cookies in Next.js server component * const cookieStore = await cookies(); * const sdk = new ComplianceSDK({ * mode: "cookie", * headers: { Cookie: cookieStore.toString() }, * }); * ``` */ headers?: Record; } export type TRPCAuthConfig = TRPCAPIKeyAuthConfig | TRPCCookieAuthConfig; export type TRPCClientConfig = TRPCAuthConfig & { /** * Base URL for the API * @example "https://api.compliance.artu.com" */ baseUrl: string; /** * Target environment for data isolation */ environment: SDKEnvironment; /** * API version to use. Defaults to latest stable version. * @default "v1" */ apiVersion?: APIVersion; /** * Request timeout in milliseconds * @default 30000 */ timeout?: number; /** * Organization ID for request validation. * When provided, the API validates that the authenticated * user/API key belongs to this organization. */ organizationId?: string; /** * Locale to advertise to the API. A function allows long-lived SDK * instances to update the header without recreating the tRPC client. */ locale?: Locale | (() => Locale); }; /** * Current stable API version */ export declare const LATEST_API_VERSION: APIVersion; /** * Default request timeout in milliseconds */ export declare const DEFAULT_TIMEOUT = 30000; /** * Request timeout for verification operations (`screening.*` + `identity.*`). * * These hit SAT-backed providers through NUFI whose upstream (the SAT) can * take ~20s+ — and occasionally >30s — to respond, so the client must wait * longer than DEFAULT_TIMEOUT before aborting (otherwise it gives up while the * server is still legitimately waiting on the SAT). Applied ONLY to the * verification link via `splitLink`; every other operation keeps * DEFAULT_TIMEOUT. */ export declare const VERIFICATION_TIMEOUT = 60000; /** * Generates a unique request ID for tracing and debugging * * Format: req_{timestamp}_{random} * @example "req_m1abc23_xk9z4w2" */ export declare function generateRequestId(): string;