import type { CachePolicy } from './CachePolicy'; import type { LuvioAdapterEventObserver } from './events'; import type { NetworkRequestPriority, LuvioRequestMethod } from './network'; export type AdapterRequestPriority = 'high' | 'normal' | 'background'; /** * A context object that can be passed in with each adapter request to * specify various options */ export interface AdapterRequestContext { /** * (optional) The cache policy the adapter will * execute with. A default policy will be specified if not provided */ cachePolicy?: CachePolicy; /** * (optional) The priority the adapter will execute with */ priority?: AdapterRequestPriority; /** * (optional) A correlator object that will be passed through * luvio and available to the network adapter if the adapter call results in a network call. * This can be used to trace back a specific adapter call to any network calls it may make */ requestCorrelator?: unknown; /** * (optional) A list of event observers that will be invoked for various adapter events */ eventObservers?: LuvioAdapterEventObserver[]; /** * (optional) The luvio method the network adapter will execute with. */ luvioMethod?: LuvioRequestMethod; /** * @private * sourceContext is for internal use only. * (optional) This can include information about the source of adapter invocation */ sourceContext?: unknown; /** * (optional) If present and set to `true`, this request will not be included in predictions (Predictive Data Loading). */ excludeFromPredictions?: boolean; } /** * A narrowed view of {@link AdapterRequestContext} accepted by DML * (mutating) adapter factories. * * DML adapters do not read from the cache and have no meaningful use for * most context fields — `cachePolicy`, `excludeFromPredictions`, * `eventObservers`, `priority`, and `luvioMethod` are all read-side or * infrastructure concerns. The only field that is relevant on the write * path today is `requestCorrelator`, which carries the caller's * observability context through to the network adapter so that mutation * network spans can be parented to the originating user action. * * If a future use case warrants additional fields on the DML write path * (e.g. a stable `priority` need), widen this `Pick<>` here in one place * rather than threading the full `AdapterRequestContext` through the * mutating-adapter factories. */ export type DmlAdapterRequestContext = Pick; export interface CoercedAdapterRequestContext { networkPriority: NetworkRequestPriority; requestCorrelator: unknown; eventObservers?: LuvioAdapterEventObserver[]; sourceContext?: unknown; } export declare function coerceAdapterRequestContext(adapterRequestContext: AdapterRequestContext): CoercedAdapterRequestContext;