configcat-common
Advanced tools
Comparing version 9.1.0 to 9.2.0
@@ -26,14 +26,22 @@ import { Setting } from "./ProjectConfig"; | ||
var MapOverrideDataSource = /** @class */ (function () { | ||
function MapOverrideDataSource(map) { | ||
this.map = {}; | ||
this.map = Object.fromEntries(Object.entries(map).map(function (_a) { | ||
function MapOverrideDataSource(map, watchChanges) { | ||
this.initialSettings = this.constructor.getCurrentSettings(map); | ||
if (watchChanges) { | ||
this.map = map; | ||
} | ||
} | ||
MapOverrideDataSource.getCurrentSettings = function (map) { | ||
return Object.fromEntries(Object.entries(map) | ||
.map(function (_a) { | ||
var key = _a[0], value = _a[1]; | ||
return [key, Setting.fromValue(value)]; | ||
})); | ||
} | ||
}; | ||
MapOverrideDataSource.prototype.getOverrides = function () { | ||
return Promise.resolve(this.map); | ||
return Promise.resolve(this.getOverridesSync()); | ||
}; | ||
MapOverrideDataSource.prototype.getOverridesSync = function () { | ||
return this.map; | ||
return this.map | ||
? this.constructor.getCurrentSettings(this.map) | ||
: this.initialSettings; | ||
}; | ||
@@ -40,0 +48,0 @@ return MapOverrideDataSource; |
import { ConfigCatClient } from "./ConfigCatClient"; | ||
import { PollingMode } from "./ConfigCatClientOptions"; | ||
import { ConfigCatConsoleLogger, LogLevel } from "./ConfigCatLogger"; | ||
import { FlagOverrides, MapOverrideDataSource, OverrideBehaviour } from "./FlagOverrides"; | ||
import { setupPolyfills } from "./Polyfills"; | ||
@@ -32,5 +33,16 @@ setupPolyfills(); | ||
} | ||
/** | ||
* Creates an instance of `FlagOverrides` that uses a map data source. | ||
* @param map The map that contains the overrides. | ||
* @param behaviour The override behaviour. | ||
* Specifies whether the local values should override the remote values | ||
* or local values should only be used when a remote value doesn't exist | ||
* or the local values should be used only. | ||
* @param watchChanges If set to `true`, the input map will be tracked for changes. | ||
*/ | ||
export function createFlagOverridesFromMap(map, behaviour, watchChanges) { | ||
return new FlagOverrides(new MapOverrideDataSource(map, watchChanges), behaviour); | ||
} | ||
export { FetchStatus, FetchResult, FetchError } from "./ConfigFetcher"; | ||
export { ExternalConfigCache } from "./ConfigCatCache"; | ||
export { FlagOverrides, MapOverrideDataSource } from "./FlagOverrides"; | ||
export { InMemoryConfigCache, ExternalConfigCache } from "./ConfigCatCache"; | ||
/* Public types for end users */ | ||
@@ -46,3 +58,3 @@ // List types here which are part of the public API of platform-specific SDKs, thus, should be exposed to end users. | ||
export { User } from "./User"; | ||
export { OverrideBehaviour } from "./FlagOverrides"; | ||
export { OverrideBehaviour }; | ||
export { ClientCacheState, RefreshResult } from "./ConfigServiceBase"; |
@@ -34,6 +34,9 @@ import type { SettingValue } from "./ProjectConfig"; | ||
export declare class MapOverrideDataSource implements IOverrideDataSource { | ||
private readonly map; | ||
private static getCurrentSettings; | ||
private readonly initialSettings; | ||
private readonly map?; | ||
private readonly ["constructor"]; | ||
constructor(map: { | ||
[name: string]: NonNullable<SettingValue>; | ||
}); | ||
}, watchChanges?: boolean); | ||
getOverrides(): Promise<{ | ||
@@ -40,0 +43,0 @@ [name: string]: Setting; |
@@ -29,14 +29,22 @@ "use strict"; | ||
var MapOverrideDataSource = /** @class */ (function () { | ||
function MapOverrideDataSource(map) { | ||
this.map = {}; | ||
this.map = Object.fromEntries(Object.entries(map).map(function (_a) { | ||
function MapOverrideDataSource(map, watchChanges) { | ||
this.initialSettings = this.constructor.getCurrentSettings(map); | ||
if (watchChanges) { | ||
this.map = map; | ||
} | ||
} | ||
MapOverrideDataSource.getCurrentSettings = function (map) { | ||
return Object.fromEntries(Object.entries(map) | ||
.map(function (_a) { | ||
var key = _a[0], value = _a[1]; | ||
return [key, ProjectConfig_1.Setting.fromValue(value)]; | ||
})); | ||
} | ||
}; | ||
MapOverrideDataSource.prototype.getOverrides = function () { | ||
return Promise.resolve(this.map); | ||
return Promise.resolve(this.getOverridesSync()); | ||
}; | ||
MapOverrideDataSource.prototype.getOverridesSync = function () { | ||
return this.map; | ||
return this.map | ||
? this.constructor.getCurrentSettings(this.map) | ||
: this.initialSettings; | ||
}; | ||
@@ -43,0 +51,0 @@ return MapOverrideDataSource; |
@@ -6,2 +6,4 @@ import type { IConfigCatClient, IConfigCatKernel } from "./ConfigCatClient"; | ||
import { LogLevel } from "./ConfigCatLogger"; | ||
import { FlagOverrides, OverrideBehaviour } from "./FlagOverrides"; | ||
import type { SettingValue } from "./ProjectConfig"; | ||
/** | ||
@@ -27,2 +29,14 @@ * Returns an instance of `ConfigCatClient` for the specified SDK Key. | ||
export declare function createConsoleLogger(logLevel: LogLevel): IConfigCatLogger; | ||
/** | ||
* Creates an instance of `FlagOverrides` that uses a map data source. | ||
* @param map The map that contains the overrides. | ||
* @param behaviour The override behaviour. | ||
* Specifies whether the local values should override the remote values | ||
* or local values should only be used when a remote value doesn't exist | ||
* or the local values should be used only. | ||
* @param watchChanges If set to `true`, the input map will be tracked for changes. | ||
*/ | ||
export declare function createFlagOverridesFromMap(map: { | ||
[name: string]: NonNullable<SettingValue>; | ||
}, behaviour: OverrideBehaviour, watchChanges?: boolean): FlagOverrides; | ||
export type { IConfigCatKernel }; | ||
@@ -33,6 +47,4 @@ export type { IConfigFetcher, IFetchResponse, FetchErrorCauses } from "./ConfigFetcher"; | ||
export type { IConfigCache } from "./ConfigCatCache"; | ||
export { ExternalConfigCache } from "./ConfigCatCache"; | ||
export { InMemoryConfigCache, ExternalConfigCache } from "./ConfigCatCache"; | ||
export type { IEventProvider, IEventEmitter } from "./EventEmitter"; | ||
export type { IOverrideDataSource } from "./FlagOverrides"; | ||
export { FlagOverrides, MapOverrideDataSource } from "./FlagOverrides"; | ||
export { PollingMode }; | ||
@@ -55,5 +67,6 @@ export type { IOptions } from "./ConfigCatClientOptions"; | ||
export { User } from "./User"; | ||
export { OverrideBehaviour } from "./FlagOverrides"; | ||
export type { FlagOverrides }; | ||
export { OverrideBehaviour }; | ||
export { ClientCacheState, RefreshResult } from "./ConfigServiceBase"; | ||
export type { IProvidesHooks, HookEvents } from "./Hooks"; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
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.MapOverrideDataSource = exports.FlagOverrides = exports.ExternalConfigCache = exports.FetchError = exports.FetchResult = exports.FetchStatus = exports.createConsoleLogger = exports.disposeAllClients = exports.getClient = void 0; | ||
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.ExternalConfigCache = exports.InMemoryConfigCache = exports.FetchError = exports.FetchResult = exports.FetchStatus = exports.createFlagOverridesFromMap = exports.createConsoleLogger = exports.disposeAllClients = exports.getClient = void 0; | ||
var ConfigCatClient_1 = require("./ConfigCatClient"); | ||
@@ -9,2 +9,4 @@ var ConfigCatClientOptions_1 = require("./ConfigCatClientOptions"); | ||
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return ConfigCatLogger_1.LogLevel; } }); | ||
var FlagOverrides_1 = require("./FlagOverrides"); | ||
Object.defineProperty(exports, "OverrideBehaviour", { enumerable: true, get: function () { return FlagOverrides_1.OverrideBehaviour; } }); | ||
var Polyfills_1 = require("./Polyfills"); | ||
@@ -41,2 +43,15 @@ Polyfills_1.setupPolyfills(); | ||
exports.createConsoleLogger = createConsoleLogger; | ||
/** | ||
* Creates an instance of `FlagOverrides` that uses a map data source. | ||
* @param map The map that contains the overrides. | ||
* @param behaviour The override behaviour. | ||
* Specifies whether the local values should override the remote values | ||
* or local values should only be used when a remote value doesn't exist | ||
* or the local values should be used only. | ||
* @param watchChanges If set to `true`, the input map will be tracked for changes. | ||
*/ | ||
function createFlagOverridesFromMap(map, behaviour, watchChanges) { | ||
return new FlagOverrides_1.FlagOverrides(new FlagOverrides_1.MapOverrideDataSource(map, watchChanges), behaviour); | ||
} | ||
exports.createFlagOverridesFromMap = createFlagOverridesFromMap; | ||
var ConfigFetcher_1 = require("./ConfigFetcher"); | ||
@@ -47,6 +62,4 @@ Object.defineProperty(exports, "FetchStatus", { enumerable: true, get: function () { return ConfigFetcher_1.FetchStatus; } }); | ||
var ConfigCatCache_1 = require("./ConfigCatCache"); | ||
Object.defineProperty(exports, "InMemoryConfigCache", { enumerable: true, get: function () { return ConfigCatCache_1.InMemoryConfigCache; } }); | ||
Object.defineProperty(exports, "ExternalConfigCache", { enumerable: true, get: function () { return ConfigCatCache_1.ExternalConfigCache; } }); | ||
var FlagOverrides_1 = require("./FlagOverrides"); | ||
Object.defineProperty(exports, "FlagOverrides", { enumerable: true, get: function () { return FlagOverrides_1.FlagOverrides; } }); | ||
Object.defineProperty(exports, "MapOverrideDataSource", { enumerable: true, get: function () { return FlagOverrides_1.MapOverrideDataSource; } }); | ||
var ConfigCatClientOptions_2 = require("./ConfigCatClientOptions"); | ||
@@ -65,6 +78,4 @@ Object.defineProperty(exports, "DataGovernance", { enumerable: true, get: function () { return ConfigCatClientOptions_2.DataGovernance; } }); | ||
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return User_1.User; } }); | ||
var FlagOverrides_2 = require("./FlagOverrides"); | ||
Object.defineProperty(exports, "OverrideBehaviour", { enumerable: true, get: function () { return FlagOverrides_2.OverrideBehaviour; } }); | ||
var ConfigServiceBase_1 = require("./ConfigServiceBase"); | ||
Object.defineProperty(exports, "ClientCacheState", { enumerable: true, get: function () { return ConfigServiceBase_1.ClientCacheState; } }); | ||
Object.defineProperty(exports, "RefreshResult", { enumerable: true, get: function () { return ConfigServiceBase_1.RefreshResult; } }); |
{ | ||
"name": "configcat-common", | ||
"version": "9.1.0", | ||
"version": "9.2.0", | ||
"description": "ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
605825
10294