@middy/ssm 7.2.1 → 7.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/index.js +13 -11
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function ssmParam<T>(path: string): ParamType<T>;
|
|
|
11
11
|
export interface SSMOptions<AwsSSMClient = SSMClient>
|
|
12
12
|
extends Omit<MiddyOptions<AwsSSMClient, SSMClientConfig>, "fetchData"> {
|
|
13
13
|
fetchData?: { [key: string]: string | ParamType<unknown> };
|
|
14
|
+
awsRequestLimit?: number;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export type Context<TOptions extends SSMOptions | undefined> =
|
package/index.js
CHANGED
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
sanitizeKey,
|
|
19
19
|
} from "@middy/util";
|
|
20
20
|
|
|
21
|
-
const awsRequestLimit = 10;
|
|
22
21
|
const defaults = {
|
|
23
22
|
AwsClient: SSMClient, // Allow for XRay
|
|
24
23
|
awsClientOptions: {},
|
|
@@ -30,6 +29,7 @@ const defaults = {
|
|
|
30
29
|
cacheKeyExpiry: {},
|
|
31
30
|
cacheExpiry: -1,
|
|
32
31
|
setToContext: false,
|
|
32
|
+
awsRequestLimit: 10,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const ssmMiddleware = (opts = {}) => {
|
|
@@ -62,7 +62,7 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
62
62
|
batchKeys.set(internalKey, fetchKey);
|
|
63
63
|
// from the first to the batch size skip, unless it's the last entry
|
|
64
64
|
if (
|
|
65
|
-
(!idx || (idx + 1) % awsRequestLimit !== 0) &&
|
|
65
|
+
(!idx || (idx + 1) % options.awsRequestLimit !== 0) &&
|
|
66
66
|
!(idx + 1 === namedKeys.length)
|
|
67
67
|
) {
|
|
68
68
|
continue;
|
|
@@ -80,15 +80,15 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
80
80
|
// Don't sanitize key, mapped to set value in options
|
|
81
81
|
const result = {};
|
|
82
82
|
for (const fetchKey of resp.InvalidParameters ?? []) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
const internalKey = internalKeys[fetchKeys.indexOf(fetchKey)];
|
|
84
|
+
const value = getCache(options.cacheKey).value ?? {};
|
|
85
|
+
value[internalKey] = undefined;
|
|
86
|
+
modifyCache(options.cacheKey, value);
|
|
87
|
+
result[fetchKey] = Promise.reject(
|
|
88
|
+
new Error(`InvalidParameter ${fetchKey}`, {
|
|
89
89
|
cause: { package: "@middy/ssm" },
|
|
90
|
-
})
|
|
91
|
-
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
92
|
}
|
|
93
93
|
for (const param of resp.Parameters ?? []) {
|
|
94
94
|
result[param.Name] = parseValue(param);
|
|
@@ -168,6 +168,7 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
let client;
|
|
171
|
+
let clientInit;
|
|
171
172
|
if (canPrefetch(options)) {
|
|
172
173
|
client = createPrefetchClient(options);
|
|
173
174
|
processCache(options, fetchRequest);
|
|
@@ -175,7 +176,8 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
175
176
|
|
|
176
177
|
const ssmMiddlewareBefore = async (request) => {
|
|
177
178
|
if (!client) {
|
|
178
|
-
|
|
179
|
+
clientInit ??= createClient(options, request);
|
|
180
|
+
client = await clientInit;
|
|
179
181
|
}
|
|
180
182
|
|
|
181
183
|
const { value } = processCache(options, fetchRequest, request);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/ssm",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.3",
|
|
4
4
|
"description": "SSM (EC2 Systems Manager) parameters middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"url": "https://github.com/sponsors/willfarrell"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@middy/util": "7.2.
|
|
68
|
+
"@middy/util": "7.2.3"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@aws-sdk/client-ssm": "^3.0.0"
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@aws-sdk/client-ssm": "^3.0.0",
|
|
80
|
-
"@middy/core": "7.2.
|
|
80
|
+
"@middy/core": "7.2.3",
|
|
81
81
|
"@types/aws-lambda": "^8.0.0",
|
|
82
82
|
"@types/node": "^22.0.0",
|
|
83
83
|
"aws-xray-sdk": "^3.3.3"
|