UNPKG

flagsmith-nodejs

Version:

Flagsmith lets you manage features flags and remote config across web, mobile and server side applications. Deliver true Continuous Integration. Get builds out faster. Control who has access to new features.

24 lines (23 loc) 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildEnvironmentAPIKeyModel = exports.buildEnvironmentModel = void 0; const util_js_1 = require("../features/util.js"); const util_js_2 = require("../identities/util.js"); const util_js_3 = require("../projects/util.js"); const models_js_1 = require("./models.js"); function buildEnvironmentModel(environmentJSON) { const project = (0, util_js_3.buildProjectModel)(environmentJSON.project); const featureStates = environmentJSON.feature_states.map((fs) => (0, util_js_1.buildFeatureStateModel)(fs)); const environmentModel = new models_js_1.EnvironmentModel(environmentJSON.id, environmentJSON.api_key, project, environmentJSON.name); environmentModel.featureStates = featureStates; if (!!environmentJSON.identity_overrides) { environmentModel.identityOverrides = environmentJSON.identity_overrides.map((identityData) => (0, util_js_2.buildIdentityModel)(identityData)); } return environmentModel; } exports.buildEnvironmentModel = buildEnvironmentModel; function buildEnvironmentAPIKeyModel(apiKeyJSON) { const model = new models_js_1.EnvironmentAPIKeyModel(apiKeyJSON.id, apiKeyJSON.key, Date.parse(apiKeyJSON.created_at), apiKeyJSON.name, apiKeyJSON.client_api_key); return model; } exports.buildEnvironmentAPIKeyModel = buildEnvironmentAPIKeyModel;