@dvsa/cvs-feature-flags 1.1.0-canary.6 → 2.0.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/feature-flags.d.ts +1 -1
- package/feature-flags.js +9 -36
- package/package.json +1 -1
- package/profiles/vta.d.ts +1 -1
- package/profiles/vta.js +2 -2
- package/profiles/vtm.d.ts +1 -1
- package/profiles/vtm.js +2 -2
- package/profiles/vtx.d.ts +1 -16
- package/profiles/vtx.js +2 -17
package/feature-flags.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FeatureFlagsClientName } from './';
|
|
2
|
-
export declare const getFeatureFlags: <T>(clientName: FeatureFlagsClientName
|
|
2
|
+
export declare const getFeatureFlags: <T>(clientName: FeatureFlagsClientName) => Promise<T>;
|
package/feature-flags.js
CHANGED
|
@@ -3,47 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getFeatureFlags = void 0;
|
|
4
4
|
const appconfig_1 = require("@aws-lambda-powertools/parameters/appconfig");
|
|
5
5
|
const config_1 = require("./config");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function resolveVariants(config, email) {
|
|
10
|
-
const resolved = {};
|
|
11
|
-
for (const [key, value] of Object.entries(config)) {
|
|
12
|
-
if (!hasEmails(value)) {
|
|
13
|
-
resolved[key] = value;
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
const { emails, ...flagValues } = value;
|
|
17
|
-
if (!emails || (emails && Array.isArray(emails) && emails.length === 0)) {
|
|
18
|
-
resolved[key] = flagValues;
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
const normalisedEmail = email?.toLowerCase();
|
|
22
|
-
console.log('got emails', { emails, normalisedEmail });
|
|
23
|
-
const isTargeted = normalisedEmail && emails.map((e) => e.toLowerCase()).includes(normalisedEmail);
|
|
24
|
-
console.log('isTargeted', isTargeted);
|
|
25
|
-
resolved[key] = isTargeted ? flagValues : { ...flagValues, enabled: false };
|
|
26
|
-
}
|
|
27
|
-
console.log('Resolving Variants', { resolved });
|
|
28
|
-
return resolved;
|
|
29
|
-
}
|
|
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).
|
|
30
9
|
class FeatureFlagsClient {
|
|
31
|
-
async get(clientName
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
...conf,
|
|
10
|
+
async get(clientName) {
|
|
11
|
+
const featureFlags = await (0, appconfig_1.getAppConfig)(`${clientName}-profile`, {
|
|
12
|
+
...config_1.defaultFeatureFlagConfig,
|
|
35
13
|
transform: 'json',
|
|
36
14
|
});
|
|
37
|
-
|
|
38
|
-
console.log('no email returning config', { config });
|
|
39
|
-
return config;
|
|
40
|
-
}
|
|
41
|
-
console.log('Try to resolve variant', { config, email });
|
|
42
|
-
return resolveVariants(config, email);
|
|
15
|
+
return featureFlags;
|
|
43
16
|
}
|
|
44
17
|
}
|
|
45
|
-
const getFeatureFlags = async (clientName
|
|
18
|
+
const getFeatureFlags = async (clientName) => {
|
|
46
19
|
const client = new FeatureFlagsClient();
|
|
47
|
-
return await client.get(clientName
|
|
20
|
+
return await client.get(clientName);
|
|
48
21
|
};
|
|
49
22
|
exports.getFeatureFlags = getFeatureFlags;
|
package/package.json
CHANGED
package/profiles/vta.d.ts
CHANGED
package/profiles/vta.js
CHANGED
|
@@ -15,8 +15,8 @@ const defaultFeatureFlags = {
|
|
|
15
15
|
enabled: false,
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
|
-
const getProfile = async (
|
|
19
|
-
const flags = await (0, feature_flags_1.getFeatureFlags)(__1.FeatureFlagsClientName.VTA
|
|
18
|
+
const getProfile = async () => {
|
|
19
|
+
const flags = await (0, feature_flags_1.getFeatureFlags)(__1.FeatureFlagsClientName.VTA);
|
|
20
20
|
return (0, lodash_merge_1.default)(defaultFeatureFlags, flags);
|
|
21
21
|
};
|
|
22
22
|
exports.getProfile = getProfile;
|
package/profiles/vtm.d.ts
CHANGED
package/profiles/vtm.js
CHANGED
|
@@ -8,8 +8,8 @@ const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
|
8
8
|
const __1 = require("..");
|
|
9
9
|
const feature_flags_1 = require("../feature-flags");
|
|
10
10
|
const defaultFeatureFlags = {};
|
|
11
|
-
const getProfile = async (
|
|
12
|
-
const flags = await (0, feature_flags_1.getFeatureFlags)(__1.FeatureFlagsClientName.VTM
|
|
11
|
+
const getProfile = async () => {
|
|
12
|
+
const flags = await (0, feature_flags_1.getFeatureFlags)(__1.FeatureFlagsClientName.VTM);
|
|
13
13
|
return (0, lodash_merge_1.default)(defaultFeatureFlags, flags);
|
|
14
14
|
};
|
|
15
15
|
exports.getProfile = getProfile;
|
package/profiles/vtx.d.ts
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
declare const defaultFeatureFlags: {
|
|
2
|
-
welshTranslation: {
|
|
3
|
-
enabled: boolean;
|
|
4
|
-
translatePassTestResult: boolean;
|
|
5
|
-
translateFailTestResult: boolean;
|
|
6
|
-
translatePrsTestResult: boolean;
|
|
7
|
-
};
|
|
8
|
-
issueDocsCentrally: {
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
};
|
|
11
2
|
recallsApi: {
|
|
12
3
|
enabled: boolean;
|
|
13
4
|
};
|
|
14
|
-
automatedCt: {
|
|
15
|
-
enabled: boolean;
|
|
16
|
-
};
|
|
17
|
-
abandonedCerts: {
|
|
18
|
-
enabled: boolean;
|
|
19
|
-
};
|
|
20
5
|
specialistDefects: {
|
|
21
6
|
enabled: boolean;
|
|
22
7
|
adasImNumbers: number[];
|
|
@@ -71,5 +56,5 @@ declare const defaultFeatureFlags: {
|
|
|
71
56
|
};
|
|
72
57
|
};
|
|
73
58
|
export type FeatureFlags = typeof defaultFeatureFlags;
|
|
74
|
-
export declare const getProfile: (
|
|
59
|
+
export declare const getProfile: () => Promise<FeatureFlags>;
|
|
75
60
|
export {};
|
package/profiles/vtx.js
CHANGED
|
@@ -8,24 +8,9 @@ const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
|
8
8
|
const __1 = require("..");
|
|
9
9
|
const feature_flags_1 = require("../feature-flags");
|
|
10
10
|
const defaultFeatureFlags = {
|
|
11
|
-
welshTranslation: {
|
|
12
|
-
enabled: true,
|
|
13
|
-
translatePassTestResult: true,
|
|
14
|
-
translateFailTestResult: true,
|
|
15
|
-
translatePrsTestResult: true,
|
|
16
|
-
},
|
|
17
|
-
issueDocsCentrally: {
|
|
18
|
-
enabled: true,
|
|
19
|
-
},
|
|
20
11
|
recallsApi: {
|
|
21
12
|
enabled: true,
|
|
22
13
|
},
|
|
23
|
-
automatedCt: {
|
|
24
|
-
enabled: false,
|
|
25
|
-
},
|
|
26
|
-
abandonedCerts: {
|
|
27
|
-
enabled: true,
|
|
28
|
-
},
|
|
29
14
|
specialistDefects: {
|
|
30
15
|
enabled: false,
|
|
31
16
|
adasImNumbers: [29],
|
|
@@ -80,8 +65,8 @@ const defaultFeatureFlags = {
|
|
|
80
65
|
reporting: false,
|
|
81
66
|
},
|
|
82
67
|
};
|
|
83
|
-
const getProfile = async (
|
|
84
|
-
const flags = await (0, feature_flags_1.getFeatureFlags)(__1.FeatureFlagsClientName.VTX
|
|
68
|
+
const getProfile = async () => {
|
|
69
|
+
const flags = await (0, feature_flags_1.getFeatureFlags)(__1.FeatureFlagsClientName.VTX);
|
|
85
70
|
return (0, lodash_merge_1.default)(defaultFeatureFlags, flags);
|
|
86
71
|
};
|
|
87
72
|
exports.getProfile = getProfile;
|