import { CloudFrontRequest, CloudFrontRequestEvent } from 'aws-lambda';

/**
 * Custom header populated by the viewer-request CloudFront Function with
 * the viewer's `Host` value. CloudFront strips the literal `Host` header
 * before reaching the origin-request stage (per the
 * `ALL_VIEWER_EXCEPT_HOST_HEADER` origin-request policy), so the per-PR
 * host gets shuttled through this side channel instead.
 */
declare const VIEWER_HOST_HEADER = "x-viewer-host";
/**
 * Host-prefix pair the construct bakes into this bundle via esbuild
 * `define` at synth time (Lambda@Edge forbids runtime env vars). At
 * bundle time these `process.env.*` references are replaced with the
 * literal strings the consumer configured on `StaticHostingProps.restApi.hostMapping`;
 * under jest (no bundling) the `??` fallbacks supply the OpenHI defaults.
 */
declare const VIEWER_HOST_PREFIX: string;
declare const API_HOST_PREFIX: string;
/**
 * Origin-request Lambda@Edge handler. Picks the per-PR REST API origin
 * based on the viewer host that the viewer-request stage copied into
 * {@link VIEWER_HOST_HEADER}.
 *
 * With the default OpenHI mapping (`admin` -> `api`):
 *   `admin.dev.openhi.org` -> `api.dev.openhi.org`
 *   `admin-feat-foo.dev.openhi.org` -> `api-feat-foo.dev.openhi.org`
 *
 * When the header is missing or the host does not start with the
 * configured viewer-host prefix, the request falls through unchanged
 * (the static `HttpOrigin` domain resolves the request).
 */
declare const originRequestHandler: (event: CloudFrontRequestEvent) => Promise<CloudFrontRequest>;
/**
 * Reads the `x-viewer-host` header value from the request. Returns
 * `null` when the header is absent or has no entries.
 */
declare const readViewerHost: (request: CloudFrontRequest) => string | null;
/**
 * Translates a viewer host like `admin-feat-foo.dev.openhi.org` to its
 * matching API host (`api-feat-foo.dev.openhi.org`) by swapping
 * `viewerPrefix` for `apiPrefix` at the start of the host. Returns
 * `null` when the input does not start with `viewerPrefix`.
 *
 * `viewerPrefix` and `apiPrefix` default to the module-level
 * {@link VIEWER_HOST_PREFIX} / {@link API_HOST_PREFIX} constants
 * (baked in by esbuild at bundle time). The positional args are
 * primarily there so unit tests can exercise custom mappings without
 * mutating module state.
 */
declare const computeApiHost: (viewerHost: string, viewerPrefix?: string, apiPrefix?: string) => string | null;
/**
 * Mutates the request so CloudFront forwards it to `apiHost` instead
 * of the construct-configured static API domain. Both the custom-origin
 * `domainName` and the `Host` header are overridden — API Gateway's
 * custom-domain mapping routes on the upstream Host header, so updating
 * just the origin domain without the header would leave API Gateway
 * unable to match the request.
 */
declare const applyOriginOverride: (request: CloudFrontRequest, apiHost: string) => CloudFrontRequest;

export { API_HOST_PREFIX, VIEWER_HOST_HEADER, VIEWER_HOST_PREFIX, applyOriginOverride, computeApiHost, originRequestHandler, readViewerHost };
