-
Notifications
You must be signed in to change notification settings - Fork 83
feat: Created declaration file for project config index.d.ts module #567
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
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cd3a438
index.d.ts added for project_config
9cf0aad
Update index.d.ts
4e0a752
Update index.d.ts
215c0fe
Update index.d.ts
ae6186c
Update index.d.ts
99cb5d1
Update index.d.ts
1f551e7
seperate entities file and modified projconfig interface
b6f73d0
comments addressed
b7df251
seperate type for traffic allocation
ecbd322
comments addressed
e54a9fc
Update index.d.ts
0e1b56c
restructure
36c9e62
Update index.d.ts
6add538
Update index.d.ts
fb07216
revise
0694c7c
Update index.ts
5f4d9d4
Update index.d.ts
941c5f5
Merge branch 'master' into uzair/project_config_interface
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/optimizely-sdk/lib/core/project_config/entities.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /** | ||
| * Copyright 2020, Optimizely | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UserAttributes and EventTags from optimizely-sdk can be defined here and import using it's reference there. |
||
|
|
||
| export interface FeatureVariable { | ||
| type: string; | ||
| } | ||
|
|
||
| export interface FeatureFlag { | ||
| variables: FeatureVariable[]; | ||
| } | ||
|
|
||
109 changes: 109 additions & 0 deletions
109
packages/optimizely-sdk/lib/core/project_config/index.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| /** | ||
| * Copyright 2020, Optimizely | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| declare module '@optimizely/optimizely-sdk/lib/core/project_config' { | ||
| import { LogHandler } from '@optimizely/js-sdk-logging'; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
| export interface ProjectConfig {} | ||
| /** | ||
| * Determine for given experiment if event is running, which determines whether should be dispatched or not | ||
| * @param {ProjectConfig} configObj Object representing project configuration | ||
| * @param {string} experimentKey Experiment key for which the status is to be determined | ||
| * @return {boolean} True is the experiment is running | ||
| * False is the experiment is not running | ||
| * | ||
| */ | ||
| export function isRunning(configObj: ProjectConfig, experimentKey: string): boolean; | ||
|
|
||
| /** | ||
| * Get the variation ID given the experiment key and variation key | ||
| * @param {ProjectConfig} configObj Object representing project configuration | ||
| * @param {string} experimentKey Key of the experiment the variation belongs to | ||
| * @param {string} variationKey The variation key | ||
| * @return {string} the variation ID | ||
| */ | ||
| export function getVariationIdFromExperimentAndVariationKey(configObj: ProjectConfig, experimentKey: string, variationKey: string): string; | ||
|
|
||
| /** | ||
| * Get experiment ID for the provided experiment key | ||
| * @param {ProjectConfig} configObj Object representing project configuration | ||
| * @param {string} experimentKey Experiment key for which ID is to be determined | ||
| * @return {string} Experiment ID corresponding to the provided experiment key | ||
| * @throws If experiment key is not in datafile | ||
| */ | ||
| export function getExperimentId(configObj: ProjectConfig, experimentKey: string): string | never; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
|
|
||
| /** | ||
| * Check if the event with a specific key is present in the datafile | ||
| * @param {ProjectConfig} configObj Object representing project configuration | ||
| * @param {string} eventKey Event key for which event is to be determined | ||
| * @returns {boolean} True if key exists in the datafile | ||
| * False if key does not exist in the datafile | ||
| */ | ||
| export function eventWithKeyExists(configObj: ProjectConfig, eventKey: string): boolean; | ||
|
|
||
| /** | ||
| * Check if the experiment is belongs to any feature | ||
| * @param {ProjectConfig} configObj Object representing project configuration | ||
| * @param {string} experimentId Experiment ID of an experiment | ||
| * @returns {boolean} True if experiement belongs to any feature | ||
| * False if experiement does not belong to any feature | ||
| */ | ||
| export function isFeatureExperiment(configObj: ProjectConfig, experimentId: string): boolean; | ||
|
|
||
| /** | ||
| * Get feature from provided feature key. Log an error if no feature exists in | ||
| * the project config with the given key. | ||
| * @param {ProjectConfig} configObj Object representing project configuration | ||
| * @param {string} featureKey Key of a feature for which feature is to be determined | ||
| * @param {LogHandler} logger Logger instance | ||
| * @return {FeatureFlag|null} Feature object, or null if no feature with the given | ||
| * key exists | ||
| */ | ||
| export function getFeatureFromKey(configObj: ProjectConfig, featureKey: string, logger: LogHandler): import('./entities').FeatureFlag | null; | ||
|
|
||
| /** | ||
| * Get the variable with the given key associated with the feature with the | ||
| * given key. If the feature key or the variable key are invalid, log an error | ||
| * message. | ||
| * @param {ProjectConfig} configObj Object representing project configuration | ||
| * @param {string} featureKey Key of a feature for which feature is to be determined | ||
| * @param {string} variableKey Key of a variable for which variable is to be determined | ||
| * @param {LogHandler} logger Logger instances | ||
| * @return {FeatureVariable|null} Variable object, or null one or both of the given | ||
| * feature and variable keys are invalid | ||
| */ | ||
| export function getVariableForFeature(configObj: ProjectConfig, featureKey: string, variableKey: string, logger: LogHandler): import('./entities').FeatureVariable | null; | ||
|
|
||
| /** | ||
| * Given a variable value in string form, try to cast it to the argument type. | ||
| * If the type cast succeeds, return the type casted value, otherwise log an | ||
| * error and return null. | ||
| * @param {string} variableValue Variable value in string form | ||
| * @param {string} type Type of the variable whose value was passed | ||
| * in the first argument. Must be one of | ||
| * FEATURE_VARIABLE_TYPES in | ||
| * lib/utils/enums/index.js. The return value's | ||
| * type is determined by this argument (boolean | ||
| * for BOOLEAN, number for INTEGER or DOUBLE, | ||
| * and string for STRING). | ||
| * @param {LogHandler} logger Logger instance | ||
| * @returns {T} Variable value of the appropriate type, or | ||
| * null if the type cast failed | ||
| */ | ||
| export function getTypeCastValue<T>(variableValue: string, type: string, logger: LogHandler): T; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.