Skip to content

Commit a0157fd

Browse files
authored
Refactor index.d.ts imports (#625)
1 parent 170ab61 commit a0157fd

File tree

7 files changed

+64
-62
lines changed

7 files changed

+64
-62
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
*/
1616
import { LogHandler } from '@optimizely/js-sdk-logging';
1717
import { ProjectConfig } from '../project_config';
18-
import { UserAttributes, UserProfileService } from '../../shared_types';
19-
import { FeatureFlag, Experiment, Variation } from '../project_config/entities';
18+
import {
19+
UserAttributes,
20+
UserProfileService,
21+
FeatureFlag,
22+
Experiment,
23+
Variation
24+
} from '../../shared_types';
2025

2126
/**
2227
* Creates an instance of the DecisionService.

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
* limitations under the License.
1616
*/
1717
import { LogHandler, ErrorHandler } from '@optimizely/js-sdk-logging';
18-
import { EventTags, UserAttributes, Event } from '../../shared_types';
19-
import { Experiment, Variation } from '../project_config/entities';
18+
import {
19+
EventTags,
20+
UserAttributes,
21+
Event,
22+
Experiment,
23+
Variation
24+
} from '../../shared_types';
2025

2126
export type NOTIFICATION_TYPES = import('@optimizely/js-sdk-utils').NOTIFICATION_TYPES;
2227

packages/optimizely-sdk/lib/core/project_config/entities.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
* limitations under the License.
1515
*/
1616
import { LogHandler } from '@optimizely/js-sdk-logging';
17-
import { FeatureFlag, FeatureVariable, Experiment, Variation } from './entities';
17+
import {
18+
FeatureFlag,
19+
FeatureVariable,
20+
Experiment,
21+
Variation
22+
} from '../../shared_types';
1823

1924
export interface ProjectConfig {
2025
revision: string;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ declare module '@optimizely/optimizely-sdk' {
177177
}
178178

179179
export interface ActivateListenerPayload extends ListenerPayload {
180-
experiment: import('./core/project_config/entities').Experiment;
181-
variation: import('./core/project_config/entities').Variation;
180+
experiment: import('./shared_types').Experiment;
181+
variation: import('./shared_types').Variation;
182182
logEvent: Event;
183183
}
184184

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@
1515
***************************************************************************/
1616
import { sprintf, objectValues } from '@optimizely/js-sdk-utils';
1717
import { LogHandler, ErrorHandler } from '@optimizely/js-sdk-logging';
18-
import { FeatureFlag, FeatureVariable } from '../core/project_config/entities';
1918
import {
2019
UserAttributes,
2120
EventTags,
2221
OptimizelyConfig,
2322
EventDispatcher,
2423
OnReadyResult,
2524
UserProfileService,
26-
DatafileOptions
25+
DatafileOptions,
26+
Variation,
27+
FeatureFlag,
28+
FeatureVariable
2729
} from '../shared_types';
28-
import { Variation } from '../core/project_config/entities';
2930
import { createProjectConfigManager, ProjectConfigManager } from '../core/project_config/project_config_manager';
3031
import { createNotificationCenter, NotificationCenter } from '../core/notification_center';
3132
import { createDecisionService, DecisionService, DecisionObj } from '../core/decision_service';

packages/optimizely-sdk/lib/shared_types.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,44 @@ export interface EventDispatcher {
5656
dispatchEvent: (event: Event, callback: (response: { statusCode: number; }) => void) => void;
5757
}
5858

59+
export interface VariationVariable {
60+
id: string;
61+
value: string;
62+
}
63+
64+
export interface Variation {
65+
id: string;
66+
key: string;
67+
featureEnabled: boolean;
68+
variables: VariationVariable[];
69+
}
70+
71+
export interface Experiment {
72+
id: string;
73+
key: string;
74+
variationKeyMap: {[key: string]: Variation}
75+
}
76+
77+
export interface FeatureVariable {
78+
type: string;
79+
key: string;
80+
id: string;
81+
defaultValue: string;
82+
}
83+
84+
export 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+
export interface FeatureKeyMap {
94+
[key: string]: FeatureFlag
95+
}
96+
5997
export interface OnReadyResult {
6098
success: boolean;
6199
reason?: string;

0 commit comments

Comments
 (0)