@dvsa/cvs-feature-flags 0.12.0 → 0.14.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/config.js +15 -0
- package/feature-flags.js +22 -0
- package/index.js +9 -0
- package/package.json +6 -3
- package/profiles/vtx.d.ts +3 -0
- package/profiles/vtx.js +3 -0
package/config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultFeatureFlagConfig = void 0;
|
|
4
|
+
// Balance between reducing the number of network hops to fetch
|
|
5
|
+
// feature flags and recycling feature flags in the event of a deployment error.
|
|
6
|
+
const MAX_AGE = Number.parseInt(process.env.FEATURE_FLAGS_MAX_AGE ?? 5 * 60);
|
|
7
|
+
const ENVIRONMENT_NAME = process.env.BRANCH;
|
|
8
|
+
const APP_NAME = process.env.FEATURE_FLAGS_APP_NAME ?? 'cvs-app-config';
|
|
9
|
+
const REQUEST_TIMEOUT = process.env.REQUEST_TIMEOUT ?? 10000;
|
|
10
|
+
exports.defaultFeatureFlagConfig = {
|
|
11
|
+
application: APP_NAME,
|
|
12
|
+
environment: ENVIRONMENT_NAME,
|
|
13
|
+
maxAge: MAX_AGE,
|
|
14
|
+
requestTimeout: REQUEST_TIMEOUT,
|
|
15
|
+
};
|
package/feature-flags.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFeatureFlags = void 0;
|
|
4
|
+
const appconfig_1 = require("@aws-lambda-powertools/parameters/appconfig");
|
|
5
|
+
const config_1 = require("./config");
|
|
6
|
+
// When instantiating the feature flags, we should be scoping this and caching it to the invocation instance.
|
|
7
|
+
// Each invocation of a lambda will get new feature flags, and that should not change throughout the lambda lifecycle.
|
|
8
|
+
// However, we don't want to cache them across invocations (ie outside the handler).
|
|
9
|
+
class FeatureFlagsClient {
|
|
10
|
+
async get(clientName) {
|
|
11
|
+
const featureFlags = await (0, appconfig_1.getAppConfig)(`${clientName}-profile`, {
|
|
12
|
+
...config_1.defaultFeatureFlagConfig,
|
|
13
|
+
transform: 'json',
|
|
14
|
+
});
|
|
15
|
+
return featureFlags;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const getFeatureFlags = async (clientName) => {
|
|
19
|
+
const client = new FeatureFlagsClient();
|
|
20
|
+
return await client.get(clientName);
|
|
21
|
+
};
|
|
22
|
+
exports.getFeatureFlags = getFeatureFlags;
|
package/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FeatureFlagsClientName = void 0;
|
|
4
|
+
var FeatureFlagsClientName;
|
|
5
|
+
(function (FeatureFlagsClientName) {
|
|
6
|
+
FeatureFlagsClientName["VTA"] = "vta";
|
|
7
|
+
FeatureFlagsClientName["VTX"] = "vtx";
|
|
8
|
+
FeatureFlagsClientName["VTM"] = "vtm";
|
|
9
|
+
})(FeatureFlagsClientName || (exports.FeatureFlagsClientName = FeatureFlagsClientName = {}));
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvsa/cvs-feature-flags",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Common package to be used in CVS to manage feature flags",
|
|
5
5
|
"author": "DVSA",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"files": [
|
|
8
8
|
"profiles/**",
|
|
9
9
|
"LICENSE",
|
|
10
|
-
"package.json"
|
|
10
|
+
"package.json",
|
|
11
|
+
"config.js",
|
|
12
|
+
"index.js",
|
|
13
|
+
"feature-flags.js"
|
|
11
14
|
],
|
|
12
15
|
"keywords": [
|
|
13
16
|
"typescript",
|
|
@@ -60,4 +63,4 @@
|
|
|
60
63
|
"npm run format"
|
|
61
64
|
]
|
|
62
65
|
}
|
|
63
|
-
}
|
|
66
|
+
}
|
package/profiles/vtx.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ declare const defaultFeatureFlags: {
|
|
|
5
5
|
translateFailTestResult: boolean;
|
|
6
6
|
translatePrsTestResult: boolean;
|
|
7
7
|
};
|
|
8
|
+
issueDocsCentrally: {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
};
|
|
8
11
|
};
|
|
9
12
|
export type FeatureFlags = typeof defaultFeatureFlags;
|
|
10
13
|
export declare const getProfile: () => Promise<FeatureFlags>;
|
package/profiles/vtx.js
CHANGED
|
@@ -14,6 +14,9 @@ const defaultFeatureFlags = {
|
|
|
14
14
|
translateFailTestResult: false,
|
|
15
15
|
translatePrsTestResult: false,
|
|
16
16
|
},
|
|
17
|
+
issueDocsCentrally: {
|
|
18
|
+
enabled: true,
|
|
19
|
+
},
|
|
17
20
|
};
|
|
18
21
|
const getProfile = async () => {
|
|
19
22
|
const flags = await (0, feature_flags_1.getFeatureFlags)(__1.FeatureFlagsClientName.VTX);
|