import middy from '@middy/core' import { Context as LambdaContext } from 'aws-lambda' import type { ArrayValues, Choose, DeepAwaited, IsUnknown, SanitizeKey, SanitizeKeys } from './type-utils.d.ts' interface Options { AwsClient?: new (...[config]: [any] | any) => Client awsClientOptions?: Partial awsClientAssumeRole?: string awsClientCapture?: (service: Client) => Client fetchData?: { [key: string]: string } disablePrefetch?: boolean cacheKey?: string cacheExpiry?: number setToContext?: boolean } declare class HttpError extends Error { status: number statusCode: number expose: boolean; [key: string]: any [key: number]: any } declare function createPrefetchClient ( options: Options ): Client declare function createClient ( options: Options, request: middy.Request ): Promise declare function canPrefetch ( options: Options ): boolean type InternalOutput = TVariables extends string[] ? { [key in TVariables[number]]: unknown } : never // get an empty object if false is passed declare function getInternal< TContext extends LambdaContext, TInternal extends Record > ( variables: false, request: middy.Request ): Promise<{}> // get all internal values if true is passed (with promises resolved) declare function getInternal< TContext extends LambdaContext, TInternal extends Record > ( variables: true, request: middy.Request ): Promise> // get a single value declare function getInternal< TContext extends LambdaContext, TInternal extends Record, TVars extends keyof TInternal | string > ( variables: TVars, request: middy.Request ): TVars extends keyof TInternal ? Promise]: TInternal[TVars] }>> : TVars extends string ? IsUnknown, TVars>> extends true ? unknown // could not find the path : Promise<{ [_ in SanitizeKey]: Choose, TVars> }> : unknown // path is not a string or a keyof TInternal // get multiple values declare function getInternal< TContext extends LambdaContext, TInternal extends Record, TVars extends Array > ( variables: TVars, request: middy.Request ): Promise< SanitizeKeys<{ [TVar in ArrayValues]: TVar extends keyof TInternal ? DeepAwaited : TVar extends string ? Choose, TVar> : unknown // path is not a string or a keyof TInternal }> > // remap object declare function getInternal< TContext extends LambdaContext, TInternal extends Record, TMap extends Record > ( variables: TMap, request: middy.Request ): Promise<{ [P in keyof TMap]: TMap[P] extends keyof TInternal ? DeepAwaited : TMap[P] extends string ? Choose, TMap[P]> : unknown // path is not a string or a keyof TInternal }> declare function sanitizeKey (key: T): SanitizeKey declare function processCache ( options: Options, fetch: (request: middy.Request, cachedValues: any) => any, request?: middy.Request ): { value: any, expiry: number } declare function getCache (keys: string): any declare function clearCache (keys?: string | string[] | null): void declare function jsonSafeParse ( string: string, reviver?: (key: string, value: any) => any ): any declare function normalizeHttpResponse ( request: any, fallbackResponse?: any ): any declare function createError ( code: number, message: string, properties?: Record ): HttpError declare function modifyCache (cacheKey: string, value: any): void