@middy/ssm 5.5.1 → 6.0.0-beta.0
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.js +10 -10
- package/package.json +7 -4
package/index.js
CHANGED
|
@@ -33,14 +33,14 @@ const defaults = {
|
|
|
33
33
|
const ssmMiddleware = (opts = {}) => {
|
|
34
34
|
const options = { ...defaults, ...opts }
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const fetchRequest = (request, cachedValues) => {
|
|
37
37
|
return {
|
|
38
|
-
...
|
|
39
|
-
...
|
|
38
|
+
...fetchSingleRequest(request, cachedValues),
|
|
39
|
+
...fetchByPathRequest(request, cachedValues)
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const fetchSingleRequest = (request, cachedValues = {}) => {
|
|
44
44
|
const values = {}
|
|
45
45
|
let batchReq = null
|
|
46
46
|
let batchInternalKeys = []
|
|
@@ -115,13 +115,13 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
115
115
|
return values
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
const
|
|
118
|
+
const fetchByPathRequest = (request, cachedValues = {}) => {
|
|
119
119
|
const values = {}
|
|
120
120
|
for (const internalKey in options.fetchData) {
|
|
121
121
|
if (cachedValues[internalKey]) continue
|
|
122
122
|
const fetchKey = options.fetchData[internalKey]
|
|
123
123
|
if (fetchKey.substr(-1) !== '/') continue // Skip not path passed in
|
|
124
|
-
values[internalKey] =
|
|
124
|
+
values[internalKey] = fetchPathRequest(fetchKey).catch((e) => {
|
|
125
125
|
const value = getCache(options.cacheKey).value ?? {}
|
|
126
126
|
value[internalKey] = undefined
|
|
127
127
|
modifyCache(options.cacheKey, value)
|
|
@@ -131,7 +131,7 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
131
131
|
return values
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
const
|
|
134
|
+
const fetchPathRequest = (path, nextToken, values = {}) => {
|
|
135
135
|
const command = new GetParametersByPathCommand({
|
|
136
136
|
Path: path,
|
|
137
137
|
NextToken: nextToken,
|
|
@@ -150,7 +150,7 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
150
150
|
}
|
|
151
151
|
})
|
|
152
152
|
)
|
|
153
|
-
if (resp.NextToken) return
|
|
153
|
+
if (resp.NextToken) { return fetchPathRequest(path, resp.NextToken, values) }
|
|
154
154
|
return values
|
|
155
155
|
})
|
|
156
156
|
}
|
|
@@ -165,7 +165,7 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
165
165
|
let client
|
|
166
166
|
if (canPrefetch(options)) {
|
|
167
167
|
client = createPrefetchClient(options)
|
|
168
|
-
processCache(options,
|
|
168
|
+
processCache(options, fetchRequest)
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
const ssmMiddlewareBefore = async (request) => {
|
|
@@ -173,7 +173,7 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
173
173
|
client = await createClient(options, request)
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
const { value } = processCache(options,
|
|
176
|
+
const { value } = processCache(options, fetchRequest, request)
|
|
177
177
|
|
|
178
178
|
Object.assign(request.internal, value)
|
|
179
179
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/ssm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-beta.0",
|
|
4
4
|
"description": "SSM (EC2 Systems Manager) parameters middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=20"
|
|
8
8
|
},
|
|
9
9
|
"engineStrict": true,
|
|
10
10
|
"publishConfig": {
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"import": {
|
|
17
17
|
"types": "./index.d.ts",
|
|
18
18
|
"default": "./index.js"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"default": "./index.js"
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
},
|
|
@@ -60,11 +63,11 @@
|
|
|
60
63
|
"url": "https://github.com/sponsors/willfarrell"
|
|
61
64
|
},
|
|
62
65
|
"dependencies": {
|
|
63
|
-
"@middy/util": "
|
|
66
|
+
"@middy/util": "6.0.0-beta.0"
|
|
64
67
|
},
|
|
65
68
|
"devDependencies": {
|
|
66
69
|
"@aws-sdk/client-ssm": "^3.0.0",
|
|
67
|
-
"@middy/core": "
|
|
70
|
+
"@middy/core": "6.0.0-beta.0",
|
|
68
71
|
"@types/aws-lambda": "^8.10.101",
|
|
69
72
|
"aws-xray-sdk": "^3.3.3"
|
|
70
73
|
},
|