Skip to content

Commit

Permalink
refactor(api-service): use new ff service name
Browse files Browse the repository at this point in the history
  • Loading branch information
djabarovgeorge committed Feb 13, 2025
1 parent b4414c1 commit 41a2afb
Show file tree
Hide file tree
Showing 30 changed files with 85 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .source
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EnvironmentEntity, IntegrationRepository, OrganizationEntity, UserEntit
import {
areNovuEmailCredentialsSet,
areNovuSmsCredentialsSet,
GetFeatureFlag,
GetFeatureFlagService,
GetFeatureFlagCommand,
} from '@novu/application-generic';

Expand All @@ -26,7 +26,7 @@ export class CreateNovuIntegrations {
private createIntegration: CreateIntegration,
private integrationRepository: IntegrationRepository,
private setIntegrationAsPrimary: SetIntegrationAsPrimary,
private getFeatureFlag: GetFeatureFlag
private getFeatureFlag: GetFeatureFlagService
) {}

private async createEmailIntegration(command: CreateNovuIntegrationsCommand) {
Expand Down Expand Up @@ -110,7 +110,7 @@ export class CreateNovuIntegrations {
});

if (inAppIntegrationCount === 0) {
const isV2Enabled = await this.getFeatureFlag.execute(
const isV2Enabled = await this.getFeatureFlag.getBoolean(
GetFeatureFlagCommand.create({
user: { _id: command.userId } as UserEntity,
environment: { _id: command.environmentId } as EnvironmentEntity,
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/app/integrations/usecases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
CalculateLimitNovuIntegration,
ConditionsFilter,
NormalizeVariables,
getFeatureFlag,
getFeatureFlagService,
} from '@novu/application-generic';

import { GetWebhookSupportStatus } from './get-webhook-support-status/get-webhook-support-status.usecase';
Expand Down Expand Up @@ -36,5 +36,5 @@ export const USE_CASES = [
SetIntegrationAsPrimary,
CreateNovuIntegrations,
NormalizeVariables,
getFeatureFlag,
getFeatureFlagService,
];
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { BadRequestException, ConflictException, Inject, Injectable, Logger, NotFoundException } from '@nestjs/common';
import {
CommunityOrganizationRepository,
EnvironmentEntity,
IntegrationEntity,
IntegrationRepository,
OrganizationEntity,
UserEntity,
} from '@novu/dal';
import {
AnalyticsService,
buildIntegrationKey,
encryptCredentials,
GetFeatureFlag,
GetFeatureFlagService,
GetFeatureFlagCommand,
InvalidateCacheService,
} from '@novu/application-generic';
Expand All @@ -29,7 +27,7 @@ export class UpdateIntegration {
private invalidateCache: InvalidateCacheService,
private integrationRepository: IntegrationRepository,
private analyticsService: AnalyticsService,
private getFeatureFlag: GetFeatureFlag,
private getFeatureFlag: GetFeatureFlagService,
private communityOrganizationRepository: CommunityOrganizationRepository
) {}

Expand Down Expand Up @@ -155,7 +153,7 @@ export class UpdateIntegration {
active: command.active,
});

const isInvalidationDisabled = await this.getFeatureFlag.execute(
const isInvalidationDisabled = await this.getFeatureFlag.getBoolean(
GetFeatureFlagCommand.create({
organization: { _id: command.organizationId } as OrganizationEntity,
key: FeatureFlagsKeysEnum.IS_INTEGRATION_INVALIDATION_DISABLED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BadRequestException, Injectable } from '@nestjs/common';
import { MessageEntity, MessageRepository, OrganizationEntity, SubscriberEntity } from '@novu/dal';
import { ActorTypeEnum, FeatureFlagsKeysEnum } from '@novu/shared';

import { GetFeatureFlag, GetFeatureFlagCommand } from '@novu/application-generic';
import { GetFeatureFlagService, GetFeatureFlagCommand } from '@novu/application-generic';
import { GetMessagesCommand } from './get-messages.command';
import { GetSubscriber, GetSubscriberCommand } from '../../../subscribers/usecases/get-subscriber';

Expand All @@ -11,7 +11,7 @@ export class GetMessages {
constructor(
private messageRepository: MessageRepository,
private getSubscriberUseCase: GetSubscriber,
private getFeatureFlag: GetFeatureFlag
private getFeatureFlag: GetFeatureFlagService
) {}

async execute(command: GetMessagesCommand) {
Expand Down Expand Up @@ -59,7 +59,7 @@ export class GetMessages {
}
}

const isEnabled = await this.getFeatureFlag.execute(
const isEnabled = await this.getFeatureFlag.getBoolean(
GetFeatureFlagCommand.create({
key: FeatureFlagsKeysEnum.IS_NEW_MESSAGES_API_RESPONSE_ENABLED,
organization: { _id: command.organizationId } as OrganizationEntity,
Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/app/rate-limiting/guards/throttler.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { CallHandler, ExecutionContext, Injectable, Logger, NestInterceptor } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import {
GetFeatureFlag,
GetFeatureFlagService,
GetFeatureFlagCommand,
Instrument,
HttpRequestHeaderKeysEnum,
Expand Down Expand Up @@ -45,7 +45,7 @@ export class ApiRateLimitInterceptor extends ThrottlerGuard implements NestInter
@InjectThrottlerStorage() protected readonly storageService: ThrottlerStorage,
reflector: Reflector,
private evaluateApiRateLimit: EvaluateApiRateLimit,
private getFeatureFlag: GetFeatureFlag
private getFeatureFlag: GetFeatureFlagService
) {
super(options, storageService, reflector);
}
Expand Down Expand Up @@ -73,7 +73,7 @@ export class ApiRateLimitInterceptor extends ThrottlerGuard implements NestInter
const user = this.getReqUser(context);
const { organizationId, environmentId, _id } = user;

const isEnabled = await this.getFeatureFlag.execute(
const isEnabled = await this.getFeatureFlag.getBoolean(
GetFeatureFlagCommand.create({
environment: { _id: environmentId } as EnvironmentEntity,
organization: { _id: organizationId } as OrganizationEntity,
Expand Down Expand Up @@ -128,7 +128,7 @@ export class ApiRateLimitInterceptor extends ThrottlerGuard implements NestInter
* The purpose of the dry run is to allow us to observe how
* the rate limiting would behave without actually enforcing it.
*/
const isDryRun = await this.getFeatureFlag.execute(
const isDryRun = await this.getFeatureFlag.getBoolean(
GetFeatureFlagCommand.create({
environment: { _id: environmentId } as EnvironmentEntity,
organization: { _id: organizationId } as OrganizationEntity,
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/app/shared/framework/idempotency.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@nestjs/common';
import {
CacheService,
GetFeatureFlag,
GetFeatureFlagService,
GetFeatureFlagCommand,
HttpResponseHeaderKeysEnum,
Instrument,
Expand Down Expand Up @@ -42,7 +42,7 @@ const ALLOWED_METHODS = ['post', 'patch'];
export class IdempotencyInterceptor implements NestInterceptor {
constructor(
private readonly cacheService: CacheService,
private getFeatureFlag: GetFeatureFlag
private getFeatureFlag: GetFeatureFlagService
) {}

protected async isEnabled(context: ExecutionContext): Promise<boolean> {
Expand All @@ -54,7 +54,7 @@ export class IdempotencyInterceptor implements NestInterceptor {
const user = this.getReqUser(context);
const { organizationId, environmentId, _id } = user;

return await this.getFeatureFlag.execute(
return await this.getFeatureFlag.getBoolean(
GetFeatureFlagCommand.create({
key: FeatureFlagsKeysEnum.IS_API_IDEMPOTENCY_ENABLED,
environment: { _id: environmentId } as EnvironmentEntity,
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
ExecutionLogRoute,
featureFlagsService,
GetDecryptedSecretKey,
getFeatureFlag,
getFeatureFlagService,
InvalidateCacheService,
launchDarklyService,
LoggerModule,
Expand Down Expand Up @@ -128,7 +128,7 @@ const PROVIDERS = [
ExecutionLogRoute,
CreateExecutionDetails,
ExecuteBridgeRequest,
getFeatureFlag,
getFeatureFlagService,
GetDecryptedSecretKey,
launchDarklyService,
];
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/app/tenant/tenant.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ApiRateLimitCategoryEnum, FeatureFlagsKeysEnum, UserSessionData } from
import {
CreateTenant,
CreateTenantCommand,
GetFeatureFlag,
GetFeatureFlagService,
GetFeatureFlagCommand,
GetTenant,
GetTenantCommand,
Expand Down Expand Up @@ -72,7 +72,7 @@ export class TenantController {
private getTenantUsecase: GetTenant,
private deleteTenantUsecase: DeleteTenant,
private getTenantsUsecase: GetTenants,
private getFeatureFlag: GetFeatureFlag
private getFeatureFlagService: GetFeatureFlagService
) {}

@Get('')
Expand Down Expand Up @@ -213,7 +213,7 @@ export class TenantController {
}

private async verifyTenantsApiAvailability(user: UserSessionData) {
const isV2Enabled = await this.getFeatureFlag.execute(
const isV2Enabled = await this.getFeatureFlagService.getBoolean(
GetFeatureFlagCommand.create({
user: { _id: user._id } as UserEntity,
environment: { _id: user.environmentId } as EnvironmentEntity,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { MessageEntity, MessageRepository, SubscriberRepository, SubscriberEntity, MemberRepository } from '@novu/dal';
import {
ChannelTypeEnum,
FeatureFlagsKeysEnum,
INVITE_TEAM_MEMBER_NUDGE_PAYLOAD_KEY,
WebSocketEventEnum,
} from '@novu/shared';
import { MessageEntity, MessageRepository, SubscriberRepository, SubscriberEntity } from '@novu/dal';
import { INVITE_TEAM_MEMBER_NUDGE_PAYLOAD_KEY, WebSocketEventEnum } from '@novu/shared';
import {
WebSocketsQueueService,
AnalyticsService,
Expand All @@ -14,8 +9,6 @@ import {
buildFeedKey,
buildMessageCountKey,
buildSubscriberKey,
GetFeatureFlag,
GetFeatureFlagCommand,
} from '@novu/application-generic';

import { MarkEnum, MarkMessageAsCommand } from './mark-message-as.command';
Expand All @@ -27,9 +20,7 @@ export class MarkMessageAs {
private messageRepository: MessageRepository,
private webSocketsQueueService: WebSocketsQueueService,
private analyticsService: AnalyticsService,
private subscriberRepository: SubscriberRepository,
private memberRepository: MemberRepository,
private getFeatureFlag: GetFeatureFlag
private subscriberRepository: SubscriberRepository
) {}

async execute(command: MarkMessageAsCommand): Promise<MessageEntity[]> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@novu/shared';
import {
DetailEnum,
GetFeatureFlag,
GetFeatureFlagService,
GetFeatureFlagCommand,
ExecutionLogRoute,
ExecutionLogRouteCommand,
Expand All @@ -43,15 +43,15 @@ export class Digest extends SendMessageType {
protected jobRepository: JobRepository,
private getDigestEventsRegular: GetDigestEventsRegular,
private getDigestEventsBackoff: GetDigestEventsBackoff,
private getFeatureFlag: GetFeatureFlag
private getFeatureFlagService: GetFeatureFlagService
) {
super(messageRepository, executionLogRoute);
}

public async execute(command: SendMessageCommand) {
const currentJob = await this.getCurrentJob(command);

const useMergedDigestId = await this.getFeatureFlag.execute(
const useMergedDigestId = await this.getFeatureFlagService.getBoolean(
GetFeatureFlagCommand.create({
key: FeatureFlagsKeysEnum.IS_USE_MERGED_DIGEST_ID_ENABLED,
environment: { _id: command.environmentId } as EnvironmentEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
SelectVariant,
ExecutionLogRoute,
ExecutionLogRouteCommand,
GetFeatureFlag,
GetFeatureFlagService,
GetFeatureFlagCommand,
} from '@novu/application-generic';
import { EmailOutput } from '@novu/framework/internal';
Expand All @@ -60,7 +60,7 @@ export class SendMessageEmail extends SendMessageBase {
protected getNovuProviderCredentials: GetNovuProviderCredentials,
protected selectVariant: SelectVariant,
protected moduleRef: ModuleRef,
private getFeatureFlag: GetFeatureFlag
private getFeatureFlagService: GetFeatureFlagService
) {
super(
messageRepository,
Expand Down Expand Up @@ -239,7 +239,7 @@ export class SendMessageEmail extends SendMessageBase {
}

// TODO: remove as part of https://linear.app/novu/issue/NV-4117/email-html-content-issue-in-mobile-devices
const shouldDisableInlineCss = await this.getFeatureFlag.execute(
const shouldDisableInlineCss = await this.getFeatureFlagService.getBoolean(
GetFeatureFlagCommand.create({
key: FeatureFlagsKeysEnum.IS_EMAIL_INLINE_CSS_DISABLED,
environment: { _id: command.environmentId } as EnvironmentEntity,
Expand Down
4 changes: 2 additions & 2 deletions apps/worker/src/app/workflow/workflow.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
CreateExecutionDetails,
ExecutionLogRoute,
GetDecryptedIntegrations,
getFeatureFlag,
GetLayoutUseCase,
GetNovuLayout,
GetNovuProviderCredentials,
Expand All @@ -26,6 +25,7 @@ import {
TriggerMulticast,
TierRestrictionsValidateUsecase,
WorkflowInMemoryProviderService,
getFeatureFlagService,
} from '@novu/application-generic';
import { CommunityOrganizationRepository, JobRepository, PreferencesRepository } from '@novu/dal';

Expand Down Expand Up @@ -126,7 +126,7 @@ const USE_CASES = [
UpdateJobStatus,
WebhookFilterBackoffStrategy,
GetTopicSubscribersUseCase,
getFeatureFlag,
getFeatureFlagService,
SubscriberJobBound,
TriggerBroadcast,
TriggerMulticast,
Expand Down
10 changes: 5 additions & 5 deletions libs/application-generic/src/custom-providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
FeatureFlagsService,
LaunchDarklyService,
} from '../services';
import { GetFeatureFlag } from '../usecases';
import { GetFeatureFlagService } from '../usecases/feature-flag';

export const featureFlagsService = {
provide: FeatureFlagsService,
Expand All @@ -29,12 +29,12 @@ export const launchDarklyService = {
},
};

export const getFeatureFlag = {
provide: GetFeatureFlag,
export const getFeatureFlagService = {
provide: GetFeatureFlagService,
useFactory: async (
featureFlagsServiceItem: FeatureFlagsService,
): Promise<GetFeatureFlag> => {
const useCase = new GetFeatureFlag(featureFlagsServiceItem);
): Promise<GetFeatureFlagService> => {
const useCase = new GetFeatureFlagService(featureFlagsServiceItem);

return useCase;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
InMemoryProviderClient,
ScanStream,
} from './types';

import { GetIsInMemoryClusterModeEnabled } from '../../usecases';
import { GetIsInMemoryClusterModeEnabled } from '../../usecases/feature-flag';

const LOG_CONTEXT = 'CacheInMemoryProviderService';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
InMemoryProviderClient,
ScanStream,
} from './types';

import { GetIsInMemoryClusterModeEnabled } from '../../usecases';
import { GetIsInMemoryClusterModeEnabled } from '../../usecases/feature-flag';

const LOG_CONTEXT = 'WebSocketsInMemoryProviderService';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Logger } from '@nestjs/common';

import { InMemoryProviderService } from './in-memory-provider.service';
import { InMemoryProviderEnum, InMemoryProviderClient } from './types';

import { GetIsInMemoryClusterModeEnabled } from '../../usecases';
import { GetIsInMemoryClusterModeEnabled } from '../../usecases/feature-flag';

const LOG_CONTEXT = 'WorkflowInMemoryProviderService';

Expand Down
Loading

0 comments on commit 41a2afb

Please sign in to comment.