alwaysai
Version:
The alwaysAI command-line interface (CLI)
47 lines • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUpgradeUrl = exports.getCurrentProjectId = exports.getProjectByUUID = exports.requireUserIsCollaboratorOnProject = void 0;
const project_json_file_1 = require("./project-json-file");
const alwayscli_1 = require("@alwaysai/alwayscli");
const infrastructure_1 = require("../../infrastructure");
async function requireUserIsCollaboratorOnProject(projectUuid) {
const { username } = await (0, infrastructure_1.CliAuthenticationClient)().getInfo();
const collabProjects = await (0, infrastructure_1.CliRpcClient)().listProjectsUserIsCollaborator({
user_name: username
});
let isCollab = false;
for (const p of collabProjects) {
if (p.uuid) {
if (projectUuid === p.uuid.toString()) {
isCollab = true;
}
}
}
if (!isCollab) {
throw new alwayscli_1.CliTerseError(`Project "${projectUuid}" does not match any projects for which you are a member. Please either contact the project owner to add you, or check that the project exists on your dashboard. \nIf the project no longer exists on your dashboard, delete the alwaysai.project.json file and re-run "aai app configure", and choose to create a new project.`);
}
}
exports.requireUserIsCollaboratorOnProject = requireUserIsCollaboratorOnProject;
async function getProjectByUUID(uuid) {
await requireUserIsCollaboratorOnProject(uuid);
const project = await (0, infrastructure_1.CliRpcClient)().getProjectByUUID({
uuid
});
return project;
}
exports.getProjectByUUID = getProjectByUUID;
async function getCurrentProjectId() {
const projectJsonFile = (0, project_json_file_1.ProjectJsonFile)();
const project = projectJsonFile.read().project;
if (!project) {
throw new alwayscli_1.CliTerseError('No project configured for this app!');
}
const uuidProject = await getProjectByUUID(project.id);
return uuidProject.id;
}
exports.getCurrentProjectId = getCurrentProjectId;
async function getUpgradeUrl() {
return `${(0, infrastructure_1.getBaseURL)()}/dashboard/team/upgrade`;
}
exports.getUpgradeUrl = getUpgradeUrl;
//# sourceMappingURL=check-for-project-id.js.map