1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- import { find , objectEntries , objectValues , sprintf , assign , keyBy } from '../utils/fns' ;
16+ import { find , objectEntries , objectValues , sprintf , keyBy } from '../utils/fns' ;
1717
1818import { ERROR_MESSAGES , LOG_LEVEL , LOG_MESSAGES , FEATURE_VARIABLE_TYPES } from '../utils/enums' ;
1919import configValidator from '../utils/config_validator' ;
@@ -36,6 +36,7 @@ import {
3636} from '../shared_types' ;
3737import { OdpConfig , OdpIntegrationConfig } from '../odp/odp_config' ;
3838import { Transformer } from '../utils/type' ;
39+ import exp from 'constants' ;
3940
4041interface TryCreatingProjectConfigConfig {
4142 // TODO[OASIS-6649]: Don't use object type
@@ -99,27 +100,27 @@ const MODULE_NAME = 'PROJECT_CONFIG';
99100
100101// eslint-disable-next-line @typescript-eslint/no-explicit-any
101102function createMutationSafeDatafileCopy ( datafile : any ) : ProjectConfig {
102- const datafileCopy = assign ( { } , datafile ) ;
103+ const datafileCopy = { ... datafile } ;
103104 datafileCopy . audiences = ( datafile . audiences || [ ] ) . map ( ( audience : Audience ) => {
104- return assign ( { } , audience ) ;
105+ return { ... audience } ;
105106 } ) ;
106107 datafileCopy . experiments = ( datafile . experiments || [ ] ) . map ( ( experiment : Experiment ) => {
107- return assign ( { } , experiment ) ;
108+ return { ... experiment } ;
108109 } ) ;
109110 datafileCopy . featureFlags = ( datafile . featureFlags || [ ] ) . map ( ( featureFlag : FeatureFlag ) => {
110- return assign ( { } , featureFlag ) ;
111+ return { ... featureFlag } ;
111112 } ) ;
112113 datafileCopy . groups = ( datafile . groups || [ ] ) . map ( ( group : Group ) => {
113- const groupCopy = assign ( { } , group ) ;
114+ const groupCopy = { ... group } ;
114115 groupCopy . experiments = ( group . experiments || [ ] ) . map ( experiment => {
115- return assign ( { } , experiment ) ;
116+ return { ... experiment } ;
116117 } ) ;
117118 return groupCopy ;
118119 } ) ;
119120 datafileCopy . rollouts = ( datafile . rollouts || [ ] ) . map ( ( rollout : Rollout ) => {
120- const rolloutCopy = assign ( { } , rollout ) ;
121+ const rolloutCopy = { ... rollout } ;
121122 rolloutCopy . experiments = ( rollout . experiments || [ ] ) . map ( experiment => {
122- return assign ( { } , experiment ) ;
123+ return { ... experiment } ;
123124 } ) ;
124125 return rolloutCopy ;
125126 } ) ;
@@ -148,8 +149,11 @@ export const createProjectConfig = function(datafileObj?: JSON, datafileStr: str
148149 ( projectConfig . audiences || [ ] ) . forEach ( audience => {
149150 audience . conditions = JSON . parse ( audience . conditions as string ) ;
150151 } ) ;
151- projectConfig . audiencesById = keyBy ( projectConfig . audiences , 'id' ) ;
152- assign ( projectConfig . audiencesById , keyBy ( projectConfig . typedAudiences , 'id' ) ) ;
152+
153+ projectConfig . audiencesById = {
154+ ...keyBy ( projectConfig . audiences , 'id' ) ,
155+ ...keyBy ( projectConfig . typedAudiences , 'id' ) ,
156+ }
153157
154158 projectConfig . attributeKeyMap = keyBy ( projectConfig . attributes , 'key' ) ;
155159 projectConfig . eventKeyMap = keyBy ( projectConfig . events , 'key' ) ;
@@ -159,7 +163,8 @@ export const createProjectConfig = function(datafileObj?: JSON, datafileStr: str
159163 Object . keys ( projectConfig . groupIdMap || { } ) . forEach ( Id => {
160164 experiments = projectConfig . groupIdMap [ Id ] . experiments ;
161165 ( experiments || [ ] ) . forEach ( experiment => {
162- projectConfig . experiments . push ( assign ( experiment , { groupId : Id } ) ) ;
166+ experiment . groupId = Id ;
167+ projectConfig . experiments . push ( experiment ) ;
163168 } ) ;
164169 } ) ;
165170
@@ -226,7 +231,11 @@ export const createProjectConfig = function(datafileObj?: JSON, datafileStr: str
226231 experiment . variationKeyMap = keyBy ( experiment . variations , 'key' ) ;
227232
228233 // Creates { <variationId>: { key: <variationKey>, id: <variationId> } } mapping for quick lookup
229- assign ( projectConfig . variationIdMap , keyBy ( experiment . variations , 'id' ) ) ;
234+ projectConfig . variationIdMap = {
235+ ...projectConfig . variationIdMap ,
236+ ...keyBy ( experiment . variations , 'id' )
237+ } ;
238+
230239 objectValues ( experiment . variationKeyMap || { } ) . forEach ( variation => {
231240 if ( variation . variables ) {
232241 projectConfig . variationVariableUsageMap [ variation . id ] = keyBy ( variation . variables , 'id' ) ;
0 commit comments