UNPKG

@mintlify/common

Version:

Commonly shared code within Mintlify

22 lines (21 loc) 819 B
import { isOrgLessThanTwoWeeksOld } from '../isOrgLessThanTwoWeeksOld.js'; export const TRIAL_ENTITLEMENTS = [ 'AI_CHAT', 'ANALYTICS', 'CUSTOM_SUBPATH', 'PREVIEW_DEPLOYMENTS', 'SOURCE_CHECK_LINK_ROT', 'SOURCE_CHECK_VALE_SPELLCHECK', 'MCP_ENDPOINTS', ]; export function checkAccess({ entitlements, org, entitlementToCheck, allowTrialAccess = false, }) { var _a; const enabledByEntitlement = ((_a = entitlements === null || entitlements === void 0 ? void 0 : entitlements[entitlementToCheck]) === null || _a === void 0 ? void 0 : _a.status) === 'ENABLED'; if (enabledByEntitlement) { return true; } if (allowTrialAccess && !!org && TRIAL_ENTITLEMENTS.includes(entitlementToCheck)) { return isOrgLessThanTwoWeeksOld(org.createdAt); } return false; }