You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/parameters/src/appconfig/AppConfigProvider.ts
+32-37Lines changed: 32 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -14,15 +14,12 @@ import type {
14
14
}from'../types/AppConfigProvider.js';
15
15
16
16
/**
17
-
* ## Intro
18
-
* The Parameters utility provides an AppConfigProvider that allows to retrieve configuration profiles from AWS AppConfig.
19
-
*
20
-
* ## Getting started
17
+
* The Parameters utility provides an `AppConfigProvider` that allows to retrieve configuration profiles from AWS AppConfig.
21
18
*
22
19
* 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
23
20
* the SDK packages you need and keep your bundle size small.
24
21
*
25
-
* ## Basic usage
22
+
* **Basic usage**
26
23
*
27
24
* @example
28
25
* ```typescript
@@ -41,9 +38,7 @@ import type {
41
38
* ```
42
39
* If you want to retrieve configs without customizing the provider, you can use the {@link getAppConfig} function instead.
43
40
*
44
-
* ## Advanced usage
45
-
*
46
-
* ### Caching
41
+
* **Caching**
47
42
*
48
43
* By default, the provider will cache parameters retrieved in-memory for 5 seconds.
49
44
* You can adjust how long values should be kept in cache by using the `maxAge` parameter.
@@ -82,7 +77,7 @@ import type {
82
77
* };
83
78
* ```
84
79
*
85
-
* ### Transformations
80
+
* **Transformations**
86
81
*
87
82
* 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.
88
83
*
@@ -118,7 +113,7 @@ import type {
118
113
* };
119
114
* ```
120
115
*
121
-
* ### Extra SDK options
116
+
* **Extra SDK options**
122
117
*
123
118
* When retrieving a configuration profile, you can pass extra options to the AWS SDK v3 for JavaScript client by using the `sdkOptions` parameter.
124
119
*
@@ -144,7 +139,7 @@ import type {
144
139
*
145
140
* 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).
146
141
*
147
-
* ### Customize AWS SDK v3 for JavaScript client
142
+
* **Customize AWS SDK v3 for JavaScript client**
148
143
*
149
144
* By default, the provider will create a new AppConfigData client using the default configuration.
150
145
*
@@ -192,21 +187,20 @@ class AppConfigProvider extends BaseProvider {
192
187
privatereadonlyapplication?: string;
193
188
privatereadonlyenvironment: string;
194
189
195
-
/**
196
-
* It initializes the AppConfigProvider class.
197
-
* *
198
-
* @param {AppConfigProviderOptions} options - The configuration object.
* @param name - The name of the configuration profile to retrieve
235
+
* @param options - Optional options to configure the provider
236
+
* @param options.maxAge - Optional maximum age of the value in the cache, in seconds (default: `5`)
237
+
* @param options.forceFetch - Optional flag to always fetch a new value from the store regardless if already available in cache (default: `false`)
238
+
* @param options.transform - Optional transform to be applied, can be `json` or `binary`
239
+
* @param options.sdkOptions - Optional additional options to pass to the AWS SDK v3 client, supports all options from {@link StartConfigurationSessionCommandInput | `StartConfigurationSessionCommandInput`} except `ApplicationIdentifier`, `EnvironmentIdentifier`, and `ConfigurationProfileIdentifier`
@@ -287,12 +278,16 @@ class AppConfigProvider extends BaseProvider {
287
278
* polls the configuration multiple times, we return the most recent value by returning the cached
288
279
* one if an empty response is returned by AppConfig.
289
280
*
290
-
* @param {string} name - Name of the configuration or its ID
291
-
* @param {AppConfigGetOptions} options - SDK options to propagate to `StartConfigurationSession` API call
281
+
* @param name - Name of the configuration or its ID
282
+
* @param options - SDK options to propagate to `StartConfigurationSession` API call
283
+
* @param options.maxAge - Maximum age of the value in the cache, in seconds.
284
+
* @param options.forceFetch - Force fetch the value from the parameter store, ignoring the cache.
285
+
* @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`.
286
+
* @param options.transform - Optional transform to be applied, can be 'json' or 'binary'.
292
287
*/
293
288
protectedasync_get(
294
289
name: string,
295
-
options?: AppConfigGetOptions
290
+
options?: NonNullable<AppConfigGetOptions>
296
291
): Promise<Uint8Array|undefined>{
297
292
if(
298
293
!this.configurationTokenStore.has(name)||
@@ -339,7 +334,7 @@ class AppConfigProvider extends BaseProvider {
339
334
/** When the response is not empty, stash the result locally before returning
* The Parameters utility provides an AppConfigProvider that allows to retrieve configuration profiles from AWS AppConfig.
9
+
* The Parameters utility provides an `AppConfigProvider` that allows to retrieve configuration profiles from AWS AppConfig.
11
10
*
12
-
* ## Getting started
13
-
*
14
-
* This utility supports AWS SDK v3 for JavaScript only. This allows the utility to be modular, and you to install only
11
+
* 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
15
12
* the SDK packages you need and keep your bundle size small.
16
13
*
17
-
* To use the provider, you must install the Parameters utility and the AWS SDK v3 for JavaScript for AppConfig:
* const config = new TextDecoder('utf-8').decode(encodedConfig);
67
+
* // Use the config variable as needed
68
+
* console.log
74
69
* };
75
70
* ```
76
71
*
77
-
* ### Transformations
72
+
* **Transformations**
78
73
*
79
74
* 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.
80
75
*
81
76
* @example
82
77
* ```typescript
83
78
* import { getAppConfig } from '@aws-lambda-powertools/parameters/appconfig';
@@ -108,7 +106,7 @@ import { AppConfigProvider } from './AppConfigProvider.js';
108
106
* };
109
107
* ```
110
108
*
111
-
* ### Extra SDK options
109
+
* **Extra SDK options**
112
110
*
113
111
* When retrieving a configuration profile, you can pass extra options to the AWS SDK v3 for JavaScript client by using the `sdkOptions` parameter.
114
112
*
@@ -131,15 +129,18 @@ import { AppConfigProvider } from './AppConfigProvider.js';
131
129
*
132
130
* 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).
133
131
*
134
-
* ### Built-in provider class
132
+
* For greater flexibility such as configuring the underlying SDK client used by built-in providers, you can use the {@link AppConfigProvider | `AppConfigProvider`} class.
135
133
*
136
-
* For greater flexibility such as configuring the underlying SDK client used by built-in providers, you can use the {@link AppConfigProvider} class.
137
-
*
138
-
* For more usage examples, see [our documentation](https://docs.powertools.aws.dev/lambda/typescript/latest/features/parameters/).
139
-
*
140
-
* @param {string} name - The name of the configuration profile or its ID
141
-
* @param {GetAppConfigOptions} options - Options to configure the provider
* @param name - The name of the configuration profile to retrieve
137
+
* @param options - Options to configure the provider
138
+
* @param options.application - The application ID or the application name
139
+
* @param options.environment - The environment ID or the environment name
140
+
* @param options.maxAge - Optional maximum age of the value in the cache, in seconds (default: `5`)
141
+
* @param options.forceFetch - Optional flag to always fetch a new value from the store regardless if already available in cache (default: `false`)
142
+
* @param options.transform - Optional transform to be applied, can be `json` or `binary`
143
+
* @param options.sdkOptions - Optional additional options to pass to the AWS SDK v3 client, supports all options from {@link StartConfigurationSessionCommandInput | `StartConfigurationSessionCommandInput`} except `ApplicationIdentifier`, `EnvironmentIdentifier`, and `ConfigurationProfileIdentifier`
0 commit comments