diff --git a/packages/idempotency/src/IdempotencyHandler.ts b/packages/idempotency/src/IdempotencyHandler.ts index aad48f9dea..c5d5e4ee6b 100644 --- a/packages/idempotency/src/IdempotencyHandler.ts +++ b/packages/idempotency/src/IdempotencyHandler.ts @@ -337,7 +337,7 @@ export class IdempotencyHandler { * * This is called when the handler throws an error. */ - #deleteInProgressRecord = async (): Promise => { + readonly #deleteInProgressRecord = async (): Promise => { try { await this.#persistenceStore.deleteRecord( this.#functionPayloadToBeHashed @@ -356,7 +356,7 @@ export class IdempotencyHandler { * Before returning a result, we might neede to look up the idempotency record * and validate it to ensure that it is consistent with the payload to be hashed. */ - #saveInProgressOrReturnExistingResult = async (): Promise<{ + readonly #saveInProgressOrReturnExistingResult = async (): Promise<{ isIdempotent: boolean; result: JSONValue; }> => { @@ -419,7 +419,9 @@ export class IdempotencyHandler { * * @param result The result returned by the handler. */ - #saveSuccessfulResult = async (result: ReturnType): Promise => { + readonly #saveSuccessfulResult = async ( + result: ReturnType + ): Promise => { try { await this.#persistenceStore.saveSuccess( this.#functionPayloadToBeHashed, diff --git a/packages/idempotency/src/config/EnvironmentVariablesService.ts b/packages/idempotency/src/config/EnvironmentVariablesService.ts index b5cc1ba262..36af2c4b4a 100644 --- a/packages/idempotency/src/config/EnvironmentVariablesService.ts +++ b/packages/idempotency/src/config/EnvironmentVariablesService.ts @@ -19,8 +19,9 @@ class EnvironmentVariablesService implements ConfigServiceInterface { // Reserved environment variables - private functionNameVariable = 'AWS_LAMBDA_FUNCTION_NAME'; - private idempotencyDisabledVariable = 'POWERTOOLS_IDEMPOTENCY_DISABLED'; + private readonly functionNameVariable = 'AWS_LAMBDA_FUNCTION_NAME'; + private readonly idempotencyDisabledVariable = + 'POWERTOOLS_IDEMPOTENCY_DISABLED'; /** * It returns the value of the AWS_LAMBDA_FUNCTION_NAME environment variable. diff --git a/packages/idempotency/src/persistence/BasePersistenceLayer.ts b/packages/idempotency/src/persistence/BasePersistenceLayer.ts index 515a315652..2ca6690336 100644 --- a/packages/idempotency/src/persistence/BasePersistenceLayer.ts +++ b/packages/idempotency/src/persistence/BasePersistenceLayer.ts @@ -28,7 +28,7 @@ abstract class BasePersistenceLayer implements BasePersistenceLayerInterface { private cache?: LRUCache; private configured = false; // envVarsService is always initialized in the constructor - private envVarsService!: EnvironmentVariablesService; + private readonly envVarsService!: EnvironmentVariablesService; private eventKeyJmesPath?: string; protected expiresAfterSeconds: number = 60 * 60; // 1 hour default private hashFunction = 'md5'; diff --git a/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts b/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts index c9daed42e9..4e88f99b51 100644 --- a/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts +++ b/packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts @@ -50,16 +50,16 @@ import { IdempotencyRecord } from './IdempotencyRecord.js'; * @category Persistence Layer */ class DynamoDBPersistenceLayer extends BasePersistenceLayer { - private client: DynamoDBClient; - private dataAttr: string; - private expiryAttr: string; - private inProgressExpiryAttr: string; - private keyAttr: string; - private sortKeyAttr?: string; - private staticPkValue: string; - private statusAttr: string; - private tableName: string; - private validationKeyAttr: string; + private readonly client: DynamoDBClient; + private readonly dataAttr: string; + private readonly expiryAttr: string; + private readonly inProgressExpiryAttr: string; + private readonly keyAttr: string; + private readonly sortKeyAttr?: string; + private readonly staticPkValue: string; + private readonly statusAttr: string; + private readonly tableName: string; + private readonly validationKeyAttr: string; public constructor(config: DynamoDBPersistenceOptions) { super(); diff --git a/packages/idempotency/src/persistence/IdempotencyRecord.ts b/packages/idempotency/src/persistence/IdempotencyRecord.ts index 9d83a17bb8..e222554c85 100644 --- a/packages/idempotency/src/persistence/IdempotencyRecord.ts +++ b/packages/idempotency/src/persistence/IdempotencyRecord.ts @@ -42,7 +42,7 @@ class IdempotencyRecord { * {@link constants.IdempotencyRecordStatusValue | IdempotencyRecordStatusValue} * @private */ - private status: IdempotencyRecordStatusValue; + private readonly status: IdempotencyRecordStatusValue; public constructor(config: IdempotencyRecordOptions) { this.idempotencyKey = config.idempotencyKey;