Skip to content

Commit a0805d7

Browse files
committed
Fix imports
1 parent c83b2d2 commit a0805d7

File tree

2 files changed

+21
-161
lines changed

2 files changed

+21
-161
lines changed

packages/optimizely-sdk/lib/core/decision_service/index.d.ts

Lines changed: 7 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
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;

packages/optimizely-sdk/lib/index.d.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
declare module '@optimizely/optimizely-sdk' {
1818
import { LogHandler, ErrorHandler } from '@optimizely/js-sdk-logging';
19-
import { UserProfileService } from '@optimizely/optimizely-sdk/lib/core/decision_service';
19+
import { Experiment, Variation } from '@optimizely/optimizely-sdk/lib/core/project_config';
2020
import * as enums from '@optimizely/optimizely-sdk/lib/utils/enums';
2121
import * as logging from '@optimizely/optimizely-sdk/lib/plugins/logger';
2222
export { enums, logging };
@@ -136,6 +136,11 @@ declare module '@optimizely/optimizely-sdk' {
136136
dispatchEvent: (event: Event, callback: () => void) => void;
137137
}
138138

139+
export interface UserProfileService {
140+
lookup: (userId: string) => UserProfile;
141+
save: (profile: UserProfile) => void;
142+
}
143+
139144
// NotificationCenter-related types
140145
export interface NotificationCenter {
141146
addNotificationListener<T extends ListenerPayload>(
@@ -176,25 +181,14 @@ declare module '@optimizely/optimizely-sdk' {
176181
logEvent: Event;
177182
}
178183

179-
export interface Experiment {
180-
id: string;
181-
key: string;
182-
status: string;
183-
layerId: string;
184-
variations: Variation[];
185-
trafficAllocation: Array<{
186-
entityId: string;
187-
endOfRange: number;
188-
}>;
189-
audienceIds: string[];
190-
// TODO[OASIS-6649]: Don't use object type
191-
// eslint-disable-next-line @typescript-eslint/ban-types
192-
forcedVariations: object;
193-
}
194-
195-
export interface Variation {
196-
id: string;
197-
key: string;
184+
// Information about past bucketing decisions for a user.
185+
export interface UserProfile {
186+
user_id: string;
187+
experiment_bucket_map: {
188+
[experiment_id: string]: {
189+
variation_id: string;
190+
};
191+
};
198192
}
199193

200194
/**

0 commit comments

Comments
 (0)