Created
February 17, 2023 11:38
-
-
Save SimenB/6608476192348cc2676dd75e6d76cdf8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git i/lib/client.js w/lib/client.js | |
index 6e23515..dfa8a8b 100644 | |
--- i/lib/client.js | |
+++ w/lib/client.js | |
@@ -1,69 +1,15 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
-var __generator = (this && this.__generator) || function (thisArg, body) { | |
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | |
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | |
- function verb(n) { return function (v) { return step([n, v]); }; } | |
- function step(op) { | |
- if (f) throw new TypeError("Generator is already executing."); | |
- while (g && (g = 0, op[0] && (_ = 0)), _) try { | |
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | |
- if (y = 0, t) op = [op[0] & 2, t.value]; | |
- switch (op[0]) { | |
- case 0: case 1: t = op; break; | |
- case 4: _.label++; return { value: op[1], done: false }; | |
- case 5: _.label++; y = op[1]; op = [0]; continue; | |
- case 7: op = _.ops.pop(); _.trys.pop(); continue; | |
- default: | |
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | |
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | |
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | |
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | |
- if (t[2]) _.ops.pop(); | |
- _.trys.pop(); continue; | |
- } | |
- op = body.call(thisArg, _); | |
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | |
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | |
- } | |
-}; | |
-var __values = (this && this.__values) || function(o) { | |
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | |
- if (m) return m.call(o); | |
- if (o && typeof o.length === "number") return { | |
- next: function () { | |
- if (o && i >= o.length) o = void 0; | |
- return { value: o && o[i++], done: !o }; | |
- } | |
- }; | |
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | |
-}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var events_1 = require("events"); | |
-var variant_1 = require("./variant"); | |
-var events_2 = require("./events"); | |
-var UnleashClient = /** @class */ (function (_super) { | |
- __extends(UnleashClient, _super); | |
- function UnleashClient(repository, strategies) { | |
- var _this = _super.call(this) || this; | |
- _this.repository = repository; | |
- _this.strategies = strategies || []; | |
- _this.warned = {}; | |
- _this.strategies.forEach(function (strategy) { | |
+const events_1 = require("events"); | |
+const variant_1 = require("./variant"); | |
+const events_2 = require("./events"); | |
+class UnleashClient extends events_1.EventEmitter { | |
+ constructor(repository, strategies) { | |
+ super(); | |
+ this.repository = repository; | |
+ this.strategies = strategies || []; | |
+ this.warned = {}; | |
+ this.strategies.forEach((strategy) => { | |
if (!strategy || | |
!strategy.name || | |
typeof strategy.name !== 'string' || | |
@@ -72,35 +18,30 @@ var UnleashClient = /** @class */ (function (_super) { | |
throw new Error('Invalid strategy data / interface'); | |
} | |
}); | |
- return _this; | |
} | |
- UnleashClient.prototype.getStrategy = function (name) { | |
- return this.strategies.find(function (strategy) { return strategy.name === name; }); | |
- }; | |
- UnleashClient.prototype.warnOnce = function (missingStrategy, name, strategies) { | |
+ getStrategy(name) { | |
+ return this.strategies.find((strategy) => strategy.name === name); | |
+ } | |
+ warnOnce(missingStrategy, name, strategies) { | |
if (!this.warned[missingStrategy + name]) { | |
this.warned[missingStrategy + name] = true; | |
- this.emit(events_2.UnleashEvents.Warn, "Missing strategy \"".concat(missingStrategy, "\" for toggle \"").concat(name, "\". Ensure that \"").concat(strategies | |
- .map(function (_a) { | |
- var n = _a.name; | |
- return n; | |
- }) | |
- .join(', '), "\" are supported before using this toggle")); | |
+ this.emit(events_2.UnleashEvents.Warn, `Missing strategy "${missingStrategy}" for toggle "${name}". Ensure that "${strategies | |
+ .map(({ name: n }) => n) | |
+ .join(', ')}" are supported before using this toggle`); | |
} | |
- }; | |
- UnleashClient.prototype.isEnabled = function (name, context, fallback) { | |
- var feature = this.repository.getToggle(name); | |
- var enabled = this.isFeatureEnabled(feature, context, fallback); | |
+ } | |
+ isEnabled(name, context, fallback) { | |
+ const feature = this.repository.getToggle(name); | |
+ const enabled = this.isFeatureEnabled(feature, context, fallback); | |
this.emit(events_2.UnleashEvents.Impression, (0, events_2.createImpressionEvent)({ | |
featureName: name, | |
- context: context, | |
- enabled: enabled, | |
+ context, | |
+ enabled, | |
eventType: 'isEnabled' | |
})); | |
return enabled; | |
- }; | |
- UnleashClient.prototype.isFeatureEnabled = function (feature, context, fallback) { | |
- var _this = this; | |
+ } | |
+ isFeatureEnabled(feature, context, fallback) { | |
if (!feature) { | |
return fallback(); | |
} | |
@@ -108,7 +49,7 @@ var UnleashClient = /** @class */ (function (_super) { | |
return false; | |
} | |
if (!Array.isArray(feature.strategies)) { | |
- var msg = "Malformed feature, strategies not an array, is a ".concat(typeof feature.strategies); | |
+ const msg = `Malformed feature, strategies not an array, is a ${typeof feature.strategies}`; | |
this.emit(events_2.UnleashEvents.Error, new Error(msg)); | |
return false; | |
} | |
@@ -116,138 +57,75 @@ var UnleashClient = /** @class */ (function (_super) { | |
return feature.enabled; | |
} | |
return (feature.strategies.length > 0 && | |
- feature.strategies.some(function (strategySelector) { | |
- var strategy = _this.getStrategy(strategySelector.name); | |
+ feature.strategies.some((strategySelector) => { | |
+ const strategy = this.getStrategy(strategySelector.name); | |
if (!strategy) { | |
- _this.warnOnce(strategySelector.name, feature.name, feature.strategies); | |
+ this.warnOnce(strategySelector.name, feature.name, feature.strategies); | |
return false; | |
} | |
- var constraints = _this.yieldConstraintsFor(strategySelector); | |
+ const constraints = this.yieldConstraintsFor(strategySelector); | |
return strategy.isEnabledWithConstraints(strategySelector.parameters, context, constraints); | |
})); | |
- }; | |
- UnleashClient.prototype.yieldConstraintsFor = function (strategy) { | |
- var segments; | |
- var _this = this; | |
+ } | |
+ *yieldConstraintsFor(strategy) { | |
var _a; | |
- return __generator(this, function (_b) { | |
- switch (_b.label) { | |
- case 0: | |
- if (!strategy.constraints) return [3 /*break*/, 2]; | |
- return [5 /*yield**/, __values(strategy.constraints)]; | |
- case 1: | |
- _b.sent(); | |
- _b.label = 2; | |
- case 2: | |
- segments = (_a = strategy.segments) === null || _a === void 0 ? void 0 : _a.map(function (segmentId) { return _this.repository.getSegment(segmentId); }); | |
- if (!segments) { | |
- return [2 /*return*/]; | |
- } | |
- return [5 /*yield**/, __values(this.yieldSegmentConstraints(segments))]; | |
- case 3: | |
- _b.sent(); | |
- return [2 /*return*/]; | |
+ if (strategy.constraints) { | |
+ yield* strategy.constraints; | |
+ } | |
+ const segments = (_a = strategy.segments) === null || _a === void 0 ? void 0 : _a.map((segmentId) => this.repository.getSegment(segmentId)); | |
+ if (!segments) { | |
+ return; | |
+ } | |
+ yield* this.yieldSegmentConstraints(segments); | |
+ } | |
+ *yieldSegmentConstraints(segments) { | |
+ // eslint-disable-next-line no-restricted-syntax | |
+ for (const segment of segments) { | |
+ if (segment) { | |
+ // eslint-disable-next-line no-restricted-syntax | |
+ for (const constraint of segment === null || segment === void 0 ? void 0 : segment.constraints) { | |
+ yield constraint; | |
+ } | |
} | |
- }); | |
- }; | |
- UnleashClient.prototype.yieldSegmentConstraints = function (segments) { | |
- var segments_1, segments_1_1, segment, _a, _b, constraint, e_1_1, e_2_1; | |
- var e_2, _c, e_1, _d; | |
- return __generator(this, function (_e) { | |
- switch (_e.label) { | |
- case 0: | |
- _e.trys.push([0, 14, 15, 16]); | |
- segments_1 = __values(segments), segments_1_1 = segments_1.next(); | |
- _e.label = 1; | |
- case 1: | |
- if (!!segments_1_1.done) return [3 /*break*/, 13]; | |
- segment = segments_1_1.value; | |
- if (!segment) return [3 /*break*/, 10]; | |
- _e.label = 2; | |
- case 2: | |
- _e.trys.push([2, 7, 8, 9]); | |
- _a = (e_1 = void 0, __values(segment === null || segment === void 0 ? void 0 : segment.constraints)), _b = _a.next(); | |
- _e.label = 3; | |
- case 3: | |
- if (!!_b.done) return [3 /*break*/, 6]; | |
- constraint = _b.value; | |
- return [4 /*yield*/, constraint]; | |
- case 4: | |
- _e.sent(); | |
- _e.label = 5; | |
- case 5: | |
- _b = _a.next(); | |
- return [3 /*break*/, 3]; | |
- case 6: return [3 /*break*/, 9]; | |
- case 7: | |
- e_1_1 = _e.sent(); | |
- e_1 = { error: e_1_1 }; | |
- return [3 /*break*/, 9]; | |
- case 8: | |
- try { | |
- if (_b && !_b.done && (_d = _a.return)) _d.call(_a); | |
- } | |
- finally { if (e_1) throw e_1.error; } | |
- return [7 /*endfinally*/]; | |
- case 9: return [3 /*break*/, 12]; | |
- case 10: return [4 /*yield*/, undefined]; | |
- case 11: | |
- _e.sent(); | |
- _e.label = 12; | |
- case 12: | |
- segments_1_1 = segments_1.next(); | |
- return [3 /*break*/, 1]; | |
- case 13: return [3 /*break*/, 16]; | |
- case 14: | |
- e_2_1 = _e.sent(); | |
- e_2 = { error: e_2_1 }; | |
- return [3 /*break*/, 16]; | |
- case 15: | |
- try { | |
- if (segments_1_1 && !segments_1_1.done && (_c = segments_1.return)) _c.call(segments_1); | |
- } | |
- finally { if (e_2) throw e_2.error; } | |
- return [7 /*endfinally*/]; | |
- case 16: return [2 /*return*/]; | |
+ else { | |
+ yield undefined; | |
} | |
- }); | |
- }; | |
- UnleashClient.prototype.getVariant = function (name, context, fallbackVariant) { | |
- var variant = this.resolveVariant(name, context, true, fallbackVariant); | |
+ } | |
+ } | |
+ getVariant(name, context, fallbackVariant) { | |
+ const variant = this.resolveVariant(name, context, true, fallbackVariant); | |
this.emit(events_2.UnleashEvents.Impression, (0, events_2.createImpressionEvent)({ | |
featureName: name, | |
- context: context, | |
+ context, | |
enabled: variant.enabled, | |
eventType: 'getVariant', | |
variant: variant.name, | |
})); | |
return variant; | |
- }; | |
+ } | |
// This function is intended to close an issue in the proxy where feature enabled | |
// state gets checked twice when resolving a variant with random stickiness and | |
// gradual rollout. This is not intended for general use, prefer getVariant instead | |
- UnleashClient.prototype.forceGetVariant = function (name, context, fallbackVariant) { | |
+ forceGetVariant(name, context, fallbackVariant) { | |
return this.resolveVariant(name, context, false, fallbackVariant); | |
- }; | |
- UnleashClient.prototype.resolveVariant = function (name, context, checkToggle, fallbackVariant) { | |
- var fallback = fallbackVariant || (0, variant_1.getDefaultVariant)(); | |
- var feature = this.repository.getToggle(name); | |
+ } | |
+ resolveVariant(name, context, checkToggle, fallbackVariant) { | |
+ const fallback = fallbackVariant || (0, variant_1.getDefaultVariant)(); | |
+ const feature = this.repository.getToggle(name); | |
if (typeof feature === 'undefined' || | |
!feature.variants || | |
!Array.isArray(feature.variants) || | |
feature.variants.length === 0) { | |
return fallback; | |
} | |
- var enabled = true; | |
+ let enabled = true; | |
if (checkToggle) { | |
- enabled = this.isFeatureEnabled(feature, context, function () { | |
- return fallbackVariant ? fallbackVariant.enabled : false; | |
- }); | |
+ enabled = this.isFeatureEnabled(feature, context, () => fallbackVariant ? fallbackVariant.enabled : false); | |
if (!enabled) { | |
return fallback; | |
} | |
} | |
- var variant = (0, variant_1.selectVariant)(feature, context); | |
+ const variant = (0, variant_1.selectVariant)(feature, context); | |
if (variant === null) { | |
return fallback; | |
} | |
@@ -256,8 +134,7 @@ var UnleashClient = /** @class */ (function (_super) { | |
payload: variant.payload, | |
enabled: !checkToggle || enabled, | |
}; | |
- }; | |
- return UnleashClient; | |
-}(events_1.EventEmitter)); | |
+ } | |
+} | |
exports.default = UnleashClient; | |
//# sourceMappingURL=client.js.map | |
\ No newline at end of file | |
diff --git i/lib/client.js.map w/lib/client.js.map | |
index 227c90d..ad6ae31 100644 | |
--- i/lib/client.js.map | |
+++ w/lib/client.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAsC;AAItC,qCAAyF;AAGzF,mCAAgE;AAMhE;IAA2C,iCAAY;IAOrD,uBAAY,UAA+B,EAAE,UAAsB;QAAnE,YACE,iBAAO,SAgBR;QAfC,KAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,KAAI,CAAC,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;QACnC,KAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QAEjB,KAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAC,QAAkB;YACzC,IACE,CAAC,QAAQ;gBACT,CAAC,QAAQ,CAAC,IAAI;gBACd,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ;gBACjC,CAAC,QAAQ,CAAC,SAAS;gBACnB,OAAO,QAAQ,CAAC,SAAS,KAAK,UAAU,EACxC;gBACA,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;aACtD;QACH,CAAC,CAAC,CAAC;;IACL,CAAC;IAEO,mCAAW,GAAnB,UAAo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AAK,IAAI,EAAE;YACpB,OAAO,QAAQ,CAAC;SACjB;QAED,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,CAAC,WAAW,IAAI,OAAO;SACjC,CAAC;IACJ,CAAC;CACF;AA7KD,gCA6KC"} | |
\ No newline at end of file | |
diff --git i/lib/helpers.js w/lib/helpers.js | |
index d04c612..ca9f21e 100644 | |
--- i/lib/helpers.js | |
+++ w/lib/helpers.js | |
@@ -1,16 +1,16 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.getAppliedJitter = exports.generateHashOfConfig = exports.generateInstanceId = exports.safeName = exports.resolveContextValue = exports.createFallbackFunction = void 0; | |
-var os_1 = require("os"); | |
-var murmurHash3 = require("murmurhash3js"); | |
+const os_1 = require("os"); | |
+const murmurHash3 = require("murmurhash3js"); | |
function createFallbackFunction(name, context, fallback) { | |
if (typeof fallback === 'function') { | |
- return function () { return fallback(name, context); }; | |
+ return () => fallback(name, context); | |
} | |
if (typeof fallback === 'boolean') { | |
- return function () { return fallback; }; | |
+ return () => fallback; | |
} | |
- return function () { return false; }; | |
+ return () => false; | |
} | |
exports.createFallbackFunction = createFallbackFunction; | |
function resolveContextValue(context, field) { | |
@@ -23,8 +23,7 @@ function resolveContextValue(context, field) { | |
return undefined; | |
} | |
exports.resolveContextValue = resolveContextValue; | |
-function safeName(str) { | |
- if (str === void 0) { str = ''; } | |
+function safeName(str = '') { | |
return str.replace(/\//g, '_'); | |
} | |
exports.safeName = safeName; | |
@@ -32,26 +31,26 @@ function generateInstanceId(instanceId) { | |
if (instanceId) { | |
return instanceId; | |
} | |
- var info; | |
+ let info; | |
try { | |
info = (0, os_1.userInfo)(); | |
} | |
catch (e) { | |
// unable to read info; | |
} | |
- var prefix = info | |
+ const prefix = info | |
? info.username | |
- : "generated-".concat(Math.round(Math.random() * 1000000), "-").concat(process.pid); | |
- return "".concat(prefix, "-").concat((0, os_1.hostname)()); | |
+ : `generated-${Math.round(Math.random() * 1000000)}-${process.pid}`; | |
+ return `${prefix}-${(0, os_1.hostname)()}`; | |
} | |
exports.generateInstanceId = generateInstanceId; | |
function generateHashOfConfig(o) { | |
- var oAsString = JSON.stringify(o); | |
+ const oAsString = JSON.stringify(o); | |
return murmurHash3.x86.hash128(oAsString); | |
} | |
exports.generateHashOfConfig = generateHashOfConfig; | |
function getAppliedJitter(jitter) { | |
- var appliedJitter = Math.random() * jitter; | |
+ const appliedJitter = Math.random() * jitter; | |
return Math.random() < 0.5 ? -appliedJitter : appliedJitter; | |
} | |
exports.getAppliedJitter = getAppliedJitter; | |
diff --git i/lib/helpers.js.map w/lib/helpers.js.map | |
index 725e387..5b7a05c 100644 | |
--- i/lib/helpers.js.map | |
+++ w/lib/helpers.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA,yBAAwC;AACxC,2CAA6C;AAK7C,SAAgB,sBAAsB,CACpC,IAAY,EACZ,OAAgB,EAChB,QAAqC;IAErC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;QAClC,OAAO,cAAM,OAAA,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,EAAvB,CAAuB,CAAC;KACtC;IACD,IAAI,OAAO,QAAQ,KAAK,SAAS,EAAE;QACjC,OAAO,cAAM,OAAA,QAAQ,EAAR,CAAQ,CAAC;KACvB;IACD,OAAO,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC;AACrB,CAAC;AAZD,wDAYC;AAED,SAAgB,mBAAmB,CAAC,OAAgB,EAAE,KAAa;IACjE,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO,OAAO,CAAC,KAAK,CAAW,CAAC;KACjC;IACD,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;QACnD,OAAO,OAAO,CAA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;IACtE,OAAO,GAAG,MAAM,IAAI,IAAA,aAAQ,GAAE,EAAE,CAAC;AACnC,CAAC;AAfD,gDAeC;AAED,SAAgB,oBAAoB,CAAC,CAAS;IAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACpC,OAAO,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC5C,CAAC;AAHD,oDAGC;AAED,SAAgB,gBAAgB,CAAC,MAAc;IAC7C,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC;IAC7C,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC;AAC9D,CAAC;AAHD,4CAGC"} | |
\ No newline at end of file | |
diff --git i/lib/index.js w/lib/index.js | |
index f0008d2..50bb81d 100644 | |
--- i/lib/index.js | |
+++ w/lib/index.js | |
@@ -1,77 +1,30 @@ | |
"use strict"; | |
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | |
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | |
- return new (P || (P = Promise))(function (resolve, reject) { | |
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | |
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | |
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | |
- step((generator = generator.apply(thisArg, _arguments || [])).next()); | |
- }); | |
-}; | |
-var __generator = (this && this.__generator) || function (thisArg, body) { | |
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | |
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | |
- function verb(n) { return function (v) { return step([n, v]); }; } | |
- function step(op) { | |
- if (f) throw new TypeError("Generator is already executing."); | |
- while (g && (g = 0, op[0] && (_ = 0)), _) try { | |
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | |
- if (y = 0, t) op = [op[0] & 2, t.value]; | |
- switch (op[0]) { | |
- case 0: case 1: t = op; break; | |
- case 4: _.label++; return { value: op[1], done: false }; | |
- case 5: _.label++; y = op[1]; op = [0]; continue; | |
- case 7: op = _.ops.pop(); _.trys.pop(); continue; | |
- default: | |
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | |
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | |
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | |
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | |
- if (t[2]) _.ops.pop(); | |
- _.trys.pop(); continue; | |
- } | |
- op = body.call(thisArg, _); | |
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | |
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | |
- } | |
-}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.destroyWithFlush = exports.flushMetrics = exports.countVariant = exports.count = exports.forceGetVariant = exports.getVariant = exports.getFeatureToggleDefinitions = exports.getFeatureToggleDefinition = exports.destroy = exports.isEnabled = exports.startUnleash = exports.initialize = exports.UnleashEvents = exports.InMemStorageProvider = exports.Unleash = exports.Strategy = void 0; | |
-var events_1 = require("events"); | |
-var unleash_1 = require("./unleash"); | |
+const events_1 = require("events"); | |
+const unleash_1 = require("./unleash"); | |
Object.defineProperty(exports, "Unleash", { enumerable: true, get: function () { return unleash_1.Unleash; } }); | |
-var variant_1 = require("./variant"); | |
-var events_2 = require("./events"); | |
+const variant_1 = require("./variant"); | |
+const events_2 = require("./events"); | |
Object.defineProperty(exports, "UnleashEvents", { enumerable: true, get: function () { return events_2.UnleashEvents; } }); | |
-var storage_provider_in_mem_1 = require("./repository/storage-provider-in-mem"); | |
+const storage_provider_in_mem_1 = require("./repository/storage-provider-in-mem"); | |
exports.InMemStorageProvider = storage_provider_in_mem_1.default; | |
// exports | |
var index_1 = require("./strategy/index"); | |
Object.defineProperty(exports, "Strategy", { enumerable: true, get: function () { return index_1.Strategy; } }); | |
-var instance; | |
+let instance; | |
function initialize(options) { | |
instance = unleash_1.Unleash.getInstance(options); | |
return instance; | |
} | |
exports.initialize = initialize; | |
-function startUnleash(options) { | |
- return __awaiter(this, void 0, void 0, function () { | |
- var unleash; | |
- return __generator(this, function (_a) { | |
- switch (_a.label) { | |
- case 0: | |
- unleash = initialize(options); | |
- return [4 /*yield*/, (0, events_1.once)(unleash, 'synchronized')]; | |
- case 1: | |
- _a.sent(); | |
- return [2 /*return*/, unleash]; | |
- } | |
- }); | |
- }); | |
+async function startUnleash(options) { | |
+ const unleash = initialize(options); | |
+ await (0, events_1.once)(unleash, 'synchronized'); | |
+ return unleash; | |
} | |
exports.startUnleash = startUnleash; | |
-function isEnabled(name, context, fallbackValue) { | |
- if (context === void 0) { context = {}; } | |
+function isEnabled(name, context = {}, fallbackValue) { | |
return instance ? instance.isEnabled(name, context, fallbackValue) : !!fallbackValue; | |
} | |
exports.isEnabled = isEnabled; | |
@@ -90,15 +43,13 @@ function getFeatureToggleDefinitions() { | |
return instance && instance.getFeatureToggleDefinitions(); | |
} | |
exports.getFeatureToggleDefinitions = getFeatureToggleDefinitions; | |
-function getVariant(name, context, fallbackVariant) { | |
- if (context === void 0) { context = {}; } | |
- var variant = fallbackVariant || (0, variant_1.getDefaultVariant)(); | |
+function getVariant(name, context = {}, fallbackVariant) { | |
+ const variant = fallbackVariant || (0, variant_1.getDefaultVariant)(); | |
return instance ? instance.getVariant(name, context, variant) : variant; | |
} | |
exports.getVariant = getVariant; | |
-function forceGetVariant(name, context, fallbackVariant) { | |
- if (context === void 0) { context = {}; } | |
- var variant = fallbackVariant || (0, variant_1.getDefaultVariant)(); | |
+function forceGetVariant(name, context = {}, fallbackVariant) { | |
+ const variant = fallbackVariant || (0, variant_1.getDefaultVariant)(); | |
return instance ? instance.forceGetVariant(name, context, variant) : variant; | |
} | |
exports.forceGetVariant = forceGetVariant; | |
@@ -110,20 +61,12 @@ function countVariant(toggleName, variantName) { | |
return instance && instance.countVariant(toggleName, variantName); | |
} | |
exports.countVariant = countVariant; | |
-function flushMetrics() { | |
- return __awaiter(this, void 0, void 0, function () { | |
- return __generator(this, function (_a) { | |
- return [2 /*return*/, instance && instance.flushMetrics()]; | |
- }); | |
- }); | |
+async function flushMetrics() { | |
+ return instance && instance.flushMetrics(); | |
} | |
exports.flushMetrics = flushMetrics; | |
-function destroyWithFlush() { | |
- return __awaiter(this, void 0, void 0, function () { | |
- return __generator(this, function (_a) { | |
- return [2 /*return*/, instance && instance.destroyWithFlush()]; | |
- }); | |
- }); | |
+async function destroyWithFlush() { | |
+ return instance && instance.destroyWithFlush(); | |
} | |
exports.destroyWithFlush = destroyWithFlush; | |
//# sourceMappingURL=index.js.map | |
\ No newline at end of file | |
diff --git i/lib/index.js.map w/lib/index.js.map | |
index 398dd0f..bdc8a62 100644 | |
--- i/lib/index.js.map | |
+++ w/lib/index.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA8B;AAC9B,qCAAoC;AAWT,wFAXlB,iBAAO,OAWkB;AAVlC,qCAAuD;AAGvD,mCAAyC;AAO4B,8FAP5D,sBAAa,OAO4D;AALlF,gFAAwE;AAKzB,+BALxC,iCAAoB,CAKwC;AAFnE,UAAU;AACV,0CAA4C;AAAnC,iGAAA,QAAQ,OAAA;AAIjB,IAAI,QAA6B,CAAC;AAGlC,SAAgB,UAAU,CAAC,OAAsB;IAC/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AEzB,MAAM,OAAO,GAAG,eAAe,IAAI,IAAA,2BAAiB,GAAE,CAAC;IACvD,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAC/E,CAAC;AAPD,0CAOC;AAED,SAAgB,KAAK,CAAC,UAAkB,EAAE,OAAgB;IACxD,OAAO,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC;AAFD,sBAEC;AAED,SAAgB,YAAY,CAAC,UAAkB,EAAE,WAAmB;IAClE,OAAO,QAAQ,IAAI,QAAQ,CAAC,YAAY,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACpE,CAAC;AAFD,oCAEC;AAEM,KAAK,UAAU,YAAY;IAChC,OAAO,QAAQ,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;AAC7C,CAAC;AAFD,oCAEC;AAEM,KAAK,UAAU,gBAAgB;IACpC,OAAO,QAAQ,IAAI,QAAQ,CAAC,gBAAgB,EAAE,CAAC;AACjD,CAAC;AAFD,4CAEC"} | |
\ No newline at end of file | |
diff --git i/lib/metrics.js w/lib/metrics.js | |
index 2f84786..64d00c2 100644 | |
--- i/lib/metrics.js | |
+++ w/lib/metrics.js | |
@@ -1,248 +1,128 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
-var __assign = (this && this.__assign) || function () { | |
- __assign = Object.assign || function(t) { | |
- for (var s, i = 1, n = arguments.length; i < n; i++) { | |
- s = arguments[i]; | |
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | |
- t[p] = s[p]; | |
- } | |
- return t; | |
- }; | |
- return __assign.apply(this, arguments); | |
-}; | |
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | |
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | |
- return new (P || (P = Promise))(function (resolve, reject) { | |
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | |
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | |
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | |
- step((generator = generator.apply(thisArg, _arguments || [])).next()); | |
- }); | |
-}; | |
-var __generator = (this && this.__generator) || function (thisArg, body) { | |
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | |
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | |
- function verb(n) { return function (v) { return step([n, v]); }; } | |
- function step(op) { | |
- if (f) throw new TypeError("Generator is already executing."); | |
- while (g && (g = 0, op[0] && (_ = 0)), _) try { | |
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | |
- if (y = 0, t) op = [op[0] & 2, t.value]; | |
- switch (op[0]) { | |
- case 0: case 1: t = op; break; | |
- case 4: _.label++; return { value: op[1], done: false }; | |
- case 5: _.label++; y = op[1]; op = [0]; continue; | |
- case 7: op = _.ops.pop(); _.trys.pop(); continue; | |
- default: | |
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | |
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | |
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | |
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | |
- if (t[2]) _.ops.pop(); | |
- _.trys.pop(); continue; | |
- } | |
- op = body.call(thisArg, _); | |
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | |
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | |
- } | |
-}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var events_1 = require("events"); | |
-var request_1 = require("./request"); | |
-var details_json_1 = require("./details.json"); | |
-var url_utils_1 = require("./url-utils"); | |
-var events_2 = require("./events"); | |
-var helpers_1 = require("./helpers"); | |
-var Metrics = /** @class */ (function (_super) { | |
- __extends(Metrics, _super); | |
- function Metrics(_a) { | |
- var appName = _a.appName, instanceId = _a.instanceId, strategies = _a.strategies, _b = _a.metricsInterval, metricsInterval = _b === void 0 ? 0 : _b, _c = _a.metricsJitter, metricsJitter = _c === void 0 ? 0 : _c, _d = _a.disableMetrics, disableMetrics = _d === void 0 ? false : _d, url = _a.url, headers = _a.headers, customHeadersFunction = _a.customHeadersFunction, timeout = _a.timeout, httpOptions = _a.httpOptions; | |
- var _this = _super.call(this) || this; | |
- _this.disabled = disableMetrics; | |
- _this.metricsInterval = metricsInterval; | |
- _this.metricsJitter = metricsJitter; | |
- _this.appName = appName; | |
- _this.instanceId = instanceId; | |
- _this.sdkVersion = details_json_1.sdkVersion; | |
- _this.strategies = strategies; | |
- _this.url = url; | |
- _this.headers = headers; | |
- _this.customHeadersFunction = customHeadersFunction; | |
- _this.started = new Date(); | |
- _this.timeout = timeout; | |
- _this.bucket = _this.createBucket(); | |
- _this.httpOptions = httpOptions; | |
- return _this; | |
+const events_1 = require("events"); | |
+const request_1 = require("./request"); | |
+const details_json_1 = require("./details.json"); | |
+const url_utils_1 = require("./url-utils"); | |
+const events_2 = require("./events"); | |
+const helpers_1 = require("./helpers"); | |
+class Metrics extends events_1.EventEmitter { | |
+ constructor({ appName, instanceId, strategies, metricsInterval = 0, metricsJitter = 0, disableMetrics = false, url, headers, customHeadersFunction, timeout, httpOptions, }) { | |
+ super(); | |
+ this.disabled = disableMetrics; | |
+ this.metricsInterval = metricsInterval; | |
+ this.metricsJitter = metricsJitter; | |
+ this.appName = appName; | |
+ this.instanceId = instanceId; | |
+ this.sdkVersion = details_json_1.sdkVersion; | |
+ this.strategies = strategies; | |
+ this.url = url; | |
+ this.headers = headers; | |
+ this.customHeadersFunction = customHeadersFunction; | |
+ this.started = new Date(); | |
+ this.timeout = timeout; | |
+ this.bucket = this.createBucket(); | |
+ this.httpOptions = httpOptions; | |
} | |
- Metrics.prototype.getAppliedJitter = function () { | |
+ getAppliedJitter() { | |
return (0, helpers_1.getAppliedJitter)(this.metricsJitter); | |
- }; | |
- Metrics.prototype.startTimer = function () { | |
- var _this = this; | |
+ } | |
+ startTimer() { | |
if (this.disabled) { | |
return; | |
} | |
- this.timer = setTimeout(function () { | |
- _this.sendMetrics(); | |
+ this.timer = setTimeout(() => { | |
+ this.sendMetrics(); | |
}, this.metricsInterval + this.getAppliedJitter()); | |
if (process.env.NODE_ENV !== 'test' && typeof this.timer.unref === 'function') { | |
this.timer.unref(); | |
} | |
- }; | |
- Metrics.prototype.start = function () { | |
+ } | |
+ start() { | |
if (typeof this.metricsInterval === 'number' && this.metricsInterval > 0) { | |
this.startTimer(); | |
this.registerInstance(); | |
} | |
- }; | |
- Metrics.prototype.stop = function () { | |
+ } | |
+ stop() { | |
if (this.timer) { | |
clearInterval(this.timer); | |
delete this.timer; | |
} | |
this.disabled = true; | |
- }; | |
- Metrics.prototype.registerInstance = function () { | |
- return __awaiter(this, void 0, void 0, function () { | |
- var url, payload, headers, _a, res, _b, _c, err_1; | |
- return __generator(this, function (_d) { | |
- switch (_d.label) { | |
- case 0: | |
- if (this.disabled) { | |
- return [2 /*return*/, false]; | |
- } | |
- url = (0, url_utils_1.resolveUrl)((0, url_utils_1.suffixSlash)(this.url), './client/register'); | |
- payload = this.getClientData(); | |
- if (!this.customHeadersFunction) return [3 /*break*/, 2]; | |
- return [4 /*yield*/, this.customHeadersFunction()]; | |
- case 1: | |
- _a = _d.sent(); | |
- return [3 /*break*/, 3]; | |
- case 2: | |
- _a = this.headers; | |
- _d.label = 3; | |
- case 3: | |
- headers = _a; | |
- _d.label = 4; | |
- case 4: | |
- _d.trys.push([4, 9, , 10]); | |
- return [4 /*yield*/, (0, request_1.post)({ | |
- url: url, | |
- json: payload, | |
- appName: this.appName, | |
- instanceId: this.instanceId, | |
- headers: headers, | |
- timeout: this.timeout, | |
- httpOptions: this.httpOptions, | |
- })]; | |
- case 5: | |
- res = _d.sent(); | |
- if (!!res.ok) return [3 /*break*/, 7]; | |
- // status code outside 200 range | |
- _b = this.emit; | |
- _c = [events_2.UnleashEvents.Warn, "".concat(url, " returning ").concat(res.status)]; | |
- return [4 /*yield*/, res.text()]; | |
- case 6: | |
- // status code outside 200 range | |
- _b.apply(this, _c.concat([_d.sent()])); | |
- return [3 /*break*/, 8]; | |
- case 7: | |
- this.emit(events_2.UnleashEvents.Registered, payload); | |
- _d.label = 8; | |
- case 8: return [3 /*break*/, 10]; | |
- case 9: | |
- err_1 = _d.sent(); | |
- this.emit(events_2.UnleashEvents.Warn, err_1); | |
- return [3 /*break*/, 10]; | |
- case 10: return [2 /*return*/, true]; | |
- } | |
+ } | |
+ async registerInstance() { | |
+ if (this.disabled) { | |
+ return false; | |
+ } | |
+ const url = (0, url_utils_1.resolveUrl)((0, url_utils_1.suffixSlash)(this.url), './client/register'); | |
+ const payload = this.getClientData(); | |
+ const headers = this.customHeadersFunction ? await this.customHeadersFunction() : this.headers; | |
+ try { | |
+ const res = await (0, request_1.post)({ | |
+ url, | |
+ json: payload, | |
+ appName: this.appName, | |
+ instanceId: this.instanceId, | |
+ headers, | |
+ timeout: this.timeout, | |
+ httpOptions: this.httpOptions, | |
}); | |
- }); | |
- }; | |
- Metrics.prototype.sendMetrics = function () { | |
- return __awaiter(this, void 0, void 0, function () { | |
- var url, payload, headers, _a, res, _b, _c, err_2; | |
- return __generator(this, function (_d) { | |
- switch (_d.label) { | |
- case 0: | |
- if (this.disabled) { | |
- return [2 /*return*/]; | |
- } | |
- if (this.bucketIsEmpty()) { | |
- this.resetBucket(); | |
- this.startTimer(); | |
- return [2 /*return*/]; | |
- } | |
- url = (0, url_utils_1.resolveUrl)((0, url_utils_1.suffixSlash)(this.url), './client/metrics'); | |
- payload = this.createMetricsData(); | |
- if (!this.customHeadersFunction) return [3 /*break*/, 2]; | |
- return [4 /*yield*/, this.customHeadersFunction()]; | |
- case 1: | |
- _a = _d.sent(); | |
- return [3 /*break*/, 3]; | |
- case 2: | |
- _a = this.headers; | |
- _d.label = 3; | |
- case 3: | |
- headers = _a; | |
- _d.label = 4; | |
- case 4: | |
- _d.trys.push([4, 9, , 10]); | |
- return [4 /*yield*/, (0, request_1.post)({ | |
- url: url, | |
- json: payload, | |
- appName: this.appName, | |
- instanceId: this.instanceId, | |
- headers: headers, | |
- timeout: this.timeout, | |
- httpOptions: this.httpOptions, | |
- })]; | |
- case 5: | |
- res = _d.sent(); | |
- this.startTimer(); | |
- if (res.status === 404) { | |
- this.emit(events_2.UnleashEvents.Warn, "".concat(url, " returning 404, stopping metrics")); | |
- this.stop(); | |
- } | |
- if (!!res.ok) return [3 /*break*/, 7]; | |
- this.restoreBucket(payload.bucket); | |
- _b = this.emit; | |
- _c = [events_2.UnleashEvents.Warn, "".concat(url, " returning ").concat(res.status)]; | |
- return [4 /*yield*/, res.text()]; | |
- case 6: | |
- _b.apply(this, _c.concat([_d.sent()])); | |
- return [3 /*break*/, 8]; | |
- case 7: | |
- this.emit(events_2.UnleashEvents.Sent, payload); | |
- _d.label = 8; | |
- case 8: return [3 /*break*/, 10]; | |
- case 9: | |
- err_2 = _d.sent(); | |
- this.restoreBucket(payload.bucket); | |
- this.emit(events_2.UnleashEvents.Warn, err_2); | |
- this.startTimer(); | |
- return [3 /*break*/, 10]; | |
- case 10: return [2 /*return*/]; | |
- } | |
+ if (!res.ok) { | |
+ // status code outside 200 range | |
+ this.emit(events_2.UnleashEvents.Warn, `${url} returning ${res.status}`, await res.text()); | |
+ } | |
+ else { | |
+ this.emit(events_2.UnleashEvents.Registered, payload); | |
+ } | |
+ } | |
+ catch (err) { | |
+ this.emit(events_2.UnleashEvents.Warn, err); | |
+ } | |
+ return true; | |
+ } | |
+ async sendMetrics() { | |
+ if (this.disabled) { | |
+ return; | |
+ } | |
+ if (this.bucketIsEmpty()) { | |
+ this.resetBucket(); | |
+ this.startTimer(); | |
+ return; | |
+ } | |
+ const url = (0, url_utils_1.resolveUrl)((0, url_utils_1.suffixSlash)(this.url), './client/metrics'); | |
+ const payload = this.createMetricsData(); | |
+ const headers = this.customHeadersFunction ? await this.customHeadersFunction() : this.headers; | |
+ try { | |
+ const res = await (0, request_1.post)({ | |
+ url, | |
+ json: payload, | |
+ appName: this.appName, | |
+ instanceId: this.instanceId, | |
+ headers, | |
+ timeout: this.timeout, | |
+ httpOptions: this.httpOptions, | |
}); | |
- }); | |
- }; | |
- Metrics.prototype.assertBucket = function (name) { | |
+ this.startTimer(); | |
+ if (res.status === 404) { | |
+ this.emit(events_2.UnleashEvents.Warn, `${url} returning 404, stopping metrics`); | |
+ this.stop(); | |
+ } | |
+ if (!res.ok) { | |
+ this.restoreBucket(payload.bucket); | |
+ this.emit(events_2.UnleashEvents.Warn, `${url} returning ${res.status}`, await res.text()); | |
+ } | |
+ else { | |
+ this.emit(events_2.UnleashEvents.Sent, payload); | |
+ } | |
+ } | |
+ catch (err) { | |
+ this.restoreBucket(payload.bucket); | |
+ this.emit(events_2.UnleashEvents.Warn, err); | |
+ this.startTimer(); | |
+ } | |
+ } | |
+ assertBucket(name) { | |
if (this.disabled) { | |
return; | |
} | |
@@ -253,31 +133,29 @@ var Metrics = /** @class */ (function (_super) { | |
variants: {}, | |
}; | |
} | |
- }; | |
- Metrics.prototype.count = function (name, enabled) { | |
+ } | |
+ count(name, enabled) { | |
if (this.disabled) { | |
return; | |
} | |
this.increaseCounter(name, enabled, 1); | |
this.emit(events_2.UnleashEvents.Count, name, enabled); | |
- }; | |
- Metrics.prototype.countVariant = function (name, variantName) { | |
+ } | |
+ countVariant(name, variantName) { | |
if (this.disabled) { | |
return; | |
} | |
this.increaseVariantCounter(name, variantName, 1); | |
this.emit(events_2.UnleashEvents.CountVariant, name, variantName); | |
- }; | |
- Metrics.prototype.increaseCounter = function (name, enabled, inc) { | |
- if (inc === void 0) { inc = 1; } | |
+ } | |
+ increaseCounter(name, enabled, inc = 1) { | |
if (inc === 0) { | |
return; | |
} | |
this.assertBucket(name); | |
this.bucket.toggles[name][enabled ? 'yes' : 'no'] += inc; | |
- }; | |
- Metrics.prototype.increaseVariantCounter = function (name, variantName, inc) { | |
- if (inc === void 0) { inc = 1; } | |
+ } | |
+ increaseVariantCounter(name, variantName, inc = 1) { | |
this.assertBucket(name); | |
if (this.bucket.toggles[name].variants[variantName]) { | |
this.bucket.toggles[name].variants[variantName] += inc; | |
@@ -285,46 +163,45 @@ var Metrics = /** @class */ (function (_super) { | |
else { | |
this.bucket.toggles[name].variants[variantName] = inc; | |
} | |
- }; | |
- Metrics.prototype.bucketIsEmpty = function () { | |
+ } | |
+ bucketIsEmpty() { | |
return Object.keys(this.bucket.toggles).length === 0; | |
- }; | |
- Metrics.prototype.createBucket = function () { | |
+ } | |
+ createBucket() { | |
return { | |
start: new Date(), | |
stop: undefined, | |
toggles: {}, | |
}; | |
- }; | |
- Metrics.prototype.resetBucket = function () { | |
+ } | |
+ resetBucket() { | |
this.bucket = this.createBucket(); | |
- }; | |
- Metrics.prototype.createMetricsData = function () { | |
- var bucket = __assign(__assign({}, this.bucket), { stop: new Date() }); | |
+ } | |
+ createMetricsData() { | |
+ const bucket = { ...this.bucket, stop: new Date() }; | |
this.resetBucket(); | |
return { | |
appName: this.appName, | |
instanceId: this.instanceId, | |
- bucket: bucket, | |
+ bucket, | |
}; | |
- }; | |
- Metrics.prototype.restoreBucket = function (bucket) { | |
- var _this = this; | |
+ } | |
+ restoreBucket(bucket) { | |
if (this.disabled) { | |
return; | |
} | |
this.bucket.start = bucket.start; | |
- var toggles = bucket.toggles; | |
- Object.keys(toggles).forEach(function (toggleName) { | |
- var toggle = toggles[toggleName]; | |
- _this.increaseCounter(toggleName, true, toggle.yes); | |
- _this.increaseCounter(toggleName, false, toggle.no); | |
- Object.keys(toggle.variants).forEach(function (variant) { | |
- _this.increaseVariantCounter(toggleName, variant, toggle.variants[variant]); | |
+ const { toggles } = bucket; | |
+ Object.keys(toggles).forEach(toggleName => { | |
+ const toggle = toggles[toggleName]; | |
+ this.increaseCounter(toggleName, true, toggle.yes); | |
+ this.increaseCounter(toggleName, false, toggle.no); | |
+ Object.keys(toggle.variants).forEach(variant => { | |
+ this.increaseVariantCounter(toggleName, variant, toggle.variants[variant]); | |
}); | |
}); | |
- }; | |
- Metrics.prototype.getClientData = function () { | |
+ } | |
+ getClientData() { | |
return { | |
appName: this.appName, | |
instanceId: this.instanceId, | |
@@ -333,8 +210,7 @@ var Metrics = /** @class */ (function (_super) { | |
started: this.started, | |
interval: this.metricsInterval, | |
}; | |
- }; | |
- return Metrics; | |
-}(events_1.EventEmitter)); | |
+ } | |
+} | |
exports.default = Metrics; | |
//# sourceMappingURL=metrics.js.map | |
\ No newline at end of file | |
diff --git i/lib/metrics.js.map w/lib/metrics.js.map | |
index 8751f41..a54df74 100644 | |
--- i/lib/metrics.js.map | |
+++ w/lib/metrics.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAsC;AACtC,qCAAiC;A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AE,IAAI,CAAC,eAAe;SAC/B,CAAC;IACJ,CAAC;CACF;AA3QD,0BA2QC"} | |
\ No newline at end of file | |
diff --git i/lib/repository/bootstrap-provider.js w/lib/repository/bootstrap-provider.js | |
index 7cf75bc..0037a63 100644 | |
--- i/lib/repository/bootstrap-provider.js | |
+++ w/lib/repository/bootstrap-provider.js | |
@@ -1,72 +1,11 @@ | |
"use strict"; | |
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | |
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | |
- return new (P || (P = Promise))(function (resolve, reject) { | |
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | |
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | |
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | |
- step((generator = generator.apply(thisArg, _arguments || [])).next()); | |
- }); | |
-}; | |
-var __generator = (this && this.__generator) || function (thisArg, body) { | |
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | |
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | |
- function verb(n) { return function (v) { return step([n, v]); }; } | |
- function step(op) { | |
- if (f) throw new TypeError("Generator is already executing."); | |
- while (g && (g = 0, op[0] && (_ = 0)), _) try { | |
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | |
- if (y = 0, t) op = [op[0] & 2, t.value]; | |
- switch (op[0]) { | |
- case 0: case 1: t = op; break; | |
- case 4: _.label++; return { value: op[1], done: false }; | |
- case 5: _.label++; y = op[1]; op = [0]; continue; | |
- case 7: op = _.ops.pop(); _.trys.pop(); continue; | |
- default: | |
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | |
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | |
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | |
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | |
- if (t[2]) _.ops.pop(); | |
- _.trys.pop(); continue; | |
- } | |
- op = body.call(thisArg, _); | |
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | |
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | |
- } | |
-}; | |
-var __read = (this && this.__read) || function (o, n) { | |
- var m = typeof Symbol === "function" && o[Symbol.iterator]; | |
- if (!m) return o; | |
- var i = m.call(o), r, ar = [], e; | |
- try { | |
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | |
- } | |
- catch (error) { e = { error: error }; } | |
- finally { | |
- try { | |
- if (r && !r.done && (m = i["return"])) m.call(i); | |
- } | |
- finally { if (e) throw e.error; } | |
- } | |
- return ar; | |
-}; | |
-var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | |
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | |
- if (ar || !(i in from)) { | |
- if (!ar) ar = Array.prototype.slice.call(from, 0, i); | |
- ar[i] = from[i]; | |
- } | |
- } | |
- return to.concat(ar || Array.prototype.slice.call(from)); | |
-}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.resolveBootstrapProvider = exports.DefaultBootstrapProvider = void 0; | |
-var fs_1 = require("fs"); | |
-var fetch = require("make-fetch-happen"); | |
-var request_1 = require("../request"); | |
-var DefaultBootstrapProvider = /** @class */ (function () { | |
- function DefaultBootstrapProvider(options, appName, instanceId) { | |
+const fs_1 = require("fs"); | |
+const fetch = require("make-fetch-happen"); | |
+const request_1 = require("../request"); | |
+class DefaultBootstrapProvider { | |
+ constructor(options, appName, instanceId) { | |
this.url = options.url; | |
this.urlHeaders = options.urlHeaders; | |
this.filePath = options.filePath; | |
@@ -75,61 +14,38 @@ var DefaultBootstrapProvider = /** @class */ (function () { | |
this.appName = appName; | |
this.instanceId = instanceId; | |
} | |
- DefaultBootstrapProvider.prototype.loadFromUrl = function (bootstrapUrl) { | |
- return __awaiter(this, void 0, void 0, function () { | |
- var response; | |
- return __generator(this, function (_a) { | |
- switch (_a.label) { | |
- case 0: return [4 /*yield*/, fetch(bootstrapUrl, { | |
- method: 'GET', | |
- timeout: 10000, | |
- headers: (0, request_1.buildHeaders)(this.appName, this.instanceId, undefined, undefined, this.urlHeaders), | |
- retry: { | |
- retries: 2, | |
- maxTimeout: 10000, | |
- }, | |
- })]; | |
- case 1: | |
- response = _a.sent(); | |
- if (response.ok) { | |
- return [2 /*return*/, response.json()]; | |
- } | |
- return [2 /*return*/, undefined]; | |
- } | |
- }); | |
- }); | |
- }; | |
- DefaultBootstrapProvider.prototype.loadFromFile = function (filePath) { | |
- return __awaiter(this, void 0, void 0, function () { | |
- var fileContent; | |
- return __generator(this, function (_a) { | |
- switch (_a.label) { | |
- case 0: return [4 /*yield*/, fs_1.promises.readFile(filePath, 'utf8')]; | |
- case 1: | |
- fileContent = _a.sent(); | |
- return [2 /*return*/, JSON.parse(fileContent)]; | |
- } | |
- }); | |
- }); | |
- }; | |
- DefaultBootstrapProvider.prototype.readBootstrap = function () { | |
- return __awaiter(this, void 0, void 0, function () { | |
- return __generator(this, function (_a) { | |
- if (this.data) { | |
- return [2 /*return*/, { version: 2, segments: this.segments, features: __spreadArray([], __read(this.data), false) }]; | |
- } | |
- if (this.url) { | |
- return [2 /*return*/, this.loadFromUrl(this.url)]; | |
- } | |
- if (this.filePath) { | |
- return [2 /*return*/, this.loadFromFile(this.filePath)]; | |
- } | |
- return [2 /*return*/, undefined]; | |
- }); | |
+ async loadFromUrl(bootstrapUrl) { | |
+ const response = await fetch(bootstrapUrl, { | |
+ method: 'GET', | |
+ timeout: 10000, | |
+ headers: (0, request_1.buildHeaders)(this.appName, this.instanceId, undefined, undefined, this.urlHeaders), | |
+ retry: { | |
+ retries: 2, | |
+ maxTimeout: 10000, | |
+ }, | |
}); | |
- }; | |
- return DefaultBootstrapProvider; | |
-}()); | |
+ if (response.ok) { | |
+ return response.json(); | |
+ } | |
+ return undefined; | |
+ } | |
+ async loadFromFile(filePath) { | |
+ const fileContent = await fs_1.promises.readFile(filePath, 'utf8'); | |
+ return JSON.parse(fileContent); | |
+ } | |
+ async readBootstrap() { | |
+ if (this.data) { | |
+ return { version: 2, segments: this.segments, features: [...this.data] }; | |
+ } | |
+ if (this.url) { | |
+ return this.loadFromUrl(this.url); | |
+ } | |
+ if (this.filePath) { | |
+ return this.loadFromFile(this.filePath); | |
+ } | |
+ return undefined; | |
+ } | |
+} | |
exports.DefaultBootstrapProvider = DefaultBootstrapProvider; | |
function resolveBootstrapProvider(options, appName, instanceId) { | |
return options.bootstrapProvider || new DefaultBootstrapProvider(options, appName, instanceId); | |
diff --git i/lib/repository/bootstrap-provider.js.map w/lib/repository/bootstrap-provider.js.map | |
index c018a7d..8264733 100644 | |
--- i/lib/repository/bootstrap-provider.js.map | |
+++ w/lib/repository/bootstrap-provider.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"bootstrap-provider.js","sourceRoot":"","sources":["../../src/repository/bootstrap-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAA8B;AAC9B,yCAA2C;AAG3C,sCAA0C;AAgB1C;IAeE,kCAAY,OAAyB,EAAE,OAAe,EAAE,UAAkB;QACxE,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;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,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC;iBACzC;gBAED,sBAAO,SAAS,EAAC;;;KAClB;IACH,+BAAC;AAAD,CAAC,AA5DD,IA4DC;AA5DY,4DAAwB;AA8DrC,SAAgB,wBAAwB,CACtC,OAAyB,EACzB,OAAe,EACf,UAAkB;IAElB,OAAO,OAAO,CAAC,iBAAiB,IAAI,IAAI,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AACjG,CAAC;AAND,4DAMC"} | |
\ No newline at end of file | |
+{"version":3,"file":"bootstrap-provider.js","sourceRoot":"","sources":["../../src/repository/bootstrap-provider.ts"],"names":[],"mappings":";;;AAAA,2BAA8B;AAC9B,2CAA2C;AAG3C,wCAA0C;AAgB1C,MAAa,wBAAwB;IAenC,YAAY,OAAyB,EAAE,OAAe,EAAE,UAAkB;QACxE,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAEjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,YAAoB;QAC5C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,YAAY,EAAE;YACzC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,KAAM;YACf,OAAO,EAAE,IAAA,sBAAY,EAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC;YAC3F,KAAK,EAAE;gBACL,OAAO,EAAE,CAAC;gBACV,UAAU,EAAE,KAAM;aACnB;SACF,CAAC,CAAC;QACH,IAAI,QAAQ,CAAC,EAAE,EAAE;YACf,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;SACxB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,QAAgB;QACzC,MAAM,WAAW,GAAG,MAAM,aAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SAC1E;QACD,IAAI,IAAI,CAAC,GAAG,EAAE;YACZ,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACnC;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACzC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA5DD,4DA4DC;AAED,SAAgB,wBAAwB,CACtC,OAAyB,EACzB,OAAe,EACf,UAAkB;IAElB,OAAO,OAAO,CAAC,iBAAiB,IAAI,IAAI,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AACjG,CAAC;AAND,4DAMC"} | |
\ No newline at end of file | |
diff --git i/lib/repository/index.js w/lib/repository/index.js | |
index baf3366..39c4940 100644 | |
--- i/lib/repository/index.js | |
+++ w/lib/repository/index.js | |
@@ -1,380 +1,215 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
-var __assign = (this && this.__assign) || function () { | |
- __assign = Object.assign || function(t) { | |
- for (var s, i = 1, n = arguments.length; i < n; i++) { | |
- s = arguments[i]; | |
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | |
- t[p] = s[p]; | |
- } | |
- return t; | |
- }; | |
- return __assign.apply(this, arguments); | |
-}; | |
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | |
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | |
- return new (P || (P = Promise))(function (resolve, reject) { | |
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | |
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | |
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | |
- step((generator = generator.apply(thisArg, _arguments || [])).next()); | |
- }); | |
-}; | |
-var __generator = (this && this.__generator) || function (thisArg, body) { | |
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | |
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | |
- function verb(n) { return function (v) { return step([n, v]); }; } | |
- function step(op) { | |
- if (f) throw new TypeError("Generator is already executing."); | |
- while (g && (g = 0, op[0] && (_ = 0)), _) try { | |
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | |
- if (y = 0, t) op = [op[0] & 2, t.value]; | |
- switch (op[0]) { | |
- case 0: case 1: t = op; break; | |
- case 4: _.label++; return { value: op[1], done: false }; | |
- case 5: _.label++; y = op[1]; op = [0]; continue; | |
- case 7: op = _.ops.pop(); _.trys.pop(); continue; | |
- default: | |
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | |
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | |
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | |
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | |
- if (t[2]) _.ops.pop(); | |
- _.trys.pop(); continue; | |
- } | |
- op = body.call(thisArg, _); | |
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | |
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | |
- } | |
-}; | |
-var __read = (this && this.__read) || function (o, n) { | |
- var m = typeof Symbol === "function" && o[Symbol.iterator]; | |
- if (!m) return o; | |
- var i = m.call(o), r, ar = [], e; | |
- try { | |
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | |
- } | |
- catch (error) { e = { error: error }; } | |
- finally { | |
- try { | |
- if (r && !r.done && (m = i["return"])) m.call(i); | |
- } | |
- finally { if (e) throw e.error; } | |
- } | |
- return ar; | |
-}; | |
-var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | |
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | |
- if (ar || !(i in from)) { | |
- if (!ar) ar = Array.prototype.slice.call(from, 0, i); | |
- ar[i] = from[i]; | |
- } | |
- } | |
- return to.concat(ar || Array.prototype.slice.call(from)); | |
-}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var events_1 = require("events"); | |
-var request_1 = require("../request"); | |
-var url_utils_1 = require("../url-utils"); | |
-var events_2 = require("../events"); | |
-var SUPPORTED_SPEC_VERSION = '4.2.0'; | |
-var Repository = /** @class */ (function (_super) { | |
- __extends(Repository, _super); | |
- function Repository(_a) { | |
- var url = _a.url, appName = _a.appName, instanceId = _a.instanceId, projectName = _a.projectName, _b = _a.refreshInterval, refreshInterval = _b === void 0 ? 15000 : _b, timeout = _a.timeout, headers = _a.headers, customHeadersFunction = _a.customHeadersFunction, httpOptions = _a.httpOptions, namePrefix = _a.namePrefix, tags = _a.tags, bootstrapProvider = _a.bootstrapProvider, _c = _a.bootstrapOverride, bootstrapOverride = _c === void 0 ? true : _c, storageProvider = _a.storageProvider; | |
- var _this = _super.call(this) || this; | |
- _this.stopped = false; | |
- _this.ready = false; | |
- _this.connected = false; | |
- _this.data = {}; | |
- _this.url = url; | |
- _this.refreshInterval = refreshInterval; | |
- _this.instanceId = instanceId; | |
- _this.appName = appName; | |
- _this.projectName = projectName; | |
- _this.headers = headers; | |
- _this.timeout = timeout; | |
- _this.customHeadersFunction = customHeadersFunction; | |
- _this.httpOptions = httpOptions; | |
- _this.namePrefix = namePrefix; | |
- _this.tags = tags; | |
- _this.bootstrapProvider = bootstrapProvider; | |
- _this.bootstrapOverride = bootstrapOverride; | |
- _this.storageProvider = storageProvider; | |
- _this.segments = new Map(); | |
- return _this; | |
+const events_1 = require("events"); | |
+const request_1 = require("../request"); | |
+const url_utils_1 = require("../url-utils"); | |
+const events_2 = require("../events"); | |
+const SUPPORTED_SPEC_VERSION = '4.2.0'; | |
+class Repository extends events_1.EventEmitter { | |
+ constructor({ url, appName, instanceId, projectName, refreshInterval = 15000, timeout, headers, customHeadersFunction, httpOptions, namePrefix, tags, bootstrapProvider, bootstrapOverride = true, storageProvider, }) { | |
+ super(); | |
+ this.stopped = false; | |
+ this.ready = false; | |
+ this.connected = false; | |
+ this.data = {}; | |
+ this.url = url; | |
+ this.refreshInterval = refreshInterval; | |
+ this.instanceId = instanceId; | |
+ this.appName = appName; | |
+ this.projectName = projectName; | |
+ this.headers = headers; | |
+ this.timeout = timeout; | |
+ this.customHeadersFunction = customHeadersFunction; | |
+ this.httpOptions = httpOptions; | |
+ this.namePrefix = namePrefix; | |
+ this.tags = tags; | |
+ this.bootstrapProvider = bootstrapProvider; | |
+ this.bootstrapOverride = bootstrapOverride; | |
+ this.storageProvider = storageProvider; | |
+ this.segments = new Map(); | |
} | |
- Repository.prototype.timedFetch = function (interval) { | |
- var _this = this; | |
+ timedFetch(interval) { | |
if (interval > 0) { | |
- this.timer = setTimeout(function () { return _this.fetch(); }, interval); | |
+ this.timer = setTimeout(() => this.fetch(), interval); | |
if (process.env.NODE_ENV !== 'test' && typeof this.timer.unref === 'function') { | |
this.timer.unref(); | |
} | |
} | |
- }; | |
- Repository.prototype.validateFeature = function (feature) { | |
- var errors = []; | |
+ } | |
+ validateFeature(feature) { | |
+ const errors = []; | |
if (!Array.isArray(feature.strategies)) { | |
- errors.push("feature.strategies should be an array, but was ".concat(typeof feature.strategies)); | |
+ errors.push(`feature.strategies should be an array, but was ${typeof feature.strategies}`); | |
} | |
if (feature.variants && !Array.isArray(feature.variants)) { | |
- errors.push("feature.variants should be an array, but was ".concat(typeof feature.variants)); | |
+ errors.push(`feature.variants should be an array, but was ${typeof feature.variants}`); | |
} | |
if (typeof feature.enabled !== 'boolean') { | |
- errors.push("feature.enabled should be an boolean, but was ".concat(typeof feature.enabled)); | |
+ errors.push(`feature.enabled should be an boolean, but was ${typeof feature.enabled}`); | |
} | |
if (errors.length > 0) { | |
- var err = new Error(errors.join(', ')); | |
+ const err = new Error(errors.join(', ')); | |
this.emit(events_2.UnleashEvents.Error, err); | |
} | |
- }; | |
- Repository.prototype.start = function () { | |
- return __awaiter(this, void 0, void 0, function () { | |
- return __generator(this, function (_a) { | |
- switch (_a.label) { | |
- case 0: return [4 /*yield*/, Promise.all([this.fetch(), this.loadBackup(), this.loadBootstrap()])]; | |
- case 1: | |
- _a.sent(); | |
- return [2 /*return*/]; | |
- } | |
- }); | |
- }); | |
- }; | |
- Repository.prototype.loadBackup = function () { | |
- return __awaiter(this, void 0, void 0, function () { | |
- var content, err_1; | |
- return __generator(this, function (_a) { | |
- switch (_a.label) { | |
- case 0: | |
- _a.trys.push([0, 2, , 3]); | |
- return [4 /*yield*/, this.storageProvider.get(this.appName)]; | |
- case 1: | |
- content = _a.sent(); | |
- if (this.ready) { | |
- return [2 /*return*/]; | |
- } | |
- if (content && this.notEmpty(content)) { | |
- this.data = this.convertToMap(content.features); | |
- this.segments = this.createSegmentLookup(content.segments); | |
- this.setReady(); | |
- } | |
- return [3 /*break*/, 3]; | |
- case 2: | |
- err_1 = _a.sent(); | |
- this.emit(events_2.UnleashEvents.Warn, err_1); | |
- return [3 /*break*/, 3]; | |
- case 3: return [2 /*return*/]; | |
- } | |
- }); | |
- }); | |
- }; | |
- Repository.prototype.setReady = function () { | |
- var _this = this; | |
- var doEmitReady = this.ready === false; | |
+ } | |
+ async start() { | |
+ await Promise.all([this.fetch(), this.loadBackup(), this.loadBootstrap()]); | |
+ } | |
+ async loadBackup() { | |
+ try { | |
+ const content = await this.storageProvider.get(this.appName); | |
+ if (this.ready) { | |
+ return; | |
+ } | |
+ if (content && this.notEmpty(content)) { | |
+ this.data = this.convertToMap(content.features); | |
+ this.segments = this.createSegmentLookup(content.segments); | |
+ this.setReady(); | |
+ } | |
+ } | |
+ catch (err) { | |
+ this.emit(events_2.UnleashEvents.Warn, err); | |
+ } | |
+ } | |
+ setReady() { | |
+ const doEmitReady = this.ready === false; | |
this.ready = true; | |
if (doEmitReady) { | |
- process.nextTick(function () { | |
- _this.emit(events_2.UnleashEvents.Ready); | |
+ process.nextTick(() => { | |
+ this.emit(events_2.UnleashEvents.Ready); | |
}); | |
} | |
- }; | |
- Repository.prototype.createSegmentLookup = function (segments) { | |
+ } | |
+ createSegmentLookup(segments) { | |
if (!segments) { | |
return new Map(); | |
} | |
- return new Map(segments.map(function (segment) { return [segment.id, segment]; })); | |
- }; | |
- Repository.prototype.save = function (response, fromApi) { | |
- return __awaiter(this, void 0, void 0, function () { | |
- return __generator(this, function (_a) { | |
- switch (_a.label) { | |
- case 0: | |
- if (fromApi) { | |
- this.connected = true; | |
- this.data = this.convertToMap(response.features); | |
- this.segments = this.createSegmentLookup(response.segments); | |
- } | |
- else if (!this.connected) { | |
- // Only allow bootstrap if not connected | |
- this.data = this.convertToMap(response.features); | |
- this.segments = this.createSegmentLookup(response.segments); | |
- } | |
- this.setReady(); | |
- this.emit(events_2.UnleashEvents.Changed, __spreadArray([], __read(response.features), false)); | |
- return [4 /*yield*/, this.storageProvider.set(this.appName, response)]; | |
- case 1: | |
- _a.sent(); | |
- return [2 /*return*/]; | |
- } | |
- }); | |
- }); | |
- }; | |
- Repository.prototype.notEmpty = function (content) { | |
+ return new Map(segments.map((segment) => [segment.id, segment])); | |
+ } | |
+ async save(response, fromApi) { | |
+ if (fromApi) { | |
+ this.connected = true; | |
+ this.data = this.convertToMap(response.features); | |
+ this.segments = this.createSegmentLookup(response.segments); | |
+ } | |
+ else if (!this.connected) { | |
+ // Only allow bootstrap if not connected | |
+ this.data = this.convertToMap(response.features); | |
+ this.segments = this.createSegmentLookup(response.segments); | |
+ } | |
+ this.setReady(); | |
+ this.emit(events_2.UnleashEvents.Changed, [...response.features]); | |
+ await this.storageProvider.set(this.appName, response); | |
+ } | |
+ notEmpty(content) { | |
return content.features.length > 0; | |
- }; | |
- Repository.prototype.loadBootstrap = function () { | |
- return __awaiter(this, void 0, void 0, function () { | |
- var content, err_2; | |
- return __generator(this, function (_a) { | |
- switch (_a.label) { | |
- case 0: | |
- _a.trys.push([0, 4, , 5]); | |
- return [4 /*yield*/, this.bootstrapProvider.readBootstrap()]; | |
- case 1: | |
- content = _a.sent(); | |
- if (!this.bootstrapOverride && this.ready) { | |
- // early exit if we already have backup data and should not override it. | |
- return [2 /*return*/]; | |
- } | |
- if (!(content && this.notEmpty(content))) return [3 /*break*/, 3]; | |
- return [4 /*yield*/, this.save(content, false)]; | |
- case 2: | |
- _a.sent(); | |
- _a.label = 3; | |
- case 3: return [3 /*break*/, 5]; | |
- case 4: | |
- err_2 = _a.sent(); | |
- this.emit(events_2.UnleashEvents.Warn, "Unleash SDK was unable to load bootstrap.\nMessage: ".concat(err_2.message)); | |
- return [3 /*break*/, 5]; | |
- case 5: return [2 /*return*/]; | |
- } | |
- }); | |
- }); | |
- }; | |
- Repository.prototype.convertToMap = function (features) { | |
- var _this = this; | |
- var obj = features.reduce(function (o, feature) { | |
- var a = __assign({}, o); | |
- _this.validateFeature(feature); | |
+ } | |
+ async loadBootstrap() { | |
+ try { | |
+ const content = await this.bootstrapProvider.readBootstrap(); | |
+ if (!this.bootstrapOverride && this.ready) { | |
+ // early exit if we already have backup data and should not override it. | |
+ return; | |
+ } | |
+ if (content && this.notEmpty(content)) { | |
+ await this.save(content, false); | |
+ } | |
+ } | |
+ catch (err) { | |
+ this.emit(events_2.UnleashEvents.Warn, `Unleash SDK was unable to load bootstrap. | |
+Message: ${err.message}`); | |
+ } | |
+ } | |
+ convertToMap(features) { | |
+ const obj = features.reduce((o, feature) => { | |
+ const a = { ...o }; | |
+ this.validateFeature(feature); | |
a[feature.name] = feature; | |
return a; | |
}, {}); | |
return obj; | |
- }; | |
- Repository.prototype.fetch = function () { | |
- return __awaiter(this, void 0, void 0, function () { | |
- var nextFetch, mergedTags, url, headers, _a, res, error, data, err_3, err_4, e; | |
- return __generator(this, function (_b) { | |
- switch (_b.label) { | |
- case 0: | |
- if (this.stopped || !(this.refreshInterval > 0)) { | |
- return [2 /*return*/]; | |
- } | |
- nextFetch = this.refreshInterval; | |
- _b.label = 1; | |
- case 1: | |
- _b.trys.push([1, 12, 13, 14]); | |
- mergedTags = void 0; | |
- if (this.tags) { | |
- mergedTags = this.mergeTagsToStringArray(this.tags); | |
- } | |
- url = (0, url_utils_1.default)(this.url, this.projectName, this.namePrefix, mergedTags); | |
- if (!this.customHeadersFunction) return [3 /*break*/, 3]; | |
- return [4 /*yield*/, this.customHeadersFunction()]; | |
- case 2: | |
- _a = _b.sent(); | |
- return [3 /*break*/, 4]; | |
- case 3: | |
- _a = this.headers; | |
- _b.label = 4; | |
- case 4: | |
- headers = _a; | |
- return [4 /*yield*/, (0, request_1.get)({ | |
- url: url, | |
- etag: this.etag, | |
- appName: this.appName, | |
- timeout: this.timeout, | |
- instanceId: this.instanceId, | |
- headers: headers, | |
- httpOptions: this.httpOptions, | |
- supportedSpecVersion: SUPPORTED_SPEC_VERSION, | |
- })]; | |
- case 5: | |
- res = _b.sent(); | |
- if (!(res.status === 304)) return [3 /*break*/, 6]; | |
- // No new data | |
- this.emit(events_2.UnleashEvents.Unchanged); | |
- return [3 /*break*/, 11]; | |
- case 6: | |
- if (!!res.ok) return [3 /*break*/, 7]; | |
- error = new Error("Response was not statusCode 2XX, but was ".concat(res.status)); | |
- this.emit(events_2.UnleashEvents.Error, error); | |
- return [3 /*break*/, 11]; | |
- case 7: | |
- _b.trys.push([7, 10, , 11]); | |
- return [4 /*yield*/, res.json()]; | |
- case 8: | |
- data = _b.sent(); | |
- if (res.headers.get('etag') !== null) { | |
- this.etag = res.headers.get('etag'); | |
- } | |
- else { | |
- this.etag = undefined; | |
- } | |
- return [4 /*yield*/, this.save(data, true)]; | |
- case 9: | |
- _b.sent(); | |
- return [3 /*break*/, 11]; | |
- case 10: | |
- err_3 = _b.sent(); | |
- this.emit(events_2.UnleashEvents.Error, err_3); | |
- return [3 /*break*/, 11]; | |
- case 11: return [3 /*break*/, 14]; | |
- case 12: | |
- err_4 = _b.sent(); | |
- e = err_4; | |
- if (e.code === 'ECONNRESET') { | |
- nextFetch = Math.max(Math.floor(this.refreshInterval / 2), 1000); | |
- this.emit(events_2.UnleashEvents.Warn, "Socket keep alive error, retrying in ".concat(nextFetch, "ms")); | |
- } | |
- else { | |
- this.emit(events_2.UnleashEvents.Error, err_4); | |
- } | |
- return [3 /*break*/, 14]; | |
- case 13: | |
- this.timedFetch(nextFetch); | |
- return [7 /*endfinally*/]; | |
- case 14: return [2 /*return*/]; | |
- } | |
+ } | |
+ async fetch() { | |
+ if (this.stopped || !(this.refreshInterval > 0)) { | |
+ return; | |
+ } | |
+ let nextFetch = this.refreshInterval; | |
+ try { | |
+ let mergedTags; | |
+ if (this.tags) { | |
+ mergedTags = this.mergeTagsToStringArray(this.tags); | |
+ } | |
+ const url = (0, url_utils_1.default)(this.url, this.projectName, this.namePrefix, mergedTags); | |
+ const headers = this.customHeadersFunction | |
+ ? await this.customHeadersFunction() | |
+ : this.headers; | |
+ const res = await (0, request_1.get)({ | |
+ url, | |
+ etag: this.etag, | |
+ appName: this.appName, | |
+ timeout: this.timeout, | |
+ instanceId: this.instanceId, | |
+ headers, | |
+ httpOptions: this.httpOptions, | |
+ supportedSpecVersion: SUPPORTED_SPEC_VERSION, | |
}); | |
- }); | |
- }; | |
- Repository.prototype.mergeTagsToStringArray = function (tags) { | |
- return tags.map(function (tag) { return "".concat(tag.name, ":").concat(tag.value); }); | |
- }; | |
- Repository.prototype.stop = function () { | |
+ if (res.status === 304) { | |
+ // No new data | |
+ this.emit(events_2.UnleashEvents.Unchanged); | |
+ } | |
+ else if (!res.ok) { | |
+ const error = new Error(`Response was not statusCode 2XX, but was ${res.status}`); | |
+ this.emit(events_2.UnleashEvents.Error, error); | |
+ } | |
+ else { | |
+ try { | |
+ const data = await res.json(); | |
+ if (res.headers.get('etag') !== null) { | |
+ this.etag = res.headers.get('etag'); | |
+ } | |
+ else { | |
+ this.etag = undefined; | |
+ } | |
+ await this.save(data, true); | |
+ } | |
+ catch (err) { | |
+ this.emit(events_2.UnleashEvents.Error, err); | |
+ } | |
+ } | |
+ } | |
+ catch (err) { | |
+ const e = err; | |
+ if (e.code === 'ECONNRESET') { | |
+ nextFetch = Math.max(Math.floor(this.refreshInterval / 2), 1000); | |
+ this.emit(events_2.UnleashEvents.Warn, `Socket keep alive error, retrying in ${nextFetch}ms`); | |
+ } | |
+ else { | |
+ this.emit(events_2.UnleashEvents.Error, err); | |
+ } | |
+ } | |
+ finally { | |
+ this.timedFetch(nextFetch); | |
+ } | |
+ } | |
+ mergeTagsToStringArray(tags) { | |
+ return tags.map((tag) => `${tag.name}:${tag.value}`); | |
+ } | |
+ stop() { | |
this.stopped = true; | |
if (this.timer) { | |
clearTimeout(this.timer); | |
} | |
this.removeAllListeners(); | |
- }; | |
- Repository.prototype.getSegment = function (segmentId) { | |
+ } | |
+ getSegment(segmentId) { | |
return this.segments.get(segmentId); | |
- }; | |
- Repository.prototype.getToggle = function (name) { | |
+ } | |
+ getToggle(name) { | |
return this.data[name]; | |
- }; | |
- Repository.prototype.getToggles = function () { | |
- var _this = this; | |
- return Object.keys(this.data).map(function (key) { return _this.data[key]; }); | |
- }; | |
- return Repository; | |
-}(events_1.EventEmitter)); | |
+ } | |
+ getToggles() { | |
+ return Object.keys(this.data).map((key) => this.data[key]); | |
+ } | |
+} | |
exports.default = Repository; | |
//# sourceMappingURL=index.js.map | |
\ No newline at end of file | |
diff --git i/lib/repository/index.js.map w/lib/repository/index.js.map | |
index 473f69b..fa19d43 100644 | |
--- i/lib/repository/index.js.map | |
+++ w/lib/repository/index.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repository/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAsC;AAEtC,sCAAiC;AAEjC,0CAAkC;AAKlC,oCAA0C;AAG1C,IAAM,sBAAsB,GAAG,OAAO,CAAC;AA8BvC;IAAwC,8BAAY;IA2ClD,oBAAY,EAeQ;YAdlB,GAAG,SAAA,EACH,OAAO,aAAA,EACP,UAAU,gBAAA,EACV,WAAW,iBAAA,EACX,uBAAwB,EAAxB,eAAe,mBAAG,KAAM,KAAA,EACxB,OAAO,aAAA,EACP,OAAO,aAAA,E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,OAAI,CAAC,CAAC;yBACtF;6BAAM;4BACL,IAAI,CAAC,IAAI,CAAC,sBAAa,CAAC,KAAK,EAAE,KAAG,CAAC,CAAC;yBACrC;;;wBAED,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;;;;;;KAE9B;IAED,2CAAsB,GAAtB,UAAuB,IAAsB;QAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,UAAG,GAAG,CAAC,IAAI,cAAI,GAAG,CAAC,KAAK,CAAE,EAA1B,CAA0B,CAAC,CAAC;IACvD,CAAC;IAED,yBAAI,GAAJ;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;QACD,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;IAED,+BAAU,GAAV,UAAW,SAAiB;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,8BAAS,GAAT,UAAU,IAAY;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,+BAAU,GAAV;QAAA,iBAEC;QADC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,KAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAd,CAAc,CAAC,CAAC;IAC7D,CAAC;IACH,iBAAC;AAAD,CAAC,AA5RD,CAAwC,qBAAY,GA4RnD"} | |
\ No newline at end of file | |
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repository/index.ts"],"names":[],"mappings":";;AAAA,mCAAsC;AAEtC,wCAAiC;AAEjC,4CAAkC;AAKlC,sCAA0C;AAG1C,MAAM,sBAAsB,GAAG,OAAO,CAAC;AA8BvC,MAA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KAAK,EAAE,GAAG,CAAC,CAAC;aACrC;SACF;gBAAS;YACR,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;SAC5B;IACH,CAAC;IAED,sBAAsB,CAAC,IAAsB;QAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,IAAI;QACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;QACD,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;IAED,UAAU,CAAC,SAAiB;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,SAAS,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,UAAU;QACR,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7D,CAAC;CACF;AA5RD,6BA4RC"} | |
\ No newline at end of file | |
diff --git i/lib/repository/storage-provider-file.js w/lib/repository/storage-provider-file.js | |
index 939b6ab..9821432 100644 | |
--- i/lib/repository/storage-provider-file.js | |
+++ w/lib/repository/storage-provider-file.js | |
@@ -1,104 +1,49 @@ | |
"use strict"; | |
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | |
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | |
- return new (P || (P = Promise))(function (resolve, reject) { | |
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | |
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | |
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | |
- step((generator = generator.apply(thisArg, _arguments || [])).next()); | |
- }); | |
-}; | |
-var __generator = (this && this.__generator) || function (thisArg, body) { | |
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | |
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | |
- function verb(n) { return function (v) { return step([n, v]); }; } | |
- function step(op) { | |
- if (f) throw new TypeError("Generator is already executing."); | |
- while (g && (g = 0, op[0] && (_ = 0)), _) try { | |
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | |
- if (y = 0, t) op = [op[0] & 2, t.value]; | |
- switch (op[0]) { | |
- case 0: case 1: t = op; break; | |
- case 4: _.label++; return { value: op[1], done: false }; | |
- case 5: _.label++; y = op[1]; op = [0]; continue; | |
- case 7: op = _.ops.pop(); _.trys.pop(); continue; | |
- default: | |
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | |
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | |
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | |
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | |
- if (t[2]) _.ops.pop(); | |
- _.trys.pop(); continue; | |
- } | |
- op = body.call(thisArg, _); | |
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | |
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | |
- } | |
-}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var path_1 = require("path"); | |
-var fs_1 = require("fs"); | |
-var helpers_1 = require("../helpers"); | |
-var writeFile = fs_1.promises.writeFile, readFile = fs_1.promises.readFile; | |
-var FileStorageProvider = /** @class */ (function () { | |
- function FileStorageProvider(backupPath) { | |
+const path_1 = require("path"); | |
+const fs_1 = require("fs"); | |
+const helpers_1 = require("../helpers"); | |
+const { writeFile, readFile } = fs_1.promises; | |
+class FileStorageProvider { | |
+ constructor(backupPath) { | |
if (!backupPath) { | |
throw new Error('backup Path is required'); | |
} | |
this.backupPath = backupPath; | |
} | |
- FileStorageProvider.prototype.getPath = function (key) { | |
- return (0, path_1.join)(this.backupPath, "/unleash-backup-".concat((0, helpers_1.safeName)(key), ".json")); | |
- }; | |
- FileStorageProvider.prototype.set = function (key, data) { | |
- return __awaiter(this, void 0, void 0, function () { | |
- return __generator(this, function (_a) { | |
- return [2 /*return*/, writeFile(this.getPath(key), JSON.stringify(data))]; | |
- }); | |
- }); | |
- }; | |
- FileStorageProvider.prototype.get = function (key) { | |
- return __awaiter(this, void 0, void 0, function () { | |
- var path, data, error_1; | |
- return __generator(this, function (_a) { | |
- switch (_a.label) { | |
- case 0: | |
- path = this.getPath(key); | |
- _a.label = 1; | |
- case 1: | |
- _a.trys.push([1, 3, , 4]); | |
- return [4 /*yield*/, readFile(path, 'utf8')]; | |
- case 2: | |
- data = _a.sent(); | |
- return [3 /*break*/, 4]; | |
- case 3: | |
- error_1 = _a.sent(); | |
- if (error_1.code !== 'ENOENT') { | |
- throw error_1; | |
- } | |
- else { | |
- return [2 /*return*/, undefined]; | |
- } | |
- return [3 /*break*/, 4]; | |
- case 4: | |
- if (!data || data.trim().length === 0) { | |
- return [2 /*return*/, undefined]; | |
- } | |
- try { | |
- return [2 /*return*/, JSON.parse(data)]; | |
- } | |
- catch (error) { | |
- if (error instanceof Error) { | |
- error.message = "Unleash storage failed parsing file ".concat(path, ": ").concat(error.message); | |
- } | |
- throw error; | |
- } | |
- return [2 /*return*/]; | |
- } | |
- }); | |
- }); | |
- }; | |
- return FileStorageProvider; | |
-}()); | |
+ getPath(key) { | |
+ return (0, path_1.join)(this.backupPath, `/unleash-backup-${(0, helpers_1.safeName)(key)}.json`); | |
+ } | |
+ async set(key, data) { | |
+ return writeFile(this.getPath(key), JSON.stringify(data)); | |
+ } | |
+ async get(key) { | |
+ const path = this.getPath(key); | |
+ let data; | |
+ try { | |
+ data = await readFile(path, 'utf8'); | |
+ } | |
+ catch (error) { | |
+ if (error.code !== 'ENOENT') { | |
+ throw error; | |
+ } | |
+ else { | |
+ return undefined; | |
+ } | |
+ } | |
+ if (!data || data.trim().length === 0) { | |
+ return undefined; | |
+ } | |
+ try { | |
+ return JSON.parse(data); | |
+ } | |
+ catch (error) { | |
+ if (error instanceof Error) { | |
+ error.message = `Unleash storage failed parsing file ${path}: ${error.message}`; | |
+ } | |
+ throw error; | |
+ } | |
+ } | |
+} | |
exports.default = FileStorageProvider; | |
//# sourceMappingURL=storage-provider-file.js.map | |
\ No newline at end of file | |
diff --git i/lib/repository/storage-provider-file.js.map w/lib/repository/storage-provider-file.js.map | |
index 0038548..0c76ca6 100644 | |
--- i/lib/repository/storage-provider-file.js.map | |
+++ w/lib/repository/storage-provider-file.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"storage-provider-file.js","sourceRoot":"","sources":["../../src/repository/storage-provider-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4B;AAC5B,yBAA8B;AAC9B,sCAAsC;AAG9B,IAAA,SAAS,GAAe,aAAQ,UAAvB,EAAE,QAAQ,GAAK,aAAQ,SAAb,CAAc;AAEzC;IAGI,6BAAY,UAAkB;QAC5B,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;SAC5C;QACD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEO,qCAAO,GAAf,UAAgB,GAAW;QACzB,OAAO,IAAA,WAAI,EAAC,IAAI,CAAC,UAAU,EAAE,0BAAmB,IAAA,kBAAQ,EAAC,GAAG,CAAC,UAAO,CAAC,CAAC;IACxE,CAAC;IAEK,iCAAG,GAAT,UAAU,GAAW,EAAE,IAAO;;;gBAC5B,sBAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAC;;;KAC3D;IAEK,iCAAG,GAAT,UAAU,GAAW;;;;;;wBACb,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;;;;wBAGtB,qBAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,EAAA;;wBAAnC,IAAI,GAAG,SAA4B,CAAC;;;;wBAEpC,IAAI,OAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;4BAC3B,MAAM,OAAK,CAAC;yBACb;6BAAM;4BACL,sBAAO,SAAS,EAAC;yBAClB;;;wBAGH,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;4BACrC,sBAAO,SAAS,EAAC;yBAClB;wBAED,IAAI;4BACF,sBAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAC;yBACzB;wBAAC,OAAO,KAAU,EAAE;4BACnB,IAAI,KAAK,YAAY,KAAK,EAAE;gCAC1B,KAAK,CAAC,OAAO,GAAG,8CAAuC,IAAI,eAAK,KAAK,CAAC,OAAO,CAAE,CAAC;6BACjF;4BACD,MAAM,KAAK,CAAC;yBACb;;;;;KACF;IACH,0BAAC;AAAD,CAAC,AA5CH,IA4CG"} | |
\ No newline at end of file | |
+{"version":3,"file":"storage-provider-file.js","sourceRoot":"","sources":["../../src/repository/storage-provider-file.ts"],"names":[],"mappings":";;AAAA,+BAA4B;AAC5B,2BAA8B;AAC9B,wCAAsC;AAGtC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,aAAQ,CAAC;AAEzC,M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;AA5CH,sCA4CG"} | |
\ No newline at end of file | |
diff --git i/lib/repository/storage-provider-in-mem.js w/lib/repository/storage-provider-in-mem.js | |
index 1aaaf8a..5fc5497 100644 | |
--- i/lib/repository/storage-provider-in-mem.js | |
+++ w/lib/repository/storage-provider-in-mem.js | |
@@ -1,61 +1,16 @@ | |
"use strict"; | |
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | |
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | |
- return new (P || (P = Promise))(function (resolve, reject) { | |
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | |
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | |
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | |
- step((generator = generator.apply(thisArg, _arguments || [])).next()); | |
- }); | |
-}; | |
-var __generator = (this && this.__generator) || function (thisArg, body) { | |
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | |
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | |
- function verb(n) { return function (v) { return step([n, v]); }; } | |
- function step(op) { | |
- if (f) throw new TypeError("Generator is already executing."); | |
- while (g && (g = 0, op[0] && (_ = 0)), _) try { | |
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | |
- if (y = 0, t) op = [op[0] & 2, t.value]; | |
- switch (op[0]) { | |
- case 0: case 1: t = op; break; | |
- case 4: _.label++; return { value: op[1], done: false }; | |
- case 5: _.label++; y = op[1]; op = [0]; continue; | |
- case 7: op = _.ops.pop(); _.trys.pop(); continue; | |
- default: | |
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | |
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | |
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | |
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | |
- if (t[2]) _.ops.pop(); | |
- _.trys.pop(); continue; | |
- } | |
- op = body.call(thisArg, _); | |
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | |
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | |
- } | |
-}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var InMemStorageProvider = /** @class */ (function () { | |
- function InMemStorageProvider() { | |
+class InMemStorageProvider { | |
+ constructor() { | |
this.store = new Map(); | |
} | |
- InMemStorageProvider.prototype.set = function (key, data) { | |
- return __awaiter(this, void 0, void 0, function () { | |
- return __generator(this, function (_a) { | |
- this.store.set(key, data); | |
- return [2 /*return*/, Promise.resolve()]; | |
- }); | |
- }); | |
- }; | |
- InMemStorageProvider.prototype.get = function (key) { | |
- return __awaiter(this, void 0, void 0, function () { | |
- return __generator(this, function (_a) { | |
- return [2 /*return*/, Promise.resolve(this.store.get(key))]; | |
- }); | |
- }); | |
- }; | |
- return InMemStorageProvider; | |
-}()); | |
+ async set(key, data) { | |
+ this.store.set(key, data); | |
+ return Promise.resolve(); | |
+ } | |
+ async get(key) { | |
+ return Promise.resolve(this.store.get(key)); | |
+ } | |
+} | |
exports.default = InMemStorageProvider; | |
//# sourceMappingURL=storage-provider-in-mem.js.map | |
\ No newline at end of file | |
diff --git i/lib/repository/storage-provider-in-mem.js.map w/lib/repository/storage-provider-in-mem.js.map | |
index f9af165..70b8fe4 100644 | |
--- i/lib/repository/storage-provider-in-mem.js.map | |
+++ w/lib/repository/storage-provider-in-mem.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"storage-provider-in-mem.js","sourceRoot":"","sources":["../../src/repository/storage-provider-in-mem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;IAAA;QACU,UAAK,GAAmB,IAAI,GAAG,EAAa,CAAC;IAUvD,CAAC;IARO,kCAAG,GAAT,UAAU,GAAW,EAAE,IAAO;;;gBAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;gBAC1B,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;;;KAC1B;IAEK,kCAAG,GAAT,UAAU,GAAW;;;gBACnB,sBAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAC;;;KAC7C;IACH,2BAAC;AAAD,CAAC,AAXD,IAWC"} | |
\ No newline at end of file | |
+{"version":3,"file":"storage-provider-in-mem.js","sourceRoot":"","sources":["../../src/repository/storage-provider-in-mem.ts"],"names":[],"mappings":";;AAEA,MAAqB,oBAAoB;IAAzC;QACU,UAAK,GAAmB,IAAI,GAAG,EAAa,CAAC;IAUvD,CAAC;IARC,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,IAAO;QAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC1B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9C,CAAC;CACF;AAXD,uCAWC"} | |
\ No newline at end of file | |
diff --git i/lib/request.js w/lib/request.js | |
index 0fb3da4..96b2b39 100644 | |
--- i/lib/request.js | |
+++ w/lib/request.js | |
@@ -1,23 +1,23 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.get = exports.post = exports.buildHeaders = exports.getDefaultAgent = void 0; | |
-var fetch = require("make-fetch-happen"); | |
-var http = require("http"); | |
-var https = require("https"); | |
-var httpAgent = new http.Agent({ | |
+const fetch = require("make-fetch-happen"); | |
+const http = require("http"); | |
+const https = require("https"); | |
+const httpAgent = new http.Agent({ | |
keepAlive: true, | |
keepAliveMsecs: 30 * 1000, | |
timeout: 10 * 1000, | |
}); | |
-var httpsAgent = new https.Agent({ | |
+const httpsAgent = new https.Agent({ | |
keepAlive: true, | |
keepAliveMsecs: 30 * 1000, | |
timeout: 10 * 1000, | |
}); | |
-var getDefaultAgent = function (url) { return (url.protocol === 'https:' ? httpsAgent : httpAgent); }; | |
+const getDefaultAgent = (url) => (url.protocol === 'https:' ? httpsAgent : httpAgent); | |
exports.getDefaultAgent = getDefaultAgent; | |
-var buildHeaders = function (appName, instanceId, etag, contentType, custom, specVersionSupported) { | |
- var head = {}; | |
+const buildHeaders = (appName, instanceId, etag, contentType, custom, specVersionSupported) => { | |
+ const head = {}; | |
if (appName) { | |
head['UNLEASH-APPNAME'] = appName; | |
head['User-Agent'] = appName; | |
@@ -40,31 +40,25 @@ var buildHeaders = function (appName, instanceId, etag, contentType, custom, spe | |
return head; | |
}; | |
exports.buildHeaders = buildHeaders; | |
-var post = function (_a) { | |
- var url = _a.url, appName = _a.appName, timeout = _a.timeout, instanceId = _a.instanceId, headers = _a.headers, json = _a.json, httpOptions = _a.httpOptions; | |
- return fetch(url, { | |
- timeout: timeout || 10000, | |
- method: 'POST', | |
- agent: (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.agent) || exports.getDefaultAgent, | |
- headers: (0, exports.buildHeaders)(appName, instanceId, undefined, 'application/json', headers), | |
- body: JSON.stringify(json), | |
- strictSSL: httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.rejectUnauthorized, | |
- }); | |
-}; | |
+const post = ({ url, appName, timeout, instanceId, headers, json, httpOptions, }) => fetch(url, { | |
+ timeout: timeout || 10000, | |
+ method: 'POST', | |
+ agent: (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.agent) || exports.getDefaultAgent, | |
+ headers: (0, exports.buildHeaders)(appName, instanceId, undefined, 'application/json', headers), | |
+ body: JSON.stringify(json), | |
+ strictSSL: httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.rejectUnauthorized, | |
+}); | |
exports.post = post; | |
-var get = function (_a) { | |
- var url = _a.url, etag = _a.etag, appName = _a.appName, timeout = _a.timeout, instanceId = _a.instanceId, headers = _a.headers, httpOptions = _a.httpOptions, supportedSpecVersion = _a.supportedSpecVersion; | |
- return fetch(url, { | |
- method: 'GET', | |
- timeout: timeout || 10000, | |
- agent: (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.agent) || exports.getDefaultAgent, | |
- headers: (0, exports.buildHeaders)(appName, instanceId, etag, undefined, headers, supportedSpecVersion), | |
- retry: { | |
- retries: 2, | |
- maxTimeout: timeout || 10000, | |
- }, | |
- strictSSL: httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.rejectUnauthorized, | |
- }); | |
-}; | |
+const get = ({ url, etag, appName, timeout, instanceId, headers, httpOptions, supportedSpecVersion, }) => fetch(url, { | |
+ method: 'GET', | |
+ timeout: timeout || 10000, | |
+ agent: (httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.agent) || exports.getDefaultAgent, | |
+ headers: (0, exports.buildHeaders)(appName, instanceId, etag, undefined, headers, supportedSpecVersion), | |
+ retry: { | |
+ retries: 2, | |
+ maxTimeout: timeout || 10000, | |
+ }, | |
+ strictSSL: httpOptions === null || httpOptions === void 0 ? void 0 : httpOptions.rejectUnauthorized, | |
+}); | |
exports.get = get; | |
//# sourceMappingURL=request.js.map | |
\ No newline at end of file | |
diff --git i/lib/request.js.map w/lib/request.js.map | |
index a0e6823..1bfa777 100644 | |
--- i/lib/request.js.map | |
+++ w/lib/request.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAC3C,2BAA6B;AAC7B,6BAA+B;AA6B/B,IAAM,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AC1F,KAAK,EAAE;QACL,OAAO,EAAE,CAAC;QACV,UAAU,EAAE,OAAO,IAAI,KAAM;KAC9B;IACD,SAAS,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB;CAC3C,CAAC,CAAC;AApBQ,QAAA,GAAG,OAoBX"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/application-hostname-strategy.js w/lib/strategy/application-hostname-strategy.js | |
index f0edd9f..1a75812 100644 | |
--- i/lib/strategy/application-hostname-strategy.js | |
+++ w/lib/strategy/application-hostname-strategy.js | |
@@ -1,30 +1,13 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var os_1 = require("os"); | |
-var strategy_1 = require("./strategy"); | |
-var ApplicationHostnameStrategy = /** @class */ (function (_super) { | |
- __extends(ApplicationHostnameStrategy, _super); | |
- function ApplicationHostnameStrategy() { | |
- var _this = _super.call(this, 'applicationHostname') || this; | |
- _this.hostname = (process.env.HOSTNAME || (0, os_1.hostname)() || 'undefined').toLowerCase(); | |
- return _this; | |
+const os_1 = require("os"); | |
+const strategy_1 = require("./strategy"); | |
+class ApplicationHostnameStrategy extends strategy_1.Strategy { | |
+ constructor() { | |
+ super('applicationHostname'); | |
+ this.hostname = (process.env.HOSTNAME || (0, os_1.hostname)() || 'undefined').toLowerCase(); | |
} | |
- ApplicationHostnameStrategy.prototype.isEnabled = function (parameters) { | |
+ isEnabled(parameters) { | |
if (!parameters.hostNames) { | |
return false; | |
} | |
@@ -32,8 +15,7 @@ var ApplicationHostnameStrategy = /** @class */ (function (_super) { | |
.toLowerCase() | |
.split(/\s*,\s*/) | |
.includes(this.hostname); | |
- }; | |
- return ApplicationHostnameStrategy; | |
-}(strategy_1.Strategy)); | |
+ } | |
+} | |
exports.default = ApplicationHostnameStrategy; | |
//# sourceMappingURL=application-hostname-strategy.js.map | |
\ No newline at end of file | |
diff --git i/lib/strategy/application-hostname-strategy.js.map w/lib/strategy/application-hostname-strategy.js.map | |
index af2097d..d1f1524 100644 | |
--- i/lib/strategy/application-hostname-strategy.js.map | |
+++ w/lib/strategy/application-hostname-strategy.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"application-hostname-strategy.js","sourceRoot":"","sources":["../../src/strategy/application-hostname-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yBAA8B;AAC9B,uCAAsC;AAEtC;IAAyD,+CAAQ;IAG/D;QAAA,YACE,kBAAM,qBAAqB,CAAC,SAE7B;QADC,KAAI,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAA,aAAQ,GAAE,IAAI,WAAW,CAAC,CAAC,WAAW,EAAE,CAAC;;IACpF,CAAC;IAED,+CAAS,GAAT,UAAU,UAAe;QACvB,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;YACzB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,UAAU,CAAC,SAAS;aACxB,WAAW,EAAE;aACb,KAAK,CAAC,SAAS,CAAC;aAChB,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IACH,kCAAC;AAAD,CAAC,AAlBD,CAAyD,mBAAQ,GAkBhE"} | |
\ No newline at end of file | |
+{"version":3,"file":"application-hostname-strategy.js","sourceRoot":"","sources":["../../src/strategy/application-hostname-strategy.ts"],"names":[],"mappings":";;AAAA,2BAA8B;AAC9B,yCAAsC;AAEtC,MAAqB,2BAA4B,SAAQ,mBAAQ;IAG/D;QACE,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAA,aAAQ,GAAE,IAAI,WAAW,CAAC,CAAC,WAAW,EAAE,CAAC;IACpF,CAAC;IAED,SAAS,CAAC,UAAe;QACvB,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;YACzB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,UAAU,CAAC,SAAS;aACxB,WAAW,EAAE;aACb,KAAK,CAAC,SAAS,CAAC;aAChB,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;CACF;AAlBD,8CAkBC"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/default-strategy.js w/lib/strategy/default-strategy.js | |
index 56d59be..72e1e7b 100644 | |
--- i/lib/strategy/default-strategy.js | |
+++ w/lib/strategy/default-strategy.js | |
@@ -1,30 +1,13 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var strategy_1 = require("./strategy"); | |
-var DefaultStrategy = /** @class */ (function (_super) { | |
- __extends(DefaultStrategy, _super); | |
- function DefaultStrategy() { | |
- return _super.call(this, 'default') || this; | |
+const strategy_1 = require("./strategy"); | |
+class DefaultStrategy extends strategy_1.Strategy { | |
+ constructor() { | |
+ super('default'); | |
} | |
- DefaultStrategy.prototype.isEnabled = function () { | |
+ isEnabled() { | |
return true; | |
- }; | |
- return DefaultStrategy; | |
-}(strategy_1.Strategy)); | |
+ } | |
+} | |
exports.default = DefaultStrategy; | |
//# sourceMappingURL=default-strategy.js.map | |
\ No newline at end of file | |
diff --git i/lib/strategy/default-strategy.js.map w/lib/strategy/default-strategy.js.map | |
index dd5b9ca..6a417a7 100644 | |
--- i/lib/strategy/default-strategy.js.map | |
+++ w/lib/strategy/default-strategy.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"default-strategy.js","sourceRoot":"","sources":["../../src/strategy/default-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAsC;AAEtC;IAA6C,mCAAQ;IACnD;eACE,kBAAM,SAAS,CAAC;IAClB,CAAC;IAED,mCAAS,GAAT;QACE,OAAO,IAAI,CAAC;IACd,CAAC;IACH,sBAAC;AAAD,CAAC,AARD,CAA6C,mBAAQ,GAQpD"} | |
\ No newline at end of file | |
+{"version":3,"file":"default-strategy.js","sourceRoot":"","sources":["../../src/strategy/default-strategy.ts"],"names":[],"mappings":";;AAAA,yCAAsC;AAEtC,MAAqB,eAAgB,SAAQ,mBAAQ;IACnD;QACE,KAAK,CAAC,SAAS,CAAC,CAAC;IACnB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AARD,kCAQC"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/flexible-rollout-strategy.js w/lib/strategy/flexible-rollout-strategy.js | |
index 00d2e70..e17471a 100644 | |
--- i/lib/strategy/flexible-rollout-strategy.js | |
+++ w/lib/strategy/flexible-rollout-strategy.js | |
@@ -1,38 +1,21 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var strategy_1 = require("./strategy"); | |
-var util_1 = require("./util"); | |
-var helpers_1 = require("../helpers"); | |
-var STICKINESS = { | |
+const strategy_1 = require("./strategy"); | |
+const util_1 = require("./util"); | |
+const helpers_1 = require("../helpers"); | |
+const STICKINESS = { | |
default: 'default', | |
random: 'random', | |
}; | |
-var FlexibleRolloutStrategy = /** @class */ (function (_super) { | |
- __extends(FlexibleRolloutStrategy, _super); | |
- function FlexibleRolloutStrategy(randomGenerator) { | |
- var _this = _super.call(this, 'flexibleRollout') || this; | |
- _this.randomGenerator = function () { return "".concat(Math.round(Math.random() * 10000) + 1); }; | |
+class FlexibleRolloutStrategy extends strategy_1.Strategy { | |
+ constructor(randomGenerator) { | |
+ super('flexibleRollout'); | |
+ this.randomGenerator = () => `${Math.round(Math.random() * 10000) + 1}`; | |
if (randomGenerator) { | |
- _this.randomGenerator = randomGenerator; | |
+ this.randomGenerator = randomGenerator; | |
} | |
- return _this; | |
} | |
- FlexibleRolloutStrategy.prototype.resolveStickiness = function (stickiness, context) { | |
+ resolveStickiness(stickiness, context) { | |
switch (stickiness) { | |
case STICKINESS.default: | |
return context.userId || context.sessionId || this.randomGenerator(); | |
@@ -41,19 +24,18 @@ var FlexibleRolloutStrategy = /** @class */ (function (_super) { | |
default: | |
return (0, helpers_1.resolveContextValue)(context, stickiness); | |
} | |
- }; | |
- FlexibleRolloutStrategy.prototype.isEnabled = function (parameters, context) { | |
- var groupId = parameters.groupId || context.featureToggle || ''; | |
- var percentage = Number(parameters.rollout); | |
- var stickiness = parameters.stickiness || STICKINESS.default; | |
- var stickinessId = this.resolveStickiness(stickiness, context); | |
+ } | |
+ isEnabled(parameters, context) { | |
+ const groupId = parameters.groupId || context.featureToggle || ''; | |
+ const percentage = Number(parameters.rollout); | |
+ const stickiness = parameters.stickiness || STICKINESS.default; | |
+ const stickinessId = this.resolveStickiness(stickiness, context); | |
if (!stickinessId) { | |
return false; | |
} | |
- var normalizedUserId = (0, util_1.default)(stickinessId, groupId); | |
+ const normalizedUserId = (0, util_1.default)(stickinessId, groupId); | |
return percentage > 0 && normalizedUserId <= percentage; | |
- }; | |
- return FlexibleRolloutStrategy; | |
-}(strategy_1.Strategy)); | |
+ } | |
+} | |
exports.default = FlexibleRolloutStrategy; | |
//# sourceMappingURL=flexible-rollout-strategy.js.map | |
\ No newline at end of file | |
diff --git i/lib/strategy/flexible-rollout-strategy.js.map w/lib/strategy/flexible-rollout-strategy.js.map | |
index e9aad7e..890ad25 100644 | |
--- i/lib/strategy/flexible-rollout-strategy.js.map | |
+++ w/lib/strategy/flexible-rollout-strategy.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"flexible-rollout-strategy.js","sourceRoot":"","sources":["../../src/strategy/flexible-rollout-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAsC;AAEtC,+BAAqC;AACrC,sCAAiD;AAEjD,IAAM,UAAU,GAAG;IACjB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF;IAAqD,2CAAQ;IAG3D,iCAAY,eAA0B;QAAtC,YACE,kBAAM,iBAAiB,CAAC,SAIzB;QAPO,qBAAe,GAAa,cAAM,OAAA,UAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAE,EAA1C,CAA0C,CAAC;QAInF,IAAI,eAAe,EAAE;YACnB,KAAI,CAAC,eAAe,GAAG,eAAe,CAAC;SACxC;;IACH,CAAC;IAED,mDAAiB,GAAjB,UAAkB,UAAkB,EAAE,OAAgB;QACpD,QAAQ,UAAU,EAAE;YAClB,KAAK,UAAU,CAAC,OAAO;gBACrB,OAAO,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACvE,KAAK,UAAU,CAAC,MAAM;gBACpB,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;YAChC;gBACE,OAAO,IAAA,6BAAmB,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;SACnD;IACH,CAAC;IAED,2CAAS,GAAT,UAAU,UAAe,EAAE,OAAgB;QACzC,IAAM,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC;QAClE,IAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAM,UAAU,GAAW,UAAU,CAAC,UAAU,IAAI,UAAU,CAAC,OAAO,CAAC;QACvE,IAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAEjE,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO,KAAK,CAAC;SACd;QACD,IAAM,gBAAgB,GAAG,IAAA,cAAe,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAChE,OAAO,UAAU,GAAG,CAAC,IAAI,gBAAgB,IAAI,UAAU,CAAC;IAC1D,CAAC;IACH,8BAAC;AAAD,CAAC,AAjCD,CAAqD,mBAAQ,GAiC5D"} | |
\ No newline at end of file | |
+{"version":3,"file":"flexible-rollout-strategy.js","sourceRoot":"","sources":["../../src/strategy/flexible-rollout-strategy.ts"],"names":[],"mappings":";;AAAA,yCAAsC;AAEtC,iCAAqC;AACrC,wCAAiD;AAEjD,MAAM,UAAU,GAA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,gBAAgB,IAAI,UAAU,CAAC;IAC1D,CAAC;CACF;AAjCD,0CAiCC"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/gradual-rollout-random.js w/lib/strategy/gradual-rollout-random.js | |
index ab1e1b1..84285db 100644 | |
--- i/lib/strategy/gradual-rollout-random.js | |
+++ w/lib/strategy/gradual-rollout-random.js | |
@@ -1,36 +1,18 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var strategy_1 = require("./strategy"); | |
-var GradualRolloutRandomStrategy = /** @class */ (function (_super) { | |
- __extends(GradualRolloutRandomStrategy, _super); | |
- function GradualRolloutRandomStrategy(randomGenerator) { | |
- var _this = _super.call(this, 'gradualRolloutRandom') || this; | |
- _this.randomGenerator = function () { return Math.floor(Math.random() * 100) + 1; }; | |
- _this.randomGenerator = randomGenerator || _this.randomGenerator; | |
- return _this; | |
+const strategy_1 = require("./strategy"); | |
+class GradualRolloutRandomStrategy extends strategy_1.Strategy { | |
+ constructor(randomGenerator) { | |
+ super('gradualRolloutRandom'); | |
+ this.randomGenerator = () => Math.floor(Math.random() * 100) + 1; | |
+ this.randomGenerator = randomGenerator || this.randomGenerator; | |
} | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
- GradualRolloutRandomStrategy.prototype.isEnabled = function (parameters, context) { | |
- var percentage = Number(parameters.percentage); | |
- var random = this.randomGenerator(); | |
+ isEnabled(parameters, context) { | |
+ const percentage = Number(parameters.percentage); | |
+ const random = this.randomGenerator(); | |
return percentage >= random; | |
- }; | |
- return GradualRolloutRandomStrategy; | |
-}(strategy_1.Strategy)); | |
+ } | |
+} | |
exports.default = GradualRolloutRandomStrategy; | |
//# sourceMappingURL=gradual-rollout-random.js.map | |
\ No newline at end of file | |
diff --git i/lib/strategy/gradual-rollout-random.js.map w/lib/strategy/gradual-rollout-random.js.map | |
index f924ed9..a795109 100644 | |
--- i/lib/strategy/gradual-rollout-random.js.map | |
+++ w/lib/strategy/gradual-rollout-random.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"gradual-rollout-random.js","sourceRoot":"","sources":["../../src/strategy/gradual-rollout-random.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAsC;AAGtC;IAA0D,gDAAQ;IAGhE,sCAAY,eAA0B;QAAtC,YACE,kBAAM,sBAAsB,CAAC,SAE9B;QALO,qBAAe,GAAa,cAAM,OAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,EAAnC,CAAmC,CAAC;QAI5E,KAAI,CAAC,eAAe,GAAG,eAAe,IAAI,KAAI,CAAC,eAAe,CAAC;;IACjE,CAAC;IAED,6DAA6D;IAC7D,gDAAS,GAAT,UAAU,UAAe,EAAE,OAAgB;QACzC,IAAM,UAAU,GAAW,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACzD,IAAM,MAAM,GAAW,IAAI,CAAC,eAAe,EAAE,CAAC;QAC9C,OAAO,UAAU,IAAI,MAAM,CAAC;IAC9B,CAAC;IACH,mCAAC;AAAD,CAAC,AAdD,CAA0D,mBAAQ,GAcjE"} | |
\ No newline at end of file | |
+{"version":3,"file":"gradual-rollout-random.js","sourceRoot":"","sources":["../../src/strategy/gradual-rollout-random.ts"],"names":[],"mappings":";;AAAA,yCAAsC;AAGtC,MAAqB,4BAA6B,SAAQ,mBAAQ;IAGhE,YAAY,eAA0B;QACpC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAHxB,oBAAe,GAAa,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAI5E,IAAI,CAAC,eAAe,GAAG,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC;IACjE,CAAC;IAED,6DAA6D;IAC7D,SAAS,CAAC,UAAe,EAAE,OAAgB;QACzC,MAAM,UAAU,GAAW,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,MAAM,GAAW,IAAI,CAAC,eAAe,EAAE,CAAC;QAC9C,OAAO,UAAU,IAAI,MAAM,CAAC;IAC9B,CAAC;CACF;AAdD,+CAcC"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/gradual-rollout-session-id.js w/lib/strategy/gradual-rollout-session-id.js | |
index 88ecb48..a4fad40 100644 | |
--- i/lib/strategy/gradual-rollout-session-id.js | |
+++ w/lib/strategy/gradual-rollout-session-id.js | |
@@ -1,38 +1,21 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var strategy_1 = require("./strategy"); | |
-var util_1 = require("./util"); | |
-var GradualRolloutSessionIdStrategy = /** @class */ (function (_super) { | |
- __extends(GradualRolloutSessionIdStrategy, _super); | |
- function GradualRolloutSessionIdStrategy() { | |
- return _super.call(this, 'gradualRolloutSessionId') || this; | |
+const strategy_1 = require("./strategy"); | |
+const util_1 = require("./util"); | |
+class GradualRolloutSessionIdStrategy extends strategy_1.Strategy { | |
+ constructor() { | |
+ super('gradualRolloutSessionId'); | |
} | |
- GradualRolloutSessionIdStrategy.prototype.isEnabled = function (parameters, context) { | |
- var sessionId = context.sessionId; | |
+ isEnabled(parameters, context) { | |
+ const { sessionId } = context; | |
if (!sessionId) { | |
return false; | |
} | |
- var percentage = Number(parameters.percentage); | |
- var groupId = parameters.groupId || ''; | |
- var normalizedId = (0, util_1.default)(sessionId, groupId); | |
+ const percentage = Number(parameters.percentage); | |
+ const groupId = parameters.groupId || ''; | |
+ const normalizedId = (0, util_1.default)(sessionId, groupId); | |
return percentage > 0 && normalizedId <= percentage; | |
- }; | |
- return GradualRolloutSessionIdStrategy; | |
-}(strategy_1.Strategy)); | |
+ } | |
+} | |
exports.default = GradualRolloutSessionIdStrategy; | |
//# sourceMappingURL=gradual-rollout-session-id.js.map | |
\ No newline at end of file | |
diff --git i/lib/strategy/gradual-rollout-session-id.js.map w/lib/strategy/gradual-rollout-session-id.js.map | |
index eac8ea2..3231587 100644 | |
--- i/lib/strategy/gradual-rollout-session-id.js.map | |
+++ w/lib/strategy/gradual-rollout-session-id.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"gradual-rollout-session-id.js","sourceRoot":"","sources":["../../src/strategy/gradual-rollout-session-id.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAsC;AACtC,+BAAqC;AAGrC;IAA6D,mDAAQ;IACnE;eACE,kBAAM,yBAAyB,CAAC;IAClC,CAAC;IAED,mDAAS,GAAT,UAAU,UAAe,EAAE,OAAgB;QACjC,IAAA,SAAS,GAAK,OAAO,UAAZ,CAAa;QAC9B,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,KAAK,CAAC;SACd;QAED,IAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACjD,IAAM,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC;QAEzC,IAAM,YAAY,GAAG,IAAA,cAAe,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAEzD,OAAO,UAAU,GAAG,CAAC,IAAI,YAAY,IAAI,UAAU,CAAC;IACtD,CAAC;IACH,sCAAC;AAAD,CAAC,AAlBD,CAA6D,mBAAQ,GAkBpE"} | |
\ No newline at end of file | |
+{"version":3,"file":"gradual-rollout-session-id.js","sourceRoot":"","sources":["../../src/strategy/gradual-rollout-session-id.ts"],"names":[],"mappings":";;AAAA,yCAAsC;AACtC,iCAAqC;AAGrC,MAAqB,+BAAgC,SAAQ,mBAAQ;IACnE;QACE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnC,CAAC;IAED,SAAS,CAAC,UAAe,EAAE,OAAgB;QACzC,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,KAAK,CAAC;SACd;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC;QAEzC,MAAM,YAAY,GAAG,IAAA,cAAe,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAEzD,OAAO,UAAU,GAAG,CAAC,IAAI,YAAY,IAAI,UAAU,CAAC;IACtD,CAAC;CACF;AAlBD,kDAkBC"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/gradual-rollout-user-id.js w/lib/strategy/gradual-rollout-user-id.js | |
index 48a9bce..71402c0 100644 | |
--- i/lib/strategy/gradual-rollout-user-id.js | |
+++ w/lib/strategy/gradual-rollout-user-id.js | |
@@ -1,38 +1,21 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var strategy_1 = require("./strategy"); | |
-var util_1 = require("./util"); | |
-var GradualRolloutUserIdStrategy = /** @class */ (function (_super) { | |
- __extends(GradualRolloutUserIdStrategy, _super); | |
- function GradualRolloutUserIdStrategy() { | |
- return _super.call(this, 'gradualRolloutUserId') || this; | |
+const strategy_1 = require("./strategy"); | |
+const util_1 = require("./util"); | |
+class GradualRolloutUserIdStrategy extends strategy_1.Strategy { | |
+ constructor() { | |
+ super('gradualRolloutUserId'); | |
} | |
- GradualRolloutUserIdStrategy.prototype.isEnabled = function (parameters, context) { | |
- var userId = context.userId; | |
+ isEnabled(parameters, context) { | |
+ const { userId } = context; | |
if (!userId) { | |
return false; | |
} | |
- var percentage = Number(parameters.percentage); | |
- var groupId = parameters.groupId || ''; | |
- var normalizedUserId = (0, util_1.default)(userId, groupId); | |
+ const percentage = Number(parameters.percentage); | |
+ const groupId = parameters.groupId || ''; | |
+ const normalizedUserId = (0, util_1.default)(userId, groupId); | |
return percentage > 0 && normalizedUserId <= percentage; | |
- }; | |
- return GradualRolloutUserIdStrategy; | |
-}(strategy_1.Strategy)); | |
+ } | |
+} | |
exports.default = GradualRolloutUserIdStrategy; | |
//# sourceMappingURL=gradual-rollout-user-id.js.map | |
\ No newline at end of file | |
diff --git i/lib/strategy/gradual-rollout-user-id.js.map w/lib/strategy/gradual-rollout-user-id.js.map | |
index 409e90d..215a564 100644 | |
--- i/lib/strategy/gradual-rollout-user-id.js.map | |
+++ w/lib/strategy/gradual-rollout-user-id.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"gradual-rollout-user-id.js","sourceRoot":"","sources":["../../src/strategy/gradual-rollout-user-id.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAsC;AAEtC,+BAAqC;AAErC;IAA0D,gDAAQ;IAChE;eACE,kBAAM,sBAAsB,CAAC;IAC/B,CAAC;IAED,gDAAS,GAAT,UAAU,UAAe,EAAE,OAAgB;QACjC,IAAA,MAAM,GAAK,OAAO,OAAZ,CAAa;QAC3B,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,KAAK,CAAC;SACd;QAED,IAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACjD,IAAM,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC;QAEzC,IAAM,gBAAgB,GAAG,IAAA,cAAe,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE1D,OAAO,UAAU,GAAG,CAAC,IAAI,gBAAgB,IAAI,UAAU,CAAC;IAC1D,CAAC;IACH,mCAAC;AAAD,CAAC,AAlBD,CAA0D,mBAAQ,GAkBjE"} | |
\ No newline at end of file | |
+{"version":3,"file":"gradual-rollout-user-id.js","sourceRoot":"","sources":["../../src/strategy/gradual-rollout-user-id.ts"],"names":[],"mappings":";;AAAA,yCAAsC;AAEtC,iCAAqC;AAErC,MAAqB,4BAA6B,SAAQ,mBAAQ;IAChE;QACE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAChC,CAAC;IAED,SAAS,CAAC,UAAe,EAAE,OAAgB;QACzC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,KAAK,CAAC;SACd;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC;QAEzC,MAAM,gBAAgB,GAAG,IAAA,cAAe,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE1D,OAAO,UAAU,GAAG,CAAC,IAAI,gBAAgB,IAAI,UAAU,CAAC;IAC1D,CAAC;CACF;AAlBD,+CAkBC"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/index.js w/lib/strategy/index.js | |
index 052d569..b114e0d 100644 | |
--- i/lib/strategy/index.js | |
+++ w/lib/strategy/index.js | |
@@ -1,14 +1,14 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.defaultStrategies = exports.Strategy = void 0; | |
-var default_strategy_1 = require("./default-strategy"); | |
-var application_hostname_strategy_1 = require("./application-hostname-strategy"); | |
-var gradual_rollout_random_1 = require("./gradual-rollout-random"); | |
-var gradual_rollout_user_id_1 = require("./gradual-rollout-user-id"); | |
-var gradual_rollout_session_id_1 = require("./gradual-rollout-session-id"); | |
-var user_with_id_strategy_1 = require("./user-with-id-strategy"); | |
-var remote_addresss_strategy_1 = require("./remote-addresss-strategy"); | |
-var flexible_rollout_strategy_1 = require("./flexible-rollout-strategy"); | |
+const default_strategy_1 = require("./default-strategy"); | |
+const application_hostname_strategy_1 = require("./application-hostname-strategy"); | |
+const gradual_rollout_random_1 = require("./gradual-rollout-random"); | |
+const gradual_rollout_user_id_1 = require("./gradual-rollout-user-id"); | |
+const gradual_rollout_session_id_1 = require("./gradual-rollout-session-id"); | |
+const user_with_id_strategy_1 = require("./user-with-id-strategy"); | |
+const remote_addresss_strategy_1 = require("./remote-addresss-strategy"); | |
+const flexible_rollout_strategy_1 = require("./flexible-rollout-strategy"); | |
var strategy_1 = require("./strategy"); | |
Object.defineProperty(exports, "Strategy", { enumerable: true, get: function () { return strategy_1.Strategy; } }); | |
exports.defaultStrategies = [ | |
diff --git i/lib/strategy/index.js.map w/lib/strategy/index.js.map | |
index 0bbc7aa..13f7d04 100644 | |
--- i/lib/strategy/index.js.map | |
+++ w/lib/strategy/index.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/strategy/index.ts"],"names":[],"mappings":";;;AAAA,uDAAiD;AACjD,iFAA0E;AAC1E,mEAAoE;AACpE,qEAAqE;AACrE,2EAA2E;AAC3E,iEAAyD;AACzD,uEAA+D;AAC/D,yEAAkE;AAGlE,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAGJ,QAAA,iBAAiB,GAAoB;IAChD,IAAI,0BAAe,EAAE;IACrB,IAAI,uCAA2B,EAAE;IACjC,IAAI,gCAA4B,EAAE;IAClC,IAAI,iCAA4B,EAAE;IAClC,IAAI,oCAA+B,EAAE;IACrC,IAAI,+BAAkB,EAAE;IACxB,IAAI,kCAAqB,EAAE;IAC3B,IAAI,mCAAuB,EAAE;CAC9B,CAAC"} | |
\ No newline at end of file | |
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/strategy/index.ts"],"names":[],"mappings":";;;AAAA,yDAAiD;AACjD,mFAA0E;AAC1E,qEAAoE;AACpE,uEAAqE;AACrE,6EAA2E;AAC3E,mEAAyD;AACzD,yEAA+D;AAC/D,2EAAkE;AAGlE,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAGJ,QAAA,iBAAiB,GAAoB;IAChD,IAAI,0BAAe,EAAE;IACrB,IAAI,uCAA2B,EAAE;IACjC,IAAI,gCAA4B,EAAE;IAClC,IAAI,iCAA4B,EAAE;IAClC,IAAI,oCAA+B,EAAE;IACrC,IAAI,+BAAkB,EAAE;IACxB,IAAI,kCAAqB,EAAE;IAC3B,IAAI,mCAAuB,EAAE;CAC9B,CAAC"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/remote-addresss-strategy.js w/lib/strategy/remote-addresss-strategy.js | |
index 147ab44..5c5388c 100644 | |
--- i/lib/strategy/remote-addresss-strategy.js | |
+++ w/lib/strategy/remote-addresss-strategy.js | |
@@ -1,32 +1,16 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var strategy_1 = require("./strategy"); | |
-var ip = require('ip'); | |
-var RemoteAddressStrategy = /** @class */ (function (_super) { | |
- __extends(RemoteAddressStrategy, _super); | |
- function RemoteAddressStrategy() { | |
- return _super.call(this, 'remoteAddress') || this; | |
+const strategy_1 = require("./strategy"); | |
+const ip = require('ip'); | |
+class RemoteAddressStrategy extends strategy_1.Strategy { | |
+ constructor() { | |
+ super('remoteAddress'); | |
} | |
- RemoteAddressStrategy.prototype.isEnabled = function (parameters, context) { | |
+ isEnabled(parameters, context) { | |
if (!parameters.IPs) { | |
return false; | |
} | |
- return parameters.IPs.split(/\s*,\s*/).some(function (range) { | |
+ return parameters.IPs.split(/\s*,\s*/).some((range) => { | |
if (range === context.remoteAddress) { | |
return true; | |
} | |
@@ -40,8 +24,7 @@ var RemoteAddressStrategy = /** @class */ (function (_super) { | |
} | |
return false; | |
}); | |
- }; | |
- return RemoteAddressStrategy; | |
-}(strategy_1.Strategy)); | |
+ } | |
+} | |
exports.default = RemoteAddressStrategy; | |
//# sourceMappingURL=remote-addresss-strategy.js.map | |
\ No newline at end of file | |
diff --git i/lib/strategy/remote-addresss-strategy.js.map w/lib/strategy/remote-addresss-strategy.js.map | |
index 02d0201..3d2e926 100644 | |
--- i/lib/strategy/remote-addresss-strategy.js.map | |
+++ w/lib/strategy/remote-addresss-strategy.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"remote-addresss-strategy.js","sourceRoot":"","sources":["../../src/strategy/remote-addresss-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAsC;AAGtC,IAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzB;IAAmD,yCAAQ;IACzD;eACE,kBAAM,eAAe,CAAC;IACxB,CAAC;IAED,yCAAS,GAAT,UAAU,UAAe,EAAE,OAAgB;QACzC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE;YACnB,OAAO,KAAK,CAAC;SACd;QACD,OAAO,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,UAAC,KAAa;YACxD,IAAI,KAAK,KAAK,OAAO,CAAC,aAAa,EAAE;gBACnC,OAAO,IAAI,CAAC;aACb;YACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;gBACzB,IAAI;oBACF,OAAO,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;iBAC7D;gBAAC,OAAO,GAAG,EAAE;oBACZ,OAAO,KAAK,CAAC;iBACd;aACF;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IACH,4BAAC;AAAD,CAAC,AAvBD,CAAmD,mBAAQ,GAuB1D"} | |
\ No newline at end of file | |
+{"version":3,"file":"remote-addresss-strategy.js","sourceRoot":"","sources":["../../src/strategy/remote-addresss-strategy.ts"],"names":[],"mappings":";;AAAA,yCAAsC;AAGtC,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzB,MAAqB,qBAAsB,SAAQ,mBAAQ;IACzD;QACE,KAAK,CAAC,eAAe,CAAC,CAAC;IACzB,CAAC;IAED,SAAS,CAAC,UAAe,EAAE,OAAgB;QACzC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE;YACnB,OAAO,KAAK,CAAC;SACd;QACD,OAAO,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,KAAa,EAAW,EAAE;YACrE,IAAI,KAAK,KAAK,OAAO,CAAC,aAAa,EAAE;gBACnC,OAAO,IAAI,CAAC;aACb;YACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;gBACzB,IAAI;oBACF,OAAO,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;iBAC7D;gBAAC,OAAO,GAAG,EAAE;oBACZ,OAAO,KAAK,CAAC;iBACd;aACF;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAvBD,wCAuBC"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/strategy.js w/lib/strategy/strategy.js | |
index 6113939..42c001e 100644 | |
--- i/lib/strategy/strategy.js | |
+++ w/lib/strategy/strategy.js | |
@@ -1,19 +1,8 @@ | |
"use strict"; | |
-var __values = (this && this.__values) || function(o) { | |
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | |
- if (m) return m.call(o); | |
- if (o && typeof o.length === "number") return { | |
- next: function () { | |
- if (o && i >= o.length) o = void 0; | |
- return { value: o && o[i++], done: !o }; | |
- } | |
- }; | |
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | |
-}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.Strategy = exports.Operator = void 0; | |
-var semver_1 = require("semver"); | |
-var helpers_1 = require("../helpers"); | |
+const semver_1 = require("semver"); | |
+const helpers_1 = require("../helpers"); | |
var Operator; | |
(function (Operator) { | |
Operator["IN"] = "IN"; | |
@@ -32,41 +21,41 @@ var Operator; | |
Operator["SEMVER_GT"] = "SEMVER_GT"; | |
Operator["SEMVER_LT"] = "SEMVER_LT"; | |
})(Operator = exports.Operator || (exports.Operator = {})); | |
-var cleanValues = function (values) { return values.filter(function (v) { return !!v; }).map(function (v) { return v.trim(); }); }; | |
-var isStrictSemver = function (version) { return (0, semver_1.clean)(version) === version; }; | |
-var InOperator = function (constraint, context) { | |
- var field = constraint.contextName; | |
- var values = cleanValues(constraint.values); | |
- var contextValue = (0, helpers_1.resolveContextValue)(context, field); | |
- var isIn = values.some(function (val) { return val === contextValue; }); | |
+const cleanValues = (values) => values.filter((v) => !!v).map((v) => v.trim()); | |
+const isStrictSemver = (version) => (0, semver_1.clean)(version) === version; | |
+const InOperator = (constraint, context) => { | |
+ const field = constraint.contextName; | |
+ const values = cleanValues(constraint.values); | |
+ const contextValue = (0, helpers_1.resolveContextValue)(context, field); | |
+ const isIn = values.some((val) => val === contextValue); | |
return constraint.operator === Operator.IN ? isIn : !isIn; | |
}; | |
-var StringOperator = function (constraint, context) { | |
- var contextName = constraint.contextName, operator = constraint.operator, caseInsensitive = constraint.caseInsensitive; | |
- var values = cleanValues(constraint.values); | |
- var contextValue = (0, helpers_1.resolveContextValue)(context, contextName); | |
+const StringOperator = (constraint, context) => { | |
+ const { contextName, operator, caseInsensitive } = constraint; | |
+ let values = cleanValues(constraint.values); | |
+ let contextValue = (0, helpers_1.resolveContextValue)(context, contextName); | |
if (caseInsensitive) { | |
- values = values.map(function (v) { return v.toLocaleLowerCase(); }); | |
+ values = values.map((v) => v.toLocaleLowerCase()); | |
contextValue = contextValue === null || contextValue === void 0 ? void 0 : contextValue.toLocaleLowerCase(); | |
} | |
if (typeof contextValue !== 'string') { | |
return false; | |
} | |
if (operator === Operator.STR_STARTS_WITH) { | |
- return values.some(function (val) { return contextValue === null || contextValue === void 0 ? void 0 : contextValue.startsWith(val); }); | |
+ return values.some((val) => contextValue === null || contextValue === void 0 ? void 0 : contextValue.startsWith(val)); | |
} | |
if (operator === Operator.STR_ENDS_WITH) { | |
- return values.some(function (val) { return contextValue === null || contextValue === void 0 ? void 0 : contextValue.endsWith(val); }); | |
+ return values.some((val) => contextValue === null || contextValue === void 0 ? void 0 : contextValue.endsWith(val)); | |
} | |
if (operator === Operator.STR_CONTAINS) { | |
- return values.some(function (val) { return contextValue === null || contextValue === void 0 ? void 0 : contextValue.includes(val); }); | |
+ return values.some((val) => contextValue === null || contextValue === void 0 ? void 0 : contextValue.includes(val)); | |
} | |
return false; | |
}; | |
-var SemverOperator = function (constraint, context) { | |
- var contextName = constraint.contextName, operator = constraint.operator; | |
- var value = constraint.value; | |
- var contextValue = (0, helpers_1.resolveContextValue)(context, contextName); | |
+const SemverOperator = (constraint, context) => { | |
+ const { contextName, operator } = constraint; | |
+ const value = constraint.value; | |
+ const contextValue = (0, helpers_1.resolveContextValue)(context, contextName); | |
if (!contextValue || !isStrictSemver(contextValue)) { | |
return false; | |
} | |
@@ -86,10 +75,10 @@ var SemverOperator = function (constraint, context) { | |
} | |
return false; | |
}; | |
-var DateOperator = function (constraint, context) { | |
- var operator = constraint.operator; | |
- var value = new Date(constraint.value); | |
- var currentTime = context.currentTime ? new Date(context.currentTime) : new Date(); | |
+const DateOperator = (constraint, context) => { | |
+ const { operator } = constraint; | |
+ const value = new Date(constraint.value); | |
+ const currentTime = context.currentTime ? new Date(context.currentTime) : new Date(); | |
if (operator === Operator.DATE_AFTER) { | |
return currentTime > value; | |
} | |
@@ -98,11 +87,11 @@ var DateOperator = function (constraint, context) { | |
} | |
return false; | |
}; | |
-var NumberOperator = function (constraint, context) { | |
- var field = constraint.contextName; | |
- var operator = constraint.operator; | |
- var value = Number(constraint.value); | |
- var contextValue = Number((0, helpers_1.resolveContextValue)(context, field)); | |
+const NumberOperator = (constraint, context) => { | |
+ const field = constraint.contextName; | |
+ const { operator } = constraint; | |
+ const value = Number(constraint.value); | |
+ const contextValue = Number((0, helpers_1.resolveContextValue)(context, field)); | |
if (Number.isNaN(value) || Number.isNaN(contextValue)) { | |
return false; | |
} | |
@@ -123,7 +112,7 @@ var NumberOperator = function (constraint, context) { | |
} | |
return false; | |
}; | |
-var operators = new Map(); | |
+const operators = new Map(); | |
operators.set(Operator.IN, InOperator); | |
operators.set(Operator.NOT_IN, InOperator); | |
operators.set(Operator.STR_STARTS_WITH, StringOperator); | |
@@ -139,14 +128,13 @@ operators.set(Operator.DATE_BEFORE, DateOperator); | |
operators.set(Operator.SEMVER_EQ, SemverOperator); | |
operators.set(Operator.SEMVER_GT, SemverOperator); | |
operators.set(Operator.SEMVER_LT, SemverOperator); | |
-var Strategy = /** @class */ (function () { | |
- function Strategy(name, returnValue) { | |
- if (returnValue === void 0) { returnValue = false; } | |
+class Strategy { | |
+ constructor(name, returnValue = false) { | |
this.name = name || 'unknown'; | |
this.returnValue = returnValue; | |
} | |
- Strategy.prototype.checkConstraint = function (constraint, context) { | |
- var evaluator = operators.get(constraint.operator); | |
+ checkConstraint(constraint, context) { | |
+ const evaluator = operators.get(constraint.operator); | |
if (!evaluator) { | |
return false; | |
} | |
@@ -154,38 +142,26 @@ var Strategy = /** @class */ (function () { | |
return !evaluator(constraint, context); | |
} | |
return evaluator(constraint, context); | |
- }; | |
- Strategy.prototype.checkConstraints = function (context, constraints) { | |
- var e_1, _a; | |
+ } | |
+ checkConstraints(context, constraints) { | |
if (!constraints) { | |
return true; | |
} | |
- try { | |
- // eslint-disable-next-line no-restricted-syntax | |
- for (var constraints_1 = __values(constraints), constraints_1_1 = constraints_1.next(); !constraints_1_1.done; constraints_1_1 = constraints_1.next()) { | |
- var constraint = constraints_1_1.value; | |
- if (!constraint || !this.checkConstraint(constraint, context)) { | |
- return false; | |
- } | |
- } | |
- } | |
- catch (e_1_1) { e_1 = { error: e_1_1 }; } | |
- finally { | |
- try { | |
- if (constraints_1_1 && !constraints_1_1.done && (_a = constraints_1.return)) _a.call(constraints_1); | |
+ // eslint-disable-next-line no-restricted-syntax | |
+ for (const constraint of constraints) { | |
+ if (!constraint || !this.checkConstraint(constraint, context)) { | |
+ return false; | |
} | |
- finally { if (e_1) throw e_1.error; } | |
} | |
return true; | |
- }; | |
+ } | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
- Strategy.prototype.isEnabled = function (parameters, context) { | |
+ isEnabled(parameters, context) { | |
return this.returnValue; | |
- }; | |
- Strategy.prototype.isEnabledWithConstraints = function (parameters, context, constraints) { | |
+ } | |
+ isEnabledWithConstraints(parameters, context, constraints) { | |
return this.checkConstraints(context, constraints) && this.isEnabled(parameters, context); | |
- }; | |
- return Strategy; | |
-}()); | |
+ } | |
+} | |
exports.Strategy = Strategy; | |
//# sourceMappingURL=strategy.js.map | |
\ No newline at end of file | |
diff --git i/lib/strategy/strategy.js.map w/lib/strategy/strategy.js.map | |
index bc505a5..790bb38 100644 | |
--- i/lib/strategy/strategy.js.map | |
+++ w/lib/strategy/strategy.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../src/strategy/strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iCAA8F;AAE9F,sCAAiD;AA2BjD,IAAY,QAgBX;AAhBD,WAAY,QAAQ;IAClB,qBAAS,CAAA;IACT,6BAAiB,CAAA;IACjB,2CAA+B,CAAA;IAC/B,+CAAmC,CAAA;IACnC,yCAA6B,CAAA;IAC7B,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;IACjB,+BAAmB,CAAA;IACnB,qCAAyB,CAAA;IACzB,uCAA2B,CAAA;IAC3B,mCAAuB,CAAA;IACvB,mCAAuB,CAAA;IACvB,mCAAuB,CAAA;AACzB,CAAC,EAhBW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAgBnB;AAID,IAAM,WAAW,GAAG,UAAC,MAAgB,IAAK,OAAA,MAAM,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,EAAH,CAA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IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE;oBAC7D,OAAO,KAAK,CAAC;iBACd;aACF;;;;;;;;;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6DAA6D;IAC7D,4BAAS,GAAT,UAAU,UAAe,EAAE,OAAgB;QACzC,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,2CAAwB,GAAxB,UACE,UAAe,EACf,OAAgB,EAChB,WAAqD;QAErD,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC5F,CAAC;IACH,eAAC;AAAD,CAAC,AAjDD,IAiDC;AAjDY,4BAAQ"} | |
\ No newline at end of file | |
+{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../src/strategy/strategy.ts"],"names":[],"mappings":";;;AAAA,mCAA8F;AAE9F,wCAAiD;AA2BjD,IAAY,QAgBX;AAhBD,WAAY,QAAQ;IAClB,qBAAS,CAAA;IACT,6BAAiB,CAAA;IACjB,2CAA+B,CAAA;IAC/B,+CAAmC,CAAA;IACnC,yCAA6B,CAAA;IAC7B,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;IACjB,+BAAmB,CAAA;IACnB,qCAAyB,CAAA;IACzB,uCAA2B,CAAA;IAC3B,mCAAuB,CAAA;IACvB,mCAAuB,CAAA;IACvB,mCAAuB,CAAA;AACzB,CAAC,EAhBW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAgBnB;AAID,MAAM,WAAW,GAAG,CAAC,MAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC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C,UAAe,EAAE,OAAgB;QACzC,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,wBAAwB,CACtB,UAAe,EACf,OAAgB,EAChB,WAAqD;QAErD,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC5F,CAAC;CACF;AAjDD,4BAiDC"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/user-with-id-strategy.js w/lib/strategy/user-with-id-strategy.js | |
index 16e4c33..b7d7c50 100644 | |
--- i/lib/strategy/user-with-id-strategy.js | |
+++ w/lib/strategy/user-with-id-strategy.js | |
@@ -1,31 +1,14 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var strategy_1 = require("./strategy"); | |
-var UserWithIdStrategy = /** @class */ (function (_super) { | |
- __extends(UserWithIdStrategy, _super); | |
- function UserWithIdStrategy() { | |
- return _super.call(this, 'userWithId') || this; | |
+const strategy_1 = require("./strategy"); | |
+class UserWithIdStrategy extends strategy_1.Strategy { | |
+ constructor() { | |
+ super('userWithId'); | |
} | |
- UserWithIdStrategy.prototype.isEnabled = function (parameters, context) { | |
- var userIdList = parameters.userIds ? parameters.userIds.split(/\s*,\s*/) : []; | |
+ isEnabled(parameters, context) { | |
+ const userIdList = parameters.userIds ? parameters.userIds.split(/\s*,\s*/) : []; | |
return userIdList.includes(context.userId); | |
- }; | |
- return UserWithIdStrategy; | |
-}(strategy_1.Strategy)); | |
+ } | |
+} | |
exports.default = UserWithIdStrategy; | |
//# sourceMappingURL=user-with-id-strategy.js.map | |
\ No newline at end of file | |
diff --git i/lib/strategy/user-with-id-strategy.js.map w/lib/strategy/user-with-id-strategy.js.map | |
index 7b53e81..036e36e 100644 | |
--- i/lib/strategy/user-with-id-strategy.js.map | |
+++ w/lib/strategy/user-with-id-strategy.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"user-with-id-strategy.js","sourceRoot":"","sources":["../../src/strategy/user-with-id-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAsC;AAGtC;IAAgD,sCAAQ;IACtD;eACE,kBAAM,YAAY,CAAC;IACrB,CAAC;IAED,sCAAS,GAAT,UAAU,UAAe,EAAE,OAAgB;QACzC,IAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjF,OAAO,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IACH,yBAAC;AAAD,CAAC,AATD,CAAgD,mBAAQ,GASvD"} | |
\ No newline at end of file | |
+{"version":3,"file":"user-with-id-strategy.js","sourceRoot":"","sources":["../../src/strategy/user-with-id-strategy.ts"],"names":[],"mappings":";;AAAA,yCAAsC;AAGtC,MAAqB,kBAAmB,SAAQ,mBAAQ;IACtD;QACE,KAAK,CAAC,YAAY,CAAC,CAAC;IACtB,CAAC;IAED,SAAS,CAAC,UAAe,EAAE,OAAgB;QACzC,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjF,OAAO,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACF;AATD,qCASC"} | |
\ No newline at end of file | |
diff --git i/lib/strategy/util.js w/lib/strategy/util.js | |
index a9eb8d7..544ae90 100644 | |
--- i/lib/strategy/util.js | |
+++ w/lib/strategy/util.js | |
@@ -1,9 +1,8 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
-var murmurHash3 = require("murmurhash3js"); | |
-function normalizedValue(id, groupId, normalizer) { | |
- if (normalizer === void 0) { normalizer = 100; } | |
- return (murmurHash3.x86.hash32("".concat(groupId, ":").concat(id)) % normalizer) + 1; | |
+const murmurHash3 = require("murmurhash3js"); | |
+function normalizedValue(id, groupId, normalizer = 100) { | |
+ return (murmurHash3.x86.hash32(`${groupId}:${id}`) % normalizer) + 1; | |
} | |
exports.default = normalizedValue; | |
//# sourceMappingURL=util.js.map | |
\ No newline at end of file | |
diff --git i/lib/strategy/util.js.map w/lib/strategy/util.js.map | |
index d558ef3..5a59494 100644 | |
--- i/lib/strategy/util.js.map | |
+++ w/lib/strategy/util.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/strategy/util.ts"],"names":[],"mappings":";;AAAA,2CAA6C;AAE7C,SAAwB,eAAe,CAAC,EAAU,EAAE,OAAe,EAAE,UAAgB;IAAhB,2BAAA,EAAA,gBAAgB;IACnF,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,UAAG,OAAO,cAAI,EAAE,CAAE,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;AACvE,CAAC;AAFD,kCAEC"} | |
\ No newline at end of file | |
+{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/strategy/util.ts"],"names":[],"mappings":";;AAAA,6CAA6C;AAE7C,SAAwB,eAAe,CAAC,EAAU,EAAE,OAAe,EAAE,UAAU,GAAG,GAAG;IACnF,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,IAAI,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;AACvE,CAAC;AAFD,kCAEC"} | |
\ No newline at end of file | |
diff --git i/lib/unleash.js w/lib/unleash.js | |
index 3e3b981..5e007e5 100644 | |
--- i/lib/unleash.js | |
+++ w/lib/unleash.js | |
@@ -1,100 +1,36 @@ | |
"use strict"; | |
-var __extends = (this && this.__extends) || (function () { | |
- var extendStatics = function (d, b) { | |
- extendStatics = Object.setPrototypeOf || | |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | |
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | |
- return extendStatics(d, b); | |
- }; | |
- return function (d, b) { | |
- if (typeof b !== "function" && b !== null) | |
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | |
- extendStatics(d, b); | |
- function __() { this.constructor = d; } | |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |
- }; | |
-})(); | |
-var __assign = (this && this.__assign) || function () { | |
- __assign = Object.assign || function(t) { | |
- for (var s, i = 1, n = arguments.length; i < n; i++) { | |
- s = arguments[i]; | |
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | |
- t[p] = s[p]; | |
- } | |
- return t; | |
- }; | |
- return __assign.apply(this, arguments); | |
-}; | |
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | |
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | |
- return new (P || (P = Promise))(function (resolve, reject) { | |
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | |
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | |
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | |
- step((generator = generator.apply(thisArg, _arguments || [])).next()); | |
- }); | |
-}; | |
-var __generator = (this && this.__generator) || function (thisArg, body) { | |
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | |
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | |
- function verb(n) { return function (v) { return step([n, v]); }; } | |
- function step(op) { | |
- if (f) throw new TypeError("Generator is already executing."); | |
- while (g && (g = 0, op[0] && (_ = 0)), _) try { | |
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | |
- if (y = 0, t) op = [op[0] & 2, t.value]; | |
- switch (op[0]) { | |
- case 0: case 1: t = op; break; | |
- case 4: _.label++; return { value: op[1], done: false }; | |
- case 5: _.label++; y = op[1]; op = [0]; continue; | |
- case 7: op = _.ops.pop(); _.trys.pop(); continue; | |
- default: | |
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | |
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | |
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | |
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | |
- if (t[2]) _.ops.pop(); | |
- _.trys.pop(); continue; | |
- } | |
- op = body.call(thisArg, _); | |
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | |
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | |
- } | |
-}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.Unleash = exports.UnleashEvents = exports.Strategy = void 0; | |
-var os_1 = require("os"); | |
-var events_1 = require("events"); | |
-var client_1 = require("./client"); | |
-var repository_1 = require("./repository"); | |
-var metrics_1 = require("./metrics"); | |
-var strategy_1 = require("./strategy"); | |
+const os_1 = require("os"); | |
+const events_1 = require("events"); | |
+const client_1 = require("./client"); | |
+const repository_1 = require("./repository"); | |
+const metrics_1 = require("./metrics"); | |
+const strategy_1 = require("./strategy"); | |
Object.defineProperty(exports, "Strategy", { enumerable: true, get: function () { return strategy_1.Strategy; } }); | |
-var variant_1 = require("./variant"); | |
-var helpers_1 = require("./helpers"); | |
-var bootstrap_provider_1 = require("./repository/bootstrap-provider"); | |
-var events_2 = require("./events"); | |
+const variant_1 = require("./variant"); | |
+const helpers_1 = require("./helpers"); | |
+const bootstrap_provider_1 = require("./repository/bootstrap-provider"); | |
+const events_2 = require("./events"); | |
Object.defineProperty(exports, "UnleashEvents", { enumerable: true, get: function () { return events_2.UnleashEvents; } }); | |
-var storage_provider_file_1 = require("./repository/storage-provider-file"); | |
-var BACKUP_PATH = (0, os_1.tmpdir)(); | |
-var Unleash = /** @class */ (function (_super) { | |
- __extends(Unleash, _super); | |
- function Unleash(_a) { | |
- var appName = _a.appName, _b = _a.environment, environment = _b === void 0 ? 'default' : _b, projectName = _a.projectName, instanceId = _a.instanceId, url = _a.url, _c = _a.refreshInterval, refreshInterval = _c === void 0 ? 15 * 1000 : _c, _d = _a.metricsInterval, metricsInterval = _d === void 0 ? 60 * 1000 : _d, _e = _a.metricsJitter, metricsJitter = _e === void 0 ? 0 : _e, _f = _a.disableMetrics, disableMetrics = _f === void 0 ? false : _f, _g = _a.backupPath, backupPath = _g === void 0 ? BACKUP_PATH : _g, _h = _a.strategies, strategies = _h === void 0 ? [] : _h, repository = _a.repository, namePrefix = _a.namePrefix, customHeaders = _a.customHeaders, customHeadersFunction = _a.customHeadersFunction, timeout = _a.timeout, httpOptions = _a.httpOptions, tags = _a.tags, _j = _a.bootstrap, bootstrap = _j === void 0 ? {} : _j, bootstrapOverride = _a.bootstrapOverride, storageProvider = _a.storageProvider, _k = _a.disableAutoStart, disableAutoStart = _k === void 0 ? false : _k, _l = _a.skipInstanceCountWarning, skipInstanceCountWarning = _l === void 0 ? false : _l; | |
- var _this = _super.call(this) || this; | |
- _this.synchronized = false; | |
- _this.ready = false; | |
+const storage_provider_file_1 = require("./repository/storage-provider-file"); | |
+const BACKUP_PATH = (0, os_1.tmpdir)(); | |
+class Unleash extends events_1.EventEmitter { | |
+ constructor({ appName, environment = 'default', projectName, instanceId, url, refreshInterval = 15 * 1000, metricsInterval = 60 * 1000, metricsJitter = 0, disableMetrics = false, backupPath = BACKUP_PATH, strategies = [], repository, namePrefix, customHeaders, customHeadersFunction, timeout, httpOptions, tags, bootstrap = {}, bootstrapOverride, storageProvider, disableAutoStart = false, skipInstanceCountWarning = false, }) { | |
+ super(); | |
+ this.synchronized = false; | |
+ this.ready = false; | |
Unleash.instanceCount++; | |
- _this.on(events_2.UnleashEvents.Error, function (error) { | |
+ this.on(events_2.UnleashEvents.Error, (error) => { | |
// Only if there does not exist other listeners for this event. | |
- if (_this.listenerCount(events_2.UnleashEvents.Error) === 1) { | |
+ if (this.listenerCount(events_2.UnleashEvents.Error) === 1) { | |
console.error(error); | |
} | |
}); | |
if (!skipInstanceCountWarning && Unleash.instanceCount > 10) { | |
- process.nextTick(function () { | |
- var error = new Error('The unleash SDK has been initialized more than 10 times'); | |
- _this.emit(events_2.UnleashEvents.Error, error); | |
+ process.nextTick(() => { | |
+ const error = new Error('The unleash SDK has been initialized more than 10 times'); | |
+ this.emit(events_2.UnleashEvents.Error, error); | |
}); | |
} | |
if (!url) { | |
@@ -103,88 +39,83 @@ var Unleash = /** @class */ (function (_super) { | |
if (!appName) { | |
throw new Error('Unleash client "appName" is required'); | |
} | |
- var unleashUrl = _this.cleanUnleashUrl(url); | |
- var unleashInstanceId = (0, helpers_1.generateInstanceId)(instanceId); | |
- _this.staticContext = { appName: appName, environment: environment }; | |
- var bootstrapProvider = (0, bootstrap_provider_1.resolveBootstrapProvider)(bootstrap, appName, unleashInstanceId); | |
- _this.repository = | |
+ const unleashUrl = this.cleanUnleashUrl(url); | |
+ const unleashInstanceId = (0, helpers_1.generateInstanceId)(instanceId); | |
+ this.staticContext = { appName, environment }; | |
+ const bootstrapProvider = (0, bootstrap_provider_1.resolveBootstrapProvider)(bootstrap, appName, unleashInstanceId); | |
+ this.repository = | |
repository || | |
new repository_1.default({ | |
- projectName: projectName, | |
+ projectName, | |
url: unleashUrl, | |
- appName: appName, | |
+ appName, | |
instanceId: unleashInstanceId, | |
- refreshInterval: refreshInterval, | |
+ refreshInterval, | |
headers: customHeaders, | |
- customHeadersFunction: customHeadersFunction, | |
- timeout: timeout, | |
- httpOptions: httpOptions, | |
- namePrefix: namePrefix, | |
- tags: tags, | |
- bootstrapProvider: bootstrapProvider, | |
- bootstrapOverride: bootstrapOverride, | |
+ customHeadersFunction, | |
+ timeout, | |
+ httpOptions, | |
+ namePrefix, | |
+ tags, | |
+ bootstrapProvider, | |
+ bootstrapOverride, | |
storageProvider: storageProvider || new storage_provider_file_1.default(backupPath), | |
}); | |
- _this.repository.on(events_2.UnleashEvents.Ready, function () { | |
- _this.ready = true; | |
- process.nextTick(function () { | |
- _this.emit(events_2.UnleashEvents.Ready); | |
+ this.repository.on(events_2.UnleashEvents.Ready, () => { | |
+ this.ready = true; | |
+ process.nextTick(() => { | |
+ this.emit(events_2.UnleashEvents.Ready); | |
}); | |
}); | |
- _this.repository.on(events_2.UnleashEvents.Error, function (err) { | |
+ this.repository.on(events_2.UnleashEvents.Error, (err) => { | |
// eslint-disable-next-line no-param-reassign | |
- err.message = "Unleash Repository error: ".concat(err.message); | |
- _this.emit(events_2.UnleashEvents.Error, err); | |
+ err.message = `Unleash Repository error: ${err.message}`; | |
+ this.emit(events_2.UnleashEvents.Error, err); | |
}); | |
- _this.repository.on(events_2.UnleashEvents.Warn, function (msg) { return _this.emit(events_2.UnleashEvents.Warn, msg); }); | |
- _this.repository.on(events_2.UnleashEvents.Unchanged, function (msg) { return _this.emit(events_2.UnleashEvents.Unchanged, msg); }); | |
- _this.repository.on(events_2.UnleashEvents.Changed, function (data) { | |
- _this.emit(events_2.UnleashEvents.Changed, data); | |
+ this.repository.on(events_2.UnleashEvents.Warn, (msg) => this.emit(events_2.UnleashEvents.Warn, msg)); | |
+ this.repository.on(events_2.UnleashEvents.Unchanged, (msg) => this.emit(events_2.UnleashEvents.Unchanged, msg)); | |
+ this.repository.on(events_2.UnleashEvents.Changed, (data) => { | |
+ this.emit(events_2.UnleashEvents.Changed, data); | |
// Only emit the fully synchronized event the first time. | |
- if (!_this.synchronized) { | |
- _this.synchronized = true; | |
- process.nextTick(function () { return _this.emit(events_2.UnleashEvents.Synchronized); }); | |
+ if (!this.synchronized) { | |
+ this.synchronized = true; | |
+ process.nextTick(() => this.emit(events_2.UnleashEvents.Synchronized)); | |
} | |
}); | |
// setup client | |
- var supportedStrategies = strategies.concat(strategy_1.defaultStrategies); | |
- _this.client = new client_1.default(_this.repository, supportedStrategies); | |
- _this.client.on(events_2.UnleashEvents.Error, function (err) { return _this.emit(events_2.UnleashEvents.Error, err); }); | |
- _this.client.on(events_2.UnleashEvents.Impression, function (e) { | |
- return _this.emit(events_2.UnleashEvents.Impression, e); | |
- }); | |
- _this.metrics = new metrics_1.default({ | |
- disableMetrics: disableMetrics, | |
- appName: appName, | |
+ const supportedStrategies = strategies.concat(strategy_1.defaultStrategies); | |
+ this.client = new client_1.default(this.repository, supportedStrategies); | |
+ this.client.on(events_2.UnleashEvents.Error, (err) => this.emit(events_2.UnleashEvents.Error, err)); | |
+ this.client.on(events_2.UnleashEvents.Impression, (e) => this.emit(events_2.UnleashEvents.Impression, e)); | |
+ this.metrics = new metrics_1.default({ | |
+ disableMetrics, | |
+ appName, | |
instanceId: unleashInstanceId, | |
- strategies: supportedStrategies.map(function (strategy) { return strategy.name; }), | |
- metricsInterval: metricsInterval, | |
- metricsJitter: metricsJitter, | |
+ strategies: supportedStrategies.map((strategy) => strategy.name), | |
+ metricsInterval, | |
+ metricsJitter, | |
url: unleashUrl, | |
headers: customHeaders, | |
- customHeadersFunction: customHeadersFunction, | |
- timeout: timeout, | |
- httpOptions: httpOptions, | |
+ customHeadersFunction, | |
+ timeout, | |
+ httpOptions, | |
}); | |
- _this.metrics.on(events_2.UnleashEvents.Error, function (err) { | |
+ this.metrics.on(events_2.UnleashEvents.Error, (err) => { | |
// eslint-disable-next-line no-param-reassign | |
- err.message = "Unleash Metrics error: ".concat(err.message); | |
- _this.emit(events_2.UnleashEvents.Error, err); | |
+ err.message = `Unleash Metrics error: ${err.message}`; | |
+ this.emit(events_2.UnleashEvents.Error, err); | |
}); | |
- _this.metrics.on(events_2.UnleashEvents.Warn, function (msg) { return _this.emit(events_2.UnleashEvents.Warn, msg); }); | |
- _this.metrics.on(events_2.UnleashEvents.Sent, function (payload) { return _this.emit(events_2.UnleashEvents.Sent, payload); }); | |
- _this.metrics.on(events_2.UnleashEvents.Count, function (name, enabled) { | |
- _this.emit(events_2.UnleashEvents.Count, name, enabled); | |
+ this.metrics.on(events_2.UnleashEvents.Warn, (msg) => this.emit(events_2.UnleashEvents.Warn, msg)); | |
+ this.metrics.on(events_2.UnleashEvents.Sent, (payload) => this.emit(events_2.UnleashEvents.Sent, payload)); | |
+ this.metrics.on(events_2.UnleashEvents.Count, (name, enabled) => { | |
+ this.emit(events_2.UnleashEvents.Count, name, enabled); | |
}); | |
- _this.metrics.on(events_2.UnleashEvents.Registered, function (payload) { | |
- _this.emit(events_2.UnleashEvents.Registered, payload); | |
+ this.metrics.on(events_2.UnleashEvents.Registered, (payload) => { | |
+ this.emit(events_2.UnleashEvents.Registered, payload); | |
}); | |
if (!disableAutoStart) { | |
- process.nextTick(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | |
- return [2 /*return*/, this.start()]; | |
- }); }); }); | |
+ process.nextTick(async () => this.start()); | |
} | |
- return _this; | |
} | |
/** | |
* Will only give you an instance the first time you call the method, | |
@@ -192,136 +123,115 @@ var Unleash = /** @class */ (function (_super) { | |
* @param config The Unleash Config. | |
* @returns the Unleash instance | |
*/ | |
- Unleash.getInstance = function (config) { | |
- var cleanConfig = __assign(__assign({}, config), { | |
+ static getInstance(config) { | |
+ const cleanConfig = { | |
+ ...config, | |
// Remove complex objects | |
- repository: undefined, customHeadersFunction: undefined, storageProvider: undefined }); | |
- var configSignature = (0, helpers_1.generateHashOfConfig)(cleanConfig); | |
+ repository: undefined, | |
+ customHeadersFunction: undefined, | |
+ storageProvider: undefined | |
+ }; | |
+ const configSignature = (0, helpers_1.generateHashOfConfig)(cleanConfig); | |
if (Unleash.instance) { | |
if (configSignature !== Unleash.configSignature) { | |
throw new Error('You already have an Unleash instance with a different configuration.'); | |
} | |
return Unleash.instance; | |
} | |
- var instance = new Unleash(config); | |
+ const instance = new Unleash(config); | |
Unleash.instance = instance; | |
Unleash.configSignature = configSignature; | |
return instance; | |
- }; | |
- Unleash.prototype.cleanUnleashUrl = function (url) { | |
- var _this = this; | |
- var unleashUrl = url; | |
+ } | |
+ cleanUnleashUrl(url) { | |
+ let unleashUrl = url; | |
if (unleashUrl.endsWith('/features')) { | |
- var oldUrl_1 = unleashUrl; | |
- process.nextTick(function () { | |
- return _this.emit(events_2.UnleashEvents.Warn, "Unleash server URL \"".concat(oldUrl_1, "\" should no longer link directly to /features")); | |
- }); | |
+ const oldUrl = unleashUrl; | |
+ process.nextTick(() => this.emit(events_2.UnleashEvents.Warn, `Unleash server URL "${oldUrl}" should no longer link directly to /features`)); | |
unleashUrl = unleashUrl.replace(/\/features$/, ''); | |
} | |
if (!unleashUrl.endsWith('/')) { | |
unleashUrl += '/'; | |
} | |
return unleashUrl; | |
- }; | |
- Unleash.prototype.start = function () { | |
- return __awaiter(this, void 0, void 0, function () { | |
- return __generator(this, function (_a) { | |
- switch (_a.label) { | |
- case 0: return [4 /*yield*/, Promise.all([this.repository.start(), this.metrics.start()])]; | |
- case 1: | |
- _a.sent(); | |
- return [2 /*return*/]; | |
- } | |
- }); | |
- }); | |
- }; | |
- Unleash.prototype.destroy = function () { | |
+ } | |
+ async start() { | |
+ await Promise.all([this.repository.start(), this.metrics.start()]); | |
+ } | |
+ destroy() { | |
this.repository.stop(); | |
this.metrics.stop(); | |
Unleash.instance = undefined; | |
Unleash.configSignature = undefined; | |
Unleash.instanceCount--; | |
- }; | |
- Unleash.prototype.isEnabled = function (name, context, fallback) { | |
- if (context === void 0) { context = {}; } | |
- var enhancedContext = __assign(__assign({}, this.staticContext), context); | |
- var fallbackFunc = (0, helpers_1.createFallbackFunction)(name, enhancedContext, fallback); | |
- var result; | |
+ } | |
+ isEnabled(name, context = {}, fallback) { | |
+ const enhancedContext = { ...this.staticContext, ...context }; | |
+ const fallbackFunc = (0, helpers_1.createFallbackFunction)(name, enhancedContext, fallback); | |
+ let result; | |
if (this.ready) { | |
result = this.client.isEnabled(name, enhancedContext, fallbackFunc); | |
} | |
else { | |
result = fallbackFunc(); | |
- this.emit(events_2.UnleashEvents.Warn, "Unleash has not been initialized yet. isEnabled(".concat(name, ") defaulted to ").concat(result)); | |
+ this.emit(events_2.UnleashEvents.Warn, `Unleash has not been initialized yet. isEnabled(${name}) defaulted to ${result}`); | |
} | |
this.count(name, result); | |
return result; | |
- }; | |
- Unleash.prototype.getVariant = function (name, context, fallbackVariant) { | |
- if (context === void 0) { context = {}; } | |
- var enhancedContext = __assign(__assign({}, this.staticContext), context); | |
- var result; | |
+ } | |
+ getVariant(name, context = {}, fallbackVariant) { | |
+ const enhancedContext = { ...this.staticContext, ...context }; | |
+ let result; | |
if (this.ready) { | |
result = this.client.getVariant(name, enhancedContext, fallbackVariant); | |
} | |
else { | |
result = typeof fallbackVariant !== 'undefined' ? fallbackVariant : (0, variant_1.getDefaultVariant)(); | |
- this.emit(events_2.UnleashEvents.Warn, "Unleash has not been initialized yet. isEnabled(".concat(name, ") defaulted to ").concat(result)); | |
+ this.emit(events_2.UnleashEvents.Warn, `Unleash has not been initialized yet. isEnabled(${name}) defaulted to ${result}`); | |
} | |
if (result.name) { | |
this.countVariant(name, result.name); | |
} | |
this.count(name, result.enabled); | |
return result; | |
- }; | |
- Unleash.prototype.forceGetVariant = function (name, context, fallbackVariant) { | |
- if (context === void 0) { context = {}; } | |
- var enhancedContext = __assign(__assign({}, this.staticContext), context); | |
- var result; | |
+ } | |
+ forceGetVariant(name, context = {}, fallbackVariant) { | |
+ const enhancedContext = { ...this.staticContext, ...context }; | |
+ let result; | |
if (this.ready) { | |
result = this.client.forceGetVariant(name, enhancedContext, fallbackVariant); | |
} | |
else { | |
result = typeof fallbackVariant !== 'undefined' ? fallbackVariant : (0, variant_1.getDefaultVariant)(); | |
- this.emit(events_2.UnleashEvents.Warn, "Unleash has not been initialized yet. isEnabled(".concat(name, ") defaulted to ").concat(result)); | |
+ this.emit(events_2.UnleashEvents.Warn, `Unleash has not been initialized yet. isEnabled(${name}) defaulted to ${result}`); | |
} | |
if (result.name) { | |
this.countVariant(name, result.name); | |
} | |
this.count(name, result.enabled); | |
return result; | |
- }; | |
- Unleash.prototype.getFeatureToggleDefinition = function (toggleName) { | |
+ } | |
+ getFeatureToggleDefinition(toggleName) { | |
return this.repository.getToggle(toggleName); | |
- }; | |
- Unleash.prototype.getFeatureToggleDefinitions = function () { | |
+ } | |
+ getFeatureToggleDefinitions() { | |
return this.repository.getToggles(); | |
- }; | |
- Unleash.prototype.count = function (toggleName, enabled) { | |
+ } | |
+ count(toggleName, enabled) { | |
this.metrics.count(toggleName, enabled); | |
- }; | |
- Unleash.prototype.countVariant = function (toggleName, variantName) { | |
+ } | |
+ countVariant(toggleName, variantName) { | |
this.metrics.countVariant(toggleName, variantName); | |
- }; | |
- Unleash.prototype.flushMetrics = function () { | |
+ } | |
+ flushMetrics() { | |
return this.metrics.sendMetrics(); | |
- }; | |
- Unleash.prototype.destroyWithFlush = function () { | |
- return __awaiter(this, void 0, void 0, function () { | |
- return __generator(this, function (_a) { | |
- switch (_a.label) { | |
- case 0: return [4 /*yield*/, this.flushMetrics()]; | |
- case 1: | |
- _a.sent(); | |
- this.destroy(); | |
- return [2 /*return*/]; | |
- } | |
- }); | |
- }); | |
- }; | |
- Unleash.instanceCount = 0; | |
- return Unleash; | |
-}(events_1.EventEmitter)); | |
+ } | |
+ async destroyWithFlush() { | |
+ await this.flushMetrics(); | |
+ this.destroy(); | |
+ } | |
+} | |
exports.Unleash = Unleash; | |
+Unleash.instanceCount = 0; | |
; | |
//# sourceMappingURL=unleash.js.map | |
\ No newline at end of file | |
diff --git i/lib/unleash.js.map w/lib/unleash.js.map | |
index 83dc291..2e37f3f 100644 | |
--- i/lib/unleash.js.map | |
+++ w/lib/unleash.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"unleash.js","sourceRoot":"","sources":["../src/unleash.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAA4B;AAC5B,iCAAsC;AACtC,mCAA8B;AAC9B,2CAA+D;AAC/D,qCAAgC;AAEhC,uCAAyD;AAYhD,yFAZA,mBAAQ,OAYA;AATjB,qCAAuD;AACvD,qCAEsF;AACtF,sEAA2E;AAC3E,mCAA0D;AAIvC,8FAJO,sBAAa,OAIP;AAFhC,4EAAqE;AAIrE,IAAM,WAAW,GAAW,IAAA,WAAM,GAAE,CAAC;AAOrC;IAA6B,2BAAY;IAmBvC,iBAAY,EAwBI;YAvBd,OAAO,aAAA,EACP,mBAAuB,EAAvB,WAAW,mBAAG,SAAS,KAAA,EACvB,WAAW,iBAAA,EACX,UAAU,gBAAA,EACV,GAAG,SAAA,EACH,uBAA2B,EAA3B,eAAe,mBAAG,EAAE,GAAG,IAAI,KAAA,EAC3B,uBAA2B,EAA3B,eAAe,mBAAG,EAAE,GAAG,IAAI,KAAA,EAC3B,qBAAiB,EAAjB,aAAa,mBAAG,CAAC,KAAA,EACjB,sBAAsB,EAAtB,cAAc,mBAAG,KAAK,KAAA,EACtB,kBAAwB,EAAxB,UAAU,mBAAG,WAAW,KAAA,EACxB,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA,EACf,UAAU,gBAAA,EACV,UAAU,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utils.js | |
index bf3d176..36b415e 100644 | |
--- i/lib/url-utils.js | |
+++ w/lib/url-utils.js | |
@@ -2,18 +2,18 @@ | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.suffixSlash = exports.resolveUrl = void 0; | |
function resolveUrl(from, to) { | |
- var resolvedUrl = new URL(to, new URL(from, 'resolve://')); | |
+ const resolvedUrl = new URL(to, new URL(from, 'resolve://')); | |
if (resolvedUrl.protocol === 'resolve:') { | |
// `from` is a relative URL. | |
- var pathname = resolvedUrl.pathname, search = resolvedUrl.search, hash = resolvedUrl.hash; | |
+ const { pathname, search, hash } = resolvedUrl; | |
return pathname + search + hash; | |
} | |
return resolvedUrl.toString(); | |
} | |
exports.resolveUrl = resolveUrl; | |
-var getUrl = function (base, projectName, namePrefix, tags) { | |
- var url = resolveUrl(base, './client/features'); | |
- var params = new URLSearchParams(); | |
+const getUrl = (base, projectName, namePrefix, tags) => { | |
+ const url = resolveUrl(base, './client/features'); | |
+ const params = new URLSearchParams(); | |
if (projectName) { | |
params.append('project', projectName); | |
} | |
@@ -21,14 +21,14 @@ var getUrl = function (base, projectName, namePrefix, tags) { | |
params.append('namePrefix', namePrefix); | |
} | |
if (tags) { | |
- tags.forEach(function (tag) { return params.append('tag', tag); }); | |
+ tags.forEach((tag) => params.append('tag', tag)); | |
} | |
if (params.toString().length > 0) { | |
- return "".concat(url, "?").concat(params.toString()); | |
+ return `${url}?${params.toString()}`; | |
} | |
return url; | |
}; | |
-var suffixSlash = function (url) { return (url.endsWith('/') ? url : "".concat(url, "/")); }; | |
+const suffixSlash = (url) => (url.endsWith('/') ? url : `${url}/`); | |
exports.suffixSlash = suffixSlash; | |
exports.default = getUrl; | |
//# sourceMappingURL=url-utils.js.map | |
\ No newline at end of file | |
diff --git i/lib/url-utils.js.map w/lib/url-utils.js.map | |
index 91b97b9..dc81eae 100644 | |
--- i/lib/url-utils.js.map | |
+++ w/lib/url-utils.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"url-ut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IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;QAChC,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;KACtC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEK,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;AAA7E,QAAA,WAAW,eAAkE;AAE1F,kBAAe,MAAM,CAAC"} | |
\ No newline at end of file | |
diff --git i/lib/variant.js w/lib/variant.js | |
index 3616966..38c7450 100644 | |
--- i/lib/variant.js | |
+++ w/lib/variant.js | |
@@ -1,8 +1,8 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.selectVariant = exports.getDefaultVariant = void 0; | |
-var util_1 = require("./strategy/util"); | |
-var helpers_1 = require("./helpers"); | |
+const util_1 = require("./strategy/util"); | |
+const helpers_1 = require("./helpers"); | |
var PayloadType; | |
(function (PayloadType) { | |
PayloadType["STRING"] = "string"; | |
@@ -17,16 +17,15 @@ exports.getDefaultVariant = getDefaultVariant; | |
function randomString() { | |
return String(Math.round(Math.random() * 100000)); | |
} | |
-var stickinessSelectors = ['userId', 'sessionId', 'remoteAddress']; | |
-function getSeed(context, stickiness) { | |
- if (stickiness === void 0) { stickiness = 'default'; } | |
+const stickinessSelectors = ['userId', 'sessionId', 'remoteAddress']; | |
+function getSeed(context, stickiness = 'default') { | |
if (stickiness !== 'default') { | |
- var value = (0, helpers_1.resolveContextValue)(context, stickiness); | |
+ const value = (0, helpers_1.resolveContextValue)(context, stickiness); | |
return value ? value.toString() : randomString(); | |
} | |
- var result; | |
- stickinessSelectors.some(function (key) { | |
- var value = context[key]; | |
+ let result; | |
+ stickinessSelectors.some((key) => { | |
+ const value = context[key]; | |
if (typeof value === 'string' && value !== '') { | |
result = value; | |
return true; | |
@@ -36,28 +35,26 @@ function getSeed(context, stickiness) { | |
return result || randomString(); | |
} | |
function overrideMatchesContext(context) { | |
- return function (o) { | |
- return o.values.some(function (value) { return value === (0, helpers_1.resolveContextValue)(context, o.contextName); }); | |
- }; | |
+ return (o) => o.values.some((value) => value === (0, helpers_1.resolveContextValue)(context, o.contextName)); | |
} | |
function findOverride(feature, context) { | |
return feature.variants | |
- .filter(function (variant) { return variant.overrides; }) | |
- .find(function (variant) { return variant.overrides.some(overrideMatchesContext(context)); }); | |
+ .filter((variant) => variant.overrides) | |
+ .find((variant) => variant.overrides.some(overrideMatchesContext(context))); | |
} | |
function selectVariant(feature, context) { | |
- var totalWeight = feature.variants.reduce(function (acc, v) { return acc + v.weight; }, 0); | |
+ const totalWeight = feature.variants.reduce((acc, v) => acc + v.weight, 0); | |
if (totalWeight <= 0) { | |
return null; | |
} | |
- var variantOverride = findOverride(feature, context); | |
+ const variantOverride = findOverride(feature, context); | |
if (variantOverride) { | |
return variantOverride; | |
} | |
- var stickiness = feature.variants[0].stickiness; | |
- var target = (0, util_1.default)(getSeed(context, stickiness), feature.name, totalWeight); | |
- var counter = 0; | |
- var variant = feature.variants.find(function (v) { | |
+ const { stickiness } = feature.variants[0]; | |
+ const target = (0, util_1.default)(getSeed(context, stickiness), feature.name, totalWeight); | |
+ let counter = 0; | |
+ const variant = feature.variants.find((v) => { | |
if (v.weight === 0) { | |
return undefined; | |
} | |
diff --git i/lib/variant.js.map w/lib/variant.js.map | |
index 235db1a..371b27b 100644 | |
--- i/lib/variant.js.map | |
+++ w/lib/variant.js.map | |
@@ -1 +1 @@ | |
-{"version":3,"file":"variant.js","sourceRoot":"","sources":["../src/variant.ts"],"names":[],"mappings":";;;AAGA,wCAA8C;AAC9C,qCAAgD;AAEhD,IAAK,WAEJ;AAFD,WAAK,WAAW;IACd,gCAAiB,CAAA;AACnB,CAAC,EAFI,WAAW,KAAX,WAAW,QAEf;AA0BD,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,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YAClB,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,OAAO,GAAG,MAAM,EAAE;YACpB,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,IAAI,IAAI,CAAC;AACzB,CAAC;AA7BD,sCA6BC"} | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment