1414 * limitations under the License.
1515 */
1616
17- declare module '@optimizely/optimizely-sdk/lib/core/decision_service' {
17+ declare module '@optimizely/optimizely-sdk/lib/core/decision_service' {
1818 import { LogHandler } from '@optimizely/js-sdk-logging' ;
19+ import { UserProfile , UserAttributes } from '@optimizely/optimizely-sdk' ;
20+ import { ProjectConfig } from '@optimizely/optimizely-sdk/lib/core/project_config' ;
21+ import { Experiment , Variation , FeatureFlag } from '@optimizely/optimizely-sdk/lib/core/project_config' ;
1922
2023 export function createDecisionService ( options : Options ) : DecisionService ;
2124
@@ -26,20 +29,10 @@ declare module '@optimizely/optimizely-sdk/lib/core/decision_service' {
2629
2730 interface DecisionService {
2831 getVariation ( experimentKey : string , userId : string , attributes ?: UserAttributes ) : string | null ;
29- getVariationForFeature ( configObj : ConfigObj , feature : FeatureFlag , userId : string , attributes : unknown ) : Decision ;
32+ getVariationForFeature ( configObj : ProjectConfig , feature : FeatureFlag , userId : string , attributes : unknown ) : Decision ;
3033 removeForcedVariation ( userId : unknown , experimentId : string , experimentKey : string ) : void ;
31- getForcedVariation ( configObj : ConfigObj , experimentKey : string , userId : string ) : string | null ;
32- setForcedVariation ( configObj : ConfigObj , experimentKey : string , userId : string , variationKey : unknown ) : boolean ;
33- }
34-
35- // Information about past bucketing decisions for a user.
36- interface UserProfile {
37- user_id : string ;
38- experiment_bucket_map : {
39- [ experiment_id : string ] : {
40- variation_id : string ;
41- } ;
42- } ;
34+ getForcedVariation ( configObj : ProjectConfig , experimentKey : string , userId : string ) : string | null ;
35+ setForcedVariation ( configObj : ProjectConfig , experimentKey : string , userId : string , variationKey : unknown ) : boolean ;
4336 }
4437
4538 interface Options {
@@ -48,133 +41,6 @@ declare module '@optimizely/optimizely-sdk/lib/core/decision_service' {
4841 UNSTABLE_conditionEvaluators : unknown ;
4942 }
5043
51- interface ConfigObj {
52- events : Event [ ] ;
53- featureFlags : FeatureFlag [ ] ;
54- experiments : Experiment [ ] ;
55- anonymizeIP : boolean ;
56- botFiltering : boolean ;
57- audiences : Audience [ ] ;
58- revision : string ;
59- groups : Group [ ] ;
60- attributes : UserAttributes ;
61- rollouts : Rollout [ ] ;
62- projectId : string ;
63- accountId : string ;
64- version : string ;
65- variables : FeatureVariable [ ] ;
66- audiencesById : { [ key : string ] : Audience } ;
67- attributeKeyMap : attributeKeyMap ;
68- groupIdMap : { [ key : string ] : Group } ;
69- rolloutIdMap : { [ key :string ] : Rollout } ;
70- experimentKeyMap : { [ key : string ] : Experiment }
71- experimentIdMap : { [ key : string ] : Experiment } ;
72- variationIdMap : { [ key : string ] : Variation } ;
73- variationVariableUsageMap : { [ key : string ] : ExperimentVariableByID } ;
74- experimentFeatureMap : { [ key : string ] : string [ ] } ;
75- featureKeyMap : { [ key : string ] : FeatureFlag } ;
76- }
77-
78- interface Event {
79- key : string ;
80- id : string ;
81- experimentIds : string [ ]
82- }
83-
84- interface FeatureFlag {
85- rolloutId : string ;
86- key : string ;
87- id : string ;
88- experimentIds : string [ ] ,
89- variables : FeatureVariable [ ] ,
90- variableKeyMap ?: { [ key : string ] : FeatureVariable }
91- }
92-
93- interface FeatureVariable {
94- type : string ;
95- subType ?: string ;
96- key : string ;
97- id : string ;
98- defaultValue : string ;
99- }
100-
101- interface Experiment {
102- id : string ;
103- key : string ;
104- status : string ;
105- layerId : string ;
106- variations : Variation [ ] ;
107- trafficAllocation : Array < TrafficAllocationEntity > ;
108- audienceIds : string [ ] ;
109- // TODO[OASIS-6649]: Don't use object type
110- // eslint-disable-next-line @typescript-eslint/ban-types
111- forcedVariations : object ;
112- variationKeyMap ?: { [ key : string ] : Variation } ;
113- }
114-
115- interface Variation {
116- id : string ;
117- key : string ;
118- featureEnabled : boolean ;
119- variables : ExperimentVariable [ ] ;
120- }
121-
122- interface Audience {
123- id : string ;
124- name : string ;
125- conditions : ConditionTree < Condition > ;
126- }
127-
128- interface Group {
129- policy : string ;
130- id : string ;
131- experiments : Experiment [ ] ;
132- trafficAllocation : Array < TrafficAllocationEntity > ;
133- }
134-
135- type UserAttributes = {
136- // TODO[OASIS-6649]: Don't use any type
137- // eslint-disable-next-line @typescript-eslint/no-explicit-any
138- [ name : string ] : any ;
139- }
140-
141- type Condition = {
142- name : string ;
143- type : string ;
144- match ?: string ;
145- value : string | number | boolean | null ;
146- }
147-
148- type ConditionTree < Leaf > = Leaf | unknown [ ] ;
149-
150- interface TrafficAllocationEntity {
151- endOfRange : number ;
152- entityId : string ;
153- }
154-
155- interface Rollout {
156- id : string ;
157- experiments : Experiment [ ] ;
158- }
159-
160- interface Attribute {
161- id : string ;
162- key : string ;
163- }
164-
165- interface attributeKeyMap {
166- [ key : string ] : Attribute ;
167- }
168-
169- type ExperimentVariable = {
170- id : string ;
171- value : string ;
172- }
173-
174- type ExperimentVariableByID = {
175- [ key : string ] : ExperimentVariable ;
176- }
177-
17844 interface Decision {
17945 experiment : Experiment | null ;
18046 variation : Variation | null ;
0 commit comments