import { IQueryParams, IQueryParamsWithSubject } from './http-client'; import SdkTokenDecoder from './sdk-token-decoder'; /** * Parameters for configuring the API endpoints * * @param queryParams Query parameters to append to the configuration endpoints * @param baseUrl Custom base URL for configuration endpoints (optional) * @param defaultUrl Default base URL for configuration endpoints (defaults to BASE_URL) * @param sdkTokenDecoder SDK token decoder for subdomain and event hostname extraction */ interface IApiEndpointsParams { queryParams?: IQueryParams | IQueryParamsWithSubject; baseUrl?: string; defaultUrl: string; sdkTokenDecoder?: SdkTokenDecoder; } /** * Utility class for constructing Eppo API endpoint URLs. * * This class handles two distinct types of endpoints: * 1. Configuration endpoints (UFC, bandits, precomputed flags) - based on the effective base URL * which considers baseUrl, subdomain from SDK token, and defaultUrl in that order. * 2. Event ingestion endpoint - either uses the default event domain with subdomain from SDK token * or a full hostname from SDK token. This endpoint IGNORES the baseUrl and defaultUrl parameters. * * For event ingestion endpoints, consider using the static helper method: * `ApiEndpoints.createEventIngestionUrl(sdkKey)` */ export default class ApiEndpoints { private readonly sdkToken; private readonly _effectiveBaseUrl; private readonly params; constructor(params: Partial); /** * Helper method to return an event ingestion endpoint URL from the customer's SDK token. * @param sdkToken */ static createEventIngestionUrl(sdkToken: string): string | null; /** * Normalizes a URL by ensuring proper protocol and removing trailing slashes */ private normalizeUrl; private joinUrlParts; /** * Determines the effective base URL for configuration endpoints based on: * 1. If baseUrl is provided, and it is not equal to the DEFAULT_BASE_URL, use it * 2. If the api key contains an encoded customer-specific subdomain, use it with DEFAULT_DOMAIN * 3. Otherwise, fall back to DEFAULT_BASE_URL * * @returns The effective base URL to use for configuration endpoints */ private determineBaseUrl; private endpoint; /** * Returns the URL for the UFC endpoint. * Uses the configuration base URL determined by baseUrl, subdomain, or default. * * @returns The full UFC endpoint URL */ ufcEndpoint(): string; /** * Returns the URL for the bandit parameters endpoint. * Uses the configuration base URL determined by baseUrl, subdomain, or default. * * @returns The full bandit parameters endpoint URL */ banditParametersEndpoint(): string; /** * Returns the URL for the precomputed flags endpoint. * Uses the configuration base URL determined by baseUrl, subdomain, or default. * * @returns The full precomputed flags endpoint URL */ precomputedFlagsEndpoint(): string; /** * Constructs the event ingestion URL from the SDK token. * * IMPORTANT: This method ignores baseUrl and defaultUrl parameters completely. * It uses ONLY the hostname or subdomain from the SDK token with a fixed event domain. * * @returns The event ingestion URL, or null if the SDK token is invalid or doesn't * contain the necessary information. */ eventIngestionEndpoint(): string | null; } export {}; //# sourceMappingURL=api-endpoints.d.ts.map