@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.
57 lines • 2.56 kB
TypeScript
import { type AttributeValue } from '@aws-sdk/client-dynamodb';
import type { DynamoDBPersistenceOptions } from '../types/DynamoDBPersistence.js';
import { BasePersistenceLayer } from './BasePersistenceLayer.js';
import { IdempotencyRecord } from './IdempotencyRecord.js';
/**
* DynamoDB persistence layer for idempotency records.
*
* This class uses the AWS SDK for JavaScript v3 to write and read idempotency records from DynamoDB.
*
* There are various options to configure the persistence layer, such as the table name, the key attribute, the status attribute, etc.
*
* With default configuration you don't need to create the client beforehand, the persistence layer will create it for you.
* You can also bring your own AWS SDK V3 client, or configure the client with the `clientConfig` option.
*
* See the {@link https://docs.powertools.aws.dev/lambda/python/latest/features/idempotency/ Idempotency documentation} for more details
* on the IAM permissions and DynamoDB table configuration.
*
* @example
* ```ts
* import { DynamoDBPersistenceLayer } from '@aws-lambda-powertools/idempotency/dynamodb';
*
* const persistence = new DynamoDBPersistenceLayer({
* tableName: 'my-idempotency-table',
* });
* ```
*
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dynamodb/index.html
* @category Persistence Layer
*/
declare class DynamoDBPersistenceLayer extends BasePersistenceLayer {
private readonly client;
private readonly dataAttr;
private readonly expiryAttr;
private readonly inProgressExpiryAttr;
private readonly keyAttr;
private readonly sortKeyAttr?;
private readonly staticPkValue;
private readonly statusAttr;
private readonly tableName;
private readonly validationKeyAttr;
constructor(config: DynamoDBPersistenceOptions);
protected _deleteRecord(record: IdempotencyRecord): Promise<void>;
protected _getRecord(idempotencyKey: string): Promise<IdempotencyRecord>;
protected _putRecord(record: IdempotencyRecord): Promise<void>;
protected _updateRecord(record: IdempotencyRecord): Promise<void>;
/**
* Build primary key attribute simple or composite based on params.
*
* When sortKeyAttr is set, we must return a composite key with staticPkValue,
* otherwise we use the idempotency key given.
*
* @param idempotencyKey
*/
protected getKey(idempotencyKey: string): Record<string, AttributeValue>;
}
export { DynamoDBPersistenceLayer };
//# sourceMappingURL=DynamoDBPersistenceLayer.d.ts.map