import type { Tagged } from "type-fest"; import type { AnyParams, AnyParamValue, NormalizedParams, NormalizedVary } from "../types/index.js"; import { type JsonOf } from "./utils.js"; export type VaryKeys = readonly string[]; export type VariantKey = Tagged, "VariantKey">; type NormalizedVaryEntry = readonly [ string, Exclude | null ]; /** * This function produces a unique/canonical string for a NormalizedVary value. * In other words, it's a string that represents the exact param names + values * that the producer said its result varies on. This is the secondary cache key. */ export declare function resultVariantKey(vary: NormalizedVary): VariantKey; export declare function resultVariantKeyFromVaryEntries(entries: readonly NormalizedVaryEntry[]): VariantKey; /** * Returns whether a given `vary` object is compatible with the request's params. */ export declare function variantMatchesRequest(vary: NormalizedVary, normalizedParams: NormalizedParams): boolean; /** * When a consumer request comes in, we need to look at its params to figure out * whether any cached entries match. However, a consumer request can match * producer results with many, many different variant keys (as returned by * {@see {@link resultVariantKey}}). * * For example, imagine a consumer request with params { "a": 1, "b": 2 }. This * could match a producer result with `vary: {}` or `vary: { "a": 1 }` or * `vary: { "b": 2 }` or `vary: { "a": 1, "b": 2 }`. So, each consumer request * with n params generates 2^n potentially-matching variant keys. * * Enumerating all these is impractical, especially because consumer requests * will tend to have way more params than producer results will have vary on. * * Therefore, this function takes a set of param names for which it's known that * at least some producer results vary on that set -- these are the `varyKeys` -- * and then computes the single variant key with exactly those params that the * request would match. */ export declare function requestVariantKeyForVaryKeys(normalizedParams: NormalizedParams, varyKeys: VaryKeys): VariantKey; export {}; //# sourceMappingURL=varyHelpers.d.ts.map