Skip to content

fix: Refactor index.d.ts imports #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/optimizely-sdk/lib/core/decision_service/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
*/
import { LogHandler } from '@optimizely/js-sdk-logging';
import { ProjectConfig } from '../project_config';
import { UserAttributes, UserProfileService } from '../../shared_types';
import { FeatureFlag, Experiment, Variation } from '../project_config/entities';
import {
UserAttributes,
UserProfileService,
FeatureFlag,
Experiment,
Variation
} from '../../shared_types';

/**
* Creates an instance of the DecisionService.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
* limitations under the License.
*/
import { LogHandler, ErrorHandler } from '@optimizely/js-sdk-logging';
import { EventTags, UserAttributes, Event } from '../../shared_types';
import { Experiment, Variation } from '../project_config/entities';
import {
EventTags,
UserAttributes,
Event,
Experiment,
Variation
} from '../../shared_types';

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

Expand Down
52 changes: 0 additions & 52 deletions packages/optimizely-sdk/lib/core/project_config/entities.ts

This file was deleted.

7 changes: 6 additions & 1 deletion packages/optimizely-sdk/lib/core/project_config/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/
import { LogHandler } from '@optimizely/js-sdk-logging';
import { FeatureFlag, FeatureVariable, Experiment, Variation } from './entities';
import {
FeatureFlag,
FeatureVariable,
Experiment,
Variation
} from '../../shared_types';

export interface ProjectConfig {
revision: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/optimizely-sdk/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ declare module '@optimizely/optimizely-sdk' {
}

export interface ActivateListenerPayload extends ListenerPayload {
experiment: import('./core/project_config/entities').Experiment;
variation: import('./core/project_config/entities').Variation;
experiment: import('./shared_types').Experiment;
variation: import('./shared_types').Variation;
logEvent: Event;
}

Expand Down
7 changes: 4 additions & 3 deletions packages/optimizely-sdk/lib/optimizely/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
***************************************************************************/
import { sprintf, objectValues } from '@optimizely/js-sdk-utils';
import { LogHandler, ErrorHandler } from '@optimizely/js-sdk-logging';
import { FeatureFlag, FeatureVariable } from '../core/project_config/entities';
import {
UserAttributes,
EventTags,
OptimizelyConfig,
EventDispatcher,
OnReadyResult,
UserProfileService,
DatafileOptions
DatafileOptions,
Variation,
FeatureFlag,
FeatureVariable
} from '../shared_types';
import { Variation } from '../core/project_config/entities';
import { createProjectConfigManager, ProjectConfigManager } from '../core/project_config/project_config_manager';
import { createNotificationCenter, NotificationCenter } from '../core/notification_center';
import { createDecisionService, DecisionService, DecisionObj } from '../core/decision_service';
Expand Down
38 changes: 38 additions & 0 deletions packages/optimizely-sdk/lib/shared_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,44 @@ export interface EventDispatcher {
dispatchEvent: (event: Event, callback: (response: { statusCode: number; }) => void) => void;
}

export interface VariationVariable {
id: string;
value: string;
}

export interface Variation {
id: string;
key: string;
featureEnabled: boolean;
variables: VariationVariable[];
}

export interface Experiment {
id: string;
key: string;
variationKeyMap: {[key: string]: Variation}
}

export interface FeatureVariable {
type: string;
key: string;
id: string;
defaultValue: string;
}

export interface FeatureFlag {
rolloutId: string;
key: string;
id: string;
experimentIds: string[],
variables: FeatureVariable[],
variableKeyMap: {[key: string]: FeatureVariable}
}

export interface FeatureKeyMap {
[key: string]: FeatureFlag
}

export interface OnReadyResult {
success: boolean;
reason?: string;
Expand Down