configcat-common
Advanced tools
Comparing version 2.4.2 to 2.5.0
@@ -26,2 +26,6 @@ import { IConfigCatKernel } from "."; | ||
getAllVariationIdsAsync(user?: User): Promise<string[]>; | ||
/** Returns the key of a setting and it's value identified by the given Variation ID (analytics) */ | ||
getKeyAndValue(variationId: string, callback: (settingkeyAndValue: SettingKeyValue) => void): void; | ||
/** Returns the key of a setting and it's value identified by the given Variation ID (analytics) */ | ||
getKeyAndValueAsync(variationId: string): Promise<SettingKeyValue>; | ||
} | ||
@@ -43,2 +47,8 @@ export declare class ConfigCatClient implements IConfigCatClient { | ||
getAllVariationIdsAsync(user?: User): Promise<string[]>; | ||
getKeyAndValue(variationId: string, callback: (settingkeyAndValue: SettingKeyValue) => void): void; | ||
getKeyAndValueAsync(variationId: string): Promise<SettingKeyValue>; | ||
} | ||
export declare class SettingKeyValue { | ||
settingKey: string; | ||
settingValue: any; | ||
} |
@@ -43,2 +43,3 @@ "use strict"; | ||
var RolloutEvaluator_1 = require("./RolloutEvaluator"); | ||
var ProjectConfig_1 = require("./ProjectConfig"); | ||
exports.CONFIG_CHANGE_EVENT_NAME = "changed"; | ||
@@ -191,4 +192,62 @@ var ConfigCatClient = /** @class */ (function () { | ||
}; | ||
ConfigCatClient.prototype.getKeyAndValue = function (variationId, callback) { | ||
this.getKeyAndValueAsync(variationId).then(function (settingKeyAndValue) { | ||
callback(settingKeyAndValue); | ||
}); | ||
}; | ||
ConfigCatClient.prototype.getKeyAndValueAsync = function (variationId) { | ||
var _this = this; | ||
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () { | ||
var config, settingKey, rolloutRules, i, rolloutRule, percentageItems, i, percentageItem; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.configService.getConfig()]; | ||
case 1: | ||
config = _a.sent(); | ||
if (!config || !config.ConfigJSON) { | ||
this.options.logger.error("JSONConfig is not present, returning null"); | ||
resolve(null); | ||
return [2 /*return*/]; | ||
} | ||
for (settingKey in config.ConfigJSON) { | ||
if (variationId === config.ConfigJSON[settingKey][ProjectConfig_1.Setting.VariationId]) { | ||
resolve({ settingKey: settingKey, settingValue: config.ConfigJSON[settingKey][ProjectConfig_1.Setting.Value] }); | ||
return [2 /*return*/]; | ||
} | ||
rolloutRules = config.ConfigJSON[settingKey][ProjectConfig_1.Setting.RolloutRules]; | ||
if (rolloutRules && rolloutRules.length > 0) { | ||
for (i = 0; i < rolloutRules.length; i++) { | ||
rolloutRule = rolloutRules[i]; | ||
if (variationId === rolloutRule[ProjectConfig_1.RolloutRules.VariationId]) { | ||
resolve({ settingKey: settingKey, settingValue: rolloutRule[ProjectConfig_1.RolloutRules.Value] }); | ||
return [2 /*return*/]; | ||
} | ||
} | ||
} | ||
percentageItems = config.ConfigJSON[settingKey][ProjectConfig_1.Setting.RolloutPercentageItems]; | ||
if (percentageItems && percentageItems.length > 0) { | ||
for (i = 0; i < percentageItems.length; i++) { | ||
percentageItem = percentageItems[i]; | ||
if (variationId === percentageItem[ProjectConfig_1.RolloutPercentageItems.VariationId]) { | ||
resolve({ settingKey: settingKey, settingValue: percentageItem[ProjectConfig_1.RolloutPercentageItems.Value] }); | ||
return [2 /*return*/]; | ||
} | ||
} | ||
} | ||
} | ||
this.options.logger.error("Could not find the setting for the given variation ID: " + variationId); | ||
resolve(null); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}; | ||
return ConfigCatClient; | ||
}()); | ||
exports.ConfigCatClient = ConfigCatClient; | ||
var SettingKeyValue = /** @class */ (function () { | ||
function SettingKeyValue() { | ||
} | ||
return SettingKeyValue; | ||
}()); | ||
exports.SettingKeyValue = SettingKeyValue; |
{ | ||
"name": "configcat-common", | ||
"version": "2.4.2", | ||
"version": "2.5.0", | ||
"description": "ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.", | ||
@@ -27,2 +27,3 @@ "main": "lib/index.js", | ||
"license": "MIT", | ||
"homepage": "https://configcat.com", | ||
"dependencies": {}, | ||
@@ -29,0 +30,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
86635
1910
0