UNPKG

@cocalc/server

Version:

CoCalc server functionality: functions used by either the hub and the next.js server

31 lines 1.25 kB
"use strict"; /* * This file is part of CoCalc: Copyright © 2020 Sagemath, Inc. * License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getProductName = void 0; const describe_quota_1 = require("@cocalc/util/licenses/describe-quota"); const misc_1 = require("@cocalc/util/misc"); const timecalcs_1 = require("@cocalc/util/stripe/timecalcs"); function getProductName(info) { // Similar to getProductId, but meant to be human readable. // This name is what customers see on invoices, // so it's very valuable as it reflects what they bought clearly. const period = getPeriod(info); // ATTN: this is the name for an SKU, not the individual product the user buys. // Hence this must not include the name of the VM or disk. const desc = (0, describe_quota_1.describeQuotaFromInfo)(info, false); return `${desc} - ${period}`; } exports.getProductName = getProductName; function getPeriod(info) { if (info.subscription == "no") { const n = (0, timecalcs_1.getDays)(info); return `${n} ${(0, misc_1.plural)(n, "day")}`; } else { return "subscription"; } } //# sourceMappingURL=product-name.js.map