import { HTTPMethod, Milliseconds, Service, UserToken, UserTrialToken } from '../models'; import { PartialBy } from '../models/types/Objects'; export declare const DEFAULT_METHOD = "POST"; export declare const DEFAULT_AUTH_KEY = "userToken"; export declare const DEFAULT_AUTH_REQUIRED = true; export interface TrialRequest { userTrialToken?: UserTrialToken; } export interface AuthRequest { userToken: UserToken; } export interface OptionalAuthRequest { userToken?: UserToken; } export interface ProtocolOptions { /** The endpoint on the service where this function lives. */ path: string; /** The endpoint HTTP method. Defaults to POST. */ method: HTTPMethod; /** The key the cached data is written at. Defaults to "{service}/{path}". */ cacheKey: string; /** The keys in the request to ignore when caching. */ cacheIgnoreProps: string[]; /** The key to use for authentication. Defaults to "userToken". */ authKey: string; /** If true, returns an error if the authKey is invalid. Defaults to true. */ authRequired: boolean; /** The service housing the protocol. */ service?: Service; /** The cache milliseconds on the client. */ clientCacheMs?: Milliseconds; /** The cache milliseconds on the server. */ serverCacheMs?: Milliseconds; /** The milliseconds before the client times out the request. */ clientTimeoutMs?: Milliseconds; /** The milliseconds before the server times out the request. */ serverTimeoutMs?: Milliseconds; /** Is the endpoint deprecated? */ deprecated?: boolean; /** The keys in the cache calling this method successfully invalidates. */ invalidatesCacheKeys?: string[]; } interface InputProtocolProperties extends PartialBy, 'cacheKey'>, 'cacheIgnoreProps'>, 'authRequired'>, 'authKey'> { /** If true, ignores the authKey when caching. */ cacheIgnoreAuthKey?: boolean; } export interface ProtocolFunctionInterface { options: ProtocolOptions; Request: RequestType; Response: ResponseType; Function: (_: RequestType) => Promise; } export declare class ProtocolFunction implements ProtocolFunctionInterface { options: ProtocolOptions; constructor(options: InputProtocolProperties); get Request(): RequestType; get Response(): ResponseType; get Function(): (_: RequestType) => Promise; } /** * A factory that creates a ProtocolFunction. Equivalent to `new ProtocolFunction(...)`. * @param options The options for the ProtocolFunction. * @returns A built ProtocolFunction. */ export declare const Protocol: (options: InputProtocolProperties) => ProtocolFunction; export {};