/** * Project Resolution Module * * Handles project slug resolution from various sources: * - Request headers (x-project-slug, x-project-id, etc.) * - Domain parsing (*.veryfront.com subdomains) * - API domain lookup (custom domains) * - Config file defaults * * @module server/runtime-handler/project-resolution */ import type { VeryfrontConfig } from "../../config/index.js"; import { type ParsedDomain, parseProjectDomain } from "../utils/domain-parser.js"; import { getEnvironmentType, lookupProjectByDomain } from "../utils/domain-lookup.js"; import { type ProxyEnvironment } from "./proxy-environment.js"; /** * Injection interface for testing project resolution dependencies */ interface ProjectResolutionDeps { lookupProjectByDomain?: typeof lookupProjectByDomain; parseProjectDomain?: typeof parseProjectDomain; getEnvironmentType?: typeof getEnvironmentType; } /** * Inject dependencies for testing. Pass null to reset to defaults. */ export declare function __injectDepsForTests(deps: ProjectResolutionDeps | null): void; interface RequestHeaders { /** Project slug from x-project-slug header */ projectSlug: string | undefined; /** Project ID from x-project-id header */ projectId: string | undefined; /** Release ID from x-release-id header */ releaseId: string | undefined; /** Branch ID from x-branch-id header */ branchId: string | undefined; /** Branch name from x-branch-name header */ branchName: string | undefined; /** Project default branch name from x-default-branch-name header */ defaultBranchName: string | undefined; /** Environment from x-environment header */ environment: string | undefined; /** Environment ID from x-environment-id header (for env var resolution) */ environmentId: string | undefined; /** Canonical environment name paired with x-environment-id by the trusted proxy */ environmentName: string | undefined; /** Token from authorization header */ token: string | undefined; /** Content source ID from x-content-source-id header */ contentSourceId: string | undefined; /** Project path from x-project-path header */ projectPath: string | undefined; } /** * Extract project-related headers from a request. * * When `x-project-slug` is absent or blank, the slug is derived from * the effective host (x-forwarded-host > host header > url.host) via * domain parsing. This allows proxy-forwarded requests to resolve * project context from the hostname alone. */ export declare function extractRequestHeaders(req: Request, url: URL, proxyTrusted?: boolean, identityHeadersTrusted?: boolean): RequestHeaders; interface ProjectResolutionResult { /** Resolved project slug */ projectSlug: string | undefined; /** Resolved project ID */ projectId: string | undefined; /** Resolved release ID */ releaseId: string | undefined; /** Environment name (e.g., "staging") */ environmentName: string | undefined; /** Resolved proxy environment (preview/production) */ proxyEnv: ProxyEnvironment | undefined; /** Parsed domain information */ parsedDomain: ParsedDomain; } interface ProjectResolutionOptions { /** Config from veryfront.config.ts */ config: VeryfrontConfig | undefined; /** Request context from createRequestContext */ reqCtx: { slug: string | undefined; mode: "preview" | "production" | undefined; branch: string | null | undefined; token: string | undefined; }; /** Default project slug for standalone mode */ defaultProjectSlug: string | undefined; /** Default project ID for standalone mode */ defaultProjectId: string | undefined; /** Default release ID for standalone mode */ defaultReleaseId?: string | undefined; /** WS slug override from query param */ wsSlugOverride: string | undefined; /** Whether the request has already passed the proxy trust check. */ proxyTrusted?: boolean; } /** * Resolve project information from multiple sources. * * Priority order: * 1. Request headers (x-project-slug, etc.) * 2. WebSocket slug override (query param) * 3. Config file defaults * 4. Domain parsing (*.veryfront.com) * 5. API domain lookup (custom domains) */ export declare function resolveProject(req: Request, url: URL, headers: RequestHeaders, opts: ProjectResolutionOptions): Promise; export { type ParsedDomain, parseProjectDomain } from "../utils/domain-parser.js"; export { parseProxyEnvironment, type ProxyEnvironment } from "./proxy-environment.js"; //# sourceMappingURL=project-resolution.d.ts.map