-
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.
fix(dashboard): added FF to FE fix(dashboard): added FF to FE fix(dashboard): change default sorting fix(api-service): compiles68457b4c79403ba223d4f360925eb0422e33dffb fix(api-service): compiles68457b4c79403ba223d4f360925eb0422e33dffb fix(api-service): compiles
- Loading branch information
Showing
44 changed files
with
1,490 additions
and
651 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Submodule .source
updated
from 266e12 to 4aa647
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
5 changes: 2 additions & 3 deletions
5
apps/api/src/app/billing/e2e/create-checkout-session.e2e-ee.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
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
4 changes: 1 addition & 3 deletions
4
apps/api/src/app/billing/e2e/customer-subscription-created.e2e-ee.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
4 changes: 1 addition & 3 deletions
4
apps/api/src/app/billing/e2e/customer-subscription-deleted.e2e-ee.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
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
3 changes: 1 addition & 2 deletions
3
apps/api/src/app/billing/e2e/get-platform-notification-usage.e2e-ee.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
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
4 changes: 4 additions & 0 deletions
4
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum TierValidationTypeEnum { | ||
ENVIRONMENT_COUNT = 'ENVIRONMENT_COUNT', | ||
WORKFLOW_COUNT = 'WORKFLOW_COUNT', | ||
} |
92 changes: 92 additions & 0 deletions
92
apps/api/src/app/environments-v1/usecases/create-environment/validate-tiers-use.case.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,92 @@ | ||
import { | ||
ApiServiceLevelEnum, | ||
FeatureFlags, | ||
FeatureFlagsKeysEnum, | ||
FeatureNameEnum, | ||
getFeatureForTierAsBoolean, | ||
getFeatureForTierAsNumber, | ||
} from '@novu/shared'; | ||
import { OrganizationRepository } from '@novu/dal'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { GetFeatureFlag, GetFeatureFlagCommand, TierRestrictionsValidateCommand } from '@novu/application-generic'; | ||
import { ValidateTiersCommand } from './validate-tiers.command'; | ||
import { TierValidationTypeEnum } from './tier-validation-type.enum'; | ||
|
||
@Injectable() | ||
export class ValidateTiersUseCase { | ||
constructor( | ||
private organizationRepository: OrganizationRepository, | ||
private getFeatureFlag: GetFeatureFlag | ||
) {} | ||
async execute(validateTiersCommand: ValidateTiersCommand): Promise<void> { | ||
const organization = await this.organizationRepository.findById(validateTiersCommand.organizationId); | ||
const featureFlags = await this.getFeatureFlags(validateTiersCommand); | ||
if (!organization || !organization.apiServiceLevel) { | ||
throw new Error(`Organization not found ${JSON.stringify(organization)}`); | ||
} | ||
if (validateTiersCommand.validationType === TierValidationTypeEnum.ENVIRONMENT_COUNT) { | ||
this.validateEnvironmentCount(organization.apiServiceLevel, featureFlags); | ||
} | ||
if (validateTiersCommand.validationType === TierValidationTypeEnum.WORKFLOW_COUNT) { | ||
this.validateWorkflowCount(validateTiersCommand, organization.apiServiceLevel, featureFlags); | ||
} | ||
} | ||
private async getFeatureFlags(command: TierRestrictionsValidateCommand): Promise<Partial<FeatureFlags>> { | ||
const featureFlags: Partial<FeatureFlags> = {}; | ||
|
||
const featureFlagKeys = [FeatureFlagsKeysEnum.IS_2025_Q1_TIERING_ENABLED]; | ||
|
||
for (const flagKey of featureFlagKeys) { | ||
const { key, value } = await this.getFeatureFlagStatus(command, flagKey); | ||
featureFlags[key] = value; | ||
} | ||
|
||
return featureFlags; | ||
} | ||
private async getFeatureFlagStatus( | ||
command: TierRestrictionsValidateCommand, | ||
key: FeatureFlagsKeysEnum | ||
): Promise<{ key: FeatureFlagsKeysEnum; value: boolean }> { | ||
const status = await this.getFeatureFlag.execute( | ||
GetFeatureFlagCommand.create({ | ||
userId: 'system', | ||
environmentId: 'system', | ||
organizationId: command.organizationId, | ||
key, | ||
}) | ||
); | ||
|
||
return { key, value: status }; | ||
} | ||
|
||
private validateEnvironmentCount(apiServiceLevel: ApiServiceLevelEnum, featureFlags: Partial<FeatureFlags>) { | ||
const allowedToAdd = getFeatureForTierAsBoolean( | ||
FeatureNameEnum.CUSTOM_ENVIRONMENTS_BOOLEAN, | ||
apiServiceLevel, | ||
featureFlags | ||
); | ||
if (!allowedToAdd) { | ||
throw new Error(`You have exceeded the maximum number of environments allowed for the [${apiServiceLevel}] tier`); | ||
} | ||
} | ||
|
||
private validateWorkflowCount( | ||
validateTiersCommand: ValidateTiersCommand, | ||
apiServiceLevel: ApiServiceLevelEnum, | ||
featureFlags: Partial<FeatureFlags> | ||
) { | ||
const numberOfWorkflows = validateTiersCommand.valueToValidate; | ||
const maxWorkflows = getFeatureForTierAsNumber( | ||
FeatureNameEnum.PLATFORM_MAX_WORKFLOWS, | ||
apiServiceLevel, | ||
featureFlags, | ||
false | ||
); | ||
if (maxWorkflows === -1) { | ||
return; | ||
} | ||
if (numberOfWorkflows >= maxWorkflows) { | ||
throw new Error(`You have exceeded the maximum number of workflows allowed for the [${apiServiceLevel}] tier`); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
apps/api/src/app/environments-v1/usecases/create-environment/validate-tiers.command.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,7 @@ | ||
import { TierValidationTypeEnum } from './tier-validation-type.enum'; | ||
|
||
export class ValidateTiersCommand { | ||
organizationId: string; | ||
validationType: TierValidationTypeEnum; | ||
valueToValidate: number; | ||
} |
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
Oops, something went wrong.