From f851c113ce56d81db8cc75063ef651d7d1ae1abe Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Mon, 22 Jul 2024 17:02:15 +0200 Subject: [PATCH 1/4] chore(maintenance): migrate parameters utility to biome --- .../src/appconfig/AppConfigProvider.ts | 3 +- packages/parameters/src/base/BaseProvider.ts | 11 +++-- .../parameters/src/base/GetMultipleOptions.ts | 4 +- packages/parameters/src/base/GetOptions.ts | 4 +- .../parameters/src/base/transformValue.ts | 3 +- .../src/config/EnvironmentVariablesService.ts | 6 +-- .../parameters/src/secrets/SecretsProvider.ts | 2 +- packages/parameters/src/ssm/SSMProvider.ts | 13 +++--- packages/parameters/src/types/BaseProvider.ts | 4 +- ...pConfigProvider.class.test.functionCode.ts | 2 +- .../tests/e2e/appConfigProvider.class.test.ts | 2 +- ...ynamoDBProvider.class.test.functionCode.ts | 2 +- .../tests/e2e/dynamoDBProvider.class.test.ts | 2 +- ...secretsProvider.class.test.functionCode.ts | 4 +- .../tests/e2e/secretsProvider.class.test.ts | 2 +- .../ssmProvider.class.test.functionCode.ts | 2 +- .../tests/e2e/ssmProvider.class.test.ts | 2 +- .../parameters/tests/helpers/resources.ts | 19 +++++---- .../tests/unit/AppConfigProvider.test.ts | 2 +- .../tests/unit/BaseProvider.test.ts | 6 +-- .../tests/unit/DynamoDBProvider.test.ts | 10 ++--- .../parameters/tests/unit/SSMProvider.test.ts | 42 +------------------ 22 files changed, 53 insertions(+), 94 deletions(-) diff --git a/packages/parameters/src/appconfig/AppConfigProvider.ts b/packages/parameters/src/appconfig/AppConfigProvider.ts index 4a77a19e99..4067c059d7 100644 --- a/packages/parameters/src/appconfig/AppConfigProvider.ts +++ b/packages/parameters/src/appconfig/AppConfigProvider.ts @@ -292,6 +292,7 @@ class AppConfigProvider extends BaseProvider { ): Promise { if ( !this.configurationTokenStore.has(name) || + // biome-ignore lint/style/noNonNullAssertion: we check if the value is in the map before accessing it this.configurationTokenStore.get(name)!.expiration <= Date.now() ) { const sessionOptions: StartConfigurationSessionCommandInput = { @@ -356,7 +357,7 @@ class AppConfigProvider extends BaseProvider { protected async _getMultiple( _path: string, _sdkOptions?: unknown - ): Promise { + ): Promise | undefined> { throw new Error('Method not implemented.'); } } diff --git a/packages/parameters/src/base/BaseProvider.ts b/packages/parameters/src/base/BaseProvider.ts index 739913e3aa..19423753cd 100644 --- a/packages/parameters/src/base/BaseProvider.ts +++ b/packages/parameters/src/base/BaseProvider.ts @@ -97,7 +97,7 @@ abstract class BaseProvider implements BaseProviderInterface { name: string, options?: GetOptionsInterface ): Promise { - const configs = new GetOptions(options, this.envVarsService); + const configs = new GetOptions(this.envVarsService, options); const key = [name, configs.transform].toString(); if (!configs.forceFetch && !this.hasKeyExpiredInCache(key)) { @@ -136,16 +136,15 @@ abstract class BaseProvider implements BaseProviderInterface { path: string, options?: GetMultipleOptionsInterface ): Promise { - const configs = new GetMultipleOptions(options, this.envVarsService); + const configs = new GetMultipleOptions(this.envVarsService, options); const key = [path, configs.transform].toString(); if (!configs.forceFetch && !this.hasKeyExpiredInCache(key)) { - // If the code enters in this block, then the key must exist & not have been expired - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + // biome-ignore lint/style/noNonNullAssertion: If the code enters in this block, then the key must exist & not have been expired return this.store.get(key)!.value as Record; } - let values; + let values: Record | undefined; try { values = await this._getMultiple(path, options); if (!isRecord(values)) { @@ -216,7 +215,7 @@ abstract class BaseProvider implements BaseProviderInterface { protected abstract _getMultiple( path: string, options?: unknown - ): Promise | void>; + ): Promise | undefined>; } export { BaseProvider }; diff --git a/packages/parameters/src/base/GetMultipleOptions.ts b/packages/parameters/src/base/GetMultipleOptions.ts index 1bf2ca5514..fdcfff4277 100644 --- a/packages/parameters/src/base/GetMultipleOptions.ts +++ b/packages/parameters/src/base/GetMultipleOptions.ts @@ -1,5 +1,5 @@ import { GetOptions } from './GetOptions.js'; -import { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js'; +import type { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js'; import type { GetMultipleOptionsInterface } from '../types/BaseProvider.js'; /** @@ -14,8 +14,8 @@ class GetMultipleOptions public throwOnTransformError = false; public constructor( + envVarsService: EnvironmentVariablesService, options: GetMultipleOptionsInterface = {}, - envVarsService: EnvironmentVariablesService ) { super(options, envVarsService); diff --git a/packages/parameters/src/base/GetOptions.ts b/packages/parameters/src/base/GetOptions.ts index 1128f47faa..360beabeb7 100644 --- a/packages/parameters/src/base/GetOptions.ts +++ b/packages/parameters/src/base/GetOptions.ts @@ -1,4 +1,4 @@ -import { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js'; +import type { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js'; import { DEFAULT_MAX_AGE_SECS } from '../constants.js'; import type { GetOptionsInterface, @@ -17,8 +17,8 @@ class GetOptions implements GetOptionsInterface { public transform?: TransformOptions; public constructor( + envVarsService: EnvironmentVariablesService, options: GetOptionsInterface = {}, - envVarsService: EnvironmentVariablesService ) { Object.assign(this, options); diff --git a/packages/parameters/src/base/transformValue.ts b/packages/parameters/src/base/transformValue.ts index 2c560689db..b69b165712 100644 --- a/packages/parameters/src/base/transformValue.ts +++ b/packages/parameters/src/base/transformValue.ts @@ -66,7 +66,8 @@ const transformValue = ( if (isJsonTransform || isAutoJsonTransform) { return JSON.parse(value) as JSONValue; // If the transform is `binary` or `auto` and the key ends with `.binary`, decode the value from base64 - } else if (isBinaryTransform || isAutoBinaryTransform) { + } + if (isBinaryTransform || isAutoBinaryTransform) { return new TextDecoder('utf-8').decode(fromBase64(value, 'base64')); } } catch (error) { diff --git a/packages/parameters/src/config/EnvironmentVariablesService.ts b/packages/parameters/src/config/EnvironmentVariablesService.ts index b0c39e9bf3..b5f41b91f7 100644 --- a/packages/parameters/src/config/EnvironmentVariablesService.ts +++ b/packages/parameters/src/config/EnvironmentVariablesService.ts @@ -1,4 +1,4 @@ -import { ConfigServiceInterface } from '../types/ConfigServiceInterface.js'; +import type { ConfigServiceInterface } from '../types/ConfigServiceInterface.js'; import { DEFAULT_MAX_AGE_SECS } from '../constants.js'; import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons'; @@ -20,8 +20,8 @@ class EnvironmentVariablesService if (maxAge.length === 0) return undefined; - const maxAgeAsNumber = parseInt(maxAge, 10); - if (isNaN(maxAgeAsNumber)) { + const maxAgeAsNumber = Number.parseInt(maxAge, 10); + if (Number.isNaN(maxAgeAsNumber)) { console.warn( `Invalid value for ${this.parametersMaxAgeVariable} environment variable: [${maxAge}], using default value of ${DEFAULT_MAX_AGE_SECS} seconds` ); diff --git a/packages/parameters/src/secrets/SecretsProvider.ts b/packages/parameters/src/secrets/SecretsProvider.ts index c60d2aee85..757d8f0591 100644 --- a/packages/parameters/src/secrets/SecretsProvider.ts +++ b/packages/parameters/src/secrets/SecretsProvider.ts @@ -245,7 +245,7 @@ class SecretsProvider extends BaseProvider { protected async _getMultiple( _path: string, _options?: unknown - ): Promise { + ): Promise | undefined> { throw new Error('Method not implemented.'); } } diff --git a/packages/parameters/src/ssm/SSMProvider.ts b/packages/parameters/src/ssm/SSMProvider.ts index a205db3716..4c4377a1be 100644 --- a/packages/parameters/src/ssm/SSMProvider.ts +++ b/packages/parameters/src/ssm/SSMProvider.ts @@ -27,6 +27,7 @@ import type { SSMSplitBatchAndDecryptParametersOutputType, SSMGetParametersByNameFromCacheOutputType, } from '../types/SSMProvider.js'; +import type { JSONValue } from '@aws-lambda-powertools/commons/types'; /** * ## Intro @@ -550,9 +551,7 @@ class SSMProvider extends BaseProvider { * The parameter name returned by SSM will contain the full path. * However, for readability, we should return only the part after the path. **/ - - // If the parameter is present in the response, then it has a Name - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + // biome-ignore lint/style/noNonNullAssertion: If the parameter is present in the response, then it has a Name let name = parameter.Name!; name = name.replace(path, ''); if (name.startsWith('/')) { @@ -656,8 +655,7 @@ class SSMProvider extends BaseProvider { )) { const cacheKey = [parameterName, parameterOptions.transform].toString(); if (!this.hasKeyExpiredInCache(cacheKey)) { - // Since we know the key exists in the cache, we can safely use the non-null assertion operator - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + // biome-ignore lint/style/noNonNullAssertion: Since we know the key exists in the cache, we can safely use the non-null assertion operator cached[parameterName] = this.store.get(cacheKey)!.value as Record< string, string | Record @@ -867,13 +865,12 @@ class SSMProvider extends BaseProvider { const processedParameters: Record = {}; for (const parameter of response.Parameters || []) { - // If the parameter is present in the response, then it has a Name - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + // biome-ignore lint/style/noNonNullAssertion: If the parameter is present in the response, then it has a Name const parameterName = parameter.Name!; const parameterValue = parameter.Value; const parameterOptions = parameters[parameterName]; - let value; + let value: string | JSONValue | Uint8Array | undefined; // NOTE: if transform is set, we do it before caching to reduce number of operations if (parameterValue && parameterOptions.transform) { value = transformValue( diff --git a/packages/parameters/src/types/BaseProvider.ts b/packages/parameters/src/types/BaseProvider.ts index f773a7267a..05e85dbe5c 100644 --- a/packages/parameters/src/types/BaseProvider.ts +++ b/packages/parameters/src/types/BaseProvider.ts @@ -1,4 +1,4 @@ -import { Transform } from '../constants.js'; +import type { Transform } from '../constants.js'; /** * Type for the transform option. @@ -74,7 +74,7 @@ interface BaseProviderInterface { getMultiple( path: string, options?: GetMultipleOptionsInterface - ): Promise; + ): Promise; clearCache?(): void; } diff --git a/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts index c55193326f..b0369735a9 100644 --- a/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts @@ -1,7 +1,7 @@ import type { Context } from 'aws-lambda'; import { Transform } from '../../src/constants.js'; import { AppConfigProvider } from '../../src/appconfig/AppConfigProvider.js'; -import { AppConfigGetOptions } from '../../src/types/AppConfigProvider.js'; +import type { AppConfigGetOptions } from '../../src/types/AppConfigProvider.js'; import { TinyLogger } from '../helpers/tinyLogger.js'; import { middleware } from '../helpers/sdkMiddlewareRequestCounter.js'; import { AppConfigDataClient } from '@aws-sdk/client-appconfigdata'; diff --git a/packages/parameters/tests/e2e/appConfigProvider.class.test.ts b/packages/parameters/tests/e2e/appConfigProvider.class.test.ts index c44d29c405..93d9c840d3 100644 --- a/packages/parameters/tests/e2e/appConfigProvider.class.test.ts +++ b/packages/parameters/tests/e2e/appConfigProvider.class.test.ts @@ -71,7 +71,7 @@ import { * is created after the previous one. This is necessary because we share the same AppConfig * application and environment for all tests. */ -describe(`Parameters E2E tests, AppConfig provider`, () => { +describe('Parameters E2E tests, AppConfig provider', () => { const testStack = new TestStack({ stackNameProps: { stackNamePrefix: RESOURCE_NAME_PREFIX, diff --git a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts index 808bb188e9..ca1980a16d 100644 --- a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts @@ -1,7 +1,7 @@ import type { Context } from 'aws-lambda'; import { Transform } from '../../src/constants.js'; import { DynamoDBProvider } from '../../src/dynamodb/DynamoDBProvider.js'; -import { +import type { DynamoDBGetOptions, DynamoDBGetMultipleOptions, } from '../../src/types/DynamoDBProvider.js'; diff --git a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts index 8f1748246a..bb1224064a 100644 --- a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts +++ b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts @@ -95,7 +95,7 @@ import { * Test 9 * Get a cached parameter and force retrieval. This also uses the same custom SDK client that counts the number of calls to DynamoDB. */ -describe(`Parameters E2E tests, dynamoDB provider`, () => { +describe('Parameters E2E tests, dynamoDB provider', () => { const testStack = new TestStack({ stackNameProps: { stackNamePrefix: RESOURCE_NAME_PREFIX, diff --git a/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts index 4c04484897..000babae2e 100644 --- a/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts @@ -1,10 +1,10 @@ -import { Context } from 'aws-lambda'; +import type { Context } from 'aws-lambda'; import { TinyLogger } from '../helpers/tinyLogger.js'; import { SecretsManagerClient } from '@aws-sdk/client-secrets-manager'; import { middleware } from '../helpers/sdkMiddlewareRequestCounter.js'; import { Transform } from '../../src/constants.js'; import { SecretsProvider } from '../../src/secrets/SecretsProvider.js'; -import { SecretsGetOptions } from '../../src/types/SecretsProvider.js'; +import type { SecretsGetOptions } from '../../src/types/SecretsProvider.js'; const logger = new TinyLogger(); const defaultProvider = new SecretsProvider(); diff --git a/packages/parameters/tests/e2e/secretsProvider.class.test.ts b/packages/parameters/tests/e2e/secretsProvider.class.test.ts index 32bcf1a5a0..d807e53b19 100644 --- a/packages/parameters/tests/e2e/secretsProvider.class.test.ts +++ b/packages/parameters/tests/e2e/secretsProvider.class.test.ts @@ -36,7 +36,7 @@ import { * Make sure to add the right permissions to the lambda function to access the resources. We use our `ResourceAccessGranter` to add permissions. * */ -describe(`Parameters E2E tests, Secrets Manager provider`, () => { +describe('Parameters E2E tests, Secrets Manager provider', () => { const testStack = new TestStack({ stackNameProps: { stackNamePrefix: RESOURCE_NAME_PREFIX, diff --git a/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts index f1b6171e0a..3c4a1aca99 100644 --- a/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts @@ -1,6 +1,6 @@ import type { Context } from 'aws-lambda'; import { SSMProvider } from '../../src/ssm/SSMProvider.js'; -import { +import type { SSMGetOptions, SSMGetMultipleOptions, SSMGetParametersByNameOptions, diff --git a/packages/parameters/tests/e2e/ssmProvider.class.test.ts b/packages/parameters/tests/e2e/ssmProvider.class.test.ts index f6fb8ed858..1b3aed047f 100644 --- a/packages/parameters/tests/e2e/ssmProvider.class.test.ts +++ b/packages/parameters/tests/e2e/ssmProvider.class.test.ts @@ -70,7 +70,7 @@ import { * get parameter twice, but force fetch 2nd time, we count number of SDK requests and * check that we made two API calls */ -describe(`Parameters E2E tests, SSM provider`, () => { +describe('Parameters E2E tests, SSM provider', () => { const testStack = new TestStack({ stackNameProps: { stackNamePrefix: RESOURCE_NAME_PREFIX, diff --git a/packages/parameters/tests/helpers/resources.ts b/packages/parameters/tests/helpers/resources.ts index 7958e74310..ef1aecf4b3 100644 --- a/packages/parameters/tests/helpers/resources.ts +++ b/packages/parameters/tests/helpers/resources.ts @@ -8,7 +8,7 @@ import { getRuntimeKey, type TestStack, } from '@aws-lambda-powertools/testing-utils'; -import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; +import type { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { TestDynamodbTable } from '@aws-lambda-powertools/testing-utils/resources/dynamodb'; import { marshall } from '@aws-sdk/util-dynamodb'; import { CfnOutput, Duration, RemovalPolicy, Stack } from 'aws-cdk-lib'; @@ -18,15 +18,15 @@ import { ConfigurationType, DeploymentStrategy, HostedConfiguration, - IEnvironment, + type IEnvironment, RolloutStrategy, - CfnHostedConfigurationVersion, + type CfnHostedConfigurationVersion, } from 'aws-cdk-lib/aws-appconfig'; import { Effect, PolicyStatement } from 'aws-cdk-lib/aws-iam'; import type { SecretProps } from 'aws-cdk-lib/aws-secretsmanager'; import { Secret } from 'aws-cdk-lib/aws-secretsmanager'; import type { StringParameterProps } from 'aws-cdk-lib/aws-ssm'; -import { IStringParameter, StringParameter } from 'aws-cdk-lib/aws-ssm'; +import { type IStringParameter, StringParameter } from 'aws-cdk-lib/aws-ssm'; import { AwsCustomResource, AwsCustomResourcePolicy, @@ -266,7 +266,7 @@ class TestAppConfigWithProfiles extends Construct { } ); - profiles.forEach((profile) => { + for (const profile of profiles) { const config = new HostedConfiguration( testStack.stack, `hc-${randomUUID()}`, @@ -291,7 +291,7 @@ class TestAppConfigWithProfiles extends Construct { config.node.defaultChild as CfnHostedConfigurationVersion ).applyRemovalPolicy(RemovalPolicy.DESTROY); this.profiles.push(config); - }); + }; } /** @@ -300,7 +300,9 @@ class TestAppConfigWithProfiles extends Construct { * @param fn The function to add the environment variables to */ public addEnvVariablesToFunction(fn: TestNodejsFunction): void { + // biome-ignore lint/style/noNonNullAssertion: we know this is called after the AppConfig resources are created fn.addEnvironment('APPLICATION_NAME', this.application.name!); + // biome-ignore lint/style/noNonNullAssertion: we know this is called after the AppConfig resources are created fn.addEnvironment('ENVIRONMENT_NAME', this.environment.name!); fn.addEnvironment( 'FREEFORM_JSON_NAME', @@ -326,9 +328,10 @@ class TestAppConfigWithProfiles extends Construct { * @param fn The function to grant access to the profiles */ public grantReadData(fn: TestNodejsFunction): void { - this.profiles.forEach((profile) => { + for (const profile of this.profiles) { const appConfigConfigurationArn = Stack.of(fn).formatArn({ service: 'appconfig', + // biome-ignore lint/style/noNonNullAssertion: we know this is called after the AppConfig resources are created resource: `application/${profile.application.applicationId}/environment/${profile.deployTo![0].environmentId}/configuration/${profile.configurationProfileId}`, }); @@ -342,7 +345,7 @@ class TestAppConfigWithProfiles extends Construct { resources: [appConfigConfigurationArn], }) ); - }); + }; } } diff --git a/packages/parameters/tests/unit/AppConfigProvider.test.ts b/packages/parameters/tests/unit/AppConfigProvider.test.ts index 71881d3c48..4be203f8e9 100644 --- a/packages/parameters/tests/unit/AppConfigProvider.test.ts +++ b/packages/parameters/tests/unit/AppConfigProvider.test.ts @@ -5,7 +5,7 @@ */ import { AppConfigProvider } from '../../src/appconfig/index.js'; import { ExpirableValue } from '../../src/base/ExpirableValue.js'; -import { AppConfigProviderOptions } from '../../src/types/AppConfigProvider.js'; +import type { AppConfigProviderOptions } from '../../src/types/AppConfigProvider.js'; import { AppConfigDataClient, GetLatestConfigurationCommand, diff --git a/packages/parameters/tests/unit/BaseProvider.test.ts b/packages/parameters/tests/unit/BaseProvider.test.ts index d3aa29c709..95fd97c879 100644 --- a/packages/parameters/tests/unit/BaseProvider.test.ts +++ b/packages/parameters/tests/unit/BaseProvider.test.ts @@ -633,8 +633,7 @@ describe('Class: GetOptions', () => { getParametersMaxAge: jest.fn(), }; const options = new GetOptions( - undefined, - envVarsService as unknown as EnvironmentVariablesService + envVarsService as unknown as EnvironmentVariablesService, ); // Assess @@ -649,8 +648,7 @@ describe('Class: GetMultipleOptions', () => { getParametersMaxAge: jest.fn(), }; const options = new GetMultipleOptions( - undefined, - envVarsService as unknown as EnvironmentVariablesService + envVarsService as unknown as EnvironmentVariablesService, ); // Assess diff --git a/packages/parameters/tests/unit/DynamoDBProvider.test.ts b/packages/parameters/tests/unit/DynamoDBProvider.test.ts index 12ccd80d09..3e71f9481e 100644 --- a/packages/parameters/tests/unit/DynamoDBProvider.test.ts +++ b/packages/parameters/tests/unit/DynamoDBProvider.test.ts @@ -311,7 +311,7 @@ describe('Class: DynamoDBProvider', () => { // Assess expect(client).toReceiveCommandWith(QueryCommand, { TableName: 'test-table', - KeyConditionExpression: `#key = :key`, + KeyConditionExpression: '#key = :key', ExpressionAttributeValues: marshall({ ':key': parameterPath, }), @@ -366,7 +366,7 @@ describe('Class: DynamoDBProvider', () => { // Assess expect(client).toReceiveCommandWith(QueryCommand, { TableName: 'test-table', - KeyConditionExpression: `#key = :key`, + KeyConditionExpression: '#key = :key', ExpressionAttributeValues: marshall({ ':key': parameterPath, }), @@ -423,7 +423,7 @@ describe('Class: DynamoDBProvider', () => { // Assess expect(client).toReceiveCommandWith(QueryCommand, { TableName: 'test-table', - KeyConditionExpression: `#key = :key`, + KeyConditionExpression: '#key = :key', ExpressionAttributeValues: marshall({ ':key': parameterPath, }), @@ -525,7 +525,7 @@ describe('Class: DynamoDBProvider', () => { // Act await provider.getMultiple(parameterPath, { sdkOptions: { - KeyConditionExpression: `key = :myKey`, + KeyConditionExpression: '#key = :key', ExpressionAttributeValues: marshall({ ':myKey': 'foo', }), @@ -538,7 +538,7 @@ describe('Class: DynamoDBProvider', () => { // Assess expect(client).toReceiveCommandWith(QueryCommand, { TableName: 'test-table', - KeyConditionExpression: `#key = :key`, + KeyConditionExpression: '#key = :key', ExpressionAttributeValues: marshall({ ':key': parameterPath, }), diff --git a/packages/parameters/tests/unit/SSMProvider.test.ts b/packages/parameters/tests/unit/SSMProvider.test.ts index 005cb7d761..3b75e72d54 100644 --- a/packages/parameters/tests/unit/SSMProvider.test.ts +++ b/packages/parameters/tests/unit/SSMProvider.test.ts @@ -122,10 +122,6 @@ describe('Class: SSMProvider', () => { class SSMProviderMock extends SSMProvider { public getParametersBatchByName = jest.fn(); public getParametersByNameWithDecryptOption = jest.fn(); - - public constructor() { - super(); - } } test('when called with no parameters to decrypt, it calls both getParametersByNameWithDecryptOption and getParametersBatchByName, then returns', async () => { @@ -559,10 +555,6 @@ describe('Class: SSMProvider', () => { class SSMProviderMock extends SSMProvider { public transformAndCacheGetParametersResponse = jest.fn(); - public constructor() { - super(); - } - public _getParametersByName( parameters: Record, throwOnError: boolean, @@ -651,10 +643,6 @@ describe('Class: SSMProvider', () => { public getParametersByNameFromCache = jest.fn(); public getParametersByNameInChunks = jest.fn(); - public constructor() { - super(); - } - public getParametersBatchByName( parameters: Record, throwOnError: boolean, @@ -800,10 +788,6 @@ describe('Class: SSMProvider', () => { describe('Method: getParametersByNameFromCache', () => { class SSMProviderMock extends SSMProvider { - public constructor() { - super(); - } - public _add(key: string, value: ExpirableValue): void { this.store.set(key, value); } @@ -846,10 +830,6 @@ describe('Class: SSMProvider', () => { public _getParametersByName = jest.fn(); public maxGetParametersItems = 1; - public constructor() { - super(); - } - public async getParametersByNameInChunks( parameters: Record, throwOnError: boolean, @@ -955,10 +935,6 @@ describe('Class: SSMProvider', () => { class SSMProviderMock extends SSMProvider { public _get = jest.fn(); - public constructor() { - super(); - } - public async getParametersByNameWithDecryptOption( parameters: Record, throwOnError: boolean @@ -1033,10 +1009,6 @@ describe('Class: SSMProvider', () => { describe('Method: handleAnyInvalidGetparameterErrors', () => { class SSMProviderMock extends SSMProvider { - public constructor() { - super(); - } - public handleAnyInvalidGetParameterErrors( result: Partial, throwOnError: boolean @@ -1092,10 +1064,6 @@ describe('Class: SSMProvider', () => { describe('Method: splitBatchAndDecryptParameters', () => { class SSMProviderMock extends SSMProvider { - public constructor() { - super(); - } - public splitBatchAndDecryptParameters( parameters: Record, configs: SSMGetParametersByNameOptions @@ -1198,16 +1166,12 @@ describe('Class: SSMProvider', () => { describe('Method: throwIfErrorsKeyIsPresent', () => { class SSMProviderMock extends SSMProvider { - public constructor() { - super(); - } - public throwIfErrorsKeyIsPresent( parameters: Record, reservedParameter: string, throwOnError: boolean ): void { - return SSMProvider.throwIfErrorsKeyIsPresent( + SSMProvider.throwIfErrorsKeyIsPresent( parameters, reservedParameter, throwOnError @@ -1264,10 +1228,6 @@ describe('Class: SSMProvider', () => { describe('Method: transformAndCacheGetParametersResponse', () => { class SSMProviderMock extends SSMProvider { - public constructor() { - super(); - } - public transformAndCacheGetParametersResponse( response: Partial, parameters: Record, From a563a9690139669bd6bee0afe5c77af1dd3d37ba Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Tue, 23 Jul 2024 13:55:34 +0200 Subject: [PATCH 2/4] chore(maintenance): migrate parameters utility to biome --- packages/parameters/package.json | 28 +++++-------------- .../src/appconfig/AppConfigProvider.ts | 8 +++--- .../parameters/src/appconfig/getAppConfig.ts | 2 +- packages/parameters/src/base/BaseProvider.ts | 10 +++---- .../parameters/src/base/GetMultipleOptions.ts | 6 ++-- packages/parameters/src/base/GetOptions.ts | 2 +- .../parameters/src/base/transformValue.ts | 15 ++++++---- .../src/config/EnvironmentVariablesService.ts | 4 +-- .../src/dynamodb/DynamoDBProvider.ts | 22 ++++++++------- .../parameters/src/secrets/SecretsProvider.ts | 6 ++-- packages/parameters/src/secrets/getSecret.ts | 2 +- packages/parameters/src/ssm/SSMProvider.ts | 24 ++++++++-------- packages/parameters/src/ssm/getParameter.ts | 2 +- packages/parameters/src/ssm/getParameters.ts | 2 +- .../parameters/src/ssm/getParametersByName.ts | 2 +- ...pConfigProvider.class.test.functionCode.ts | 6 ++-- .../tests/e2e/appConfigProvider.class.test.ts | 4 +-- ...ynamoDBProvider.class.test.functionCode.ts | 6 ++-- .../tests/e2e/dynamoDBProvider.class.test.ts | 4 +-- ...secretsProvider.class.test.functionCode.ts | 6 ++-- .../tests/e2e/secretsProvider.class.test.ts | 4 +-- .../ssmProvider.class.test.functionCode.ts | 6 ++-- .../tests/e2e/ssmProvider.class.test.ts | 4 +-- .../parameters/tests/helpers/resources.ts | 20 ++++++------- .../helpers/sdkMiddlewareRequestCounter.ts | 2 +- packages/parameters/tests/tsconfig.json | 17 +++++------ .../tests/unit/AppConfigProvider.test.ts | 8 +++--- .../tests/unit/BaseProvider.test.ts | 12 ++++---- .../tests/unit/DynamoDBProvider.test.ts | 6 ++-- .../parameters/tests/unit/SSMProvider.test.ts | 16 +++++------ .../tests/unit/SecretsProvider.test.ts | 6 ++-- .../tests/unit/getAppConfig.test.ts | 10 +++---- .../tests/unit/getParameter.test.ts | 4 +-- .../tests/unit/getParameters.test.ts | 4 +-- .../parameters/tests/unit/getSecret.test.ts | 6 ++-- packages/parameters/tsconfig.esm.json | 6 ++-- packages/parameters/tsconfig.json | 18 ++++++------ packages/parameters/typedoc.json | 8 ++---- 38 files changed, 150 insertions(+), 168 deletions(-) diff --git a/packages/parameters/package.json b/packages/parameters/package.json index d42f9b7823..10039da231 100644 --- a/packages/parameters/package.json +++ b/packages/parameters/package.json @@ -20,8 +20,8 @@ "build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json", "build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json", "build": "npm run build:esm & npm run build:cjs", - "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", - "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", + "lint": "biome lint .", + "lint:fix": "biome check --write .", "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/parameters#readme", @@ -89,26 +89,17 @@ "lib/cjs/types/BaseProvider.d.ts", "lib/esm/types/BaseProvider.d.ts" ], - "base": [ - "lib/cjs/base/index.d.ts", - "lib/esm/base/index.d.ts" - ], + "base": ["lib/cjs/base/index.d.ts", "lib/esm/base/index.d.ts"], "ssm/types": [ "lib/cjs/types/SSMProvider.d.ts", "lib/esm/types/SSMProvider.d.ts" ], - "ssm": [ - "lib/cjs/ssm/index.d.ts", - "lib/esm/ssm/index.d.ts" - ], + "ssm": ["lib/cjs/ssm/index.d.ts", "lib/esm/ssm/index.d.ts"], "secrets/types": [ "lib/cjs/types/SecretsProvider.d.ts", "lib/esm/types/SecretsProvider.d.ts" ], - "secrets": [ - "lib/cjs/secrets/index.d.ts", - "lib/esm/secrets/index.d.ts" - ], + "secrets": ["lib/cjs/secrets/index.d.ts", "lib/esm/secrets/index.d.ts"], "dynamodb/types": [ "./lib/cjs/types/DynamoDBProvider.d.ts", "./lib/esm/types/DynamoDBProvider.d.ts" @@ -125,17 +116,12 @@ "lib/cjs/appconfig/index.d.ts", "lib/esm/appconfig/index.d.ts" ], - "errors": [ - "lib/cjs/errors.d.ts", - "lib/esm/errors.d.ts" - ] + "errors": ["lib/cjs/errors.d.ts", "lib/esm/errors.d.ts"] } }, "types": "./lib/cjs/index.d.ts", "main": "./lib/cjs/index.js", - "files": [ - "lib" - ], + "files": ["lib"], "repository": { "type": "git", "url": "git+https://github.com/aws-powertools/powertools-lambda-typescript.git" diff --git a/packages/parameters/src/appconfig/AppConfigProvider.ts b/packages/parameters/src/appconfig/AppConfigProvider.ts index 4067c059d7..9fc781b688 100644 --- a/packages/parameters/src/appconfig/AppConfigProvider.ts +++ b/packages/parameters/src/appconfig/AppConfigProvider.ts @@ -1,16 +1,16 @@ -import { BaseProvider } from '../base/BaseProvider.js'; import { AppConfigDataClient, - StartConfigurationSessionCommand, GetLatestConfigurationCommand, + StartConfigurationSessionCommand, } from '@aws-sdk/client-appconfigdata'; import type { StartConfigurationSessionCommandInput } from '@aws-sdk/client-appconfigdata'; +import { BaseProvider } from '../base/BaseProvider.js'; +import { APPCONFIG_TOKEN_EXPIRATION } from '../constants.js'; import type { - AppConfigProviderOptions, AppConfigGetOptions, AppConfigGetOutput, + AppConfigProviderOptions, } from '../types/AppConfigProvider.js'; -import { APPCONFIG_TOKEN_EXPIRATION } from '../constants.js'; /** * ## Intro diff --git a/packages/parameters/src/appconfig/getAppConfig.ts b/packages/parameters/src/appconfig/getAppConfig.ts index feac798a68..914adb3954 100644 --- a/packages/parameters/src/appconfig/getAppConfig.ts +++ b/packages/parameters/src/appconfig/getAppConfig.ts @@ -1,9 +1,9 @@ -import { AppConfigProvider } from './AppConfigProvider.js'; import { DEFAULT_PROVIDERS } from '../base/index.js'; import type { AppConfigGetOutput, GetAppConfigOptions, } from '../types/AppConfigProvider.js'; +import { AppConfigProvider } from './AppConfigProvider.js'; /** * ## Intro diff --git a/packages/parameters/src/base/BaseProvider.ts b/packages/parameters/src/base/BaseProvider.ts index 19423753cd..bbaeff91c1 100644 --- a/packages/parameters/src/base/BaseProvider.ts +++ b/packages/parameters/src/base/BaseProvider.ts @@ -5,17 +5,17 @@ import { isSdkClient, isString, } from '@aws-lambda-powertools/commons'; -import { GetOptions } from './GetOptions.js'; -import { GetMultipleOptions } from './GetMultipleOptions.js'; -import { ExpirableValue } from './ExpirableValue.js'; -import { GetParameterError, TransformParameterError } from '../errors.js'; import { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js'; -import { transformValue } from './transformValue.js'; +import { GetParameterError, TransformParameterError } from '../errors.js'; import type { BaseProviderInterface, GetMultipleOptionsInterface, GetOptionsInterface, } from '../types/BaseProvider.js'; +import { ExpirableValue } from './ExpirableValue.js'; +import { GetMultipleOptions } from './GetMultipleOptions.js'; +import { GetOptions } from './GetOptions.js'; +import { transformValue } from './transformValue.js'; /** * Base class for all providers. diff --git a/packages/parameters/src/base/GetMultipleOptions.ts b/packages/parameters/src/base/GetMultipleOptions.ts index fdcfff4277..26ab6f06ce 100644 --- a/packages/parameters/src/base/GetMultipleOptions.ts +++ b/packages/parameters/src/base/GetMultipleOptions.ts @@ -1,6 +1,6 @@ -import { GetOptions } from './GetOptions.js'; import type { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js'; import type { GetMultipleOptionsInterface } from '../types/BaseProvider.js'; +import { GetOptions } from './GetOptions.js'; /** * Options for the `getMultiple` method. @@ -15,9 +15,9 @@ class GetMultipleOptions public constructor( envVarsService: EnvironmentVariablesService, - options: GetMultipleOptionsInterface = {}, + options: GetMultipleOptionsInterface = {} ) { - super(options, envVarsService); + super(envVarsService, options); if (options.throwOnTransformError !== undefined) { this.throwOnTransformError = options.throwOnTransformError; diff --git a/packages/parameters/src/base/GetOptions.ts b/packages/parameters/src/base/GetOptions.ts index 360beabeb7..fb61ce578e 100644 --- a/packages/parameters/src/base/GetOptions.ts +++ b/packages/parameters/src/base/GetOptions.ts @@ -18,7 +18,7 @@ class GetOptions implements GetOptionsInterface { public constructor( envVarsService: EnvironmentVariablesService, - options: GetOptionsInterface = {}, + options: GetOptionsInterface = {} ) { Object.assign(this, options); diff --git a/packages/parameters/src/base/transformValue.ts b/packages/parameters/src/base/transformValue.ts index b69b165712..7e5f4db64c 100644 --- a/packages/parameters/src/base/transformValue.ts +++ b/packages/parameters/src/base/transformValue.ts @@ -1,5 +1,5 @@ -import type { JSONValue } from '@aws-lambda-powertools/commons/types'; import { isString } from '@aws-lambda-powertools/commons'; +import type { JSONValue } from '@aws-lambda-powertools/commons/types'; import { fromBase64 } from '@aws-lambda-powertools/commons/utils/base64'; import { TRANSFORM_METHOD_BINARY, @@ -58,17 +58,20 @@ const transformValue = ( try { // If the value is a Uint8Array, decode it to a string first - if (value instanceof Uint8Array) { - value = new TextDecoder('utf-8').decode(value); - } + const valueToTransform = + value instanceof Uint8Array + ? new TextDecoder('utf-8').decode(value) + : value; // If the transform is `json` or `auto` and the key ends with `.json`, parse the value as JSON if (isJsonTransform || isAutoJsonTransform) { - return JSON.parse(value) as JSONValue; + return JSON.parse(valueToTransform) as JSONValue; // If the transform is `binary` or `auto` and the key ends with `.binary`, decode the value from base64 } if (isBinaryTransform || isAutoBinaryTransform) { - return new TextDecoder('utf-8').decode(fromBase64(value, 'base64')); + return new TextDecoder('utf-8').decode( + fromBase64(valueToTransform, 'base64') + ); } } catch (error) { if (throwOnTransformError) diff --git a/packages/parameters/src/config/EnvironmentVariablesService.ts b/packages/parameters/src/config/EnvironmentVariablesService.ts index b5f41b91f7..2f8ce4011c 100644 --- a/packages/parameters/src/config/EnvironmentVariablesService.ts +++ b/packages/parameters/src/config/EnvironmentVariablesService.ts @@ -1,6 +1,6 @@ -import type { ConfigServiceInterface } from '../types/ConfigServiceInterface.js'; -import { DEFAULT_MAX_AGE_SECS } from '../constants.js'; import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons'; +import { DEFAULT_MAX_AGE_SECS } from '../constants.js'; +import type { ConfigServiceInterface } from '../types/ConfigServiceInterface.js'; class EnvironmentVariablesService extends CommonEnvironmentVariablesService diff --git a/packages/parameters/src/dynamodb/DynamoDBProvider.ts b/packages/parameters/src/dynamodb/DynamoDBProvider.ts index 566635a626..dc7922000b 100644 --- a/packages/parameters/src/dynamodb/DynamoDBProvider.ts +++ b/packages/parameters/src/dynamodb/DynamoDBProvider.ts @@ -1,23 +1,23 @@ -import { BaseProvider } from '../base/BaseProvider.js'; +import type { JSONValue } from '@aws-lambda-powertools/commons/types'; import { DynamoDBClient, + type DynamoDBPaginationConfiguration, GetItemCommand, paginateQuery, - type DynamoDBPaginationConfiguration, +} from '@aws-sdk/client-dynamodb'; +import type { + GetItemCommandInput, + QueryCommandInput, } from '@aws-sdk/client-dynamodb'; import { marshall, unmarshall } from '@aws-sdk/util-dynamodb'; +import { BaseProvider } from '../base/BaseProvider.js'; import type { - DynamoDBProviderOptions, - DynamoDBGetOptions, DynamoDBGetMultipleOptions, - DynamoDBGetOutput, DynamoDBGetMultipleOutput, + DynamoDBGetOptions, + DynamoDBGetOutput, + DynamoDBProviderOptions, } from '../types/DynamoDBProvider.js'; -import type { - GetItemCommandInput, - QueryCommandInput, -} from '@aws-sdk/client-dynamodb'; -import type { JSONValue } from '@aws-lambda-powertools/commons/types'; /** * ## Intro @@ -248,7 +248,9 @@ class DynamoDBProvider extends BaseProvider { */ public constructor(config: DynamoDBProviderOptions) { super({ + // biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: awsSdkV3Client: config.awsSdkV3Client, + // biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: clientConfig: config.clientConfig, proto: DynamoDBClient as new (config?: unknown) => DynamoDBClient, }); diff --git a/packages/parameters/src/secrets/SecretsProvider.ts b/packages/parameters/src/secrets/SecretsProvider.ts index 757d8f0591..0ad5122e06 100644 --- a/packages/parameters/src/secrets/SecretsProvider.ts +++ b/packages/parameters/src/secrets/SecretsProvider.ts @@ -1,13 +1,13 @@ -import { BaseProvider } from '../base/BaseProvider.js'; import { - SecretsManagerClient, GetSecretValueCommand, + SecretsManagerClient, } from '@aws-sdk/client-secrets-manager'; import type { GetSecretValueCommandInput } from '@aws-sdk/client-secrets-manager'; +import { BaseProvider } from '../base/BaseProvider.js'; import type { - SecretsProviderOptions, SecretsGetOptions, SecretsGetOutput, + SecretsProviderOptions, } from '../types/SecretsProvider.js'; /** diff --git a/packages/parameters/src/secrets/getSecret.ts b/packages/parameters/src/secrets/getSecret.ts index 1eb080cd91..2e2388bc50 100644 --- a/packages/parameters/src/secrets/getSecret.ts +++ b/packages/parameters/src/secrets/getSecret.ts @@ -1,9 +1,9 @@ import { DEFAULT_PROVIDERS } from '../base/DefaultProviders.js'; -import { SecretsProvider } from './SecretsProvider.js'; import type { SecretsGetOptions, SecretsGetOutput, } from '../types/SecretsProvider.js'; +import { SecretsProvider } from './SecretsProvider.js'; /** * ## Intro diff --git a/packages/parameters/src/ssm/SSMProvider.ts b/packages/parameters/src/ssm/SSMProvider.ts index 4c4377a1be..d1a1a56412 100644 --- a/packages/parameters/src/ssm/SSMProvider.ts +++ b/packages/parameters/src/ssm/SSMProvider.ts @@ -1,12 +1,9 @@ -import { BaseProvider } from '../base/BaseProvider.js'; -import { transformValue } from '../base/transformValue.js'; -import { GetParameterError } from '../errors.js'; -import { DEFAULT_MAX_AGE_SECS } from '../constants.js'; +import type { JSONValue } from '@aws-lambda-powertools/commons/types'; import { - SSMClient, GetParameterCommand, - paginateGetParametersByPath, GetParametersCommand, + SSMClient, + paginateGetParametersByPath, } from '@aws-sdk/client-ssm'; import type { GetParameterCommandInput, @@ -15,19 +12,22 @@ import type { GetParametersCommandOutput, SSMPaginationConfiguration, } from '@aws-sdk/client-ssm'; +import { BaseProvider } from '../base/BaseProvider.js'; +import { transformValue } from '../base/transformValue.js'; +import { DEFAULT_MAX_AGE_SECS } from '../constants.js'; +import { GetParameterError } from '../errors.js'; import type { - SSMProviderOptions, - SSMGetOptions, - SSMGetOutput, SSMGetMultipleOptions, SSMGetMultipleOutput, + SSMGetOptions, + SSMGetOutput, + SSMGetParametersByNameFromCacheOutputType, + SSMGetParametersByNameOptions, SSMGetParametersByNameOutput, SSMGetParametersByNameOutputInterface, - SSMGetParametersByNameOptions, + SSMProviderOptions, SSMSplitBatchAndDecryptParametersOutputType, - SSMGetParametersByNameFromCacheOutputType, } from '../types/SSMProvider.js'; -import type { JSONValue } from '@aws-lambda-powertools/commons/types'; /** * ## Intro diff --git a/packages/parameters/src/ssm/getParameter.ts b/packages/parameters/src/ssm/getParameter.ts index 0c0b0a330a..a3a00932da 100644 --- a/packages/parameters/src/ssm/getParameter.ts +++ b/packages/parameters/src/ssm/getParameter.ts @@ -1,6 +1,6 @@ import { DEFAULT_PROVIDERS } from '../base/DefaultProviders.js'; -import { SSMProvider } from './SSMProvider.js'; import type { SSMGetOptions, SSMGetOutput } from '../types/SSMProvider.js'; +import { SSMProvider } from './SSMProvider.js'; /** * ## Intro diff --git a/packages/parameters/src/ssm/getParameters.ts b/packages/parameters/src/ssm/getParameters.ts index e09420c04d..efcebf741a 100644 --- a/packages/parameters/src/ssm/getParameters.ts +++ b/packages/parameters/src/ssm/getParameters.ts @@ -1,9 +1,9 @@ import { DEFAULT_PROVIDERS } from '../base/DefaultProviders.js'; -import { SSMProvider } from './SSMProvider.js'; import type { SSMGetMultipleOptions, SSMGetMultipleOutput, } from '../types/SSMProvider.js'; +import { SSMProvider } from './SSMProvider.js'; /** * ## Intro diff --git a/packages/parameters/src/ssm/getParametersByName.ts b/packages/parameters/src/ssm/getParametersByName.ts index dce867387a..b740511746 100644 --- a/packages/parameters/src/ssm/getParametersByName.ts +++ b/packages/parameters/src/ssm/getParametersByName.ts @@ -1,9 +1,9 @@ import { DEFAULT_PROVIDERS } from '../base/DefaultProviders.js'; -import { SSMProvider } from './SSMProvider.js'; import type { SSMGetParametersByNameOptions, SSMGetParametersByNameOutput, } from '../types/SSMProvider.js'; +import { SSMProvider } from './SSMProvider.js'; /** * ## Intro diff --git a/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts index b0369735a9..831f2b1230 100644 --- a/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts @@ -1,10 +1,10 @@ +import { AppConfigDataClient } from '@aws-sdk/client-appconfigdata'; import type { Context } from 'aws-lambda'; -import { Transform } from '../../src/constants.js'; import { AppConfigProvider } from '../../src/appconfig/AppConfigProvider.js'; +import { Transform } from '../../src/constants.js'; import type { AppConfigGetOptions } from '../../src/types/AppConfigProvider.js'; -import { TinyLogger } from '../helpers/tinyLogger.js'; import { middleware } from '../helpers/sdkMiddlewareRequestCounter.js'; -import { AppConfigDataClient } from '@aws-sdk/client-appconfigdata'; +import { TinyLogger } from '../helpers/tinyLogger.js'; // We use a custom logger to log pure JSON objects to stdout const logger = new TinyLogger(); diff --git a/packages/parameters/tests/e2e/appConfigProvider.class.test.ts b/packages/parameters/tests/e2e/appConfigProvider.class.test.ts index 93d9c840d3..5007636c9d 100644 --- a/packages/parameters/tests/e2e/appConfigProvider.class.test.ts +++ b/packages/parameters/tests/e2e/appConfigProvider.class.test.ts @@ -3,14 +3,14 @@ * * @group e2e/parameters/appconfig/class */ +import { join } from 'node:path'; import { - invokeFunctionOnce, TestInvocationLogs, TestStack, + invokeFunctionOnce, } from '@aws-lambda-powertools/testing-utils'; import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { toBase64 } from '@smithy/util-base64'; -import { join } from 'node:path'; import { TestAppConfigWithProfiles } from '../helpers/resources.js'; import { RESOURCE_NAME_PREFIX, diff --git a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts index ca1980a16d..f50e2fee60 100644 --- a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts @@ -1,13 +1,13 @@ +import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; import type { Context } from 'aws-lambda'; import { Transform } from '../../src/constants.js'; import { DynamoDBProvider } from '../../src/dynamodb/DynamoDBProvider.js'; import type { - DynamoDBGetOptions, DynamoDBGetMultipleOptions, + DynamoDBGetOptions, } from '../../src/types/DynamoDBProvider.js'; -import { TinyLogger } from '../helpers/tinyLogger.js'; import { middleware } from '../helpers/sdkMiddlewareRequestCounter.js'; -import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; +import { TinyLogger } from '../helpers/tinyLogger.js'; // We use a custom logger to log pure JSON objects to stdout const logger = new TinyLogger(); diff --git a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts index bb1224064a..90b9f65eed 100644 --- a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts +++ b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts @@ -3,14 +3,14 @@ * * @group e2e/parameters/dynamodb/class */ +import { join } from 'node:path'; import { - invokeFunctionOnce, TestInvocationLogs, TestStack, + invokeFunctionOnce, } from '@aws-lambda-powertools/testing-utils'; import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { AttributeType } from 'aws-cdk-lib/aws-dynamodb'; -import { join } from 'node:path'; import { TestDynamodbTableWithItems } from '../helpers/resources.js'; import { RESOURCE_NAME_PREFIX, diff --git a/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts index 000babae2e..077219aecc 100644 --- a/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts @@ -1,10 +1,10 @@ -import type { Context } from 'aws-lambda'; -import { TinyLogger } from '../helpers/tinyLogger.js'; import { SecretsManagerClient } from '@aws-sdk/client-secrets-manager'; -import { middleware } from '../helpers/sdkMiddlewareRequestCounter.js'; +import type { Context } from 'aws-lambda'; import { Transform } from '../../src/constants.js'; import { SecretsProvider } from '../../src/secrets/SecretsProvider.js'; import type { SecretsGetOptions } from '../../src/types/SecretsProvider.js'; +import { middleware } from '../helpers/sdkMiddlewareRequestCounter.js'; +import { TinyLogger } from '../helpers/tinyLogger.js'; const logger = new TinyLogger(); const defaultProvider = new SecretsProvider(); diff --git a/packages/parameters/tests/e2e/secretsProvider.class.test.ts b/packages/parameters/tests/e2e/secretsProvider.class.test.ts index d807e53b19..6ba4bbd1db 100644 --- a/packages/parameters/tests/e2e/secretsProvider.class.test.ts +++ b/packages/parameters/tests/e2e/secretsProvider.class.test.ts @@ -3,14 +3,14 @@ * * @group e2e/parameters/secrets/class */ +import { join } from 'node:path'; import { - invokeFunctionOnce, TestInvocationLogs, TestStack, + invokeFunctionOnce, } from '@aws-lambda-powertools/testing-utils'; import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { SecretValue } from 'aws-cdk-lib'; -import { join } from 'node:path'; import { TestSecret } from '../helpers/resources.js'; import { RESOURCE_NAME_PREFIX, diff --git a/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts index 3c4a1aca99..01429bd9a2 100644 --- a/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts @@ -1,13 +1,13 @@ +import { SSMClient } from '@aws-sdk/client-ssm'; import type { Context } from 'aws-lambda'; import { SSMProvider } from '../../src/ssm/SSMProvider.js'; import type { - SSMGetOptions, SSMGetMultipleOptions, + SSMGetOptions, SSMGetParametersByNameOptions, } from '../../src/types/SSMProvider.js'; -import { TinyLogger } from '../helpers/tinyLogger.js'; import { middleware } from '../helpers/sdkMiddlewareRequestCounter.js'; -import { SSMClient } from '@aws-sdk/client-ssm'; +import { TinyLogger } from '../helpers/tinyLogger.js'; // We use a custom logger to log pure JSON objects to stdout const logger = new TinyLogger(); diff --git a/packages/parameters/tests/e2e/ssmProvider.class.test.ts b/packages/parameters/tests/e2e/ssmProvider.class.test.ts index 1b3aed047f..cea69b6df6 100644 --- a/packages/parameters/tests/e2e/ssmProvider.class.test.ts +++ b/packages/parameters/tests/e2e/ssmProvider.class.test.ts @@ -3,13 +3,13 @@ * * @group e2e/parameters/ssm/class */ +import { join } from 'node:path'; import { - invokeFunctionOnce, TestInvocationLogs, TestStack, + invokeFunctionOnce, } from '@aws-lambda-powertools/testing-utils'; import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; -import { join } from 'node:path'; import { TestSecureStringParameter, TestStringParameter, diff --git a/packages/parameters/tests/helpers/resources.ts b/packages/parameters/tests/helpers/resources.ts index ef1aecf4b3..44f664d60a 100644 --- a/packages/parameters/tests/helpers/resources.ts +++ b/packages/parameters/tests/helpers/resources.ts @@ -1,26 +1,27 @@ -import type { - ExtraTestProps, - TestDynamodbTableProps, -} from '@aws-lambda-powertools/testing-utils/types'; +import { randomUUID } from 'node:crypto'; import { + type TestStack, concatenateResourceName, getArchitectureKey, getRuntimeKey, - type TestStack, } from '@aws-lambda-powertools/testing-utils'; -import type { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; import { TestDynamodbTable } from '@aws-lambda-powertools/testing-utils/resources/dynamodb'; +import type { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda'; +import type { + ExtraTestProps, + TestDynamodbTableProps, +} from '@aws-lambda-powertools/testing-utils/types'; import { marshall } from '@aws-sdk/util-dynamodb'; import { CfnOutput, Duration, RemovalPolicy, Stack } from 'aws-cdk-lib'; import { Application, + type CfnHostedConfigurationVersion, ConfigurationContent, ConfigurationType, DeploymentStrategy, HostedConfiguration, type IEnvironment, RolloutStrategy, - type CfnHostedConfigurationVersion, } from 'aws-cdk-lib/aws-appconfig'; import { Effect, PolicyStatement } from 'aws-cdk-lib/aws-iam'; import type { SecretProps } from 'aws-cdk-lib/aws-secretsmanager'; @@ -33,7 +34,6 @@ import { PhysicalResourceId, } from 'aws-cdk-lib/custom-resources'; import { Construct } from 'constructs'; -import { randomUUID } from 'node:crypto'; /** * A secure string parameter that can be used in tests. @@ -291,7 +291,7 @@ class TestAppConfigWithProfiles extends Construct { config.node.defaultChild as CfnHostedConfigurationVersion ).applyRemovalPolicy(RemovalPolicy.DESTROY); this.profiles.push(config); - }; + } } /** @@ -345,7 +345,7 @@ class TestAppConfigWithProfiles extends Construct { resources: [appConfigConfigurationArn], }) ); - }; + } } } diff --git a/packages/parameters/tests/helpers/sdkMiddlewareRequestCounter.ts b/packages/parameters/tests/helpers/sdkMiddlewareRequestCounter.ts index be8885876f..4f0680dd6a 100644 --- a/packages/parameters/tests/helpers/sdkMiddlewareRequestCounter.ts +++ b/packages/parameters/tests/helpers/sdkMiddlewareRequestCounter.ts @@ -1,6 +1,6 @@ import type { - InitializeHandler, HandlerExecutionContext, + InitializeHandler, InitializeHandlerArguments, MiddlewareStack, } from '@aws-sdk/types'; diff --git a/packages/parameters/tests/tsconfig.json b/packages/parameters/tests/tsconfig.json index 5654b3e15f..45ba862a85 100644 --- a/packages/parameters/tests/tsconfig.json +++ b/packages/parameters/tests/tsconfig.json @@ -1,11 +1,8 @@ { - "extends": "../tsconfig.json", - "compilerOptions": { - "rootDir": "../", - "noEmit": true - }, - "include": [ - "../src/**/*", - "./**/*", - ] -} \ No newline at end of file + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": ["../src/**/*", "./**/*"] +} diff --git a/packages/parameters/tests/unit/AppConfigProvider.test.ts b/packages/parameters/tests/unit/AppConfigProvider.test.ts index 4be203f8e9..0a0ef35f24 100644 --- a/packages/parameters/tests/unit/AppConfigProvider.test.ts +++ b/packages/parameters/tests/unit/AppConfigProvider.test.ts @@ -3,9 +3,7 @@ * * @group unit/parameters/AppConfigProvider/class */ -import { AppConfigProvider } from '../../src/appconfig/index.js'; -import { ExpirableValue } from '../../src/base/ExpirableValue.js'; -import type { AppConfigProviderOptions } from '../../src/types/AppConfigProvider.js'; +import { addUserAgentMiddleware } from '@aws-lambda-powertools/commons'; import { AppConfigDataClient, GetLatestConfigurationCommand, @@ -13,7 +11,9 @@ import { } from '@aws-sdk/client-appconfigdata'; import { Uint8ArrayBlobAdapter } from '@smithy/util-stream'; import { mockClient } from 'aws-sdk-client-mock'; -import { addUserAgentMiddleware } from '@aws-lambda-powertools/commons'; +import { AppConfigProvider } from '../../src/appconfig/index.js'; +import { ExpirableValue } from '../../src/base/ExpirableValue.js'; +import type { AppConfigProviderOptions } from '../../src/types/AppConfigProvider.js'; import 'aws-sdk-client-mock-jest'; import { APPCONFIG_TOKEN_EXPIRATION } from '../../src/constants'; diff --git a/packages/parameters/tests/unit/BaseProvider.test.ts b/packages/parameters/tests/unit/BaseProvider.test.ts index 95fd97c879..977727eac5 100644 --- a/packages/parameters/tests/unit/BaseProvider.test.ts +++ b/packages/parameters/tests/unit/BaseProvider.test.ts @@ -3,21 +3,21 @@ * * @group unit/parameters/baseProvider/class */ +import { toBase64 } from '@smithy/util-base64'; +import { ExpirableValue } from '../../src/base/ExpirableValue.js'; import { BaseProvider, DEFAULT_PROVIDERS, - GetOptions, GetMultipleOptions, + GetOptions, } from '../../src/base/index.js'; -import { DEFAULT_MAX_AGE_SECS } from '../../src/constants.js'; import type { EnvironmentVariablesService } from '../../src/config/EnvironmentVariablesService.js'; -import { ExpirableValue } from '../../src/base/ExpirableValue.js'; +import { DEFAULT_MAX_AGE_SECS } from '../../src/constants.js'; import { GetParameterError, TransformParameterError, clearCaches, } from '../../src/index.js'; -import { toBase64 } from '@smithy/util-base64'; const encoder = new TextEncoder(); jest.mock('@aws-lambda-powertools/commons', () => ({ @@ -633,7 +633,7 @@ describe('Class: GetOptions', () => { getParametersMaxAge: jest.fn(), }; const options = new GetOptions( - envVarsService as unknown as EnvironmentVariablesService, + envVarsService as unknown as EnvironmentVariablesService ); // Assess @@ -648,7 +648,7 @@ describe('Class: GetMultipleOptions', () => { getParametersMaxAge: jest.fn(), }; const options = new GetMultipleOptions( - envVarsService as unknown as EnvironmentVariablesService, + envVarsService as unknown as EnvironmentVariablesService ); // Assess diff --git a/packages/parameters/tests/unit/DynamoDBProvider.test.ts b/packages/parameters/tests/unit/DynamoDBProvider.test.ts index 3e71f9481e..1c9cf6f892 100644 --- a/packages/parameters/tests/unit/DynamoDBProvider.test.ts +++ b/packages/parameters/tests/unit/DynamoDBProvider.test.ts @@ -3,7 +3,7 @@ * * @group unit/parameters/DynamoDBProvider/class */ -import { DynamoDBProvider } from '../../src/dynamodb/index.js'; +import { addUserAgentMiddleware } from '@aws-lambda-powertools/commons'; import { DynamoDBClient, GetItemCommand, @@ -13,10 +13,10 @@ import type { GetItemCommandInput, QueryCommandInput, } from '@aws-sdk/client-dynamodb'; -import type { DynamoDBProviderOptions } from '../../src/types/DynamoDBProvider.js'; import { marshall } from '@aws-sdk/util-dynamodb'; -import { addUserAgentMiddleware } from '@aws-lambda-powertools/commons'; import { mockClient } from 'aws-sdk-client-mock'; +import { DynamoDBProvider } from '../../src/dynamodb/index.js'; +import type { DynamoDBProviderOptions } from '../../src/types/DynamoDBProvider.js'; import 'aws-sdk-client-mock-jest'; jest.mock('@aws-lambda-powertools/commons', () => ({ ...jest.requireActual('@aws-lambda-powertools/commons'), diff --git a/packages/parameters/tests/unit/SSMProvider.test.ts b/packages/parameters/tests/unit/SSMProvider.test.ts index 3b75e72d54..ee9edc217a 100644 --- a/packages/parameters/tests/unit/SSMProvider.test.ts +++ b/packages/parameters/tests/unit/SSMProvider.test.ts @@ -3,26 +3,26 @@ * * @group unit/parameters/ssm/class */ -import { SSMProvider } from '../../src/ssm/index.js'; import { - SSMClient, GetParameterCommand, - GetParametersCommand, GetParametersByPathCommand, + GetParametersCommand, + SSMClient, } from '@aws-sdk/client-ssm'; import type { GetParametersCommandOutput } from '@aws-sdk/client-ssm'; import { mockClient } from 'aws-sdk-client-mock'; +import { SSMProvider } from '../../src/ssm/index.js'; import 'aws-sdk-client-mock-jest'; +import { addUserAgentMiddleware } from '@aws-lambda-powertools/commons'; +import { toBase64 } from '@smithy/util-base64'; +import { ExpirableValue } from '../../src/base/ExpirableValue.js'; import type { - SSMProviderOptions, SSMGetParametersByNameFromCacheOutputType, SSMGetParametersByNameOptions, - SSMSplitBatchAndDecryptParametersOutputType, SSMGetParametersByNameOutputInterface, + SSMProviderOptions, + SSMSplitBatchAndDecryptParametersOutputType, } from '../../src/types/SSMProvider.js'; -import { ExpirableValue } from '../../src/base/ExpirableValue.js'; -import { toBase64 } from '@smithy/util-base64'; -import { addUserAgentMiddleware } from '@aws-lambda-powertools/commons'; const encoder = new TextEncoder(); jest.mock('@aws-lambda-powertools/commons', () => ({ diff --git a/packages/parameters/tests/unit/SecretsProvider.test.ts b/packages/parameters/tests/unit/SecretsProvider.test.ts index 04f54adc26..3bc6a90b2e 100644 --- a/packages/parameters/tests/unit/SecretsProvider.test.ts +++ b/packages/parameters/tests/unit/SecretsProvider.test.ts @@ -3,14 +3,14 @@ * * @group unit/parameters/SecretsProvider/class */ -import { SecretsProvider } from '../../src/secrets/index.js'; import { - SecretsManagerClient, GetSecretValueCommand, + SecretsManagerClient, } from '@aws-sdk/client-secrets-manager'; import type { GetSecretValueCommandInput } from '@aws-sdk/client-secrets-manager'; -import type { SecretsProviderOptions } from '../../src/types/SecretsProvider.js'; import { mockClient } from 'aws-sdk-client-mock'; +import { SecretsProvider } from '../../src/secrets/index.js'; +import type { SecretsProviderOptions } from '../../src/types/SecretsProvider.js'; import 'aws-sdk-client-mock-jest'; import { addUserAgentMiddleware } from '@aws-lambda-powertools/commons'; diff --git a/packages/parameters/tests/unit/getAppConfig.test.ts b/packages/parameters/tests/unit/getAppConfig.test.ts index b012cd0c10..8204252ae0 100644 --- a/packages/parameters/tests/unit/getAppConfig.test.ts +++ b/packages/parameters/tests/unit/getAppConfig.test.ts @@ -3,19 +3,19 @@ * * @group unit/parameters/AppConfigProvider/getAppConfig/function */ -import { AppConfigProvider, getAppConfig } from '../../src/appconfig/index.js'; -import { DEFAULT_PROVIDERS } from '../../src/base/DefaultProviders.js'; -import { Transform } from '../../src/index.js'; import { AppConfigDataClient, - StartConfigurationSessionCommand, GetLatestConfigurationCommand, + StartConfigurationSessionCommand, } from '@aws-sdk/client-appconfigdata'; import { mockClient } from 'aws-sdk-client-mock'; +import { AppConfigProvider, getAppConfig } from '../../src/appconfig/index.js'; +import { DEFAULT_PROVIDERS } from '../../src/base/DefaultProviders.js'; +import { Transform } from '../../src/index.js'; import 'aws-sdk-client-mock-jest'; +import type { JSONValue } from '@aws-lambda-powertools/commons/types'; import { toBase64 } from '@smithy/util-base64'; import { Uint8ArrayBlobAdapter } from '@smithy/util-stream'; -import type { JSONValue } from '@aws-lambda-powertools/commons/types'; describe('Function: getAppConfig', () => { const client = mockClient(AppConfigDataClient); diff --git a/packages/parameters/tests/unit/getParameter.test.ts b/packages/parameters/tests/unit/getParameter.test.ts index e02b2b887e..9eed76dcec 100644 --- a/packages/parameters/tests/unit/getParameter.test.ts +++ b/packages/parameters/tests/unit/getParameter.test.ts @@ -3,10 +3,10 @@ * * @group unit/parameters/ssm/getParameter/function */ +import { GetParameterCommand, SSMClient } from '@aws-sdk/client-ssm'; +import { mockClient } from 'aws-sdk-client-mock'; import { DEFAULT_PROVIDERS } from '../../src/base/index.js'; import { SSMProvider, getParameter } from '../../src/ssm/index.js'; -import { SSMClient, GetParameterCommand } from '@aws-sdk/client-ssm'; -import { mockClient } from 'aws-sdk-client-mock'; import 'aws-sdk-client-mock-jest'; /** diff --git a/packages/parameters/tests/unit/getParameters.test.ts b/packages/parameters/tests/unit/getParameters.test.ts index e8b0d7b430..ec0e98f17c 100644 --- a/packages/parameters/tests/unit/getParameters.test.ts +++ b/packages/parameters/tests/unit/getParameters.test.ts @@ -3,10 +3,10 @@ * * @group unit/parameters/ssm/getParameters/function */ +import { GetParametersByPathCommand, SSMClient } from '@aws-sdk/client-ssm'; +import { mockClient } from 'aws-sdk-client-mock'; import { DEFAULT_PROVIDERS } from '../../src/base/index.js'; import { SSMProvider, getParameters } from '../../src/ssm/index.js'; -import { SSMClient, GetParametersByPathCommand } from '@aws-sdk/client-ssm'; -import { mockClient } from 'aws-sdk-client-mock'; import 'aws-sdk-client-mock-jest'; /** diff --git a/packages/parameters/tests/unit/getSecret.test.ts b/packages/parameters/tests/unit/getSecret.test.ts index da72fab483..c480d9ffbd 100644 --- a/packages/parameters/tests/unit/getSecret.test.ts +++ b/packages/parameters/tests/unit/getSecret.test.ts @@ -3,13 +3,13 @@ * * @group unit/parameters/SecretsProvider/getSecret/function */ -import { DEFAULT_PROVIDERS } from '../../src/base/index.js'; -import { SecretsProvider, getSecret } from '../../src/secrets/index.js'; import { - SecretsManagerClient, GetSecretValueCommand, + SecretsManagerClient, } from '@aws-sdk/client-secrets-manager'; import { mockClient } from 'aws-sdk-client-mock'; +import { DEFAULT_PROVIDERS } from '../../src/base/index.js'; +import { SecretsProvider, getSecret } from '../../src/secrets/index.js'; import 'aws-sdk-client-mock-jest'; const encoder = new TextEncoder(); diff --git a/packages/parameters/tsconfig.esm.json b/packages/parameters/tsconfig.esm.json index 123291b0cf..82486b64fa 100644 --- a/packages/parameters/tsconfig.esm.json +++ b/packages/parameters/tsconfig.esm.json @@ -6,7 +6,5 @@ "rootDir": "./src", "tsBuildInfoFile": ".tsbuildinfo/esm.json" }, - "include": [ - "./src/**/*" - ] -} \ No newline at end of file + "include": ["./src/**/*"] +} diff --git a/packages/parameters/tsconfig.json b/packages/parameters/tsconfig.json index 4836a14962..4923c4f6f4 100644 --- a/packages/parameters/tsconfig.json +++ b/packages/parameters/tsconfig.json @@ -1,11 +1,9 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib/cjs/", - "rootDir": "./src", - "tsBuildInfoFile": ".tsbuildinfo/cjs.json" - }, - "include": [ - "./src/**/*" - ], -} \ No newline at end of file + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./lib/cjs/", + "rootDir": "./src", + "tsBuildInfoFile": ".tsbuildinfo/cjs.json" + }, + "include": ["./src/**/*"] +} diff --git a/packages/parameters/typedoc.json b/packages/parameters/typedoc.json index 9a2e53d7f6..90daedca0b 100644 --- a/packages/parameters/typedoc.json +++ b/packages/parameters/typedoc.json @@ -1,7 +1,5 @@ { - "extends": [ - "../../typedoc.base.json" - ], + "extends": ["../../typedoc.base.json"], "entryPoints": [ "./src/appconfig/index.ts", "./src/types/AppConfigProvider.ts", @@ -13,7 +11,7 @@ "./src/types/SecretsProvider.ts", "./src/base/index.ts", "./src/errors.ts", - "./src/constants.ts", + "./src/constants.ts" ], "readme": "README.md" -} \ No newline at end of file +} From 8d9afd96a0a3568e5db0c68b185148466f50fba5 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Tue, 23 Jul 2024 14:04:28 +0200 Subject: [PATCH 3/4] chore: remove ignore --- packages/parameters/src/dynamodb/DynamoDBProvider.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/parameters/src/dynamodb/DynamoDBProvider.ts b/packages/parameters/src/dynamodb/DynamoDBProvider.ts index dc7922000b..42f3c4c854 100644 --- a/packages/parameters/src/dynamodb/DynamoDBProvider.ts +++ b/packages/parameters/src/dynamodb/DynamoDBProvider.ts @@ -248,11 +248,8 @@ class DynamoDBProvider extends BaseProvider { */ public constructor(config: DynamoDBProviderOptions) { super({ - // biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: - awsSdkV3Client: config.awsSdkV3Client, - // biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: - clientConfig: config.clientConfig, proto: DynamoDBClient as new (config?: unknown) => DynamoDBClient, + ...config, }); const { tableName, keyAttr, sortAttr, valueAttr } = config; From 4bbcace391cbc12483030a9d59b6dd74a6942735 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Tue, 23 Jul 2024 15:23:19 +0200 Subject: [PATCH 4/4] chore: address Sonar findings --- packages/parameters/src/types/BaseProvider.ts | 2 +- packages/parameters/tests/helpers/resources.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/parameters/src/types/BaseProvider.ts b/packages/parameters/src/types/BaseProvider.ts index 05e85dbe5c..8ad41705b5 100644 --- a/packages/parameters/src/types/BaseProvider.ts +++ b/packages/parameters/src/types/BaseProvider.ts @@ -74,7 +74,7 @@ interface BaseProviderInterface { getMultiple( path: string, options?: GetMultipleOptionsInterface - ): Promise; + ): Promise; clearCache?(): void; } diff --git a/packages/parameters/tests/helpers/resources.ts b/packages/parameters/tests/helpers/resources.ts index 44f664d60a..366e07da1e 100644 --- a/packages/parameters/tests/helpers/resources.ts +++ b/packages/parameters/tests/helpers/resources.ts @@ -26,8 +26,11 @@ import { import { Effect, PolicyStatement } from 'aws-cdk-lib/aws-iam'; import type { SecretProps } from 'aws-cdk-lib/aws-secretsmanager'; import { Secret } from 'aws-cdk-lib/aws-secretsmanager'; -import type { StringParameterProps } from 'aws-cdk-lib/aws-ssm'; -import { type IStringParameter, StringParameter } from 'aws-cdk-lib/aws-ssm'; +import { + type IStringParameter, + StringParameter, + type StringParameterProps, +} from 'aws-cdk-lib/aws-ssm'; import { AwsCustomResource, AwsCustomResourcePolicy,