/** * Create a mock where the responses are determined by the value of a specific cookie. * @public * @typeParam TMockCookieValue - Possible values for the cookie. * @typeParam TResponse - The type of the response bodies. * @param options - The options for the mock setup. * @returns A complete mock. */ export declare function createMockByCookie(options: MockCookieByOptions): Mock; /** * @public */ export declare function createResponseByCookie(cookieName: string, cookieValue: string, response: MockResponse): MockMatcher; /** * @public */ export declare function defineMock(mock: Mock): Mock; /** * A callback function for dynamically loading a mock response. * * @public * @typeParam T - The type of the response body. */ export declare type DynamicMockResponse = (req: MockRequest) => StaticMockResponse; /** * A complete mock description. * * @public * @typeParam T - The type of the response bodies. * @typeParam U - The type of the request bodies. */ export declare interface Mock { meta?: MockMeta; /** * An array of mappings between requests and corresponding mock responses. */ responses?: Array>; /** * The default response if no other match (from responses) could be found. */ defaultResponse: MockResponse; } /** * Describes possible values for a cookie used to select a mock response. * * @public * @typeParam TMockCookieValue - A (narrowed) string type constraint for possible values for the cookie. */ export declare interface MockCookie { /** * The name of the cookie that specifies which mock response to use. */ name: string; /** * A dictionary of possible values this cookie can be set to. */ values: Record; } /** * Describes a complete mock depending on the value of a cookie. * * @public * @typeParam TMockCookieValue - Possible values for the cookie. * @typeParam TResponse - The type of the response bodies. */ export declare interface MockCookieByOptions { /** * Meta data for the mock. */ meta?: MockMeta; /** * The name of the cookie that specifies which mock response to use. */ cookieName: string; /** * The default response to use if the cookie is not set to a value with a defined mapping. */ defaultResponse: MockResponse; /** * A dictionary of possible cookie values and their respective mock response. */ responses: Record>; } /** * A value for a cookie specifying which mock response to use. * * @public * @typeParam T - A mock cookie description defining the possible values for the cookie. */ export declare type MockCookieValue = T["values"][keyof T["values"]]; /** * Describes a mapping of a request to a specific mock response. * * @public * @typeParam T - The type of the response body. * @typeParam U - The type of the request body. */ export declare interface MockMatcher { /** * The response (value) for this mock match. */ response: MockResponse; /** * The request (key) for this mock match. */ request: MockRequest; } /** * API metadata. * * @public */ export declare interface MockMeta { /** Human readable title of this endpoint */ title?: string; /** Unique key for this endpoint, if present it should be used as the cookie * for all requests */ key?: string; /** Unique url for mock, not in use for file based mocks, example: /path/subpath */ url?: string; /** HTTP Method, not in use for file based mocks. * Valid values: GET / POST / DELETE / PUT */ method?: string; } /** * Describes a request for the mock server to listen for. * * @public * @typeParam T - The type of the request body. */ export declare interface MockRequest { /** * A key to value mapping of cookies to match. */ cookies?: Record; /** * A key to value mapping of parameters to match. */ parameters?: Record; /** * A key to value mapping of headers to match. */ headers?: Record; /** * The request body to match. */ body?: T; } /** * Describes a mock response. * * @public * @typeParam T - The type of the response body. */ export declare type MockResponse = StaticMockResponse | DynamicMockResponse; /** * A description of a static mock response. * * @public * @typeParam T - The type of the response body. */ export declare interface StaticMockResponse { /** Human readable label for this mock entry. */ label?: string; /** Human readable description for this mock entry. */ description?: string; /** * Number of milliseconds of delay before responding. */ delay?: number; /** * The HTTP status code to respond with. */ status?: number; /** * A key to value mapping of HTTP headers to respond with. */ headers?: Record; /** * The response body. */ body?: T | ((req: MockRequest) => T); } export { }