Skip to content

Commit a563a96

Browse files
committed
chore(maintenance): migrate parameters utility to biome
1 parent f851c11 commit a563a96

38 files changed

+150
-168
lines changed

packages/parameters/package.json

+7-21
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json",
2121
"build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json",
2222
"build": "npm run build:esm & npm run build:cjs",
23-
"lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .",
24-
"lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .",
23+
"lint": "biome lint .",
24+
"lint:fix": "biome check --write .",
2525
"prepack": "node ../../.github/scripts/release_patch_package_json.js ."
2626
},
2727
"homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/parameters#readme",
@@ -89,26 +89,17 @@
8989
"lib/cjs/types/BaseProvider.d.ts",
9090
"lib/esm/types/BaseProvider.d.ts"
9191
],
92-
"base": [
93-
"lib/cjs/base/index.d.ts",
94-
"lib/esm/base/index.d.ts"
95-
],
92+
"base": ["lib/cjs/base/index.d.ts", "lib/esm/base/index.d.ts"],
9693
"ssm/types": [
9794
"lib/cjs/types/SSMProvider.d.ts",
9895
"lib/esm/types/SSMProvider.d.ts"
9996
],
100-
"ssm": [
101-
"lib/cjs/ssm/index.d.ts",
102-
"lib/esm/ssm/index.d.ts"
103-
],
97+
"ssm": ["lib/cjs/ssm/index.d.ts", "lib/esm/ssm/index.d.ts"],
10498
"secrets/types": [
10599
"lib/cjs/types/SecretsProvider.d.ts",
106100
"lib/esm/types/SecretsProvider.d.ts"
107101
],
108-
"secrets": [
109-
"lib/cjs/secrets/index.d.ts",
110-
"lib/esm/secrets/index.d.ts"
111-
],
102+
"secrets": ["lib/cjs/secrets/index.d.ts", "lib/esm/secrets/index.d.ts"],
112103
"dynamodb/types": [
113104
"./lib/cjs/types/DynamoDBProvider.d.ts",
114105
"./lib/esm/types/DynamoDBProvider.d.ts"
@@ -125,17 +116,12 @@
125116
"lib/cjs/appconfig/index.d.ts",
126117
"lib/esm/appconfig/index.d.ts"
127118
],
128-
"errors": [
129-
"lib/cjs/errors.d.ts",
130-
"lib/esm/errors.d.ts"
131-
]
119+
"errors": ["lib/cjs/errors.d.ts", "lib/esm/errors.d.ts"]
132120
}
133121
},
134122
"types": "./lib/cjs/index.d.ts",
135123
"main": "./lib/cjs/index.js",
136-
"files": [
137-
"lib"
138-
],
124+
"files": ["lib"],
139125
"repository": {
140126
"type": "git",
141127
"url": "git+https://github.com/aws-powertools/powertools-lambda-typescript.git"

packages/parameters/src/appconfig/AppConfigProvider.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { BaseProvider } from '../base/BaseProvider.js';
21
import {
32
AppConfigDataClient,
4-
StartConfigurationSessionCommand,
53
GetLatestConfigurationCommand,
4+
StartConfigurationSessionCommand,
65
} from '@aws-sdk/client-appconfigdata';
76
import type { StartConfigurationSessionCommandInput } from '@aws-sdk/client-appconfigdata';
7+
import { BaseProvider } from '../base/BaseProvider.js';
8+
import { APPCONFIG_TOKEN_EXPIRATION } from '../constants.js';
89
import type {
9-
AppConfigProviderOptions,
1010
AppConfigGetOptions,
1111
AppConfigGetOutput,
12+
AppConfigProviderOptions,
1213
} from '../types/AppConfigProvider.js';
13-
import { APPCONFIG_TOKEN_EXPIRATION } from '../constants.js';
1414

1515
/**
1616
* ## Intro

packages/parameters/src/appconfig/getAppConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { AppConfigProvider } from './AppConfigProvider.js';
21
import { DEFAULT_PROVIDERS } from '../base/index.js';
32
import type {
43
AppConfigGetOutput,
54
GetAppConfigOptions,
65
} from '../types/AppConfigProvider.js';
6+
import { AppConfigProvider } from './AppConfigProvider.js';
77

88
/**
99
* ## Intro

packages/parameters/src/base/BaseProvider.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import {
55
isSdkClient,
66
isString,
77
} from '@aws-lambda-powertools/commons';
8-
import { GetOptions } from './GetOptions.js';
9-
import { GetMultipleOptions } from './GetMultipleOptions.js';
10-
import { ExpirableValue } from './ExpirableValue.js';
11-
import { GetParameterError, TransformParameterError } from '../errors.js';
128
import { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js';
13-
import { transformValue } from './transformValue.js';
9+
import { GetParameterError, TransformParameterError } from '../errors.js';
1410
import type {
1511
BaseProviderInterface,
1612
GetMultipleOptionsInterface,
1713
GetOptionsInterface,
1814
} from '../types/BaseProvider.js';
15+
import { ExpirableValue } from './ExpirableValue.js';
16+
import { GetMultipleOptions } from './GetMultipleOptions.js';
17+
import { GetOptions } from './GetOptions.js';
18+
import { transformValue } from './transformValue.js';
1919

2020
/**
2121
* Base class for all providers.

packages/parameters/src/base/GetMultipleOptions.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { GetOptions } from './GetOptions.js';
21
import type { EnvironmentVariablesService } from '../config/EnvironmentVariablesService.js';
32
import type { GetMultipleOptionsInterface } from '../types/BaseProvider.js';
3+
import { GetOptions } from './GetOptions.js';
44

55
/**
66
* Options for the `getMultiple` method.
@@ -15,9 +15,9 @@ class GetMultipleOptions
1515

1616
public constructor(
1717
envVarsService: EnvironmentVariablesService,
18-
options: GetMultipleOptionsInterface = {},
18+
options: GetMultipleOptionsInterface = {}
1919
) {
20-
super(options, envVarsService);
20+
super(envVarsService, options);
2121

2222
if (options.throwOnTransformError !== undefined) {
2323
this.throwOnTransformError = options.throwOnTransformError;

packages/parameters/src/base/GetOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class GetOptions implements GetOptionsInterface {
1818

1919
public constructor(
2020
envVarsService: EnvironmentVariablesService,
21-
options: GetOptionsInterface = {},
21+
options: GetOptionsInterface = {}
2222
) {
2323
Object.assign(this, options);
2424

packages/parameters/src/base/transformValue.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { JSONValue } from '@aws-lambda-powertools/commons/types';
21
import { isString } from '@aws-lambda-powertools/commons';
2+
import type { JSONValue } from '@aws-lambda-powertools/commons/types';
33
import { fromBase64 } from '@aws-lambda-powertools/commons/utils/base64';
44
import {
55
TRANSFORM_METHOD_BINARY,
@@ -58,17 +58,20 @@ const transformValue = (
5858

5959
try {
6060
// If the value is a Uint8Array, decode it to a string first
61-
if (value instanceof Uint8Array) {
62-
value = new TextDecoder('utf-8').decode(value);
63-
}
61+
const valueToTransform =
62+
value instanceof Uint8Array
63+
? new TextDecoder('utf-8').decode(value)
64+
: value;
6465

6566
// If the transform is `json` or `auto` and the key ends with `.json`, parse the value as JSON
6667
if (isJsonTransform || isAutoJsonTransform) {
67-
return JSON.parse(value) as JSONValue;
68+
return JSON.parse(valueToTransform) as JSONValue;
6869
// If the transform is `binary` or `auto` and the key ends with `.binary`, decode the value from base64
6970
}
7071
if (isBinaryTransform || isAutoBinaryTransform) {
71-
return new TextDecoder('utf-8').decode(fromBase64(value, 'base64'));
72+
return new TextDecoder('utf-8').decode(
73+
fromBase64(valueToTransform, 'base64')
74+
);
7275
}
7376
} catch (error) {
7477
if (throwOnTransformError)

packages/parameters/src/config/EnvironmentVariablesService.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { ConfigServiceInterface } from '../types/ConfigServiceInterface.js';
2-
import { DEFAULT_MAX_AGE_SECS } from '../constants.js';
31
import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons';
2+
import { DEFAULT_MAX_AGE_SECS } from '../constants.js';
3+
import type { ConfigServiceInterface } from '../types/ConfigServiceInterface.js';
44

55
class EnvironmentVariablesService
66
extends CommonEnvironmentVariablesService

packages/parameters/src/dynamodb/DynamoDBProvider.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import { BaseProvider } from '../base/BaseProvider.js';
1+
import type { JSONValue } from '@aws-lambda-powertools/commons/types';
22
import {
33
DynamoDBClient,
4+
type DynamoDBPaginationConfiguration,
45
GetItemCommand,
56
paginateQuery,
6-
type DynamoDBPaginationConfiguration,
7+
} from '@aws-sdk/client-dynamodb';
8+
import type {
9+
GetItemCommandInput,
10+
QueryCommandInput,
711
} from '@aws-sdk/client-dynamodb';
812
import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
13+
import { BaseProvider } from '../base/BaseProvider.js';
914
import type {
10-
DynamoDBProviderOptions,
11-
DynamoDBGetOptions,
1215
DynamoDBGetMultipleOptions,
13-
DynamoDBGetOutput,
1416
DynamoDBGetMultipleOutput,
17+
DynamoDBGetOptions,
18+
DynamoDBGetOutput,
19+
DynamoDBProviderOptions,
1520
} from '../types/DynamoDBProvider.js';
16-
import type {
17-
GetItemCommandInput,
18-
QueryCommandInput,
19-
} from '@aws-sdk/client-dynamodb';
20-
import type { JSONValue } from '@aws-lambda-powertools/commons/types';
2121

2222
/**
2323
* ## Intro
@@ -248,7 +248,9 @@ class DynamoDBProvider extends BaseProvider {
248248
*/
249249
public constructor(config: DynamoDBProviderOptions) {
250250
super({
251+
// biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: <explanation>
251252
awsSdkV3Client: config.awsSdkV3Client,
253+
// biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: <explanation>
252254
clientConfig: config.clientConfig,
253255
proto: DynamoDBClient as new (config?: unknown) => DynamoDBClient,
254256
});

packages/parameters/src/secrets/SecretsProvider.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { BaseProvider } from '../base/BaseProvider.js';
21
import {
3-
SecretsManagerClient,
42
GetSecretValueCommand,
3+
SecretsManagerClient,
54
} from '@aws-sdk/client-secrets-manager';
65
import type { GetSecretValueCommandInput } from '@aws-sdk/client-secrets-manager';
6+
import { BaseProvider } from '../base/BaseProvider.js';
77
import type {
8-
SecretsProviderOptions,
98
SecretsGetOptions,
109
SecretsGetOutput,
10+
SecretsProviderOptions,
1111
} from '../types/SecretsProvider.js';
1212

1313
/**

packages/parameters/src/secrets/getSecret.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { DEFAULT_PROVIDERS } from '../base/DefaultProviders.js';
2-
import { SecretsProvider } from './SecretsProvider.js';
32
import type {
43
SecretsGetOptions,
54
SecretsGetOutput,
65
} from '../types/SecretsProvider.js';
6+
import { SecretsProvider } from './SecretsProvider.js';
77

88
/**
99
* ## Intro

packages/parameters/src/ssm/SSMProvider.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import { BaseProvider } from '../base/BaseProvider.js';
2-
import { transformValue } from '../base/transformValue.js';
3-
import { GetParameterError } from '../errors.js';
4-
import { DEFAULT_MAX_AGE_SECS } from '../constants.js';
1+
import type { JSONValue } from '@aws-lambda-powertools/commons/types';
52
import {
6-
SSMClient,
73
GetParameterCommand,
8-
paginateGetParametersByPath,
94
GetParametersCommand,
5+
SSMClient,
6+
paginateGetParametersByPath,
107
} from '@aws-sdk/client-ssm';
118
import type {
129
GetParameterCommandInput,
@@ -15,19 +12,22 @@ import type {
1512
GetParametersCommandOutput,
1613
SSMPaginationConfiguration,
1714
} from '@aws-sdk/client-ssm';
15+
import { BaseProvider } from '../base/BaseProvider.js';
16+
import { transformValue } from '../base/transformValue.js';
17+
import { DEFAULT_MAX_AGE_SECS } from '../constants.js';
18+
import { GetParameterError } from '../errors.js';
1819
import type {
19-
SSMProviderOptions,
20-
SSMGetOptions,
21-
SSMGetOutput,
2220
SSMGetMultipleOptions,
2321
SSMGetMultipleOutput,
22+
SSMGetOptions,
23+
SSMGetOutput,
24+
SSMGetParametersByNameFromCacheOutputType,
25+
SSMGetParametersByNameOptions,
2426
SSMGetParametersByNameOutput,
2527
SSMGetParametersByNameOutputInterface,
26-
SSMGetParametersByNameOptions,
28+
SSMProviderOptions,
2729
SSMSplitBatchAndDecryptParametersOutputType,
28-
SSMGetParametersByNameFromCacheOutputType,
2930
} from '../types/SSMProvider.js';
30-
import type { JSONValue } from '@aws-lambda-powertools/commons/types';
3131

3232
/**
3333
* ## Intro

packages/parameters/src/ssm/getParameter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DEFAULT_PROVIDERS } from '../base/DefaultProviders.js';
2-
import { SSMProvider } from './SSMProvider.js';
32
import type { SSMGetOptions, SSMGetOutput } from '../types/SSMProvider.js';
3+
import { SSMProvider } from './SSMProvider.js';
44

55
/**
66
* ## Intro

packages/parameters/src/ssm/getParameters.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { DEFAULT_PROVIDERS } from '../base/DefaultProviders.js';
2-
import { SSMProvider } from './SSMProvider.js';
32
import type {
43
SSMGetMultipleOptions,
54
SSMGetMultipleOutput,
65
} from '../types/SSMProvider.js';
6+
import { SSMProvider } from './SSMProvider.js';
77

88
/**
99
* ## Intro

packages/parameters/src/ssm/getParametersByName.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { DEFAULT_PROVIDERS } from '../base/DefaultProviders.js';
2-
import { SSMProvider } from './SSMProvider.js';
32
import type {
43
SSMGetParametersByNameOptions,
54
SSMGetParametersByNameOutput,
65
} from '../types/SSMProvider.js';
6+
import { SSMProvider } from './SSMProvider.js';
77

88
/**
99
* ## Intro

packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { AppConfigDataClient } from '@aws-sdk/client-appconfigdata';
12
import type { Context } from 'aws-lambda';
2-
import { Transform } from '../../src/constants.js';
33
import { AppConfigProvider } from '../../src/appconfig/AppConfigProvider.js';
4+
import { Transform } from '../../src/constants.js';
45
import type { AppConfigGetOptions } from '../../src/types/AppConfigProvider.js';
5-
import { TinyLogger } from '../helpers/tinyLogger.js';
66
import { middleware } from '../helpers/sdkMiddlewareRequestCounter.js';
7-
import { AppConfigDataClient } from '@aws-sdk/client-appconfigdata';
7+
import { TinyLogger } from '../helpers/tinyLogger.js';
88

99
// We use a custom logger to log pure JSON objects to stdout
1010
const logger = new TinyLogger();

packages/parameters/tests/e2e/appConfigProvider.class.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
*
44
* @group e2e/parameters/appconfig/class
55
*/
6+
import { join } from 'node:path';
67
import {
7-
invokeFunctionOnce,
88
TestInvocationLogs,
99
TestStack,
10+
invokeFunctionOnce,
1011
} from '@aws-lambda-powertools/testing-utils';
1112
import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda';
1213
import { toBase64 } from '@smithy/util-base64';
13-
import { join } from 'node:path';
1414
import { TestAppConfigWithProfiles } from '../helpers/resources.js';
1515
import {
1616
RESOURCE_NAME_PREFIX,

packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
12
import type { Context } from 'aws-lambda';
23
import { Transform } from '../../src/constants.js';
34
import { DynamoDBProvider } from '../../src/dynamodb/DynamoDBProvider.js';
45
import type {
5-
DynamoDBGetOptions,
66
DynamoDBGetMultipleOptions,
7+
DynamoDBGetOptions,
78
} from '../../src/types/DynamoDBProvider.js';
8-
import { TinyLogger } from '../helpers/tinyLogger.js';
99
import { middleware } from '../helpers/sdkMiddlewareRequestCounter.js';
10-
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
10+
import { TinyLogger } from '../helpers/tinyLogger.js';
1111

1212
// We use a custom logger to log pure JSON objects to stdout
1313
const logger = new TinyLogger();

packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
*
44
* @group e2e/parameters/dynamodb/class
55
*/
6+
import { join } from 'node:path';
67
import {
7-
invokeFunctionOnce,
88
TestInvocationLogs,
99
TestStack,
10+
invokeFunctionOnce,
1011
} from '@aws-lambda-powertools/testing-utils';
1112
import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda';
1213
import { AttributeType } from 'aws-cdk-lib/aws-dynamodb';
13-
import { join } from 'node:path';
1414
import { TestDynamodbTableWithItems } from '../helpers/resources.js';
1515
import {
1616
RESOURCE_NAME_PREFIX,

0 commit comments

Comments
 (0)