import { TracerProvider } from '@opentelemetry/api'; interface EmbeddedEdgeConfig { digest: string; items: Record; } /** * The parsed info contained in a connection string. */ type Connection = { baseUrl: string; id: string; token: string; version: string; type: 'vercel'; } | { baseUrl: string; id: string; token: string; version: string; type: 'external'; }; /** * An Edge Config Client. * * You can create new Edge Config clients using createClient(). */ interface EdgeConfigClient { /** * The parsed info from the connection string which was used to create this client. */ connection: Connection; /** * Read a single value. * * @param key - the key to read * @returns the value stored under the given key, or undefined */ get: (key: string, options?: EdgeConfigFunctionsOptions) => Promise; /** * Reads multiple or all values. * * Allows you to read all or only selected keys of an Edge Config at once. * * @param keys - the keys to read * @returns Returns all entries when called with no arguments or only entries matching the given keys otherwise. */ getAll: (keys?: (keyof T)[], options?: EdgeConfigFunctionsOptions) => Promise; /** * Check if a given key exists in the Edge Config. * * @param key - the key to check * @returns true if the given key exists in the Edge Config. */ has: (key: string, options?: EdgeConfigFunctionsOptions) => Promise; /** * Get the digest of the Edge Config. * * The digest is a unique hash result based on the contents stored in the Edge Config. * * @returns The digest of the Edge Config. */ digest: (options?: EdgeConfigFunctionsOptions) => Promise; } type EdgeConfigItems = Record; type EdgeConfigValue = string | number | boolean | null | { [x: string]: EdgeConfigValue; } | EdgeConfigValue[]; interface EdgeConfigFunctionsOptions { /** * Enabling `consistentRead` will bypass all caches and hit the origin * directly. This will make sure to fetch the most recent version of * an Edge Config with the downside of an increased latency. * * We do **not** recommend enabling this option, unless you are reading * Edge Config specifically for generating a page using ISR and you * need to ensure you generate with the latest content. */ consistentRead?: boolean; } interface EdgeConfigClientOptions { /** * The stale-if-error response directive indicates that the cache can reuse a * stale response when an upstream server generates an error, or when the error * is generated locally - for example due to a connection error. * * Any response with a status code of 500, 502, 503, or 504 is considered an error. * * Pass a negative number, 0, or false to turn disable stale-if-error semantics. * * The time is supplied in seconds. Defaults to one week (`604800`). */ staleIfError?: number | false; /** * In development, a stale-while-revalidate cache is employed as the default caching strategy. * * This cache aims to deliver speedy Edge Config reads during development, though it comes * at the cost of delayed visibility for updates to Edge Config. Typically, you may need to * refresh twice to observe these changes as the stale value is replaced. * * This cache is not used in preview or production deployments as superior optimisations are applied there. */ disableDevelopmentCache?: boolean; /** * Sets a `cache` option on the `fetch` call made by Edge Config. * * Unlike Next.js, this defaults to `no-store`, as you most likely want to use Edge Config dynamically. */ cache?: 'no-store' | 'force-cache'; } /** * Parse the edgeConfigId and token from an Edge Config Connection String. * * Edge Config Connection Strings usually look like one of the following: * - https://edge-config.vercel.com/?token= * - edge-config:id=&token= * * @param text - A potential Edge Config Connection String * @returns The connection parsed from the given Connection String or null. */ declare function parseConnectionString(connectionString: string): Connection | null; /** * Allows setting the `@opentelemetry/api` tracer provider to generate traces * for Edge Config related operations. */ declare function setTracerProvider(tracer: TracerProvider): void; /** * Create an Edge Config client. * * The client has multiple methods which allow you to read the Edge Config. * * If you need to programmatically write to an Edge Config, check out the [Update your Edge Config items](https://vercel.com/docs/storage/edge-config/vercel-api#update-your-edge-config-items) section. * * @param connectionString - A connection string. Usually you'd pass in `process.env.EDGE_CONFIG` here, which contains a connection string. * @returns An Edge Config Client instance */ declare const createClient: (connectionString: string | undefined, options?: EdgeConfigClientOptions) => EdgeConfigClient; /** * Reads a single item from the default Edge Config. * * This is a convenience method which reads the default Edge Config. * It is conceptually similar to `createClient(process.env.EDGE_CONFIG).get()`. * * @see {@link EdgeConfigClient.get} * @param key - the key to read * @returns the value stored under the given key, or undefined */ declare const get: EdgeConfigClient['get']; /** * Reads multiple or all values. * * This is a convenience method which reads the default Edge Config. * It is conceptually similar to `createClient(process.env.EDGE_CONFIG).getAll()`. * * @see {@link EdgeConfigClient.getAll} * @param keys - the keys to read * @returns the value stored under the given key, or undefined */ declare const getAll: EdgeConfigClient['getAll']; /** * Check if a given key exists in the Edge Config. * * This is a convenience method which reads the default Edge Config. * It is conceptually similar to `createClient(process.env.EDGE_CONFIG).has()`. * * @see {@link EdgeConfigClient.has} * @param key - the key to check * @returns true if the given key exists in the Edge Config. */ declare const has: EdgeConfigClient['has']; /** * Get the digest of the Edge Config. * * This is a convenience method which reads the default Edge Config. * It is conceptually similar to `createClient(process.env.EDGE_CONFIG).digest()`. * * @see {@link EdgeConfigClient.digest} * @returns The digest of the Edge Config. */ declare const digest: EdgeConfigClient['digest']; /** * Safely clones a read-only Edge Config object and makes it mutable. */ declare function clone(edgeConfigValue: T): T; export { type EdgeConfigClient, type EdgeConfigItems, type EdgeConfigValue, type EmbeddedEdgeConfig, clone, createClient, digest, get, getAll, has, parseConnectionString, setTracerProvider };