UNPKG

next

Version:

The React Framework

50 lines (49 loc) 3.29 kB
import type { InstantSample } from '../../../build/segment-config/app/app-segment-config'; import type { ReadonlyRequestCookies } from '../../web/spec-extension/adapters/request-cookies'; import type { ReadonlyHeaders } from '../../web/spec-extension/adapters/headers'; import type { DraftModeProvider } from '../../async-storage/draft-mode-provider'; import type { Params } from '../../request/params'; import type { SearchParams } from '../../request/search-params'; import { InstantValidationError } from './instant-validation-error'; import type { WorkStore } from '../work-async-storage.external'; export type InstantValidationSampleTracking = { missingSampleErrors: InstantValidationError[]; }; export declare function createValidationSampleTracking(): InstantValidationSampleTracking; export declare function trackMissingSampleError(error: InstantValidationError): void; export declare function trackMissingSampleErrorAndThrow(error: InstantValidationError): never; /** * Creates ReadonlyRequestCookies from sample cookie data. * Accessing a cookie not declared in the sample will throw an error. * Cookies with `value: null` are declared (allowed to access) but return no value. */ export declare function createCookiesFromSample(sampleCookies: InstantSample['cookies'], route: string): ReadonlyRequestCookies; /** * Creates ReadonlyHeaders from sample header data. * Accessing a header not declared in the sample will throw an error. * Headers with `value: null` are declared (allowed to access) but return null. */ export declare function createHeadersFromSample(rawSampleHeaders: InstantSample['headers'], sampleCookies: InstantSample['cookies'], route: string): ReadonlyHeaders; /** * Creates a DraftModeProvider that always returns isEnabled: false. */ export declare function createDraftModeForValidation(): DraftModeProvider; /** * Creates params wrapped with an exhaustive proxy. * Accessing a param not declared in the sample will throw an error. */ export declare function createExhaustiveParamsProxy<TParams extends Params>(underlyingParams: TParams, declaredParamNames: Set<string>, route: string): TParams; /** * Creates searchParams wrapped with an exhaustive proxy. * Accessing a searchParam not declared in the sample will throw an error. * A searchParam with `value: undefined` means "declared but absent" (allowed to access, returns undefined). */ export declare function createExhaustiveSearchParamsProxy(searchParams: SearchParams, declaredSearchParamNames: Set<string>, route: string): SearchParams; /** * Wraps a URLSearchParams (or subclass like ReadonlyURLSearchParams) with an * exhaustive proxy. Accessing a search param not declared in the sample via * get/getAll/has will throw an error. */ export declare function createExhaustiveURLSearchParamsProxy<T extends URLSearchParams>(searchParams: T, declaredSearchParamNames: Set<string>, route: string): T; export declare function createRelativeURLFromSamples(route: string, sampleParams: InstantSample['params'], sampleSearchParams: InstantSample['searchParams']): import("../../../shared/lib/router/utils/parse-relative-url").ParsedRelativeUrl; export declare function assertRootParamInSamples(workStore: WorkStore, sampleParams: Params | undefined, paramName: string): void;