"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 the collaborators on a given project.  Unlisted collaborators are NOT included.
*/
const pool_1 = __importDefault(require("@cocalc/database/pool"));
const util_1 = require("./util");
async function getCollaborators(project_id) {
    if (!(0, util_1.isUUID)(project_id)) {
        throw Error("project_id must be a uuid");
    }
    const pool = (0, pool_1.default)('medium');
    const result = await pool.query("SELECT accounts.account_id, accounts.first_name, accounts.last_name FROM accounts, (SELECT jsonb_object_keys(users) AS account_id FROM projects WHERE project_id=$1) AS users WHERE accounts.account_id=users.account_id::UUID AND accounts.unlisted IS NOT TRUE", [project_id]);
    return result.rows;
}
exports.default = getCollaborators;
//# sourceMappingURL=get-collaborators.js.map