@splitsoftware/splitio-commons
Version:
Split JavaScript SDK common components
66 lines (65 loc) • 2.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.myLargeSegmentsKeyBuilder = exports.KeyBuilderCS = void 0;
var tslib_1 = require("tslib");
var lang_1 = require("../utils/lang");
var KeyBuilder_1 = require("./KeyBuilder");
var KeyBuilderCS = /** @class */ (function (_super) {
tslib_1.__extends(KeyBuilderCS, _super);
function KeyBuilderCS(prefix, matchingKey) {
var _this = _super.call(this, prefix) || this;
_this.matchingKey = matchingKey;
_this.regexDefinitionsCacheKey = new RegExp("^".concat(prefix, "\\.(splits?|trafficType|flagSet)\\."));
return _this;
}
/**
* @override
*/
KeyBuilderCS.prototype.buildSegmentNameKey = function (segmentName) {
return "".concat(this.prefix, ".").concat(this.matchingKey, ".segment.").concat(segmentName);
};
KeyBuilderCS.prototype.extractSegmentName = function (builtSegmentKeyName) {
var prefix = "".concat(this.prefix, ".").concat(this.matchingKey, ".segment.");
if ((0, lang_1.startsWith)(builtSegmentKeyName, prefix))
return builtSegmentKeyName.slice(prefix.length);
};
KeyBuilderCS.prototype.buildLastUpdatedKey = function () {
return "".concat(this.prefix, ".splits.lastUpdated");
};
KeyBuilderCS.prototype.isDefinitionsCacheKey = function (key) {
return this.regexDefinitionsCacheKey.test(key);
};
KeyBuilderCS.prototype.buildTillKey = function () {
return "".concat(this.prefix, ".").concat(this.matchingKey, ".segments.till");
};
KeyBuilderCS.prototype.isDefinitionKey = function (key) {
return (0, lang_1.startsWith)(key, "".concat(this.prefix, ".split."));
};
KeyBuilderCS.prototype.isRBSegmentKey = function (key) {
return (0, lang_1.startsWith)(key, "".concat(this.prefix, ".rbsegment."));
};
KeyBuilderCS.prototype.buildDefinitionsWithSegmentCountKey = function () {
return "".concat(this.prefix, ".splits.usingSegments");
};
KeyBuilderCS.prototype.buildLastClear = function () {
return "".concat(this.prefix, ".lastClear");
};
return KeyBuilderCS;
}(KeyBuilder_1.KeyBuilder));
exports.KeyBuilderCS = KeyBuilderCS;
function myLargeSegmentsKeyBuilder(prefix, matchingKey) {
return {
buildSegmentNameKey: function (segmentName) {
return "".concat(prefix, ".").concat(matchingKey, ".largeSegment.").concat(segmentName);
},
extractSegmentName: function (builtSegmentKeyName) {
var p = "".concat(prefix, ".").concat(matchingKey, ".largeSegment.");
if ((0, lang_1.startsWith)(builtSegmentKeyName, p))
return builtSegmentKeyName.slice(p.length);
},
buildTillKey: function () {
return "".concat(prefix, ".").concat(matchingKey, ".largeSegments.till");
}
};
}
exports.myLargeSegmentsKeyBuilder = myLargeSegmentsKeyBuilder;