@cocalc/server
Version:
CoCalc server functionality: functions used by either the hub and the next.js server
28 lines • 1.14 kB
JavaScript
;
/*
Returns array of licenses that a given user manages.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const pool_1 = __importDefault(require("@cocalc/database/pool"));
const util_1 = require("@cocalc/database/postgres/util");
const misc_1 = require("@cocalc/util/misc");
async function getManagedLicenses(account_id) {
if (!(0, misc_1.isValidUUID)(account_id)) {
throw Error("invalid account_id -- must be a uuid");
}
const pool = (0, pool_1.default)();
const { rows } = await pool.query(`SELECT id, title, description,
expires, activates, last_used, created,
managers, upgrades, quota, run_limit, info
FROM site_licenses WHERE $1=ANY(managers) ORDER BY created DESC`, [account_id]);
(0, util_1.toEpoch)(rows, ["expires", "activates", "last_used", "created"]);
for (const row of rows) {
row.is_manager = true;
}
return rows;
}
exports.default = getManagedLicenses;
//# sourceMappingURL=get-managed.js.map