import type { JSONValue } from '@aws-lambda-powertools/commons/types';
import type { BasePersistenceLayerInterface, BasePersistenceLayerOptions } from '../types/BasePersistenceLayer.js';
import { IdempotencyRecord } from './IdempotencyRecord.js';
/**
 * Base class for all persistence layers. This class provides the basic functionality for
 * saving, retrieving, and deleting idempotency records. It also provides the ability to
 * configure the persistence layer from the idempotency config.
 * @class
 */
declare abstract class BasePersistenceLayer implements BasePersistenceLayerInterface {
    #private;
    idempotencyKeyPrefix: string;
    private cache?;
    private configured;
    private eventKeyJmesPath?;
    protected expiresAfterSeconds: number;
    private hashFunction;
    private payloadValidationEnabled;
    private throwOnNoIdempotencyKey;
    private useLocalCache;
    private validationKeyJmesPath?;
    constructor();
    /**
     * Initialize the base persistence layer from the configuration settings
     *
     * @param {BasePersistenceLayerConfigureOptions} options - configuration object for the persistence layer
     */
    configure(options: BasePersistenceLayerOptions): void;
    /**
     * Deletes a record from the persistence store for the persistence key generated from the data passed in.
     *
     * @param data - the data payload that will be hashed to create the hash portion of the idempotency key
     */
    deleteRecord(data: JSONValue): Promise<void>;
    /**
     * Retrieve the number of seconds that records will be kept in the persistence store
     */
    getExpiresAfterSeconds(): number;
    /**
     * Retrieves idempotency key for the provided data and fetches data for that key from the persistence store
     *
     * @param data - the data payload that will be hashed to create the hash portion of the idempotency key
     */
    getRecord(data: JSONValue): Promise<IdempotencyRecord>;
    /**
     * Check whether payload validation is enabled or not
     */
    isPayloadValidationEnabled(): boolean;
    /**
     * Validates an existing record against the data payload being processed.
     * If the payload does not match the stored record, an `IdempotencyValidationError` error is thrown.
     *
     * Whenever a record is retrieved from the persistence layer, it should be validated against the data payload
     * being processed. This is to ensure that the data payload being processed is the same as the one that was
     * used to create the record in the first place.
     *
     * The record is also saved to the local cache if local caching is enabled.
     *
     * @param storedDataRecord - the stored record to validate against
     * @param processedData - the data payload being processed and to be validated against the stored record
     */
    processExistingRecord(storedDataRecord: IdempotencyRecord, processedData: JSONValue | IdempotencyRecord): IdempotencyRecord;
    /**
     * Saves a record indicating that the function's execution is currently in progress
     *
     * @param data - the data payload that will be hashed to create the hash portion of the idempotency key
     * @param remainingTimeInMillis - the remaining time left in the lambda execution context
     */
    saveInProgress(data: JSONValue, remainingTimeInMillis?: number): Promise<void>;
    /**
     * Saves a record of the function completing successfully. This will create a record with a COMPLETED status
     * and will save the result of the completed function in the idempotency record.
     *
     * @param data - the data payload that will be hashed to create the hash portion of the idempotency key
     * @param result - the result of the successfully completed function
     */
    saveSuccess(data: JSONValue, result: JSONValue): Promise<void>;
    protected abstract _deleteRecord(record: IdempotencyRecord): Promise<void>;
    protected abstract _getRecord(idempotencyKey: string): Promise<IdempotencyRecord>;
    protected abstract _putRecord(record: IdempotencyRecord): Promise<void>;
    protected abstract _updateRecord(record: IdempotencyRecord): Promise<void>;
    private deleteFromCache;
    /**
     * Generates a hash of the data and returns the digest of that hash
     *
     * @param data the data payload that will generate the hash
     * @returns the digest of the generated hash
     */
    private generateHash;
    /**
     * Creates the expiry timestamp for the idempotency record
     *
     * @returns the expiry time for the record expressed as number of seconds past the UNIX epoch
     */
    private getExpiryTimestamp;
    private getFromCache;
    /**
     * Generates the idempotency key used to identify records in the persistence store.
     *
     * @param data the data payload that will be hashed to create the hash portion of the idempotency key
     * @returns the idempotency key
     */
    protected getHashedIdempotencyKey(data: JSONValue): string;
    /**
     * Extract payload using validation key jmespath and return a hashed representation
     *
     * @param data payload
     */
    private getHashedPayload;
    private static isMissingIdempotencyKey;
    /**
     * Save record to local cache except for when status is `INPROGRESS`.
     *
     * Records with `INPROGRESS` status are not cached because we have no way to
     * reflect updates that might happen to the record outside the execution
     * context of the function.
     *
     * @param record - record to save
     */
    private saveToCache;
    /**
     * Validates the payload against the stored record. If the payload does not match the stored record,
     * an `IdempotencyValidationError` error is thrown.
     *
     * @param data - The data payload to validate against the stored record
     * @param storedDataRecord - The stored record to validate against
     */
    private validatePayload;
}
export { BasePersistenceLayer };
//# sourceMappingURL=BasePersistenceLayer.d.ts.map