Socket
Socket
Sign inDemoInstall

configcat-common

Package Overview
Dependencies
Maintainers
4
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configcat-common - npm Package Compare versions

Comparing version 9.0.0 to 9.1.0

lib/ConfigJson.d.ts

2

lib/ConfigCatClient.d.ts

@@ -205,3 +205,3 @@ import type { IConfigCache } from "./ConfigCatCache";

/** Setting key-value pair. */
export declare class SettingKeyValue<TValue = SettingValue> {
export declare class SettingKeyValue<TValue extends SettingValue = SettingValue> {
settingKey: string;

@@ -208,0 +208,0 @@ settingValue: TValue;

@@ -351,3 +351,3 @@ "use strict";

if (variationId === setting.variationId) {
return [2 /*return*/, new SettingKeyValue(settingKey, setting.value)];
return [2 /*return*/, new SettingKeyValue(settingKey, ensureAllowedValue(setting.value))];
}

@@ -362,3 +362,3 @@ targetingRules = settings[settingKey].targetingRules;

if (variationId === percentageOption.variationId) {
return [2 /*return*/, new SettingKeyValue(settingKey, percentageOption.value)];
return [2 /*return*/, new SettingKeyValue(settingKey, ensureAllowedValue(percentageOption.value))];
}

@@ -368,3 +368,3 @@ }

else if (variationId === then.variationId) {
return [2 /*return*/, new SettingKeyValue(settingKey, then.value)];
return [2 /*return*/, new SettingKeyValue(settingKey, ensureAllowedValue(then.value))];
}

@@ -378,3 +378,3 @@ }

if (variationId === percentageOption.variationId) {
return [2 /*return*/, new SettingKeyValue(settingKey, percentageOption.value)];
return [2 /*return*/, new SettingKeyValue(settingKey, ensureAllowedValue(percentageOption.value))];
}

@@ -654,2 +654,5 @@ }

}
function ensureAllowedValue(value) {
return RolloutEvaluator_1.isAllowedValue(value) ? value : RolloutEvaluator_1.handleInvalidReturnValue(value);
}
var registerForFinalization = function (client, data) {

@@ -656,0 +659,0 @@ // Use FinalizationRegistry (finalization callbacks) if the runtime provides that feature.

@@ -67,3 +67,3 @@ import type { SafeHooksWrapper } from "./Hooks";

fetchFailedDueToRedirectLoop(): LogMessage;
fetchReceived200WithInvalidBody(): LogMessage;
fetchReceived200WithInvalidBody(ex: any): LogMessage;
fetchReceived304WhenLocalCacheIsEmpty(statusCode: number, reasonPhrase: string): LogMessage;

@@ -70,0 +70,0 @@ settingForVariationIdIsNotPresent(variationId: string): LogMessage;

@@ -129,3 +129,3 @@ "use strict";

LoggerWrapper.prototype.fetchFailedDueToUnexpectedError = function (ex) {
return this.log(LogLevel.Error, 1103, "Unexpected error occurred while trying to fetch config JSON.", ex);
return this.log(LogLevel.Error, 1103, "Unexpected error occurred while trying to fetch config JSON. It is most likely due to a local network issue. Please make sure your application can reach the ConfigCat CDN servers (or your proxy server) over HTTP.", ex);
};

@@ -135,4 +135,4 @@ LoggerWrapper.prototype.fetchFailedDueToRedirectLoop = function () {

};
LoggerWrapper.prototype.fetchReceived200WithInvalidBody = function () {
return this.log(LogLevel.Error, 1105, "Fetching config JSON was successful but the HTTP response content was invalid.");
LoggerWrapper.prototype.fetchReceived200WithInvalidBody = function (ex) {
return this.log(LogLevel.Error, 1105, "Fetching config JSON was successful but the HTTP response content was invalid.", ex);
};

@@ -139,0 +139,0 @@ LoggerWrapper.prototype.fetchReceived304WhenLocalCacheIsEmpty = function (statusCode, reasonPhrase) {

@@ -6,2 +6,3 @@ "use strict";

var ConfigFetcher_1 = require("./ConfigFetcher");
var ConfigJson_1 = require("./ConfigJson");
var ProjectConfig_1 = require("./ProjectConfig");

@@ -149,3 +150,3 @@ /** Contains the result of an `IConfigCatClient.forceRefresh` or `IConfigCatClient.forceRefreshAsync` operation. */

return tslib_1.__awaiter(this, void 0, void 0, function () {
var options, errorMessage, _b, response, config, err_1;
var options, errorMessage, _b, response, configOrError, err_1;
return tslib_1.__generator(this, function (_c) {

@@ -161,12 +162,12 @@ switch (_c.label) {

case 2:
_b = _c.sent(), response = _b[0], config = _b[1];
_b = _c.sent(), response = _b[0], configOrError = _b[1];
switch (response.statusCode) {
case 200: // OK
if (!config) {
errorMessage = options.logger.fetchReceived200WithInvalidBody().toString();
if (!(configOrError instanceof ProjectConfig_1.Config)) {
errorMessage = options.logger.fetchReceived200WithInvalidBody(configOrError).toString();
options.logger.debug("ConfigServiceBase.fetchLogicAsync(): " + response.statusCode + " " + response.reasonPhrase + " was received but the HTTP response content was invalid. Returning null.");
return [2 /*return*/, ConfigFetcher_1.FetchResult.error(lastConfig, errorMessage)];
return [2 /*return*/, ConfigFetcher_1.FetchResult.error(lastConfig, errorMessage, configOrError)];
}
options.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was successful. Returning new config.");
return [2 /*return*/, ConfigFetcher_1.FetchResult.success(new ProjectConfig_1.ProjectConfig(response.body, config, ProjectConfig_1.ProjectConfig.generateTimestamp(), response.eTag))];
return [2 /*return*/, ConfigFetcher_1.FetchResult.success(new ProjectConfig_1.ProjectConfig(response.body, configOrError, ProjectConfig_1.ProjectConfig.generateTimestamp(), response.eTag))];
case 304: // Not Modified

@@ -224,11 +225,11 @@ if (!lastConfig) {

options.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body.");
return [2 /*return*/, [response]];
return [2 /*return*/, [response, new Error("No response body.")]];
}
config = void 0;
try {
config = new ProjectConfig_1.Config(JSON.parse(response.body));
config = ProjectConfig_1.Config.deserialize(response.body);
}
catch (_b) {
catch (err) {
options.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body.");
return [2 /*return*/, [response]];
return [2 /*return*/, [response, err]];
}

@@ -249,3 +250,3 @@ preferences = config.preferences;

// the SDK should not redirect the calls and it just have to return the response.
if (options.baseUrlOverriden && redirect !== ProjectConfig_1.RedirectMode.Force) {
if (options.baseUrlOverriden && redirect !== ConfigJson_1.RedirectMode.Force) {
options.logger.debug("ConfigServiceBase.fetchRequestAsync(): options.baseUrlOverriden && redirect !== 2.");

@@ -255,6 +256,6 @@ return [2 /*return*/, [response, config]];

options.baseUrl = baseUrl;
if (redirect === ProjectConfig_1.RedirectMode.No) {
if (redirect === ConfigJson_1.RedirectMode.No) {
return [2 /*return*/, [response, config]];
}
if (redirect === ProjectConfig_1.RedirectMode.Should) {
if (redirect === ConfigJson_1.RedirectMode.Should) {
options.logger.dataGovernanceIsOutOfSync();

@@ -261,0 +262,0 @@ }

@@ -9,3 +9,3 @@ import { __assign, __awaiter, __generator } from "tslib";

import { getWeakRefStub, isWeakRefAvailable } from "./Polyfills";
import { RolloutEvaluator, checkSettingsAvailable, evaluate, evaluateAll, evaluationDetailsFromDefaultValue, getTimestampAsDate, isAllowedValue } from "./RolloutEvaluator";
import { RolloutEvaluator, checkSettingsAvailable, evaluate, evaluateAll, evaluationDetailsFromDefaultValue, getTimestampAsDate, handleInvalidReturnValue, isAllowedValue } from "./RolloutEvaluator";
import { errorToString, isArray, throwError } from "./Utils";

@@ -349,3 +349,3 @@ var ConfigCatClientCache = /** @class */ (function () {

if (variationId === setting.variationId) {
return [2 /*return*/, new SettingKeyValue(settingKey, setting.value)];
return [2 /*return*/, new SettingKeyValue(settingKey, ensureAllowedValue(setting.value))];
}

@@ -360,3 +360,3 @@ targetingRules = settings[settingKey].targetingRules;

if (variationId === percentageOption.variationId) {
return [2 /*return*/, new SettingKeyValue(settingKey, percentageOption.value)];
return [2 /*return*/, new SettingKeyValue(settingKey, ensureAllowedValue(percentageOption.value))];
}

@@ -366,3 +366,3 @@ }

else if (variationId === then.variationId) {
return [2 /*return*/, new SettingKeyValue(settingKey, then.value)];
return [2 /*return*/, new SettingKeyValue(settingKey, ensureAllowedValue(then.value))];
}

@@ -376,3 +376,3 @@ }

if (variationId === percentageOption.variationId) {
return [2 /*return*/, new SettingKeyValue(settingKey, percentageOption.value)];
return [2 /*return*/, new SettingKeyValue(settingKey, ensureAllowedValue(percentageOption.value))];
}

@@ -652,2 +652,5 @@ }

}
function ensureAllowedValue(value) {
return isAllowedValue(value) ? value : handleInvalidReturnValue(value);
}
var registerForFinalization = function (client, data) {

@@ -654,0 +657,0 @@ // Use FinalizationRegistry (finalization callbacks) if the runtime provides that feature.

@@ -126,3 +126,3 @@ import { __makeTemplateObject } from "tslib";

LoggerWrapper.prototype.fetchFailedDueToUnexpectedError = function (ex) {
return this.log(LogLevel.Error, 1103, "Unexpected error occurred while trying to fetch config JSON.", ex);
return this.log(LogLevel.Error, 1103, "Unexpected error occurred while trying to fetch config JSON. It is most likely due to a local network issue. Please make sure your application can reach the ConfigCat CDN servers (or your proxy server) over HTTP.", ex);
};

@@ -132,4 +132,4 @@ LoggerWrapper.prototype.fetchFailedDueToRedirectLoop = function () {

};
LoggerWrapper.prototype.fetchReceived200WithInvalidBody = function () {
return this.log(LogLevel.Error, 1105, "Fetching config JSON was successful but the HTTP response content was invalid.");
LoggerWrapper.prototype.fetchReceived200WithInvalidBody = function (ex) {
return this.log(LogLevel.Error, 1105, "Fetching config JSON was successful but the HTTP response content was invalid.", ex);
};

@@ -136,0 +136,0 @@ LoggerWrapper.prototype.fetchReceived304WhenLocalCacheIsEmpty = function (statusCode, reasonPhrase) {

import { __awaiter, __generator } from "tslib";
import { FetchError, FetchResult, FetchStatus } from "./ConfigFetcher";
import { Config, ProjectConfig, RedirectMode } from "./ProjectConfig";
import { RedirectMode } from "./ConfigJson";
import { Config, ProjectConfig } from "./ProjectConfig";
/** Contains the result of an `IConfigCatClient.forceRefresh` or `IConfigCatClient.forceRefreshAsync` operation. */

@@ -145,3 +146,3 @@ var RefreshResult = /** @class */ (function () {

return __awaiter(this, void 0, void 0, function () {
var options, errorMessage, _b, response, config, err_1;
var options, errorMessage, _b, response, configOrError, err_1;
return __generator(this, function (_c) {

@@ -157,12 +158,12 @@ switch (_c.label) {

case 2:
_b = _c.sent(), response = _b[0], config = _b[1];
_b = _c.sent(), response = _b[0], configOrError = _b[1];
switch (response.statusCode) {
case 200: // OK
if (!config) {
errorMessage = options.logger.fetchReceived200WithInvalidBody().toString();
if (!(configOrError instanceof Config)) {
errorMessage = options.logger.fetchReceived200WithInvalidBody(configOrError).toString();
options.logger.debug("ConfigServiceBase.fetchLogicAsync(): " + response.statusCode + " " + response.reasonPhrase + " was received but the HTTP response content was invalid. Returning null.");
return [2 /*return*/, FetchResult.error(lastConfig, errorMessage)];
return [2 /*return*/, FetchResult.error(lastConfig, errorMessage, configOrError)];
}
options.logger.debug("ConfigServiceBase.fetchLogicAsync(): fetch was successful. Returning new config.");
return [2 /*return*/, FetchResult.success(new ProjectConfig(response.body, config, ProjectConfig.generateTimestamp(), response.eTag))];
return [2 /*return*/, FetchResult.success(new ProjectConfig(response.body, configOrError, ProjectConfig.generateTimestamp(), response.eTag))];
case 304: // Not Modified

@@ -220,11 +221,11 @@ if (!lastConfig) {

options.logger.debug("ConfigServiceBase.fetchRequestAsync(): no response body.");
return [2 /*return*/, [response]];
return [2 /*return*/, [response, new Error("No response body.")]];
}
config = void 0;
try {
config = new Config(JSON.parse(response.body));
config = Config.deserialize(response.body);
}
catch (_b) {
catch (err) {
options.logger.debug("ConfigServiceBase.fetchRequestAsync(): invalid response body.");
return [2 /*return*/, [response]];
return [2 /*return*/, [response, err]];
}

@@ -231,0 +232,0 @@ preferences = config.preferences;

@@ -1,2 +0,2 @@

import { PrerequisiteFlagComparator, SegmentComparator, UserComparator } from "./ProjectConfig";
import { PrerequisiteFlagComparator, SegmentComparator, UserComparator } from "./ConfigJson";
import { isAllowedValue } from "./RolloutEvaluator";

@@ -3,0 +3,0 @@ import { formatStringList, isArray } from "./Utils";

@@ -42,3 +42,3 @@ import { ConfigCatClient } from "./ConfigCatClient";

export { FormattableLogMessage } from "./ConfigCatLogger";
export { SettingType, UserComparator, PrerequisiteFlagComparator, SegmentComparator } from "./ProjectConfig";
export { SettingType, UserComparator, PrerequisiteFlagComparator, SegmentComparator } from "./ConfigJson";
export { SettingKeyValue } from "./ConfigCatClient";

@@ -45,0 +45,0 @@ export { User } from "./User";

@@ -58,8 +58,3 @@ import { __extends } from "tslib";

if (slice.length > 0) {
try {
config = new Config(JSON.parse(slice));
}
catch (_a) {
throw new Error("Invalid config JSON content: " + slice);
}
config = Config.deserialize(slice);
configJson = slice;

@@ -87,2 +82,9 @@ }

}
Config.deserialize = function (configJson) {
var configJsonParsed = JSON.parse(configJson);
if (typeof configJsonParsed !== "object" || !configJsonParsed) {
throw new Error("Invalid config JSON content:" + configJson);
}
return new Config(configJsonParsed);
};
Object.defineProperty(Config.prototype, "salt", {

@@ -96,8 +98,2 @@ get: function () { var _a; return (_a = this.preferences) === null || _a === void 0 ? void 0 : _a.salt; },

export { Config };
export var RedirectMode;
(function (RedirectMode) {
RedirectMode[RedirectMode["No"] = 0] = "No";
RedirectMode[RedirectMode["Should"] = 1] = "Should";
RedirectMode[RedirectMode["Force"] = 2] = "Force";
})(RedirectMode || (RedirectMode = {}));
var Preferences = /** @class */ (function () {

@@ -121,18 +117,6 @@ function Preferences(json) {

export { Segment };
/** Setting type. */
export var SettingType;
(function (SettingType) {
/** On/off type (feature flag). */
SettingType[SettingType["Boolean"] = 0] = "Boolean";
/** Text type. */
SettingType[SettingType["String"] = 1] = "String";
/** Whole number type. */
SettingType[SettingType["Int"] = 2] = "Int";
/** Decimal number type. */
SettingType[SettingType["Double"] = 3] = "Double";
})(SettingType || (SettingType = {}));
var SettingValueContainer = /** @class */ (function () {
function SettingValueContainer(json, hasUnwrappedValue) {
if (hasUnwrappedValue === void 0) { hasUnwrappedValue = false; }
this.value = !hasUnwrappedValue ? unwrapSettingValue(json.v) : json.v;
this.value = (!hasUnwrappedValue ? unwrapSettingValue(json.v) : json.v);
this.variationId = json.i;

@@ -191,78 +175,2 @@ }

export { PercentageOption };
/** User Object attribute comparison operator used during the evaluation process. */
export var UserComparator;
(function (UserComparator) {
/** IS ONE OF (cleartext) - It matches when the comparison attribute is equal to any of the comparison values. */
UserComparator[UserComparator["IsOneOf"] = 0] = "IsOneOf";
/** IS NOT ONE OF (cleartext) - It matches when the comparison attribute is not equal to any of the comparison values. */
UserComparator[UserComparator["IsNotOneOf"] = 1] = "IsNotOneOf";
/** CONTAINS ANY OF (cleartext) - It matches when the comparison attribute contains any comparison values as a substring. */
UserComparator[UserComparator["ContainsAnyOf"] = 2] = "ContainsAnyOf";
/** NOT CONTAINS ANY OF (cleartext) - It matches when the comparison attribute does not contain any comparison values as a substring. */
UserComparator[UserComparator["NotContainsAnyOf"] = 3] = "NotContainsAnyOf";
/** IS ONE OF (semver) - It matches when the comparison attribute interpreted as a semantic version is equal to any of the comparison values. */
UserComparator[UserComparator["SemVerIsOneOf"] = 4] = "SemVerIsOneOf";
/** IS NOT ONE OF (semver) - It matches when the comparison attribute interpreted as a semantic version is not equal to any of the comparison values. */
UserComparator[UserComparator["SemVerIsNotOneOf"] = 5] = "SemVerIsNotOneOf";
/** &lt; (semver) - It matches when the comparison attribute interpreted as a semantic version is less than the comparison value. */
UserComparator[UserComparator["SemVerLess"] = 6] = "SemVerLess";
/** &lt;= (semver) - It matches when the comparison attribute interpreted as a semantic version is less than or equal to the comparison value. */
UserComparator[UserComparator["SemVerLessOrEquals"] = 7] = "SemVerLessOrEquals";
/** &gt; (semver) - It matches when the comparison attribute interpreted as a semantic version is greater than the comparison value. */
UserComparator[UserComparator["SemVerGreater"] = 8] = "SemVerGreater";
/** &gt;= (semver) - It matches when the comparison attribute interpreted as a semantic version is greater than or equal to the comparison value. */
UserComparator[UserComparator["SemVerGreaterOrEquals"] = 9] = "SemVerGreaterOrEquals";
/** = (number) - It matches when the comparison attribute interpreted as a decimal number is equal to the comparison value. */
UserComparator[UserComparator["NumberEquals"] = 10] = "NumberEquals";
/** != (number) - It matches when the comparison attribute interpreted as a decimal number is not equal to the comparison value. */
UserComparator[UserComparator["NumberNotEquals"] = 11] = "NumberNotEquals";
/** &lt; (number) - It matches when the comparison attribute interpreted as a decimal number is less than the comparison value. */
UserComparator[UserComparator["NumberLess"] = 12] = "NumberLess";
/** &lt;= (number) - It matches when the comparison attribute interpreted as a decimal number is less than or equal to the comparison value. */
UserComparator[UserComparator["NumberLessOrEquals"] = 13] = "NumberLessOrEquals";
/** &gt; (number) - It matches when the comparison attribute interpreted as a decimal number is greater than the comparison value. */
UserComparator[UserComparator["NumberGreater"] = 14] = "NumberGreater";
/** &gt;= (number) - It matches when the comparison attribute interpreted as a decimal number is greater than or equal to the comparison value. */
UserComparator[UserComparator["NumberGreaterOrEquals"] = 15] = "NumberGreaterOrEquals";
/** IS ONE OF (hashed) - It matches when the comparison attribute is equal to any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveIsOneOf"] = 16] = "SensitiveIsOneOf";
/** IS NOT ONE OF (hashed) - It matches when the comparison attribute is not equal to any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveIsNotOneOf"] = 17] = "SensitiveIsNotOneOf";
/** BEFORE (UTC datetime) - It matches when the comparison attribute interpreted as the seconds elapsed since <see href="https://en.wikipedia.org/wiki/Unix_time">Unix Epoch</see> is less than the comparison value. */
UserComparator[UserComparator["DateTimeBefore"] = 18] = "DateTimeBefore";
/** AFTER (UTC datetime) - It matches when the comparison attribute interpreted as the seconds elapsed since <see href="https://en.wikipedia.org/wiki/Unix_time">Unix Epoch</see> is greater than the comparison value. */
UserComparator[UserComparator["DateTimeAfter"] = 19] = "DateTimeAfter";
/** EQUALS (hashed) - It matches when the comparison attribute is equal to the comparison value (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextEquals"] = 20] = "SensitiveTextEquals";
/** NOT EQUALS (hashed) - It matches when the comparison attribute is not equal to the comparison value (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextNotEquals"] = 21] = "SensitiveTextNotEquals";
/** STARTS WITH ANY OF (hashed) - It matches when the comparison attribute starts with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextStartsWithAnyOf"] = 22] = "SensitiveTextStartsWithAnyOf";
/** NOT STARTS WITH ANY OF (hashed) - It matches when the comparison attribute does not start with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextNotStartsWithAnyOf"] = 23] = "SensitiveTextNotStartsWithAnyOf";
/** ENDS WITH ANY OF (hashed) - It matches when the comparison attribute ends with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextEndsWithAnyOf"] = 24] = "SensitiveTextEndsWithAnyOf";
/** NOT ENDS WITH ANY OF (hashed) - It matches when the comparison attribute does not end with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextNotEndsWithAnyOf"] = 25] = "SensitiveTextNotEndsWithAnyOf";
/** ARRAY CONTAINS ANY OF (hashed) - It matches when the comparison attribute interpreted as a comma-separated list contains any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveArrayContainsAnyOf"] = 26] = "SensitiveArrayContainsAnyOf";
/** ARRAY NOT CONTAINS ANY OF (hashed) - It matches when the comparison attribute interpreted as a comma-separated list does not contain any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveArrayNotContainsAnyOf"] = 27] = "SensitiveArrayNotContainsAnyOf";
/** EQUALS (cleartext) - It matches when the comparison attribute is equal to the comparison value. */
UserComparator[UserComparator["TextEquals"] = 28] = "TextEquals";
/** NOT EQUALS (cleartext) - It matches when the comparison attribute is not equal to the comparison value. */
UserComparator[UserComparator["TextNotEquals"] = 29] = "TextNotEquals";
/** STARTS WITH ANY OF (cleartext) - It matches when the comparison attribute starts with any of the comparison values. */
UserComparator[UserComparator["TextStartsWithAnyOf"] = 30] = "TextStartsWithAnyOf";
/** NOT STARTS WITH ANY OF (cleartext) - It matches when the comparison attribute does not start with any of the comparison values. */
UserComparator[UserComparator["TextNotStartsWithAnyOf"] = 31] = "TextNotStartsWithAnyOf";
/** ENDS WITH ANY OF (cleartext) - It matches when the comparison attribute ends with any of the comparison values. */
UserComparator[UserComparator["TextEndsWithAnyOf"] = 32] = "TextEndsWithAnyOf";
/** NOT ENDS WITH ANY OF (cleartext) - It matches when the comparison attribute does not end with any of the comparison values. */
UserComparator[UserComparator["TextNotEndsWithAnyOf"] = 33] = "TextNotEndsWithAnyOf";
/** ARRAY CONTAINS ANY OF (cleartext) - It matches when the comparison attribute interpreted as a comma-separated list contains any of the comparison values. */
UserComparator[UserComparator["ArrayContainsAnyOf"] = 34] = "ArrayContainsAnyOf";
/** ARRAY NOT CONTAINS ANY OF (cleartext) - It matches when the comparison attribute interpreted as a comma-separated list does not contain any of the comparison values. */
UserComparator[UserComparator["ArrayNotContainsAnyOf"] = 35] = "ArrayNotContainsAnyOf";
})(UserComparator || (UserComparator = {}));
var UserCondition = /** @class */ (function () {

@@ -274,3 +182,3 @@ function UserCondition(json) {

this.comparator = json.c;
this.comparisonValue = (_b = (_a = json.s) !== null && _a !== void 0 ? _a : json.d) !== null && _b !== void 0 ? _b : json.l;
this.comparisonValue = ((_b = (_a = json.s) !== null && _a !== void 0 ? _a : json.d) !== null && _b !== void 0 ? _b : json.l);
}

@@ -280,10 +188,2 @@ return UserCondition;

export { UserCondition };
/** Prerequisite flag comparison operator used during the evaluation process. */
export var PrerequisiteFlagComparator;
(function (PrerequisiteFlagComparator) {
/** EQUALS - It matches when the evaluated value of the specified prerequisite flag is equal to the comparison value. */
PrerequisiteFlagComparator[PrerequisiteFlagComparator["Equals"] = 0] = "Equals";
/** NOT EQUALS - It matches when the evaluated value of the specified prerequisite flag is not equal to the comparison value. */
PrerequisiteFlagComparator[PrerequisiteFlagComparator["NotEquals"] = 1] = "NotEquals";
})(PrerequisiteFlagComparator || (PrerequisiteFlagComparator = {}));
var PrerequisiteFlagCondition = /** @class */ (function () {

@@ -299,10 +199,2 @@ function PrerequisiteFlagCondition(json) {

export { PrerequisiteFlagCondition };
/** Segment comparison operator used during the evaluation process. */
export var SegmentComparator;
(function (SegmentComparator) {
/** IS IN SEGMENT - It matches when the conditions of the specified segment are evaluated to true. */
SegmentComparator[SegmentComparator["IsIn"] = 0] = "IsIn";
/** IS NOT IN SEGMENT - It matches when the conditions of the specified segment are evaluated to false. */
SegmentComparator[SegmentComparator["IsNotIn"] = 1] = "IsNotIn";
})(SegmentComparator || (SegmentComparator = {}));
var SegmentCondition = /** @class */ (function () {

@@ -319,3 +211,3 @@ function SegmentCondition(json, config) {

var _a, _b, _c;
return (_c = (_b = (_a = json.b) !== null && _a !== void 0 ? _a : json.s) !== null && _b !== void 0 ? _b : json.i) !== null && _c !== void 0 ? _c : json.d;
return ((_c = (_b = (_a = json.b) !== null && _a !== void 0 ? _a : json.s) !== null && _b !== void 0 ? _b : json.i) !== null && _c !== void 0 ? _c : json.d);
}
import { LogLevel } from "./ConfigCatLogger";
import { PrerequisiteFlagComparator, SegmentComparator, SettingType, UserComparator } from "./ConfigJson";
import { EvaluateLogBuilder, formatSegmentComparator, formatUserCondition, valueToString } from "./EvaluateLogBuilder";
import { sha1, sha256 } from "./Hash";
import { PrerequisiteFlagComparator, SegmentComparator, SettingType, UserComparator } from "./ProjectConfig";
import { parse as parseSemVer } from "./Semver";

@@ -691,3 +691,3 @@ import { getUserAttributes } from "./User";

}
function handleInvalidReturnValue(value) {
export function handleInvalidReturnValue(value) {
throw new TypeError(value === null ? "Setting value is null." :

@@ -694,0 +694,0 @@ value === void 0 ? "Setting value is undefined." :

@@ -0,3 +1,3 @@

import { PrerequisiteFlagComparator, SegmentComparator, UserComparator } from "./ConfigJson";
import type { PrerequisiteFlagCondition, SegmentCondition, SettingValue, TargetingRule, UserConditionUnion } from "./ProjectConfig";
import { PrerequisiteFlagComparator, SegmentComparator, UserComparator } from "./ProjectConfig";
export declare class EvaluateLogBuilder {

@@ -4,0 +4,0 @@ private log;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.valueToString = exports.formatSegmentComparator = exports.formatPrerequisiteFlagComparator = exports.formatUserCondition = exports.formatUserComparator = exports.EvaluateLogBuilder = void 0;
var ProjectConfig_1 = require("./ProjectConfig");
var ConfigJson_1 = require("./ConfigJson");
var RolloutEvaluator_1 = require("./RolloutEvaluator");

@@ -76,43 +76,43 @@ var Utils_1 = require("./Utils");

switch (condition.comparator) {
case ProjectConfig_1.UserComparator.IsOneOf:
case ProjectConfig_1.UserComparator.IsNotOneOf:
case ProjectConfig_1.UserComparator.ContainsAnyOf:
case ProjectConfig_1.UserComparator.NotContainsAnyOf:
case ProjectConfig_1.UserComparator.SemVerIsOneOf:
case ProjectConfig_1.UserComparator.SemVerIsNotOneOf:
case ProjectConfig_1.UserComparator.TextStartsWithAnyOf:
case ProjectConfig_1.UserComparator.TextNotStartsWithAnyOf:
case ProjectConfig_1.UserComparator.TextEndsWithAnyOf:
case ProjectConfig_1.UserComparator.TextNotEndsWithAnyOf:
case ProjectConfig_1.UserComparator.ArrayContainsAnyOf:
case ProjectConfig_1.UserComparator.ArrayNotContainsAnyOf:
case ConfigJson_1.UserComparator.IsOneOf:
case ConfigJson_1.UserComparator.IsNotOneOf:
case ConfigJson_1.UserComparator.ContainsAnyOf:
case ConfigJson_1.UserComparator.NotContainsAnyOf:
case ConfigJson_1.UserComparator.SemVerIsOneOf:
case ConfigJson_1.UserComparator.SemVerIsNotOneOf:
case ConfigJson_1.UserComparator.TextStartsWithAnyOf:
case ConfigJson_1.UserComparator.TextNotStartsWithAnyOf:
case ConfigJson_1.UserComparator.TextEndsWithAnyOf:
case ConfigJson_1.UserComparator.TextNotEndsWithAnyOf:
case ConfigJson_1.UserComparator.ArrayContainsAnyOf:
case ConfigJson_1.UserComparator.ArrayNotContainsAnyOf:
return this.appendUserConditionStringList(comparisonAttribute, comparator, condition.comparisonValue, false);
case ProjectConfig_1.UserComparator.SemVerLess:
case ProjectConfig_1.UserComparator.SemVerLessOrEquals:
case ProjectConfig_1.UserComparator.SemVerGreater:
case ProjectConfig_1.UserComparator.SemVerGreaterOrEquals:
case ProjectConfig_1.UserComparator.TextEquals:
case ProjectConfig_1.UserComparator.TextNotEquals:
case ConfigJson_1.UserComparator.SemVerLess:
case ConfigJson_1.UserComparator.SemVerLessOrEquals:
case ConfigJson_1.UserComparator.SemVerGreater:
case ConfigJson_1.UserComparator.SemVerGreaterOrEquals:
case ConfigJson_1.UserComparator.TextEquals:
case ConfigJson_1.UserComparator.TextNotEquals:
return this.appendUserConditionString(comparisonAttribute, comparator, condition.comparisonValue, false);
case ProjectConfig_1.UserComparator.NumberEquals:
case ProjectConfig_1.UserComparator.NumberNotEquals:
case ProjectConfig_1.UserComparator.NumberLess:
case ProjectConfig_1.UserComparator.NumberLessOrEquals:
case ProjectConfig_1.UserComparator.NumberGreater:
case ProjectConfig_1.UserComparator.NumberGreaterOrEquals:
case ConfigJson_1.UserComparator.NumberEquals:
case ConfigJson_1.UserComparator.NumberNotEquals:
case ConfigJson_1.UserComparator.NumberLess:
case ConfigJson_1.UserComparator.NumberLessOrEquals:
case ConfigJson_1.UserComparator.NumberGreater:
case ConfigJson_1.UserComparator.NumberGreaterOrEquals:
return this.appendUserConditionNumber(comparisonAttribute, comparator, condition.comparisonValue);
case ProjectConfig_1.UserComparator.SensitiveIsOneOf:
case ProjectConfig_1.UserComparator.SensitiveIsNotOneOf:
case ProjectConfig_1.UserComparator.SensitiveTextStartsWithAnyOf:
case ProjectConfig_1.UserComparator.SensitiveTextNotStartsWithAnyOf:
case ProjectConfig_1.UserComparator.SensitiveTextEndsWithAnyOf:
case ProjectConfig_1.UserComparator.SensitiveTextNotEndsWithAnyOf:
case ProjectConfig_1.UserComparator.SensitiveArrayContainsAnyOf:
case ProjectConfig_1.UserComparator.SensitiveArrayNotContainsAnyOf:
case ConfigJson_1.UserComparator.SensitiveIsOneOf:
case ConfigJson_1.UserComparator.SensitiveIsNotOneOf:
case ConfigJson_1.UserComparator.SensitiveTextStartsWithAnyOf:
case ConfigJson_1.UserComparator.SensitiveTextNotStartsWithAnyOf:
case ConfigJson_1.UserComparator.SensitiveTextEndsWithAnyOf:
case ConfigJson_1.UserComparator.SensitiveTextNotEndsWithAnyOf:
case ConfigJson_1.UserComparator.SensitiveArrayContainsAnyOf:
case ConfigJson_1.UserComparator.SensitiveArrayNotContainsAnyOf:
return this.appendUserConditionStringList(comparisonAttribute, comparator, condition.comparisonValue, true);
case ProjectConfig_1.UserComparator.DateTimeBefore:
case ProjectConfig_1.UserComparator.DateTimeAfter:
case ConfigJson_1.UserComparator.DateTimeBefore:
case ConfigJson_1.UserComparator.DateTimeAfter:
return this.appendUserConditionNumber(comparisonAttribute, comparator, condition.comparisonValue, true);
case ProjectConfig_1.UserComparator.SensitiveTextEquals:
case ProjectConfig_1.UserComparator.SensitiveTextNotEquals:
case ConfigJson_1.UserComparator.SensitiveTextEquals:
case ConfigJson_1.UserComparator.SensitiveTextNotEquals:
return this.appendUserConditionString(comparisonAttribute, comparator, condition.comparisonValue, true);

@@ -157,38 +157,38 @@ default:

switch (comparator) {
case ProjectConfig_1.UserComparator.IsOneOf:
case ProjectConfig_1.UserComparator.SensitiveIsOneOf:
case ProjectConfig_1.UserComparator.SemVerIsOneOf: return "IS ONE OF";
case ProjectConfig_1.UserComparator.IsNotOneOf:
case ProjectConfig_1.UserComparator.SensitiveIsNotOneOf:
case ProjectConfig_1.UserComparator.SemVerIsNotOneOf: return "IS NOT ONE OF";
case ProjectConfig_1.UserComparator.ContainsAnyOf: return "CONTAINS ANY OF";
case ProjectConfig_1.UserComparator.NotContainsAnyOf: return "NOT CONTAINS ANY OF";
case ProjectConfig_1.UserComparator.SemVerLess:
case ProjectConfig_1.UserComparator.NumberLess: return "<";
case ProjectConfig_1.UserComparator.SemVerLessOrEquals:
case ProjectConfig_1.UserComparator.NumberLessOrEquals: return "<=";
case ProjectConfig_1.UserComparator.SemVerGreater:
case ProjectConfig_1.UserComparator.NumberGreater: return ">";
case ProjectConfig_1.UserComparator.SemVerGreaterOrEquals:
case ProjectConfig_1.UserComparator.NumberGreaterOrEquals: return ">=";
case ProjectConfig_1.UserComparator.NumberEquals: return "=";
case ProjectConfig_1.UserComparator.NumberNotEquals: return "!=";
case ProjectConfig_1.UserComparator.DateTimeBefore: return "BEFORE";
case ProjectConfig_1.UserComparator.DateTimeAfter: return "AFTER";
case ProjectConfig_1.UserComparator.TextEquals:
case ProjectConfig_1.UserComparator.SensitiveTextEquals: return "EQUALS";
case ProjectConfig_1.UserComparator.TextNotEquals:
case ProjectConfig_1.UserComparator.SensitiveTextNotEquals: return "NOT EQUALS";
case ProjectConfig_1.UserComparator.TextStartsWithAnyOf:
case ProjectConfig_1.UserComparator.SensitiveTextStartsWithAnyOf: return "STARTS WITH ANY OF";
case ProjectConfig_1.UserComparator.TextNotStartsWithAnyOf:
case ProjectConfig_1.UserComparator.SensitiveTextNotStartsWithAnyOf: return "NOT STARTS WITH ANY OF";
case ProjectConfig_1.UserComparator.TextEndsWithAnyOf:
case ProjectConfig_1.UserComparator.SensitiveTextEndsWithAnyOf: return "ENDS WITH ANY OF";
case ProjectConfig_1.UserComparator.TextNotEndsWithAnyOf:
case ProjectConfig_1.UserComparator.SensitiveTextNotEndsWithAnyOf: return "NOT ENDS WITH ANY OF";
case ProjectConfig_1.UserComparator.ArrayContainsAnyOf:
case ProjectConfig_1.UserComparator.SensitiveArrayContainsAnyOf: return "ARRAY CONTAINS ANY OF";
case ProjectConfig_1.UserComparator.ArrayNotContainsAnyOf:
case ProjectConfig_1.UserComparator.SensitiveArrayNotContainsAnyOf: return "ARRAY NOT CONTAINS ANY OF";
case ConfigJson_1.UserComparator.IsOneOf:
case ConfigJson_1.UserComparator.SensitiveIsOneOf:
case ConfigJson_1.UserComparator.SemVerIsOneOf: return "IS ONE OF";
case ConfigJson_1.UserComparator.IsNotOneOf:
case ConfigJson_1.UserComparator.SensitiveIsNotOneOf:
case ConfigJson_1.UserComparator.SemVerIsNotOneOf: return "IS NOT ONE OF";
case ConfigJson_1.UserComparator.ContainsAnyOf: return "CONTAINS ANY OF";
case ConfigJson_1.UserComparator.NotContainsAnyOf: return "NOT CONTAINS ANY OF";
case ConfigJson_1.UserComparator.SemVerLess:
case ConfigJson_1.UserComparator.NumberLess: return "<";
case ConfigJson_1.UserComparator.SemVerLessOrEquals:
case ConfigJson_1.UserComparator.NumberLessOrEquals: return "<=";
case ConfigJson_1.UserComparator.SemVerGreater:
case ConfigJson_1.UserComparator.NumberGreater: return ">";
case ConfigJson_1.UserComparator.SemVerGreaterOrEquals:
case ConfigJson_1.UserComparator.NumberGreaterOrEquals: return ">=";
case ConfigJson_1.UserComparator.NumberEquals: return "=";
case ConfigJson_1.UserComparator.NumberNotEquals: return "!=";
case ConfigJson_1.UserComparator.DateTimeBefore: return "BEFORE";
case ConfigJson_1.UserComparator.DateTimeAfter: return "AFTER";
case ConfigJson_1.UserComparator.TextEquals:
case ConfigJson_1.UserComparator.SensitiveTextEquals: return "EQUALS";
case ConfigJson_1.UserComparator.TextNotEquals:
case ConfigJson_1.UserComparator.SensitiveTextNotEquals: return "NOT EQUALS";
case ConfigJson_1.UserComparator.TextStartsWithAnyOf:
case ConfigJson_1.UserComparator.SensitiveTextStartsWithAnyOf: return "STARTS WITH ANY OF";
case ConfigJson_1.UserComparator.TextNotStartsWithAnyOf:
case ConfigJson_1.UserComparator.SensitiveTextNotStartsWithAnyOf: return "NOT STARTS WITH ANY OF";
case ConfigJson_1.UserComparator.TextEndsWithAnyOf:
case ConfigJson_1.UserComparator.SensitiveTextEndsWithAnyOf: return "ENDS WITH ANY OF";
case ConfigJson_1.UserComparator.TextNotEndsWithAnyOf:
case ConfigJson_1.UserComparator.SensitiveTextNotEndsWithAnyOf: return "NOT ENDS WITH ANY OF";
case ConfigJson_1.UserComparator.ArrayContainsAnyOf:
case ConfigJson_1.UserComparator.SensitiveArrayContainsAnyOf: return "ARRAY CONTAINS ANY OF";
case ConfigJson_1.UserComparator.ArrayNotContainsAnyOf:
case ConfigJson_1.UserComparator.SensitiveArrayNotContainsAnyOf: return "ARRAY NOT CONTAINS ANY OF";
default: return invalidOperatorPlaceholder;

@@ -204,4 +204,4 @@ }

switch (comparator) {
case ProjectConfig_1.PrerequisiteFlagComparator.Equals: return "EQUALS";
case ProjectConfig_1.PrerequisiteFlagComparator.NotEquals: return "NOT EQUALS";
case ConfigJson_1.PrerequisiteFlagComparator.Equals: return "EQUALS";
case ConfigJson_1.PrerequisiteFlagComparator.NotEquals: return "NOT EQUALS";
default: return invalidOperatorPlaceholder;

@@ -213,4 +213,4 @@ }

switch (comparator) {
case ProjectConfig_1.SegmentComparator.IsIn: return "IS IN SEGMENT";
case ProjectConfig_1.SegmentComparator.IsNotIn: return "IS NOT IN SEGMENT";
case ConfigJson_1.SegmentComparator.IsIn: return "IS IN SEGMENT";
case ConfigJson_1.SegmentComparator.IsNotIn: return "IS NOT IN SEGMENT";
default: return invalidOperatorPlaceholder;

@@ -217,0 +217,0 @@ }

@@ -45,3 +45,3 @@ import type { IConfigCatClient, IConfigCatKernel } from "./ConfigCatClient";

export type { IConfig, ISegment, SettingTypeMap, SettingValue, VariationIdValue, ISettingValueContainer, ISettingUnion, ISetting, ITargetingRule, IPercentageOption, ConditionTypeMap, IConditionUnion, ICondition, UserConditionComparisonValueTypeMap, IUserConditionUnion, IUserCondition, IPrerequisiteFlagCondition, ISegmentCondition } from "./ProjectConfig";
export { SettingType, UserComparator, PrerequisiteFlagComparator, SegmentComparator } from "./ProjectConfig";
export { SettingType, UserComparator, PrerequisiteFlagComparator, SegmentComparator } from "./ConfigJson";
export type { IConfigCatClient };

@@ -48,0 +48,0 @@ export type { IConfigCatClientSnapshot } from "./ConfigCatClient";

@@ -53,7 +53,7 @@ "use strict";

Object.defineProperty(exports, "FormattableLogMessage", { enumerable: true, get: function () { return ConfigCatLogger_2.FormattableLogMessage; } });
var ProjectConfig_1 = require("./ProjectConfig");
Object.defineProperty(exports, "SettingType", { enumerable: true, get: function () { return ProjectConfig_1.SettingType; } });
Object.defineProperty(exports, "UserComparator", { enumerable: true, get: function () { return ProjectConfig_1.UserComparator; } });
Object.defineProperty(exports, "PrerequisiteFlagComparator", { enumerable: true, get: function () { return ProjectConfig_1.PrerequisiteFlagComparator; } });
Object.defineProperty(exports, "SegmentComparator", { enumerable: true, get: function () { return ProjectConfig_1.SegmentComparator; } });
var ConfigJson_1 = require("./ConfigJson");
Object.defineProperty(exports, "SettingType", { enumerable: true, get: function () { return ConfigJson_1.SettingType; } });
Object.defineProperty(exports, "UserComparator", { enumerable: true, get: function () { return ConfigJson_1.UserComparator; } });
Object.defineProperty(exports, "PrerequisiteFlagComparator", { enumerable: true, get: function () { return ConfigJson_1.PrerequisiteFlagComparator; } });
Object.defineProperty(exports, "SegmentComparator", { enumerable: true, get: function () { return ConfigJson_1.SegmentComparator; } });
var ConfigCatClient_2 = require("./ConfigCatClient");

@@ -60,0 +60,0 @@ Object.defineProperty(exports, "SettingKeyValue", { enumerable: true, get: function () { return ConfigCatClient_2.SettingKeyValue; } });

@@ -0,1 +1,3 @@

import type * as ConfigJson from "./ConfigJson";
import type { PrerequisiteFlagComparator, RedirectMode, SegmentComparator, SettingType, UserComparator } from "./ConfigJson";
export declare class ProjectConfig {

@@ -29,2 +31,3 @@ readonly configJson: string | undefined;

export declare class Config implements IConfig {
static deserialize(configJson: string): Config;
readonly preferences: Preferences | undefined;

@@ -35,10 +38,5 @@ readonly segments: ReadonlyArray<Segment>;

}>;
constructor(json: any);
constructor(json: Partial<ConfigJson.Config>);
get salt(): string | undefined;
}
export declare enum RedirectMode {
No = 0,
Should = 1,
Force = 2
}
export declare class Preferences {

@@ -48,3 +46,3 @@ readonly baseUrl: string | undefined;

readonly salt: string | undefined;
constructor(json: any);
constructor(json: ConfigJson.Preferences);
}

@@ -61,15 +59,4 @@ /** Describes a segment. */

readonly conditions: ReadonlyArray<UserConditionUnion>;
constructor(json: any);
constructor(json: ConfigJson.Segment);
}
/** Setting type. */
export declare enum SettingType {
/** On/off type (feature flag). */
Boolean = 0,
/** Text type. */
String = 1,
/** Whole number type. */
Int = 2,
/** Decimal number type. */
Double = 3
}
export declare type SettingTypeMap = {

@@ -84,12 +71,12 @@ [SettingType.Boolean]: boolean;

/** A model object which contains a setting value along with related data. */
export interface ISettingValueContainer<TValue extends NonNullable<SettingValue> = NonNullable<SettingValue>> {
export interface ISettingValueContainer<TSetting extends SettingType = SettingType> {
/** Setting value. */
readonly value: TValue;
readonly value: SettingTypeMap[TSetting];
/** Variation ID. */
readonly variationId?: NonNullable<VariationIdValue>;
}
export declare class SettingValueContainer<TValue extends NonNullable<SettingValue> = NonNullable<SettingValue>> implements ISettingValueContainer<TValue> {
readonly value: TValue;
export declare class SettingValueContainer<TSetting extends SettingType = SettingType> implements ISettingValueContainer<TSetting> {
readonly value: SettingTypeMap[TSetting];
readonly variationId?: NonNullable<VariationIdValue>;
constructor(json: any, hasUnwrappedValue?: boolean);
constructor(json: ConfigJson.ServedValue, hasUnwrappedValue?: boolean);
}

@@ -100,11 +87,11 @@ export declare type ISettingUnion = {

/** Feature flag or setting. */
export interface ISetting<T extends SettingType = SettingType> extends ISettingValueContainer<SettingTypeMap[T]> {
export interface ISetting<TSetting extends SettingType = SettingType> extends ISettingValueContainer<TSetting> {
/** Setting type. */
readonly type: T;
readonly type: TSetting;
/** The User Object attribute which serves as the basis of percentage options evaluation. */
readonly percentageOptionsAttribute: string;
/** The array of targeting rules (where there is a logical OR relation between the items). */
readonly targetingRules: ReadonlyArray<ITargetingRule>;
readonly targetingRules: ReadonlyArray<ITargetingRule<TSetting>>;
/** The array of percentage options. */
readonly percentageOptions: ReadonlyArray<IPercentageOption>;
readonly percentageOptions: ReadonlyArray<IPercentageOption<TSetting>>;
}

@@ -114,31 +101,31 @@ export declare type SettingUnion = {

}[SettingType];
export declare class Setting<T extends SettingType = SettingType> extends SettingValueContainer<SettingTypeMap[T]> implements ISetting {
readonly type: T;
export declare class Setting<TSetting extends SettingType = SettingType> extends SettingValueContainer<TSetting> implements ISetting<TSetting> {
readonly type: TSetting;
readonly percentageOptionsAttribute: string;
readonly targetingRules: ReadonlyArray<TargetingRule<SettingTypeMap[T]>>;
readonly percentageOptions: ReadonlyArray<PercentageOption<SettingTypeMap[T]>>;
readonly targetingRules: ReadonlyArray<TargetingRule<TSetting>>;
readonly percentageOptions: ReadonlyArray<PercentageOption<TSetting>>;
readonly configJsonSalt: string;
constructor(json: any, config?: Config);
constructor(json: ConfigJson.Setting<TSetting>, config?: Config);
static fromValue(value: NonNullable<SettingValue>): Setting;
}
/** Describes a targeting rule. */
export interface ITargetingRule<TValue extends NonNullable<SettingValue> = NonNullable<SettingValue>> {
export interface ITargetingRule<TSetting extends SettingType = SettingType> {
/** The array of conditions that are combined with the AND logical operator. (The IF part of the targeting rule.) */
readonly conditions: ReadonlyArray<IConditionUnion>;
/** The simple value or the array of percentage options associated with the targeting rule. (The THEN part of the targeting rule.) */
readonly then: ISettingValueContainer<TValue> | ReadonlyArray<IPercentageOption<TValue>>;
readonly then: ISettingValueContainer<TSetting> | ReadonlyArray<IPercentageOption<TSetting>>;
}
export declare class TargetingRule<TValue extends NonNullable<SettingValue> = NonNullable<SettingValue>> implements ITargetingRule {
export declare class TargetingRule<TSetting extends SettingType = SettingType> implements ITargetingRule<TSetting> {
readonly conditions: ReadonlyArray<ConditionUnion>;
readonly then: SettingValueContainer<TValue> | ReadonlyArray<PercentageOption<TValue>>;
constructor(json: any, config: Config);
readonly then: SettingValueContainer<TSetting> | ReadonlyArray<PercentageOption<TSetting>>;
constructor(json: ConfigJson.TargetingRule<TSetting>, config: Config);
}
/** Represents a percentage option. */
export interface IPercentageOption<TValue extends NonNullable<SettingValue> = NonNullable<SettingValue>> extends ISettingValueContainer<TValue> {
export interface IPercentageOption<TSetting extends SettingType = SettingType> extends ISettingValueContainer<TSetting> {
/** A number between 0 and 100 that represents a randomly allocated fraction of the users. */
readonly percentage: number;
}
export declare class PercentageOption<TValue extends NonNullable<SettingValue> = NonNullable<SettingValue>> extends SettingValueContainer<TValue> implements IPercentageOption {
export declare class PercentageOption<TSetting extends SettingType = SettingType> extends SettingValueContainer<TSetting> implements IPercentageOption<TSetting> {
readonly percentage: number;
constructor(json: any);
constructor(json: ConfigJson.PercentageOption<TSetting>);
}

@@ -152,82 +139,7 @@ export declare type ConditionTypeMap = {

/** Represents a condition. */
export interface ICondition<T extends keyof ConditionTypeMap = keyof ConditionTypeMap> {
export interface ICondition<TCondition extends keyof ConditionTypeMap = keyof ConditionTypeMap> {
/** The type of the condition. */
readonly type: T;
readonly type: TCondition;
}
export declare type ConditionUnion = UserConditionUnion | PrerequisiteFlagCondition | SegmentCondition;
/** User Object attribute comparison operator used during the evaluation process. */
export declare enum UserComparator {
/** IS ONE OF (cleartext) - It matches when the comparison attribute is equal to any of the comparison values. */
IsOneOf = 0,
/** IS NOT ONE OF (cleartext) - It matches when the comparison attribute is not equal to any of the comparison values. */
IsNotOneOf = 1,
/** CONTAINS ANY OF (cleartext) - It matches when the comparison attribute contains any comparison values as a substring. */
ContainsAnyOf = 2,
/** NOT CONTAINS ANY OF (cleartext) - It matches when the comparison attribute does not contain any comparison values as a substring. */
NotContainsAnyOf = 3,
/** IS ONE OF (semver) - It matches when the comparison attribute interpreted as a semantic version is equal to any of the comparison values. */
SemVerIsOneOf = 4,
/** IS NOT ONE OF (semver) - It matches when the comparison attribute interpreted as a semantic version is not equal to any of the comparison values. */
SemVerIsNotOneOf = 5,
/** &lt; (semver) - It matches when the comparison attribute interpreted as a semantic version is less than the comparison value. */
SemVerLess = 6,
/** &lt;= (semver) - It matches when the comparison attribute interpreted as a semantic version is less than or equal to the comparison value. */
SemVerLessOrEquals = 7,
/** &gt; (semver) - It matches when the comparison attribute interpreted as a semantic version is greater than the comparison value. */
SemVerGreater = 8,
/** &gt;= (semver) - It matches when the comparison attribute interpreted as a semantic version is greater than or equal to the comparison value. */
SemVerGreaterOrEquals = 9,
/** = (number) - It matches when the comparison attribute interpreted as a decimal number is equal to the comparison value. */
NumberEquals = 10,
/** != (number) - It matches when the comparison attribute interpreted as a decimal number is not equal to the comparison value. */
NumberNotEquals = 11,
/** &lt; (number) - It matches when the comparison attribute interpreted as a decimal number is less than the comparison value. */
NumberLess = 12,
/** &lt;= (number) - It matches when the comparison attribute interpreted as a decimal number is less than or equal to the comparison value. */
NumberLessOrEquals = 13,
/** &gt; (number) - It matches when the comparison attribute interpreted as a decimal number is greater than the comparison value. */
NumberGreater = 14,
/** &gt;= (number) - It matches when the comparison attribute interpreted as a decimal number is greater than or equal to the comparison value. */
NumberGreaterOrEquals = 15,
/** IS ONE OF (hashed) - It matches when the comparison attribute is equal to any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
SensitiveIsOneOf = 16,
/** IS NOT ONE OF (hashed) - It matches when the comparison attribute is not equal to any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
SensitiveIsNotOneOf = 17,
/** BEFORE (UTC datetime) - It matches when the comparison attribute interpreted as the seconds elapsed since <see href="https://en.wikipedia.org/wiki/Unix_time">Unix Epoch</see> is less than the comparison value. */
DateTimeBefore = 18,
/** AFTER (UTC datetime) - It matches when the comparison attribute interpreted as the seconds elapsed since <see href="https://en.wikipedia.org/wiki/Unix_time">Unix Epoch</see> is greater than the comparison value. */
DateTimeAfter = 19,
/** EQUALS (hashed) - It matches when the comparison attribute is equal to the comparison value (where the comparison is performed using the salted SHA256 hashes of the values). */
SensitiveTextEquals = 20,
/** NOT EQUALS (hashed) - It matches when the comparison attribute is not equal to the comparison value (where the comparison is performed using the salted SHA256 hashes of the values). */
SensitiveTextNotEquals = 21,
/** STARTS WITH ANY OF (hashed) - It matches when the comparison attribute starts with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
SensitiveTextStartsWithAnyOf = 22,
/** NOT STARTS WITH ANY OF (hashed) - It matches when the comparison attribute does not start with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
SensitiveTextNotStartsWithAnyOf = 23,
/** ENDS WITH ANY OF (hashed) - It matches when the comparison attribute ends with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
SensitiveTextEndsWithAnyOf = 24,
/** NOT ENDS WITH ANY OF (hashed) - It matches when the comparison attribute does not end with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
SensitiveTextNotEndsWithAnyOf = 25,
/** ARRAY CONTAINS ANY OF (hashed) - It matches when the comparison attribute interpreted as a comma-separated list contains any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
SensitiveArrayContainsAnyOf = 26,
/** ARRAY NOT CONTAINS ANY OF (hashed) - It matches when the comparison attribute interpreted as a comma-separated list does not contain any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
SensitiveArrayNotContainsAnyOf = 27,
/** EQUALS (cleartext) - It matches when the comparison attribute is equal to the comparison value. */
TextEquals = 28,
/** NOT EQUALS (cleartext) - It matches when the comparison attribute is not equal to the comparison value. */
TextNotEquals = 29,
/** STARTS WITH ANY OF (cleartext) - It matches when the comparison attribute starts with any of the comparison values. */
TextStartsWithAnyOf = 30,
/** NOT STARTS WITH ANY OF (cleartext) - It matches when the comparison attribute does not start with any of the comparison values. */
TextNotStartsWithAnyOf = 31,
/** ENDS WITH ANY OF (cleartext) - It matches when the comparison attribute ends with any of the comparison values. */
TextEndsWithAnyOf = 32,
/** NOT ENDS WITH ANY OF (cleartext) - It matches when the comparison attribute does not end with any of the comparison values. */
TextNotEndsWithAnyOf = 33,
/** ARRAY CONTAINS ANY OF (cleartext) - It matches when the comparison attribute interpreted as a comma-separated list contains any of the comparison values. */
ArrayContainsAnyOf = 34,
/** ARRAY NOT CONTAINS ANY OF (cleartext) - It matches when the comparison attribute interpreted as a comma-separated list does not contain any of the comparison values. */
ArrayNotContainsAnyOf = 35
}
export declare type UserConditionComparisonValueTypeMap = {

@@ -291,11 +203,4 @@ [UserComparator.IsOneOf]: Readonly<string[]>;

readonly comparisonValue: UserConditionComparisonValueTypeMap[TComparator];
constructor(json: any);
constructor(json: ConfigJson.UserCondition<TComparator>);
}
/** Prerequisite flag comparison operator used during the evaluation process. */
export declare enum PrerequisiteFlagComparator {
/** EQUALS - It matches when the evaluated value of the specified prerequisite flag is equal to the comparison value. */
Equals = 0,
/** NOT EQUALS - It matches when the evaluated value of the specified prerequisite flag is not equal to the comparison value. */
NotEquals = 1
}
/** Describes a condition that is based on a prerequisite flag. */

@@ -315,11 +220,4 @@ export interface IPrerequisiteFlagCondition extends ICondition<"PrerequisiteFlagCondition"> {

readonly comparisonValue: NonNullable<SettingValue>;
constructor(json: any);
constructor(json: ConfigJson.PrerequisiteFlagCondition);
}
/** Segment comparison operator used during the evaluation process. */
export declare enum SegmentComparator {
/** IS IN SEGMENT - It matches when the conditions of the specified segment are evaluated to true. */
IsIn = 0,
/** IS NOT IN SEGMENT - It matches when the conditions of the specified segment are evaluated to false. */
IsNotIn = 1
}
/** Describes a condition that is based on a segment. */

@@ -336,4 +234,4 @@ export interface ISegmentCondition extends ICondition<"SegmentCondition"> {

readonly comparator: SegmentComparator;
constructor(json: any, config: Config);
constructor(json: ConfigJson.SegmentCondition, config: Config);
}
//# sourceMappingURL=ProjectConfig.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SegmentCondition = exports.SegmentComparator = exports.PrerequisiteFlagCondition = exports.PrerequisiteFlagComparator = exports.UserCondition = exports.UserComparator = exports.PercentageOption = exports.TargetingRule = exports.Setting = exports.SettingValueContainer = exports.SettingType = exports.Segment = exports.Preferences = exports.RedirectMode = exports.Config = exports.ProjectConfig = void 0;
exports.SegmentCondition = exports.PrerequisiteFlagCondition = exports.UserCondition = exports.PercentageOption = exports.TargetingRule = exports.Setting = exports.SettingValueContainer = exports.Segment = exports.Preferences = exports.Config = exports.ProjectConfig = void 0;
var tslib_1 = require("tslib");

@@ -61,8 +61,3 @@ var ProjectConfig = /** @class */ (function () {

if (slice.length > 0) {
try {
config = new Config(JSON.parse(slice));
}
catch (_a) {
throw new Error("Invalid config JSON content: " + slice);
}
config = Config.deserialize(slice);
configJson = slice;

@@ -90,2 +85,9 @@ }

}
Config.deserialize = function (configJson) {
var configJsonParsed = JSON.parse(configJson);
if (typeof configJsonParsed !== "object" || !configJsonParsed) {
throw new Error("Invalid config JSON content:" + configJson);
}
return new Config(configJsonParsed);
};
Object.defineProperty(Config.prototype, "salt", {

@@ -99,8 +101,2 @@ get: function () { var _a; return (_a = this.preferences) === null || _a === void 0 ? void 0 : _a.salt; },

exports.Config = Config;
var RedirectMode;
(function (RedirectMode) {
RedirectMode[RedirectMode["No"] = 0] = "No";
RedirectMode[RedirectMode["Should"] = 1] = "Should";
RedirectMode[RedirectMode["Force"] = 2] = "Force";
})(RedirectMode = exports.RedirectMode || (exports.RedirectMode = {}));
var Preferences = /** @class */ (function () {

@@ -124,18 +120,6 @@ function Preferences(json) {

exports.Segment = Segment;
/** Setting type. */
var SettingType;
(function (SettingType) {
/** On/off type (feature flag). */
SettingType[SettingType["Boolean"] = 0] = "Boolean";
/** Text type. */
SettingType[SettingType["String"] = 1] = "String";
/** Whole number type. */
SettingType[SettingType["Int"] = 2] = "Int";
/** Decimal number type. */
SettingType[SettingType["Double"] = 3] = "Double";
})(SettingType = exports.SettingType || (exports.SettingType = {}));
var SettingValueContainer = /** @class */ (function () {
function SettingValueContainer(json, hasUnwrappedValue) {
if (hasUnwrappedValue === void 0) { hasUnwrappedValue = false; }
this.value = !hasUnwrappedValue ? unwrapSettingValue(json.v) : json.v;
this.value = (!hasUnwrappedValue ? unwrapSettingValue(json.v) : json.v);
this.variationId = json.i;

@@ -194,78 +178,2 @@ }

exports.PercentageOption = PercentageOption;
/** User Object attribute comparison operator used during the evaluation process. */
var UserComparator;
(function (UserComparator) {
/** IS ONE OF (cleartext) - It matches when the comparison attribute is equal to any of the comparison values. */
UserComparator[UserComparator["IsOneOf"] = 0] = "IsOneOf";
/** IS NOT ONE OF (cleartext) - It matches when the comparison attribute is not equal to any of the comparison values. */
UserComparator[UserComparator["IsNotOneOf"] = 1] = "IsNotOneOf";
/** CONTAINS ANY OF (cleartext) - It matches when the comparison attribute contains any comparison values as a substring. */
UserComparator[UserComparator["ContainsAnyOf"] = 2] = "ContainsAnyOf";
/** NOT CONTAINS ANY OF (cleartext) - It matches when the comparison attribute does not contain any comparison values as a substring. */
UserComparator[UserComparator["NotContainsAnyOf"] = 3] = "NotContainsAnyOf";
/** IS ONE OF (semver) - It matches when the comparison attribute interpreted as a semantic version is equal to any of the comparison values. */
UserComparator[UserComparator["SemVerIsOneOf"] = 4] = "SemVerIsOneOf";
/** IS NOT ONE OF (semver) - It matches when the comparison attribute interpreted as a semantic version is not equal to any of the comparison values. */
UserComparator[UserComparator["SemVerIsNotOneOf"] = 5] = "SemVerIsNotOneOf";
/** &lt; (semver) - It matches when the comparison attribute interpreted as a semantic version is less than the comparison value. */
UserComparator[UserComparator["SemVerLess"] = 6] = "SemVerLess";
/** &lt;= (semver) - It matches when the comparison attribute interpreted as a semantic version is less than or equal to the comparison value. */
UserComparator[UserComparator["SemVerLessOrEquals"] = 7] = "SemVerLessOrEquals";
/** &gt; (semver) - It matches when the comparison attribute interpreted as a semantic version is greater than the comparison value. */
UserComparator[UserComparator["SemVerGreater"] = 8] = "SemVerGreater";
/** &gt;= (semver) - It matches when the comparison attribute interpreted as a semantic version is greater than or equal to the comparison value. */
UserComparator[UserComparator["SemVerGreaterOrEquals"] = 9] = "SemVerGreaterOrEquals";
/** = (number) - It matches when the comparison attribute interpreted as a decimal number is equal to the comparison value. */
UserComparator[UserComparator["NumberEquals"] = 10] = "NumberEquals";
/** != (number) - It matches when the comparison attribute interpreted as a decimal number is not equal to the comparison value. */
UserComparator[UserComparator["NumberNotEquals"] = 11] = "NumberNotEquals";
/** &lt; (number) - It matches when the comparison attribute interpreted as a decimal number is less than the comparison value. */
UserComparator[UserComparator["NumberLess"] = 12] = "NumberLess";
/** &lt;= (number) - It matches when the comparison attribute interpreted as a decimal number is less than or equal to the comparison value. */
UserComparator[UserComparator["NumberLessOrEquals"] = 13] = "NumberLessOrEquals";
/** &gt; (number) - It matches when the comparison attribute interpreted as a decimal number is greater than the comparison value. */
UserComparator[UserComparator["NumberGreater"] = 14] = "NumberGreater";
/** &gt;= (number) - It matches when the comparison attribute interpreted as a decimal number is greater than or equal to the comparison value. */
UserComparator[UserComparator["NumberGreaterOrEquals"] = 15] = "NumberGreaterOrEquals";
/** IS ONE OF (hashed) - It matches when the comparison attribute is equal to any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveIsOneOf"] = 16] = "SensitiveIsOneOf";
/** IS NOT ONE OF (hashed) - It matches when the comparison attribute is not equal to any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveIsNotOneOf"] = 17] = "SensitiveIsNotOneOf";
/** BEFORE (UTC datetime) - It matches when the comparison attribute interpreted as the seconds elapsed since <see href="https://en.wikipedia.org/wiki/Unix_time">Unix Epoch</see> is less than the comparison value. */
UserComparator[UserComparator["DateTimeBefore"] = 18] = "DateTimeBefore";
/** AFTER (UTC datetime) - It matches when the comparison attribute interpreted as the seconds elapsed since <see href="https://en.wikipedia.org/wiki/Unix_time">Unix Epoch</see> is greater than the comparison value. */
UserComparator[UserComparator["DateTimeAfter"] = 19] = "DateTimeAfter";
/** EQUALS (hashed) - It matches when the comparison attribute is equal to the comparison value (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextEquals"] = 20] = "SensitiveTextEquals";
/** NOT EQUALS (hashed) - It matches when the comparison attribute is not equal to the comparison value (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextNotEquals"] = 21] = "SensitiveTextNotEquals";
/** STARTS WITH ANY OF (hashed) - It matches when the comparison attribute starts with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextStartsWithAnyOf"] = 22] = "SensitiveTextStartsWithAnyOf";
/** NOT STARTS WITH ANY OF (hashed) - It matches when the comparison attribute does not start with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextNotStartsWithAnyOf"] = 23] = "SensitiveTextNotStartsWithAnyOf";
/** ENDS WITH ANY OF (hashed) - It matches when the comparison attribute ends with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextEndsWithAnyOf"] = 24] = "SensitiveTextEndsWithAnyOf";
/** NOT ENDS WITH ANY OF (hashed) - It matches when the comparison attribute does not end with any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveTextNotEndsWithAnyOf"] = 25] = "SensitiveTextNotEndsWithAnyOf";
/** ARRAY CONTAINS ANY OF (hashed) - It matches when the comparison attribute interpreted as a comma-separated list contains any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveArrayContainsAnyOf"] = 26] = "SensitiveArrayContainsAnyOf";
/** ARRAY NOT CONTAINS ANY OF (hashed) - It matches when the comparison attribute interpreted as a comma-separated list does not contain any of the comparison values (where the comparison is performed using the salted SHA256 hashes of the values). */
UserComparator[UserComparator["SensitiveArrayNotContainsAnyOf"] = 27] = "SensitiveArrayNotContainsAnyOf";
/** EQUALS (cleartext) - It matches when the comparison attribute is equal to the comparison value. */
UserComparator[UserComparator["TextEquals"] = 28] = "TextEquals";
/** NOT EQUALS (cleartext) - It matches when the comparison attribute is not equal to the comparison value. */
UserComparator[UserComparator["TextNotEquals"] = 29] = "TextNotEquals";
/** STARTS WITH ANY OF (cleartext) - It matches when the comparison attribute starts with any of the comparison values. */
UserComparator[UserComparator["TextStartsWithAnyOf"] = 30] = "TextStartsWithAnyOf";
/** NOT STARTS WITH ANY OF (cleartext) - It matches when the comparison attribute does not start with any of the comparison values. */
UserComparator[UserComparator["TextNotStartsWithAnyOf"] = 31] = "TextNotStartsWithAnyOf";
/** ENDS WITH ANY OF (cleartext) - It matches when the comparison attribute ends with any of the comparison values. */
UserComparator[UserComparator["TextEndsWithAnyOf"] = 32] = "TextEndsWithAnyOf";
/** NOT ENDS WITH ANY OF (cleartext) - It matches when the comparison attribute does not end with any of the comparison values. */
UserComparator[UserComparator["TextNotEndsWithAnyOf"] = 33] = "TextNotEndsWithAnyOf";
/** ARRAY CONTAINS ANY OF (cleartext) - It matches when the comparison attribute interpreted as a comma-separated list contains any of the comparison values. */
UserComparator[UserComparator["ArrayContainsAnyOf"] = 34] = "ArrayContainsAnyOf";
/** ARRAY NOT CONTAINS ANY OF (cleartext) - It matches when the comparison attribute interpreted as a comma-separated list does not contain any of the comparison values. */
UserComparator[UserComparator["ArrayNotContainsAnyOf"] = 35] = "ArrayNotContainsAnyOf";
})(UserComparator = exports.UserComparator || (exports.UserComparator = {}));
var UserCondition = /** @class */ (function () {

@@ -277,3 +185,3 @@ function UserCondition(json) {

this.comparator = json.c;
this.comparisonValue = (_b = (_a = json.s) !== null && _a !== void 0 ? _a : json.d) !== null && _b !== void 0 ? _b : json.l;
this.comparisonValue = ((_b = (_a = json.s) !== null && _a !== void 0 ? _a : json.d) !== null && _b !== void 0 ? _b : json.l);
}

@@ -283,10 +191,2 @@ return UserCondition;

exports.UserCondition = UserCondition;
/** Prerequisite flag comparison operator used during the evaluation process. */
var PrerequisiteFlagComparator;
(function (PrerequisiteFlagComparator) {
/** EQUALS - It matches when the evaluated value of the specified prerequisite flag is equal to the comparison value. */
PrerequisiteFlagComparator[PrerequisiteFlagComparator["Equals"] = 0] = "Equals";
/** NOT EQUALS - It matches when the evaluated value of the specified prerequisite flag is not equal to the comparison value. */
PrerequisiteFlagComparator[PrerequisiteFlagComparator["NotEquals"] = 1] = "NotEquals";
})(PrerequisiteFlagComparator = exports.PrerequisiteFlagComparator || (exports.PrerequisiteFlagComparator = {}));
var PrerequisiteFlagCondition = /** @class */ (function () {

@@ -302,10 +202,2 @@ function PrerequisiteFlagCondition(json) {

exports.PrerequisiteFlagCondition = PrerequisiteFlagCondition;
/** Segment comparison operator used during the evaluation process. */
var SegmentComparator;
(function (SegmentComparator) {
/** IS IN SEGMENT - It matches when the conditions of the specified segment are evaluated to true. */
SegmentComparator[SegmentComparator["IsIn"] = 0] = "IsIn";
/** IS NOT IN SEGMENT - It matches when the conditions of the specified segment are evaluated to false. */
SegmentComparator[SegmentComparator["IsNotIn"] = 1] = "IsNotIn";
})(SegmentComparator = exports.SegmentComparator || (exports.SegmentComparator = {}));
var SegmentCondition = /** @class */ (function () {

@@ -322,3 +214,3 @@ function SegmentCondition(json, config) {

var _a, _b, _c;
return (_c = (_b = (_a = json.b) !== null && _a !== void 0 ? _a : json.s) !== null && _b !== void 0 ? _b : json.i) !== null && _c !== void 0 ? _c : json.d;
return ((_c = (_b = (_a = json.b) !== null && _a !== void 0 ? _a : json.s) !== null && _b !== void 0 ? _b : json.i) !== null && _c !== void 0 ? _c : json.d);
}

@@ -62,3 +62,3 @@ import type { LoggerWrapper } from "./ConfigCatLogger";

/** The evaluated value and additional information about the evaluation of a feature flag or setting. */
export interface IEvaluationDetails<TValue = SettingValue> {
export interface IEvaluationDetails<TValue extends SettingValue = SettingValue> {
/** Key of the feature flag or setting. */

@@ -101,3 +101,4 @@ key: string;

export declare function isAllowedValue(value: unknown): value is NonNullable<SettingValue>;
export declare function handleInvalidReturnValue(value: unknown): never;
export declare function getTimestampAsDate(projectConfig: ProjectConfig | null): Date | undefined;
//# sourceMappingURL=RolloutEvaluator.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTimestampAsDate = exports.isAllowedValue = exports.checkSettingsAvailable = exports.evaluateAll = exports.evaluate = exports.evaluationDetailsFromDefaultValue = exports.isStringArray = exports.RolloutEvaluator = exports.EvaluateContext = void 0;
exports.getTimestampAsDate = exports.handleInvalidReturnValue = exports.isAllowedValue = exports.checkSettingsAvailable = exports.evaluateAll = exports.evaluate = exports.evaluationDetailsFromDefaultValue = exports.isStringArray = exports.RolloutEvaluator = exports.EvaluateContext = void 0;
var ConfigCatLogger_1 = require("./ConfigCatLogger");
var ConfigJson_1 = require("./ConfigJson");
var EvaluateLogBuilder_1 = require("./EvaluateLogBuilder");
var Hash_1 = require("./Hash");
var ProjectConfig_1 = require("./ProjectConfig");
var Semver_1 = require("./Semver");

@@ -70,4 +70,4 @@ var User_1 = require("./User");

throw new TypeError("The type of a setting must match the type of the specified default value. "
+ ("Setting's type was " + ProjectConfig_1.SettingType[settingType] + " but the default value's type was " + typeof defaultValue + ". ")
+ ("Please use a default value which corresponds to the setting type " + ProjectConfig_1.SettingType[settingType] + ". ")
+ ("Setting's type was " + ConfigJson_1.SettingType[settingType] + " but the default value's type was " + typeof defaultValue + ". ")
+ ("Please use a default value which corresponds to the setting type " + ConfigJson_1.SettingType[settingType] + ". ")
+ "Learn more: https://configcat.com/docs/sdk-reference/js/#setting-type-mapping");

@@ -247,48 +247,48 @@ }

switch (condition.comparator) {
case ProjectConfig_1.UserComparator.TextEquals:
case ProjectConfig_1.UserComparator.TextNotEquals:
case ConfigJson_1.UserComparator.TextEquals:
case ConfigJson_1.UserComparator.TextNotEquals:
text = getUserAttributeValueAsText(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return this.evaluateTextEquals(text, condition.comparisonValue, condition.comparator === ProjectConfig_1.UserComparator.TextNotEquals);
case ProjectConfig_1.UserComparator.SensitiveTextEquals:
case ProjectConfig_1.UserComparator.SensitiveTextNotEquals:
return this.evaluateTextEquals(text, condition.comparisonValue, condition.comparator === ConfigJson_1.UserComparator.TextNotEquals);
case ConfigJson_1.UserComparator.SensitiveTextEquals:
case ConfigJson_1.UserComparator.SensitiveTextNotEquals:
text = getUserAttributeValueAsText(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return this.evaluateSensitiveTextEquals(text, condition.comparisonValue, context.setting.configJsonSalt, contextSalt, condition.comparator === ProjectConfig_1.UserComparator.SensitiveTextNotEquals);
case ProjectConfig_1.UserComparator.IsOneOf:
case ProjectConfig_1.UserComparator.IsNotOneOf:
return this.evaluateSensitiveTextEquals(text, condition.comparisonValue, context.setting.configJsonSalt, contextSalt, condition.comparator === ConfigJson_1.UserComparator.SensitiveTextNotEquals);
case ConfigJson_1.UserComparator.IsOneOf:
case ConfigJson_1.UserComparator.IsNotOneOf:
text = getUserAttributeValueAsText(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return this.evaluateIsOneOf(text, condition.comparisonValue, condition.comparator === ProjectConfig_1.UserComparator.IsNotOneOf);
case ProjectConfig_1.UserComparator.SensitiveIsOneOf:
case ProjectConfig_1.UserComparator.SensitiveIsNotOneOf:
return this.evaluateIsOneOf(text, condition.comparisonValue, condition.comparator === ConfigJson_1.UserComparator.IsNotOneOf);
case ConfigJson_1.UserComparator.SensitiveIsOneOf:
case ConfigJson_1.UserComparator.SensitiveIsNotOneOf:
text = getUserAttributeValueAsText(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return this.evaluateSensitiveIsOneOf(text, condition.comparisonValue, context.setting.configJsonSalt, contextSalt, condition.comparator === ProjectConfig_1.UserComparator.SensitiveIsNotOneOf);
case ProjectConfig_1.UserComparator.TextStartsWithAnyOf:
case ProjectConfig_1.UserComparator.TextNotStartsWithAnyOf:
return this.evaluateSensitiveIsOneOf(text, condition.comparisonValue, context.setting.configJsonSalt, contextSalt, condition.comparator === ConfigJson_1.UserComparator.SensitiveIsNotOneOf);
case ConfigJson_1.UserComparator.TextStartsWithAnyOf:
case ConfigJson_1.UserComparator.TextNotStartsWithAnyOf:
text = getUserAttributeValueAsText(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return this.evaluateTextSliceEqualsAnyOf(text, condition.comparisonValue, true, condition.comparator === ProjectConfig_1.UserComparator.TextNotStartsWithAnyOf);
case ProjectConfig_1.UserComparator.SensitiveTextStartsWithAnyOf:
case ProjectConfig_1.UserComparator.SensitiveTextNotStartsWithAnyOf:
return this.evaluateTextSliceEqualsAnyOf(text, condition.comparisonValue, true, condition.comparator === ConfigJson_1.UserComparator.TextNotStartsWithAnyOf);
case ConfigJson_1.UserComparator.SensitiveTextStartsWithAnyOf:
case ConfigJson_1.UserComparator.SensitiveTextNotStartsWithAnyOf:
text = getUserAttributeValueAsText(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return this.evaluateSensitiveTextSliceEqualsAnyOf(text, condition.comparisonValue, context.setting.configJsonSalt, contextSalt, true, condition.comparator === ProjectConfig_1.UserComparator.SensitiveTextNotStartsWithAnyOf);
case ProjectConfig_1.UserComparator.TextEndsWithAnyOf:
case ProjectConfig_1.UserComparator.TextNotEndsWithAnyOf:
return this.evaluateSensitiveTextSliceEqualsAnyOf(text, condition.comparisonValue, context.setting.configJsonSalt, contextSalt, true, condition.comparator === ConfigJson_1.UserComparator.SensitiveTextNotStartsWithAnyOf);
case ConfigJson_1.UserComparator.TextEndsWithAnyOf:
case ConfigJson_1.UserComparator.TextNotEndsWithAnyOf:
text = getUserAttributeValueAsText(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return this.evaluateTextSliceEqualsAnyOf(text, condition.comparisonValue, false, condition.comparator === ProjectConfig_1.UserComparator.TextNotEndsWithAnyOf);
case ProjectConfig_1.UserComparator.SensitiveTextEndsWithAnyOf:
case ProjectConfig_1.UserComparator.SensitiveTextNotEndsWithAnyOf:
return this.evaluateTextSliceEqualsAnyOf(text, condition.comparisonValue, false, condition.comparator === ConfigJson_1.UserComparator.TextNotEndsWithAnyOf);
case ConfigJson_1.UserComparator.SensitiveTextEndsWithAnyOf:
case ConfigJson_1.UserComparator.SensitiveTextNotEndsWithAnyOf:
text = getUserAttributeValueAsText(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return this.evaluateSensitiveTextSliceEqualsAnyOf(text, condition.comparisonValue, context.setting.configJsonSalt, contextSalt, false, condition.comparator === ProjectConfig_1.UserComparator.SensitiveTextNotEndsWithAnyOf);
case ProjectConfig_1.UserComparator.ContainsAnyOf:
case ProjectConfig_1.UserComparator.NotContainsAnyOf:
return this.evaluateSensitiveTextSliceEqualsAnyOf(text, condition.comparisonValue, context.setting.configJsonSalt, contextSalt, false, condition.comparator === ConfigJson_1.UserComparator.SensitiveTextNotEndsWithAnyOf);
case ConfigJson_1.UserComparator.ContainsAnyOf:
case ConfigJson_1.UserComparator.NotContainsAnyOf:
text = getUserAttributeValueAsText(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return this.evaluateContainsAnyOf(text, condition.comparisonValue, condition.comparator === ProjectConfig_1.UserComparator.NotContainsAnyOf);
case ProjectConfig_1.UserComparator.SemVerIsOneOf:
case ProjectConfig_1.UserComparator.SemVerIsNotOneOf:
return this.evaluateContainsAnyOf(text, condition.comparisonValue, condition.comparator === ConfigJson_1.UserComparator.NotContainsAnyOf);
case ConfigJson_1.UserComparator.SemVerIsOneOf:
case ConfigJson_1.UserComparator.SemVerIsNotOneOf:
versionOrError = getUserAttributeValueAsSemVer(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return typeof versionOrError !== "string"
? this.evaluateSemVerIsOneOf(versionOrError, condition.comparisonValue, condition.comparator === ProjectConfig_1.UserComparator.SemVerIsNotOneOf)
? this.evaluateSemVerIsOneOf(versionOrError, condition.comparisonValue, condition.comparator === ConfigJson_1.UserComparator.SemVerIsNotOneOf)
: versionOrError;
case ProjectConfig_1.UserComparator.SemVerLess:
case ProjectConfig_1.UserComparator.SemVerLessOrEquals:
case ProjectConfig_1.UserComparator.SemVerGreater:
case ProjectConfig_1.UserComparator.SemVerGreaterOrEquals:
case ConfigJson_1.UserComparator.SemVerLess:
case ConfigJson_1.UserComparator.SemVerLessOrEquals:
case ConfigJson_1.UserComparator.SemVerGreater:
case ConfigJson_1.UserComparator.SemVerGreaterOrEquals:
versionOrError = getUserAttributeValueAsSemVer(userAttributeName, userAttributeValue, condition, context.key, this.logger);

@@ -298,8 +298,8 @@ return typeof versionOrError !== "string"

: versionOrError;
case ProjectConfig_1.UserComparator.NumberEquals:
case ProjectConfig_1.UserComparator.NumberNotEquals:
case ProjectConfig_1.UserComparator.NumberLess:
case ProjectConfig_1.UserComparator.NumberLessOrEquals:
case ProjectConfig_1.UserComparator.NumberGreater:
case ProjectConfig_1.UserComparator.NumberGreaterOrEquals:
case ConfigJson_1.UserComparator.NumberEquals:
case ConfigJson_1.UserComparator.NumberNotEquals:
case ConfigJson_1.UserComparator.NumberLess:
case ConfigJson_1.UserComparator.NumberLessOrEquals:
case ConfigJson_1.UserComparator.NumberGreater:
case ConfigJson_1.UserComparator.NumberGreaterOrEquals:
numberOrError = getUserAttributeValueAsNumber(userAttributeName, userAttributeValue, condition, context.key, this.logger);

@@ -309,19 +309,19 @@ return typeof numberOrError !== "string"

: numberOrError;
case ProjectConfig_1.UserComparator.DateTimeBefore:
case ProjectConfig_1.UserComparator.DateTimeAfter:
case ConfigJson_1.UserComparator.DateTimeBefore:
case ConfigJson_1.UserComparator.DateTimeAfter:
numberOrError = getUserAttributeValueAsUnixTimeSeconds(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return typeof numberOrError !== "string"
? this.evaluateDateTimeRelation(numberOrError, condition.comparisonValue, condition.comparator === ProjectConfig_1.UserComparator.DateTimeBefore)
? this.evaluateDateTimeRelation(numberOrError, condition.comparisonValue, condition.comparator === ConfigJson_1.UserComparator.DateTimeBefore)
: numberOrError;
case ProjectConfig_1.UserComparator.ArrayContainsAnyOf:
case ProjectConfig_1.UserComparator.ArrayNotContainsAnyOf:
case ConfigJson_1.UserComparator.ArrayContainsAnyOf:
case ConfigJson_1.UserComparator.ArrayNotContainsAnyOf:
arrayOrError = getUserAttributeValueAsStringArray(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return typeof arrayOrError !== "string"
? this.evaluateArrayContainsAnyOf(arrayOrError, condition.comparisonValue, condition.comparator === ProjectConfig_1.UserComparator.ArrayNotContainsAnyOf)
? this.evaluateArrayContainsAnyOf(arrayOrError, condition.comparisonValue, condition.comparator === ConfigJson_1.UserComparator.ArrayNotContainsAnyOf)
: arrayOrError;
case ProjectConfig_1.UserComparator.SensitiveArrayContainsAnyOf:
case ProjectConfig_1.UserComparator.SensitiveArrayNotContainsAnyOf:
case ConfigJson_1.UserComparator.SensitiveArrayContainsAnyOf:
case ConfigJson_1.UserComparator.SensitiveArrayNotContainsAnyOf:
arrayOrError = getUserAttributeValueAsStringArray(userAttributeName, userAttributeValue, condition, context.key, this.logger);
return typeof arrayOrError !== "string"
? this.evaluateSensitiveArrayContainsAnyOf(arrayOrError, condition.comparisonValue, context.setting.configJsonSalt, contextSalt, condition.comparator === ProjectConfig_1.UserComparator.SensitiveArrayNotContainsAnyOf)
? this.evaluateSensitiveArrayContainsAnyOf(arrayOrError, condition.comparisonValue, context.setting.configJsonSalt, contextSalt, condition.comparator === ConfigJson_1.UserComparator.SensitiveArrayNotContainsAnyOf)
: arrayOrError;

@@ -421,6 +421,6 @@ default:

switch (comparator) {
case ProjectConfig_1.UserComparator.SemVerLess: return comparisonResult < 0;
case ProjectConfig_1.UserComparator.SemVerLessOrEquals: return comparisonResult <= 0;
case ProjectConfig_1.UserComparator.SemVerGreater: return comparisonResult > 0;
case ProjectConfig_1.UserComparator.SemVerGreaterOrEquals: return comparisonResult >= 0;
case ConfigJson_1.UserComparator.SemVerLess: return comparisonResult < 0;
case ConfigJson_1.UserComparator.SemVerLessOrEquals: return comparisonResult <= 0;
case ConfigJson_1.UserComparator.SemVerGreater: return comparisonResult > 0;
case ConfigJson_1.UserComparator.SemVerGreaterOrEquals: return comparisonResult >= 0;
}

@@ -430,8 +430,8 @@ };

switch (comparator) {
case ProjectConfig_1.UserComparator.NumberEquals: return number === comparisonValue;
case ProjectConfig_1.UserComparator.NumberNotEquals: return number !== comparisonValue;
case ProjectConfig_1.UserComparator.NumberLess: return number < comparisonValue;
case ProjectConfig_1.UserComparator.NumberLessOrEquals: return number <= comparisonValue;
case ProjectConfig_1.UserComparator.NumberGreater: return number > comparisonValue;
case ProjectConfig_1.UserComparator.NumberGreaterOrEquals: return number >= comparisonValue;
case ConfigJson_1.UserComparator.NumberEquals: return number === comparisonValue;
case ConfigJson_1.UserComparator.NumberNotEquals: return number !== comparisonValue;
case ConfigJson_1.UserComparator.NumberLess: return number < comparisonValue;
case ConfigJson_1.UserComparator.NumberLessOrEquals: return number <= comparisonValue;
case ConfigJson_1.UserComparator.NumberGreater: return number > comparisonValue;
case ConfigJson_1.UserComparator.NumberGreaterOrEquals: return number >= comparisonValue;
}

@@ -489,6 +489,6 @@ };

switch (condition.comparator) {
case ProjectConfig_1.PrerequisiteFlagComparator.Equals:
case ConfigJson_1.PrerequisiteFlagComparator.Equals:
result = prerequisiteFlagValue === condition.comparisonValue;
break;
case ProjectConfig_1.PrerequisiteFlagComparator.NotEquals:
case ConfigJson_1.PrerequisiteFlagComparator.NotEquals:
result = prerequisiteFlagValue !== condition.comparisonValue;

@@ -518,5 +518,5 @@ break;

switch (condition.comparator) {
case ProjectConfig_1.SegmentComparator.IsIn:
case ConfigJson_1.SegmentComparator.IsIn:
break;
case ProjectConfig_1.SegmentComparator.IsNotIn:
case ConfigJson_1.SegmentComparator.IsNotIn:
result = !result;

@@ -531,3 +531,3 @@ break;

(!isEvaluationError(result)
? logBuilder.append("User " + EvaluateLogBuilder_1.formatSegmentComparator(segmentResult ? ProjectConfig_1.SegmentComparator.IsIn : ProjectConfig_1.SegmentComparator.IsNotIn))
? logBuilder.append("User " + EvaluateLogBuilder_1.formatSegmentComparator(segmentResult ? ConfigJson_1.SegmentComparator.IsIn : ConfigJson_1.SegmentComparator.IsNotIn))
: logBuilder.append(result))

@@ -702,6 +702,6 @@ .append(".");

switch (settingType) {
case ProjectConfig_1.SettingType.Boolean: return typeof value === "boolean";
case ProjectConfig_1.SettingType.String: return typeof value === "string";
case ProjectConfig_1.SettingType.Int:
case ProjectConfig_1.SettingType.Double: return typeof value === "number";
case ConfigJson_1.SettingType.Boolean: return typeof value === "boolean";
case ConfigJson_1.SettingType.String: return typeof value === "string";
case ConfigJson_1.SettingType.Int:
case ConfigJson_1.SettingType.Double: return typeof value === "number";
default: return false;

@@ -715,2 +715,3 @@ }

}
exports.handleInvalidReturnValue = handleInvalidReturnValue;
function getTimestampAsDate(projectConfig) {

@@ -717,0 +718,0 @@ return projectConfig ? new Date(projectConfig.timestamp) : void 0;

{
"name": "configcat-common",
"version": "9.0.0",
"version": "9.1.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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc