configcat-js
Version:
ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.
59 lines (58 loc) • 4.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RefreshResult = exports.ClientCacheState = exports.OverrideBehaviour = exports.User = exports.SettingKeyValue = exports.SegmentComparator = exports.PrerequisiteFlagComparator = exports.UserComparator = exports.SettingType = exports.FormattableLogMessage = exports.LogLevel = exports.DataGovernance = exports.PollingMode = exports.createFlagOverridesFromMap = exports.createConsoleLogger = exports.disposeAllClients = exports.getClient = void 0;
var configcat_common_1 = require("configcat-common");
var Cache_1 = require("./Cache");
var ConfigFetcher_1 = require("./ConfigFetcher");
var Version_1 = require("./Version");
/**
* Returns an instance of `ConfigCatClient` for the specified SDK Key.
* @remarks This method returns a single, shared instance per each distinct SDK Key.
* That is, a new client object is created only when there is none available for the specified SDK Key.
* Otherwise, the already created instance is returned (in which case the `pollingMode` and `options` arguments are ignored).
* So, please keep in mind that when you make multiple calls to this method using the same SDK Key, you may end up with multiple references to the same client object.
* @param sdkKey SDK Key to access the ConfigCat config.
* @param pollingMode The polling mode to use.
* @param options Options for the specified polling mode.
*/
function getClient(sdkKey, pollingMode, options) {
return (0, configcat_common_1.getClient)(sdkKey, pollingMode !== null && pollingMode !== void 0 ? pollingMode : configcat_common_1.PollingMode.AutoPoll, options, Cache_1.LocalStorageCache.setup({
configFetcher: new ConfigFetcher_1.HttpConfigFetcher(),
sdkType: "ConfigCat-JS",
sdkVersion: Version_1.default,
}));
}
exports.getClient = getClient;
var configcat_common_2 = require("configcat-common");
Object.defineProperty(exports, "disposeAllClients", { enumerable: true, get: function () { return configcat_common_2.disposeAllClients; } });
Object.defineProperty(exports, "createConsoleLogger", { enumerable: true, get: function () { return configcat_common_2.createConsoleLogger; } });
Object.defineProperty(exports, "createFlagOverridesFromMap", { enumerable: true, get: function () { return configcat_common_2.createFlagOverridesFromMap; } });
/* Public types re-export from common-js */
// These exports should be kept in sync with the exports listed in the section "Public types for end users" of common-js/src/index.ts!
var configcat_common_3 = require("configcat-common");
Object.defineProperty(exports, "PollingMode", { enumerable: true, get: function () { return configcat_common_3.PollingMode; } });
var configcat_common_4 = require("configcat-common");
Object.defineProperty(exports, "DataGovernance", { enumerable: true, get: function () { return configcat_common_4.DataGovernance; } });
var configcat_common_5 = require("configcat-common");
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return configcat_common_5.LogLevel; } });
var configcat_common_6 = require("configcat-common");
Object.defineProperty(exports, "FormattableLogMessage", { enumerable: true, get: function () { return configcat_common_6.FormattableLogMessage; } });
var configcat_common_7 = require("configcat-common");
Object.defineProperty(exports, "SettingType", { enumerable: true, get: function () { return configcat_common_7.SettingType; } });
Object.defineProperty(exports, "UserComparator", { enumerable: true, get: function () { return configcat_common_7.UserComparator; } });
Object.defineProperty(exports, "PrerequisiteFlagComparator", { enumerable: true, get: function () { return configcat_common_7.PrerequisiteFlagComparator; } });
Object.defineProperty(exports, "SegmentComparator", { enumerable: true, get: function () { return configcat_common_7.SegmentComparator; } });
var configcat_common_8 = require("configcat-common");
Object.defineProperty(exports, "SettingKeyValue", { enumerable: true, get: function () { return configcat_common_8.SettingKeyValue; } });
var configcat_common_9 = require("configcat-common");
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return configcat_common_9.User; } });
var configcat_common_10 = require("configcat-common");
Object.defineProperty(exports, "OverrideBehaviour", { enumerable: true, get: function () { return configcat_common_10.OverrideBehaviour; } });
var configcat_common_11 = require("configcat-common");
Object.defineProperty(exports, "ClientCacheState", { enumerable: true, get: function () { return configcat_common_11.ClientCacheState; } });
Object.defineProperty(exports, "RefreshResult", { enumerable: true, get: function () { return configcat_common_11.RefreshResult; } });
/* Default export */
function default_1(sdkKey, options) {
return getClient(sdkKey, configcat_common_1.PollingMode.AutoPoll, options);
}
exports.default = default_1;