"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultEnvironment = getDefaultEnvironment;
exports.getDefaultDatasourceEnvironment = getDefaultDatasourceEnvironment;
exports.checkEnvironment = checkEnvironment;
const index_js_1 = require("../errors/index.js");
const index_js_2 = require("../types/index.js");
function getDefaultEnvironment(isPublished) {
    return isPublished ? index_js_2.ENVIRONMENT_PRODUCTION : index_js_2.ENVIRONMENT_STAGING;
}
function getDefaultDatasourceEnvironment(isPublished) {
    return isPublished ? index_js_2.DatasourceEnvironments.PRODUCTION : index_js_2.DatasourceEnvironments.STAGING;
}
function checkEnvironment(environment) {
    if (!environment) {
        throw new index_js_1.BadRequestError(`Environment is missing. Please choose one of the following environments: '${index_js_2.VALID_DATASOURCE_ENVIRONMENTS}'`);
    }
    if (!index_js_2.VALID_DATASOURCE_ENVIRONMENTS.find((valid) => environment === valid)) {
        throw new index_js_1.BadRequestError(`An unsupported environment - '${environment}' - was provided. Please choose one of the following environments: '${index_js_2.VALID_DATASOURCE_ENVIRONMENTS}'`);
    }
    return environment;
}
//# sourceMappingURL=environment.js.map