Skip to content

Commit 7f09718

Browse files
committed
style(parser): apply stricter linting & improve docstrings
1 parent 7e9bb9c commit 7f09718

23 files changed

+480
-517
lines changed

packages/parameters/src/appconfig/AppConfigProvider.ts

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { getServiceName } from '@aws-lambda-powertools/commons/utils/env';
2-
import type { StartConfigurationSessionCommandInput } from '@aws-sdk/client-appconfigdata';
2+
import type {
3+
AppConfigDataClientConfig,
4+
StartConfigurationSessionCommandInput,
5+
} from '@aws-sdk/client-appconfigdata';
36
import {
47
AppConfigDataClient,
58
GetLatestConfigurationCommand,
@@ -14,15 +17,12 @@ import type {
1417
} from '../types/AppConfigProvider.js';
1518

1619
/**
17-
* ## Intro
18-
* The Parameters utility provides an AppConfigProvider that allows to retrieve configuration profiles from AWS AppConfig.
19-
*
20-
* ## Getting started
20+
* The Parameters utility provides an `AppConfigProvider` that allows to retrieve configuration profiles from AWS AppConfig.
2121
*
2222
* This utility supports AWS SDK v3 for JavaScript only (`@aws-sdk/client-appconfigdata`). This allows the utility to be modular, and you to install only
2323
* the SDK packages you need and keep your bundle size small.
2424
*
25-
* ## Basic usage
25+
* **Basic usage**
2626
*
2727
* @example
2828
* ```typescript
@@ -41,9 +41,7 @@ import type {
4141
* ```
4242
* If you want to retrieve configs without customizing the provider, you can use the {@link getAppConfig} function instead.
4343
*
44-
* ## Advanced usage
45-
*
46-
* ### Caching
44+
* **Caching**
4745
*
4846
* By default, the provider will cache parameters retrieved in-memory for 5 seconds.
4947
* You can adjust how long values should be kept in cache by using the `maxAge` parameter.
@@ -82,7 +80,7 @@ import type {
8280
* };
8381
* ```
8482
*
85-
* ### Transformations
83+
* **Transformations**
8684
*
8785
* For configurations stored as freeform JSON, Freature Flag, you can use the transform argument for deserialization. This will return a JavaScript object instead of a string.
8886
*
@@ -118,7 +116,7 @@ import type {
118116
* };
119117
* ```
120118
*
121-
* ### Extra SDK options
119+
* **Extra SDK options**
122120
*
123121
* When retrieving a configuration profile, you can pass extra options to the AWS SDK v3 for JavaScript client by using the `sdkOptions` parameter.
124122
*
@@ -144,7 +142,7 @@ import type {
144142
*
145143
* This object accepts the same options as the [AWS SDK v3 for JavaScript AppConfigData client](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-appconfigdata/interfaces/startconfigurationsessioncommandinput.html).
146144
*
147-
* ### Customize AWS SDK v3 for JavaScript client
145+
* **Customize AWS SDK v3 for JavaScript client**
148146
*
149147
* By default, the provider will create a new AppConfigData client using the default configuration.
150148
*
@@ -193,9 +191,14 @@ class AppConfigProvider extends BaseProvider {
193191
private readonly environment: string;
194192

195193
/**
196-
* It initializes the AppConfigProvider class.
197-
* *
198-
* @param {AppConfigProviderOptions} options - The configuration object.
194+
* initializes an `AppConfigProvider` class instance.
195+
*
196+
* @param options - The configuration object.
197+
* @param options.environment - The environment ID or the environment name.
198+
* @param options.application - Optional application ID or the application name.
199+
* @param options.clientConfig - Optional configuration to pass during client initialization, e.g. AWS region. Mutually exclusive with `awsSdkV3Client`. Accepts the same configuration object as the AWS SDK v3 client ({@link AppConfigDataClientConfig | `AppConfigDataClientConfig`}).
200+
* @param options.awsSdkV3Client - Optional ({@link AppConfigDataClient | `AppConfigDataClient`}) instance to pass during `AppConfigProvider` class instantiation. Mutually exclusive with `clientConfig`.
201+
*
199202
*/
200203
public constructor(options: AppConfigProviderOptions) {
201204
super({
@@ -235,19 +238,16 @@ class AppConfigProvider extends BaseProvider {
235238
* };
236239
* ```
237240
*
238-
* You can customize the retrieval of the configuration profile by passing options to the function:
239-
* * `maxAge` - The maximum age of the value in cache before fetching a new one (in seconds) (default: 5)
240-
* * `forceFetch` - Whether to always fetch a new value from the store regardless if already available in cache
241-
* * `transform` - Whether to transform the value before returning it. Supported values: `json`, `binary`
242-
* * `sdkOptions` - Extra options to pass to the AWS SDK v3 for JavaScript client
243-
*
244-
* For usage examples check {@link AppConfigProvider}.
245-
*
246-
* @param {string} name - The name of the configuration profile or its ID
247-
* @param {AppConfigGetOptions} options - Options to configure the provider
248241
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/features/parameters/
242+
*
243+
* @param name - The name of the configuration profile or its ID
244+
* @param options - Options to configure the provider
245+
* @param options.maxAge - Maximum age of the value in the cache, in seconds.
246+
* @param options.forceFetch - Force fetch the value from the parameter store, ignoring the cache.
247+
* @param options.sdkOptions - Additional options to pass to the AWS SDK v3 client. Supports all options from {@link StartConfigurationSessionCommandInput | `StartConfigurationSessionCommandInput`} except `ApplicationIdentifier`, `EnvironmentIdentifier`, and `ConfigurationProfileIdentifier`.
248+
* @param options.transform - Optional transform to be applied, can be 'json' or 'binary'.
249249
*/
250-
public async get<
250+
public get<
251251
ExplicitUserProvidedType = undefined,
252252
InferredFromOptionsType extends
253253
| AppConfigGetOptions
@@ -287,8 +287,12 @@ class AppConfigProvider extends BaseProvider {
287287
* polls the configuration multiple times, we return the most recent value by returning the cached
288288
* one if an empty response is returned by AppConfig.
289289
*
290-
* @param {string} name - Name of the configuration or its ID
291-
* @param {AppConfigGetOptions} options - SDK options to propagate to `StartConfigurationSession` API call
290+
* @param name - Name of the configuration or its ID
291+
* @param options - SDK options to propagate to `StartConfigurationSession` API call
292+
* @param options.maxAge - Maximum age of the value in the cache, in seconds.
293+
* @param options.forceFetch - Force fetch the value from the parameter store, ignoring the cache.
294+
* @param options.sdkOptions - Additional options to pass to the AWS SDK v3 client. Supports all options from {@link StartConfigurationSessionCommandInput | `StartConfigurationSessionCommandInput`} except `ApplicationIdentifier`, `EnvironmentIdentifier`, and `ConfigurationProfileIdentifier`.
295+
* @param options.transform - Optional transform to be applied, can be 'json' or 'binary'.
292296
*/
293297
protected async _get(
294298
name: string,
@@ -339,7 +343,7 @@ class AppConfigProvider extends BaseProvider {
339343
/** When the response is not empty, stash the result locally before returning
340344
* See AppConfig docs:
341345
* {@link https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-retrieving-the-configuration.html}
342-
**/
346+
*/
343347
if (
344348
response.Configuration !== undefined &&
345349
response.Configuration?.length > 0
@@ -358,7 +362,7 @@ class AppConfigProvider extends BaseProvider {
358362
*
359363
* @throws Not Implemented Error.
360364
*/
361-
protected async _getMultiple(
365+
protected _getMultiple(
362366
_path: string,
363367
_sdkOptions?: unknown
364368
): Promise<Record<string, unknown> | undefined> {

packages/parameters/src/dynamodb/DynamoDBProvider.ts

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@ import type {
1818
} from '../types/DynamoDBProvider.js';
1919

2020
/**
21-
* ## Intro
22-
* The Parameters utility provides a DynamoDBProvider that allows to retrieve values from Amazon DynamoDB.
23-
*
24-
* ## Getting started
21+
* The Parameters utility provides a `DynamoDBProvider` that allows to retrieve values from Amazon DynamoDB.
2522
*
2623
* This utility supports AWS SDK v3 for JavaScript only (`@aws-sdk/client-dynamodb` and `@aws-sdk/util-dynamodb`). This allows the utility to be modular, and you to install only
2724
* the SDK packages you need and keep your bundle size small.
2825
*
29-
* ## Basic usage
26+
* **Basic usage**
3027
*
3128
* Retrieve a value from DynamoDB:
3229
*
@@ -60,9 +57,7 @@ import type {
6057
* };
6158
* ```
6259
*
63-
* ## Advanced usage
64-
*
65-
* ### Caching
60+
* **Caching**
6661
*
6762
* By default, the provider will cache parameters retrieved in-memory for 5 seconds.
6863
* You can adjust how long values should be kept in cache by using the `maxAge` parameter.
@@ -101,7 +96,7 @@ import type {
10196
* };
10297
* ```
10398
*
104-
* ### Transformations
99+
* **Transformations**
105100
*
106101
* For values stored as JSON you can use the transform argument for deserialization. This will return a JavaScript object instead of a string.
107102
*
@@ -157,7 +152,7 @@ import type {
157152
* };
158153
* ```
159154
*
160-
* ### Custom key names
155+
* **Custom key names**
161156
*
162157
* By default, the provider will use the following key names: `id` for the partition key, `sk` for the sort key, and `value` for the value.
163158
* You can adjust the key names by using the `keyAttr`, `sortAttr`, and `valueAttr` parameters.
@@ -174,7 +169,7 @@ import type {
174169
* });
175170
* ```
176171
*
177-
* ### Extra SDK options
172+
* **Extra SDK options**
178173
*
179174
* When retrieving values, you can pass extra options to the AWS SDK v3 for JavaScript client by using the `sdkOptions` parameter.
180175
*
@@ -198,7 +193,7 @@ import type {
198193
*
199194
* The objects accept the same options as respectively the [AWS SDK v3 for JavaScript PutItem command](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dynamodb/classes/putitemcommand.html) and the [AWS SDK v3 for JavaScript DynamoDB client Query command](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dynamodb/classes/querycommand.html).
200195
*
201-
* ### Customize AWS SDK v3 for JavaScript client
196+
* **Customize AWS SDK v3 for JavaScript client**
202197
*
203198
* By default, the provider will create a new DynamoDB client using the default configuration.
204199
*
@@ -240,9 +235,15 @@ class DynamoDBProvider extends BaseProvider {
240235
protected valueAttr = 'value';
241236

242237
/**
243-
* It initializes the DynamoDBProvider class.
238+
* Initialize a DynamoDBProvider class instance.
244239
*
245-
* @param {DynamoDBProviderOptions} config - The configuration object.
240+
* @param config - The configuration object.
241+
* @param config.tableName - The DynamoDB table name.
242+
* @param config.keyAttr - Optional DynamoDB table key attribute name. Defaults to 'id'.
243+
* @param config.sortAttr - Optional DynamoDB table sort attribute name. Defaults to 'sk'.
244+
* @param config.valueAttr - Optional DynamoDB table value attribute name. Defaults to 'value'.
245+
* @param config.clientConfig - Optional configuration to pass during client initialization, e.g. AWS region. Mutually exclusive with `awsSdkV3Client`, accepts the same options as the AWS SDK v3 client ({@link DynamoDBClient | `DynamoDBClient`}).
246+
* @param config.awsSdkV3Client - Optional AWS SDK v3 client to pass during DynamoDBProvider class instantiation. Mutually exclusive with `clientConfig`, should be an instance of {@link DynamoDBClient | `DynamoDBClient`}.
246247
*/
247248
public constructor(config: DynamoDBProviderOptions) {
248249
super({
@@ -276,19 +277,16 @@ class DynamoDBProvider extends BaseProvider {
276277
* };
277278
* ```
278279
*
279-
* You can customize the retrieval of the value by passing options to the function:
280-
* * `maxAge` - The maximum age of the value in cache before fetching a new one (in seconds) (default: 5)
281-
* * `forceFetch` - Whether to always fetch a new value from the store regardless if already available in cache
282-
* * `transform` - Whether to transform the value before returning it. Supported values: `json`, `binary`
283-
* * `sdkOptions` - Extra options to pass to the AWS SDK v3 for JavaScript client
284-
*
285-
* For usage examples check {@link DynamoDBProvider}.
286-
*
287-
* @param {string} name - The name of the value to retrieve (i.e. the partition key)
288-
* @param {DynamoDBGetOptionsInterface} options - Options to configure the provider
289280
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/features/parameters/
281+
*
282+
* @param name - The name of the value to retrieve (i.e. the partition key)
283+
* @param options - Options to configure the provider
284+
* @param options.maxAge - Maximum age of the value in the cache, in seconds.
285+
* @param options.forceFetch - Force fetch the value from the parameter store, ignoring the cache.
286+
* @param options.sdkOptions - Additional options to pass to the AWS SDK v3 client, supports all options from {@link GetItemCommandInput | `GetItemCommandInput`} except `Key`, `TableName`, and `ProjectionExpression`.
287+
* @param options.transform - Transform to be applied, can be 'json' or 'binary'.
290288
*/
291-
public async get<
289+
public get<
292290
ExplicitUserProvidedType = undefined,
293291
InferredFromOptionsType extends
294292
| DynamoDBGetOptions
@@ -323,20 +321,17 @@ class DynamoDBProvider extends BaseProvider {
323321
* };
324322
* ```
325323
*
326-
* You can customize the retrieval of the values by passing options to the function:
327-
* * `maxAge` - The maximum age of the value in cache before fetching a new one (in seconds) (default: 5)
328-
* * `forceFetch` - Whether to always fetch a new value from the store regardless if already available in cache
329-
* * `transform` - Whether to transform the value before returning it. Supported values: `json`, `binary`
330-
* * `sdkOptions` - Extra options to pass to the AWS SDK v3 for JavaScript client
331-
* * `throwOnTransformError` - Whether to throw an error if the transform fails (default: `true`)
332-
*
333-
* For usage examples check {@link DynamoDBProvider}.
334-
*
335-
* @param {string} path - The path of the values to retrieve (i.e. the partition key)
336-
* @param {DynamoDBGetMultipleOptions} options - Options to configure the provider
337324
* @see https://docs.powertools.aws.dev/lambda/typescript/latest/features/parameters/
325+
*
326+
* @param path - The path of the values to retrieve (i.e. the partition key)
327+
* @param options - Options to configure the provider
328+
* @param options.maxAge - Maximum age of the value in the cache, in seconds.
329+
* @param options.forceFetch - Force fetch the value from the parameter store, ignoring the cache.
330+
* @param options.sdkOptions - Additional options to pass to the AWS SDK v3 client, supports all options from {@link QueryCommandInput | `QueryCommandInput`} except `TableName` and `KeyConditionExpression`.
331+
* @param options.transform - Transform to be applied, can be 'json' or 'binary'.
332+
* @param options.throwOnTransformError - Whether to throw an error if the transform fails (default: `true`)
338333
*/
339-
public async getMultiple<
334+
public getMultiple<
340335
ExplicitUserProvidedType = undefined,
341336
InferredFromOptionsType extends
342337
| DynamoDBGetMultipleOptions
@@ -363,8 +358,12 @@ class DynamoDBProvider extends BaseProvider {
363358
/**
364359
* Retrieve an item from Amazon DynamoDB.
365360
*
366-
* @param {string} name - Key of the item to retrieve (i.e. the partition key)
367-
* @param {DynamoDBGetOptions} options - Options to customize the retrieval
361+
* @param name - Key of the item to retrieve (i.e. the partition key)
362+
* @param options - Options to customize the retrieval
363+
* @param options.maxAge - Maximum age of the value in the cache, in seconds.
364+
* @param options.sdkOptions - Additional options to pass to the AWS SDK v3 client, supports all options from {@link GetItemCommandInput | `GetItemCommandInput`} except `Key`, `TableName`, and `ProjectionExpression`.
365+
* @param params.forceFetch - Force fetch the value from the parameter store, ignoring the cache.
366+
* @param options.transform - Transform to be applied, can be 'json' or 'binary'.
368367
*/
369368
protected async _get(
370369
name: string,
@@ -387,8 +386,13 @@ class DynamoDBProvider extends BaseProvider {
387386
/**
388387
* Retrieve multiple items from Amazon DynamoDB.
389388
*
390-
* @param {string} path - The path of the values to retrieve (i.e. the partition key)
391-
* @param {DynamoDBGetMultipleOptions} options - Options to customize the retrieval
389+
* @param path - The path of the values to retrieve (i.e. the partition key)
390+
* @param options - Options to customize the retrieval
391+
* @param options.maxAge - Maximum age of the value in the cache, in seconds.
392+
* @param options.forceFetch - Force fetch the value from the parameter store, ignoring the cache.
393+
* @param options.sdkOptions - Additional options to pass to the AWS SDK v3 client, supports all options from {@link QueryCommandInput | `QueryCommandInput`} except `TableName` and `KeyConditionExpression`.
394+
* @param options.transform - Transform to be applied, can be 'json' or 'binary'.
395+
* @param options.throwOnTransformError - Whether to throw an error if the transform fails (default: `true`)
392396
*/
393397
protected async _getMultiple(
394398
path: string,

0 commit comments

Comments
 (0)