"use strict";
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/*
Get information about a project.
*/
const pool_1 = __importDefault(require("@cocalc/database/pool"));
const util_1 = require("./util");
async function getProjectInfo(project_id, columns = ["title", "description", "name"], 
// not cached by default since editing then reloading is confusing with this cached.
cache) {
    const pool = (0, pool_1.default)(cache);
    if (!(0, util_1.isUUID)(project_id)) {
        throw Error(`project_id ${project_id} must be a uuid`);
    }
    const project = await pool.query(`SELECT ${columns.join(",")} FROM projects WHERE project_id=$1`, [project_id]);
    if (project.rows.length == 0) {
        throw Error(`no project with id ${project_id}`);
    }
    const info = {};
    for (const name of columns) {
        info[name] = project.rows[0][name] ?? "";
    }
    return info;
}
exports.default = getProjectInfo;
//# sourceMappingURL=get-project.js.map