-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
139 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
apps/api/src/app/environments-v1/usecases/create-environment/tier-exceeded.exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { TierValidationTypeEnum } from './tier-validation-type.enum'; | ||
|
||
export class TierExceededException extends Error { | ||
constructor( | ||
public tierValidationEnum: TierValidationTypeEnum, | ||
message: string | ||
) { | ||
super(message); | ||
this.name = 'TierExceededException'; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
apps/api/src/app/environments-v1/usecases/create-environment/tier-validation-type.enum.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export enum TierValidationTypeEnum { | ||
ENVIRONMENT_COUNT = 'ENVIRONMENT_COUNT', | ||
CUSTOM_ENVIROMENTS = 'CUSTOM_ENVIROMENTS', | ||
Check warning on line 2 in apps/api/src/app/environments-v1/usecases/create-environment/tier-validation-type.enum.ts
|
||
WORKFLOW_COUNT = 'WORKFLOW_COUNT', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 25 additions & 6 deletions
31
packages/shared/src/consts/productFeatureEnabledForServiceLevel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
import { ApiServiceLevelEnum, ProductFeatureKeyEnum } from '../types'; | ||
import { FeatureNameEnum, getFeatureForTierAsBoolean } from './feature-tiers-constants'; | ||
|
||
export const productFeatureEnabledForServiceLevel: Record<ProductFeatureKeyEnum, ApiServiceLevelEnum[]> = Object.freeze( | ||
{ | ||
[ProductFeatureKeyEnum.TRANSLATIONS]: [ApiServiceLevelEnum.BUSINESS, ApiServiceLevelEnum.ENTERPRISE], | ||
[ProductFeatureKeyEnum.MANAGE_ENVIRONMENTS]: [ApiServiceLevelEnum.BUSINESS, ApiServiceLevelEnum.ENTERPRISE], | ||
} | ||
); | ||
const featureAccessAtoFeatureNameMapping = { | ||
[ProductFeatureKeyEnum.TRANSLATIONS]: FeatureNameEnum.AUTO_TRANSLATIONS, | ||
[ProductFeatureKeyEnum.MANAGE_ENVIRONMENTS]: FeatureNameEnum.CUSTOM_ENVIRONMENTS_BOOLEAN, | ||
}; | ||
function createProductFeatureMap(): Record<ProductFeatureKeyEnum, ApiServiceLevelEnum[]> { | ||
const productFeatures: Partial<Record<ProductFeatureKeyEnum, ApiServiceLevelEnum[]>> = {}; | ||
Object.values(ApiServiceLevelEnum).forEach((apiServiceLevel) => { | ||
Object.entries(featureAccessAtoFeatureNameMapping).forEach(([productFeatureKey, featureName]) => { | ||
const isFeatureEnabled = getFeatureForTierAsBoolean(featureName, apiServiceLevel, {}); | ||
|
||
if (isFeatureEnabled) { | ||
if (!productFeatures[productFeatureKey]) { | ||
productFeatures[productFeatureKey] = []; | ||
} | ||
productFeatures[productFeatureKey]!.push(apiServiceLevel); | ||
} | ||
}); | ||
}); | ||
|
||
return Object.freeze(productFeatures as Record<ProductFeatureKeyEnum, ApiServiceLevelEnum[]>); | ||
} | ||
|
||
export const productFeatureEnabledForServiceLevel: Record<ProductFeatureKeyEnum, ApiServiceLevelEnum[]> = | ||
createProductFeatureMap(); |