/
githubmirror
/
novu
Обзор
Документация
Войти
/
githubmirror
/
novu
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
next
packages/shared/src/consts/productFeatureEnabledForServiceLevel.ts
39 строк
2 KB
Dima Grossman
feat(api-service,worker,dashboard): auto-provision agent default shared inbox fixes NV-7671 (#11138)
17 май 2026, 18:57
Не верифицирован
17 май 2026, 18:57
ddfb615
Код
Авторство
О чём код?
import { ApiServiceLevelEnum, ProductFeatureKeyEnum } from '../types'; import { FeatureNameEnum, getFeatureForTierAsBoolean } from './feature-tiers-constants'; const featureAccessAtoFeatureNameMapping: Record<ProductFeatureKeyEnum, FeatureNameEnum> = { [ProductFeatureKeyEnum.TRANSLATIONS]: FeatureNameEnum.AUTO_TRANSLATIONS, [ProductFeatureKeyEnum.MANAGE_ENVIRONMENTS]: FeatureNameEnum.CUSTOM_ENVIRONMENTS_BOOLEAN, [ProductFeatureKeyEnum.WEBHOOKS]: FeatureNameEnum.WEBHOOKS, [ProductFeatureKeyEnum.AGENT_EMAIL_INTEGRATION]: FeatureNameEnum.AGENT_EMAIL_INTEGRATION, [ProductFeatureKeyEnum.CUSTOM_DOMAINS]: FeatureNameEnum.DOMAINS_BOOLEAN, } as const; function createProductFeatureMap(): Record<ProductFeatureKeyEnum, ApiServiceLevelEnum[]> { const productFeatures: Record<ProductFeatureKeyEnum, ApiServiceLevelEnum[]> = { [ProductFeatureKeyEnum.TRANSLATIONS]: [], [ProductFeatureKeyEnum.MANAGE_ENVIRONMENTS]: [], [ProductFeatureKeyEnum.WEBHOOKS]: [], [ProductFeatureKeyEnum.AGENT_EMAIL_INTEGRATION]: [], [ProductFeatureKeyEnum.CUSTOM_DOMAINS]: [], }; for (const apiServiceLevel of Object.values(ApiServiceLevelEnum)) { for (const [productFeatureKey, featureName] of Object.entries(featureAccessAtoFeatureNameMapping)) { const typedProductKey = productFeatureKey as unknown as ProductFeatureKeyEnum; if (Object.values(ProductFeatureKeyEnum).includes(typedProductKey)) { const isFeatureEnabled = getFeatureForTierAsBoolean(featureName, apiServiceLevel); if (isFeatureEnabled) { productFeatures[typedProductKey]!.push(apiServiceLevel); } } } } return Object.freeze(productFeatures); } export const productFeatureEnabledForServiceLevel: Record<ProductFeatureKeyEnum, ApiServiceLevelEnum[]> = createProductFeatureMap();