@friggframework/core 2.0.0--canary.625.8f60019.0 → 2.0.0--canary.625.3f500f2.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/core/parameters-to-env.js +18 -0
- package/core/ssm-preload.mjs +10 -2
- package/package.json +5 -5
|
@@ -199,6 +199,23 @@ const parametersToEnv = async () => {
|
|
|
199
199
|
return inflight;
|
|
200
200
|
};
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Adopt keys the INIT preload (ssm-preload.mjs) already populated into
|
|
204
|
+
* process.env, so the handler-time loader treats them as its own: it seeds
|
|
205
|
+
* the cache TTL and marks the keys owned so the TTL-refresh path re-fetches
|
|
206
|
+
* them. The preload runs in-process (NODE_OPTIONS=--import), sharing this
|
|
207
|
+
* module singleton. Pass ONLY the keys the preload actually set (not keys
|
|
208
|
+
* already present as real env vars) so the real-env-wins rule is preserved.
|
|
209
|
+
*/
|
|
210
|
+
const adoptPreloadedKeys = (keys) => {
|
|
211
|
+
for (const key of keys) {
|
|
212
|
+
ownedKeys.add(key);
|
|
213
|
+
}
|
|
214
|
+
const ttlSeconds = getCacheTtlSeconds();
|
|
215
|
+
cacheExpiresAt =
|
|
216
|
+
ttlSeconds === 0 ? Infinity : Date.now() + ttlSeconds * 1000;
|
|
217
|
+
};
|
|
218
|
+
|
|
202
219
|
const _resetCache = () => {
|
|
203
220
|
client = null;
|
|
204
221
|
cacheExpiresAt = null;
|
|
@@ -209,5 +226,6 @@ const _resetCache = () => {
|
|
|
209
226
|
module.exports = {
|
|
210
227
|
parametersToEnv,
|
|
211
228
|
fetchOffloadedParameters,
|
|
229
|
+
adoptPreloadedKeys,
|
|
212
230
|
_resetCache,
|
|
213
231
|
};
|
package/core/ssm-preload.mjs
CHANGED
|
@@ -25,15 +25,23 @@ if (prefix && rawKeys) {
|
|
|
25
25
|
.filter(Boolean);
|
|
26
26
|
|
|
27
27
|
if (keys.length > 0) {
|
|
28
|
-
const {
|
|
28
|
+
const {
|
|
29
|
+
fetchOffloadedParameters,
|
|
30
|
+
adoptPreloadedKeys,
|
|
31
|
+
} = require('./parameters-to-env');
|
|
29
32
|
const values = await fetchOffloadedParameters(prefix, keys);
|
|
30
33
|
|
|
31
34
|
// Real env vars win over SSM (console-override debugging escape hatch).
|
|
35
|
+
const setKeys = [];
|
|
32
36
|
for (const [key, value] of Object.entries(values)) {
|
|
33
37
|
if (process.env[key] === undefined) {
|
|
34
38
|
process.env[key] = value;
|
|
39
|
+
setKeys.push(key);
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
|
-
|
|
42
|
+
// Hand the keys we set to the handler-time loader (same in-process
|
|
43
|
+
// module singleton) so its TTL-refresh path re-fetches them.
|
|
44
|
+
adoptPreloadedKeys(setKeys);
|
|
45
|
+
console.log(`frigg-ssm-preload: loaded ${setKeys.length} parameter(s) at INIT under ${prefix}`);
|
|
38
46
|
}
|
|
39
47
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.625.
|
|
4
|
+
"version": "2.0.0--canary.625.3f500f2.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.588.0",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@friggframework/eslint-config": "2.0.0--canary.625.
|
|
43
|
-
"@friggframework/prettier-config": "2.0.0--canary.625.
|
|
44
|
-
"@friggframework/test": "2.0.0--canary.625.
|
|
42
|
+
"@friggframework/eslint-config": "2.0.0--canary.625.3f500f2.0",
|
|
43
|
+
"@friggframework/prettier-config": "2.0.0--canary.625.3f500f2.0",
|
|
44
|
+
"@friggframework/test": "2.0.0--canary.625.3f500f2.0",
|
|
45
45
|
"@prisma/client": "^6.19.3",
|
|
46
46
|
"@types/lodash": "4.17.15",
|
|
47
47
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "3f500f202c8dcf2210c07835c76abbab30e0d0ee"
|
|
85
85
|
}
|