UNPKG

@automattic/calypso-products

Version:

This module contains information about the various products sold within calypso, such as product slugs, plan intervals, etc.

29 lines 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = isSupersedingJetpackItem; const constants_1 = require("./constants"); const get_jetpack_item_term_variants_1 = require("./get-jetpack-item-term-variants"); const is_jetpack_plan_slug_1 = require("./is-jetpack-plan-slug"); const is_jetpack_product_slug_1 = require("./is-jetpack-product-slug"); const main_1 = require("./main"); /** * Check if a Jetpack item (product or plan) is superseding another one. Based on yearly variants. * @param supersedingItem Item potentially superseding the other one * @param supersededItem Item potentially superseded by the other one * @returns True if the first item is superseding the second one */ function isSupersedingJetpackItem(supersedingItem, supersededItem) { const yearlySuperseding = (0, get_jetpack_item_term_variants_1.getJetpackItemTermVariants)(supersedingItem)?.yearly; const yearlySuperseded = (0, get_jetpack_item_term_variants_1.getJetpackItemTermVariants)(supersededItem)?.yearly; if (!yearlySuperseding || !yearlySuperseded) { return undefined; } if ((0, is_jetpack_plan_slug_1.isJetpackPlanSlug)(yearlySuperseding)) { return (constants_1.JETPACK_PLAN_UPGRADE_MAP[yearlySuperseding]?.includes(yearlySuperseded) || (0, main_1.planHasSuperiorFeature)(supersedingItem, supersededItem)); } if ((0, is_jetpack_product_slug_1.isJetpackProductSlug)(yearlySuperseding)) { return constants_1.JETPACK_PRODUCT_UPGRADE_MAP[yearlySuperseding]?.includes(yearlySuperseded); } } //# sourceMappingURL=is-superseding-jetpack-item.js.map