UNPKG

shyft

Version:

Model driven GraphQL API framework

37 lines (36 loc) 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isProtocolConfiguration = exports.ProtocolConfiguration = void 0; var util_1 = require("../util"); var ProtocolConfiguration = /** @class */ (function () { function ProtocolConfiguration(setup) { if (setup === void 0) { setup = {}; } // this.features = []; this.features = {}; var features = setup.features; if (features) { this.enableFeatures(features); } } ProtocolConfiguration.prototype.enableFeature = function (feature, enable) { if (enable === void 0) { enable = true; } util_1.passOrThrow(util_1.isString(feature), function () { return 'enableFeature() expects a feature name'; }); this.features[feature] = !!enable; }; ProtocolConfiguration.prototype.enableFeatures = function (features, enable) { var _this = this; if (enable === void 0) { enable = true; } util_1.passOrThrow(util_1.isArray(features), function () { return 'enableFeatures() expects an array of feature names'; }); features.map(function (feature) { return _this.enableFeature(feature, enable); }); }; ProtocolConfiguration.prototype.getEnabledFeatures = function () { return this.features; }; return ProtocolConfiguration; }()); exports.ProtocolConfiguration = ProtocolConfiguration; // eslint-disable-next-line @typescript-eslint/no-explicit-any var isProtocolConfiguration = function (obj) { return obj instanceof ProtocolConfiguration; }; exports.isProtocolConfiguration = isProtocolConfiguration;