@devcycle/js-cloud-server-sdk
Version:
The DevCycle JS Cloud Bucketing Server SDK used for feature management.
38 lines • 1.55 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.VariableAndMetadata = exports.VariableMetadata = exports.DVCVariable = void 0;
const paramUtils_1 = require("../utils/paramUtils");
class DVCVariable {
constructor(variable) {
const { key, defaultValue, value, eval: evalReason, type } = variable;
(0, paramUtils_1.checkParamDefined)('key', key);
(0, paramUtils_1.checkParamDefined)('defaultValue', defaultValue);
(0, paramUtils_1.checkParamType)('key', key, paramUtils_1.typeEnum.string);
// kind of cheating here with the type assertion but we're basically assuming that all variable keys in
// generated types are lowercase since the system enforces that elsewhere
this.key = key.toLowerCase();
this.isDefaulted = value === undefined || value === null;
this.value =
value === undefined || value === null
? defaultValue
: value;
this.defaultValue = defaultValue;
this.eval = evalReason;
this.type = type;
}
}
exports.DVCVariable = DVCVariable;
class VariableMetadata {
constructor(featureId) {
this.featureId = featureId;
}
}
exports.VariableMetadata = VariableMetadata;
class VariableAndMetadata {
constructor(variableParams, featureId) {
this.variable = new DVCVariable(variableParams);
this.metadata = new VariableMetadata(featureId);
}
}
exports.VariableAndMetadata = VariableAndMetadata;
//# sourceMappingURL=variable.js.map
;