UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

29 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getUserProjects = exports.validateIsUserProject = void 0; const alwayscli_1 = require("@alwaysai/alwayscli"); const infrastructure_1 = require("../../infrastructure"); async function validateIsUserProject(props) { const { project } = props; const projectIds = await getUserProjects(); // if user doesn't have access to project, throw error if (!projectIds.includes(project)) { throw new alwayscli_1.CliTerseError('The provided project is not in your list of projects!'); } } exports.validateIsUserProject = validateIsUserProject; async function getUserProjects() { const authInfo = await (0, infrastructure_1.CliAuthenticationClient)().getInfo(); const projects = await (0, infrastructure_1.CliRpcClient)().listProjectsUserIsCollaborator({ user_name: authInfo.username }); const projectIds = []; projects.forEach((project, _) => { if (project.uuid !== null) { projectIds.push(project.uuid); } }); return projectIds; } exports.getUserProjects = getUserProjects; //# sourceMappingURL=get-user-projects.js.map