Skip to content

fix: Fix type definitions to avoid compiling source files #655

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 4 commits into from
Mar 2, 2021
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
18 changes: 9 additions & 9 deletions packages/optimizely-sdk/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,31 @@ declare module '@optimizely/optimizely-sdk' {

export type OptimizelyFeature = import('./shared_types').OptimizelyFeature;

export type EventTags = import ('./shared_types').EventTags;
export type EventTags = import('./shared_types').EventTags;

export type Event = import ('./shared_types').Event;
export type Event = import('./shared_types').Event;

export type EventDispatcher = import ('./shared_types').EventDispatcher;
export type EventDispatcher = import('./shared_types').EventDispatcher;

export type DatafileOptions = import ('./shared_types').DatafileOptions;
export type DatafileOptions = import('./shared_types').DatafileOptions;

export type SDKOptions = import ('./shared_types').SDKOptions;
export type SDKOptions = import('./shared_types').SDKOptions;

export type OptimizelyOptions = import ('./shared_types').OptimizelyOptions;
export type OptimizelyOptions = import('./shared_types').OptimizelyOptions;

export type UserProfileService = import('./shared_types').UserProfileService;

export type UserProfile = import('./shared_types').UserProfile;

export type ListenerPayload = import('./shared_types').ListenerPayload;

export type OptimizelyUserContext = import('./optimizely_user_context').default;
export type OptimizelyDecision = import('./shared_types').OptimizelyDecision;

export type OptimizelyDecision = import('./optimizely_decision').OptimizelyDecision;
export type OptimizelyUserContext = import('./shared_types').OptimizelyUserContext;

export enum OptimizelyDecideOption {
DISABLE_DECISION_EVENT = 'DISABLE_DECISION_EVENT',
ENABLED_FLAGS_ONLY = 'ENABLED_FLAGS_ONLY',
ENABLED_FLAGS_ONLY = 'ENABLED_FLAGS_ONLY',
IGNORE_USER_PROFILE_SERVICE = 'IGNORE_USER_PROFILE_SERVICE',
INCLUDE_REASONS = 'INCLUDE_REASONS',
EXCLUDE_VARIABLES = 'EXCLUDE_VARIABLES'
Expand Down
5 changes: 3 additions & 2 deletions packages/optimizely-sdk/lib/optimizely/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import {
FeatureFlag,
FeatureVariable,
OptimizelyOptions,
OptimizelyDecideOption
OptimizelyDecideOption,
OptimizelyDecision
} from '../shared_types';
import { OptimizelyDecision, newErrorDecision } from '../optimizely_decision';
import { newErrorDecision } from '../optimizely_decision';
import OptimizelyUserContext from '../optimizely_user_context';
import { createProjectConfigManager, ProjectConfigManager } from '../core/project_config/project_config_manager';
import { createNotificationCenter, NotificationCenter } from '../core/notification_center';
Expand Down
18 changes: 1 addition & 17 deletions packages/optimizely-sdk/lib/optimizely_decision/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,7 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
import OptimizelyUserContext from '../optimizely_user_context';

export interface OptimizelyDecision {
variationKey: string | null;
// The boolean value indicating if the flag is enabled or not
enabled: boolean;
// The collection of variables associated with the decision
variables: { [variableKey: string]: unknown };
// The rule key of the decision
ruleKey: string | null;
// The flag key for which the decision has been made for
flagKey: string;
// A copy of the user context for which the decision has been made for
userContext: OptimizelyUserContext;
// An array of error/info messages describing why the decision has been made.
reasons: string[];
}
import { OptimizelyUserContext, OptimizelyDecision } from '../shared_types';

export function newErrorDecision(key: string, user: OptimizelyUserContext, reasons: string[]): OptimizelyDecision {
return {
Expand Down
8 changes: 6 additions & 2 deletions packages/optimizely-sdk/lib/optimizely_user_context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
* limitations under the License. *
***************************************************************************/
import Optimizely from '../../lib/optimizely';
import { UserAttributes, OptimizelyDecideOption, EventTags } from '../../lib/shared_types';
import { OptimizelyDecision } from '../optimizely_decision';
import {
UserAttributes,
OptimizelyDecideOption,
OptimizelyDecision,
EventTags
} from '../../lib/shared_types';

export default class OptimizelyUserContext {
private optimizely: Optimizely;
Expand Down
34 changes: 34 additions & 0 deletions packages/optimizely-sdk/lib/shared_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,37 @@ export interface OptimizelyConfig {
revision: string;
getDatafile(): string;
}

export interface OptimizelyUserContext {
getUserId(): string;
getAttributes(): UserAttributes;
setAttribute(key: string, value: unknown): void;
decide(
key: string,
options: OptimizelyDecideOption[]
): OptimizelyDecision;
decideForKeys(
keys: string[],
options: OptimizelyDecideOption[],
): { [key: string]: OptimizelyDecision };
decideAll(
options: OptimizelyDecideOption[],
): { [key: string]: OptimizelyDecision };
trackEvent(eventName: string, eventTags?: EventTags): void;
}

export interface OptimizelyDecision {
variationKey: string | null;
// The boolean value indicating if the flag is enabled or not
enabled: boolean;
// The collection of variables associated with the decision
variables: { [variableKey: string]: unknown };
// The rule key of the decision
ruleKey: string | null;
// The flag key for which the decision has been made for
flagKey: string;
// A copy of the user context for which the decision has been made for
userContext: OptimizelyUserContext;
// An array of error/info messages describing why the decision has been made.
reasons: string[];
}