Skip to content

Commit f5de932

Browse files
raju-opticlaude
andcommitted
[FSSDK-12880] Refactor project config creation
- Simplify createProjectConfig to accept a datafile string directly instead of string | object, inlining datafile validation - Remove the separate config_validator module and its tests - Break monolithic config builder into focused parse functions: parseAudienceConfig, parseAttributeConfig, parseGroupConfig, parseRolloutConfig, parseIntegrationConfig, parseExperimentConfig, parseFeatureFlagConfig - Eliminate mutation-safe datafile copy in favor of direct construction - Refactor redundant iterations over experiments and feature flags - Remove lodash dev dependency Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e3ba148 commit f5de932

26 files changed

Lines changed: 670 additions & 994 deletions

lib/core/bucketer/index.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('excluding groups', () => {
7474
vi.clearAllMocks();
7575

7676
setLogSpy(mockLogger);
77-
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
77+
configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
7878

7979
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
8080
// @ts-ignore
@@ -125,7 +125,7 @@ describe('including groups: random', () => {
125125
vi.clearAllMocks();
126126

127127
setLogSpy(mockLogger);
128-
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
128+
configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
129129
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
130130
// @ts-ignore
131131
bucketerParams = {
@@ -231,7 +231,7 @@ describe('including groups: overlapping', () => {
231231
vi.clearAllMocks();
232232

233233
setLogSpy(mockLogger);
234-
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
234+
configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
235235
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
236236
// @ts-ignore
237237
bucketerParams = {
@@ -276,7 +276,7 @@ describe('bucket value falls into empty traffic allocation ranges', () => {
276276

277277
beforeEach(() => {
278278
setLogSpy(mockLogger);
279-
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
279+
configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
280280
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
281281
// @ts-ignore
282282
bucketerParams = {
@@ -326,7 +326,7 @@ describe('traffic allocation has invalid variation ids', () => {
326326

327327
beforeEach(() => {
328328
setLogSpy(mockLogger);
329-
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
329+
configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
330330
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
331331
//@ts-ignore
332332
bucketerParams = {
@@ -369,7 +369,7 @@ describe('testBucketWithBucketingId', () => {
369369
let bucketerParams: BucketerParams;
370370

371371
beforeEach(() => {
372-
const configObj = projectConfig.createProjectConfig(cloneDeep(testData));
372+
const configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
373373
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
374374
// @ts-ignore
375375
bucketerParams = {

lib/core/bucketer/index.tests.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('lib/core/bucketer', function () {
6565

6666
describe('return values for bucketing (excluding groups)', function () {
6767
beforeEach(function () {
68-
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
68+
configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
6969
bucketerParams = {
7070
experimentId: configObj.experiments[0].id,
7171
experimentKey: configObj.experiments[0].key,
@@ -107,7 +107,7 @@ describe('lib/core/bucketer', function () {
107107
describe('return values for bucketing (including groups)', function () {
108108
var bucketerStub;
109109
beforeEach(function () {
110-
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
110+
configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
111111
bucketerParams = {
112112
experimentId: configObj.experiments[0].id,
113113
experimentKey: configObj.experiments[0].key,
@@ -255,7 +255,7 @@ describe('lib/core/bucketer', function () {
255255

256256
describe('when the bucket value falls into empty traffic allocation ranges', function () {
257257
beforeEach(function () {
258-
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
258+
configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
259259
bucketerParams = {
260260
experimentId: configObj.experiments[0].id,
261261
experimentKey: configObj.experiments[0].key,
@@ -303,7 +303,7 @@ describe('lib/core/bucketer', function () {
303303

304304
describe('when the traffic allocation has invalid variation ids', function () {
305305
beforeEach(function () {
306-
configObj = projectConfig.createProjectConfig(cloneDeep(testData));
306+
configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
307307
bucketerParams = {
308308
experimentId: configObj.experiments[0].id,
309309
experimentKey: configObj.experiments[0].key,
@@ -364,7 +364,7 @@ describe('lib/core/bucketer', function () {
364364
});
365365

366366
beforeEach(function () {
367-
var configObj = projectConfig.createProjectConfig(cloneDeep(testData));
367+
var configObj = projectConfig.createProjectConfig(JSON.stringify(testData));
368368
bucketerParams = {
369369
trafficAllocationConfig: configObj.experiments[0].trafficAllocation,
370370
variationIdMap: configObj.variationIdMap,

0 commit comments

Comments
 (0)