export interface Domain { /** The domain hostname (e.g. `www.example.com`). For a wildcard domain, the `*.` prefix is stripped (see `isWildcard`). */ hostname: string; /** The path prefix the domain is routed on (e.g. `/api`), or `/` when routed at the root. */ pathPrefix: string; /** Whether the domain is a wildcard (e.g. `*.example.com`). */ isWildcard: boolean; } /** A domain as attached to an application, carrying its role in the app's domain list. */ export interface ApplicationDomain extends Domain { /** Whether this is the application's primary domain. */ isPrimary: boolean; } /** * Extracts `hostname`, `pathPrefix`, `isWildcard` from a given `domain` */ export declare function parseDomain(domain: string): Domain; /** * Guesses which domain should be the primary one among a list of domains, used as a * fallback when an application has no favourite domain set. * * Domains are preferred in the following order: * - the first non-test (see {@link isTestDomain}), non-wildcard domain * - the first non-test domain * - the first non-wildcard domain * - the first domain * * @returns the guessed primary domain, or `undefined` when the list is empty */ export declare function guessPrimaryDomain(domains: Array): string | undefined; export declare class DomainParseError extends Error { code: 'empty' | 'invalid-wildcard' | 'invalid-format'; constructor(code: 'empty' | 'invalid-wildcard' | 'invalid-format', message: string, cause?: unknown); } /** * If isWildcard is `true`, returns `*.${hostname}` * else returns the `hostname` untouched */ export declare function getHostWithWildcard(hostname: string, isWildcard: boolean): string; /** * Builds the browsable URL for a domain, prefixing a wildcard hostname with `www.` * (since `*.example.com` itself isn't a valid browsable URL) and choosing the scheme * based on `isHttpOnly`. */ export declare function getDomainUrl(hostname: string, pathPrefix: string, isWildcard: boolean, isHttpOnly: boolean): string; /** * Parses a `domainWithPath` and builds its browsable URL in one step. * * The scheme is derived from the domain: test subdomains (e.g. `sub.app.cleverapps.io`) * are HTTP only, everything else uses HTTPS. */ export declare function domainToUrl(domainWithPath: string): string; /** * Checks if the domain is a Clever Cloud test domain (`*.cleverapps.io`) */ export declare function isTestDomain(hostname: string): boolean; /** * Checks if the domain is a `cleverapps.io` domain and if it contains a subdomain. * For instance `subdomain.main.cleverapps.io` is HTTP only. * * @returns whether the domain is a `cleverapps.io` is HTTP only or not */ export declare function isTestDomainWithSubdomain(domain: string): boolean; /** * Comparator for sorting domains: the primary domain always comes first, the rest are * ordered alphabetically by their reversed hostname (e.g. `com.example.www`), so that * domains sharing a common suffix end up next to each other. */ export declare function sortDomains(domainA: ApplicationDomain, domainB: ApplicationDomain): number; //# sourceMappingURL=domain-utils.d.ts.map