/** * Domain Lookup Utility * * Resolves custom domains to project information via API lookup. * Supports optional CacheRepository injection for testing and distributed caching. * * @module server/utils/domain-lookup */ import type { CacheRepository } from "../../repositories/types.js"; export interface DomainLookupResult { project_id: string; project_slug: string; project_name: string; environment: { id: string; name: string; } | null; release_id: string | null; } /** * Thrown when the domain lookup API returns a transient non-404 error (e.g., 500, 503). * Callers should distinguish this from a null return (domain genuinely not mapped): * a null return means 404/not-found, this error means the lookup service itself failed * and the request should be treated as a 502 rather than a 404. */ export declare class DomainLookupApiError extends Error { readonly status: number; readonly statusText: string; constructor(status: number, statusText: string, domain: string); } interface DomainLookupConfig { apiBaseUrl: string; apiToken: string; } export declare function lookupProjectByDomain(domain: string, config: DomainLookupConfig): Promise; export declare function clearDomainCache(): void; /** * Inject a CacheRepository for testing or distributed caching. * Call with null to restore default Map-based caching. * * @example * ```typescript * import { MockCacheRepository, createMockRepositoryContext } from "#veryfront/repositories/testing"; * * const mockCache = new MockCacheRepository({ context: createMockRepositoryContext() }); * __injectCacheForTests(mockCache); * * // Run tests... * * __injectCacheForTests(null); // Restore default * ``` */ export declare function __injectCacheForTests(cacheRepo: CacheRepository | null): void; export declare function getEnvironmentType(result: DomainLookupResult | null): "preview" | "production" | undefined; export {}; //# sourceMappingURL=domain-lookup.d.ts.map