UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

32 lines 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.requirePaidPlan = exports.checkPaidPlan = void 0; const alwayscli_1 = require("@alwaysai/alwayscli"); const infrastructure_1 = require("../../infrastructure"); const check_for_project_id_1 = require("./check-for-project-id"); async function checkPaidPlan() { const { username } = await (0, infrastructure_1.CliAuthenticationClient)().getInfo(); const client = (0, infrastructure_1.CliRpcClient)(); const teams = await client.listTeamsUserIsOwner({ user_name: username }); if (teams.length === 0) { throw new alwayscli_1.CliTerseError('You are not a member of a team, please join a team to continue.'); } // FIXME: Handle multiple teams const teamLimits = await client.checkTeamLimits({ team_id: teams[0].id }); const planName = teamLimits['plan_name']; if (planName === 'Free' || planName === 'unknown') { return false; } return true; } exports.checkPaidPlan = checkPaidPlan; async function requirePaidPlan() { const isPaid = await checkPaidPlan(); if (!isPaid) { throw new alwayscli_1.CliTerseError(`This feature is only available for Basic or Premium users. Please upgrade to continue: ${(0, check_for_project_id_1.getUpgradeUrl)()}`); } } exports.requirePaidPlan = requirePaidPlan; //# sourceMappingURL=check-paid-plan.js.map