UNPKG

@aws-lambda-powertools/idempotency

Version:

The idempotency package for the Powertools for AWS Lambda (TypeScript) library. It provides options to make your Lambda functions idempotent and safe to retry.

71 lines 2.58 kB
import type { JMESPathParsingOptions } from '@aws-lambda-powertools/jmespath/types'; import type { Context } from 'aws-lambda'; import type { IdempotencyConfigOptions, ResponseHook } from './types/IdempotencyOptions.js'; /** * Configuration for the idempotency feature. */ declare class IdempotencyConfig { #private; /** * The JMESPath expression used to extract the idempotency key from the event. * @default '' */ eventKeyJmesPath: string; /** * The number of seconds the idempotency key is valid. * @default 3600 (1 hour) */ expiresAfterSeconds: number; /** * The hash function used to generate the idempotency key. * @see https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options * @default 'md5' */ hashFunction: string; /** * Options for parsing JMESPath expressions. * * By default, you can use any of the {@link https://jmespath.org/specification.html | JMESPath built-in functions} as well as the * {@link https://docs.powertools.aws.dev/lambda/typescript/latest/api/classes/_aws_lambda_powertools_jmespath.PowertoolsFunctions.PowertoolsFunctions.html | custom functions provided} * by the `@aws-lambda-powertools/jmespath` package. */ jmesPathOptions: JMESPathParsingOptions; /** * The lambda context object. */ lambdaContext?: Context; /** * The maximum number of items to store in the local cache. * @default 1000 */ maxLocalCacheSize: number; /** * The JMESPath expression used to extract the payload to validate. */ payloadValidationJmesPath?: string; /** * Throw an error if the idempotency key is not found in the event. * In some cases, you may want to allow the request to continue without idempotency. * If set to false and idempotency key is not found, the request will continue without idempotency. * @default false */ throwOnNoIdempotencyKey: boolean; /** * A hook that runs when an idempotent request is made. */ responseHook?: ResponseHook; /** * Use the local cache to store idempotency keys. */ useLocalCache: boolean; constructor(config: IdempotencyConfigOptions); /** * Determines if the idempotency feature is enabled. * * @returns {boolean} Returns true if the idempotency feature is enabled. */ isEnabled(): boolean; registerLambdaContext(context: Context): void; } export { IdempotencyConfig }; //# sourceMappingURL=IdempotencyConfig.d.ts.map