rename core-module environment to twenty-config (#11445)

closes https://github.com/twentyhq/core-team-issues/issues/759
This commit is contained in:
nitin
2025-04-09 17:41:26 +05:30
committed by GitHub
parent fe6d0241a8
commit bd3ec6d5e3
193 changed files with 1454 additions and 1422 deletions

View File

@ -6,21 +6,21 @@ import { OnCustomBatchEvent } from 'src/engine/api/graphql/graphql-query-runner/
import { BILLING_FEATURE_USED } from 'src/engine/core-modules/billing/constants/billing-feature-used.constant';
import { BillingUsageService } from 'src/engine/core-modules/billing/services/billing-usage.service';
import { BillingUsageEvent } from 'src/engine/core-modules/billing/types/billing-usage-event.type';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
import { WorkspaceEventBatch } from 'src/engine/workspace-event-emitter/types/workspace-event.type';
@Injectable()
export class BillingFeatureUsedListener {
constructor(
private readonly billingUsageService: BillingUsageService,
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
) {}
@OnCustomBatchEvent(BILLING_FEATURE_USED)
async handleBillingFeatureUsedEvent(
payload: WorkspaceEventBatch<BillingUsageEvent>,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}

View File

@ -8,11 +8,11 @@ import {
UpdateSubscriptionQuantityJob,
UpdateSubscriptionQuantityJobData,
} from 'src/engine/core-modules/billing/jobs/update-subscription-quantity.job';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { ObjectRecordCreateEvent } from 'src/engine/core-modules/event-emitter/types/object-record-create.event';
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
import { WorkspaceEventBatch } from 'src/engine/workspace-event-emitter/types/workspace-event.type';
import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/standard-objects/workspace-member.workspace-entity';
@ -21,7 +21,7 @@ export class BillingWorkspaceMemberListener {
constructor(
@InjectMessageQueue(MessageQueue.billingQueue)
private readonly messageQueueService: MessageQueueService,
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
) {}
@OnDatabaseBatchEvent('workspaceMember', DatabaseEventAction.CREATED)
@ -31,7 +31,7 @@ export class BillingWorkspaceMemberListener {
ObjectRecordCreateEvent<WorkspaceMemberWorkspaceEntity>
>,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}

View File

@ -17,7 +17,7 @@ import { BillingSubscriptionItemService } from 'src/engine/core-modules/billing/
import { BillingSubscriptionService } from 'src/engine/core-modules/billing/services/billing-subscription.service';
import { StripeBillingMeterEventService } from 'src/engine/core-modules/billing/stripe/services/stripe-billing-meter-event.service';
import { BillingUsageEvent } from 'src/engine/core-modules/billing/types/billing-usage-event.type';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
@Injectable()
@ -28,12 +28,12 @@ export class BillingUsageService {
private readonly billingCustomerRepository: Repository<BillingCustomer>,
private readonly billingSubscriptionService: BillingSubscriptionService,
private readonly stripeBillingMeterEventService: StripeBillingMeterEventService,
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly billingSubscriptionItemService: BillingSubscriptionItemService,
) {}
async canFeatureBeUsed(workspaceId: string): Promise<boolean> {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return true;
}

View File

@ -13,15 +13,15 @@ import { SubscriptionStatus } from 'src/engine/core-modules/billing/enums/billin
import { BillingProductService } from 'src/engine/core-modules/billing/services/billing-product.service';
import { BillingSubscriptionService } from 'src/engine/core-modules/billing/services/billing-subscription.service';
import { getPlanKeyFromSubscription } from 'src/engine/core-modules/billing/utils/get-plan-key-from-subscription.util';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
@Injectable()
export class BillingService {
protected readonly logger = new Logger(BillingService.name);
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly billingSubscriptionService: BillingSubscriptionService,
private readonly billingProductService: BillingProductService,
private readonly featureFlagService: FeatureFlagService,
@ -30,7 +30,7 @@ export class BillingService {
) {}
isBillingEnabled() {
return this.environmentService.get('IS_BILLING_ENABLED');
return this.twentyConfigService.get('IS_BILLING_ENABLED');
}
async hasWorkspaceAnySubscription(workspaceId: string) {

View File

@ -6,7 +6,7 @@ import Stripe from 'stripe';
import { BillingMeterEventName } from 'src/engine/core-modules/billing/enums/billing-meter-event-names';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
@Injectable()
export class StripeBillingMeterEventService {
@ -14,14 +14,14 @@ export class StripeBillingMeterEventService {
private readonly stripe: Stripe;
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly stripeSDKService: StripeSDKService,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}
this.stripe = this.stripeSDKService.getStripe(
this.environmentService.get('BILLING_STRIPE_API_KEY'),
this.twentyConfigService.get('BILLING_STRIPE_API_KEY'),
);
}

View File

@ -5,7 +5,7 @@ import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
@Injectable()
export class StripeBillingMeterService {
@ -13,14 +13,14 @@ export class StripeBillingMeterService {
private readonly stripe: Stripe;
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly stripeSDKService: StripeSDKService,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}
this.stripe = this.stripeSDKService.getStripe(
this.environmentService.get('BILLING_STRIPE_API_KEY'),
this.twentyConfigService.get('BILLING_STRIPE_API_KEY'),
);
}

View File

@ -6,7 +6,7 @@ import Stripe from 'stripe';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
import { DomainManagerService } from 'src/engine/core-modules/domain-manager/services/domain-manager.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
@Injectable()
export class StripeBillingPortalService {
@ -14,15 +14,15 @@ export class StripeBillingPortalService {
private readonly stripe: Stripe;
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly domainManagerService: DomainManagerService,
private readonly stripeSDKService: StripeSDKService,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}
this.stripe = this.stripeSDKService.getStripe(
this.environmentService.get('BILLING_STRIPE_API_KEY'),
this.twentyConfigService.get('BILLING_STRIPE_API_KEY'),
);
}

View File

@ -6,7 +6,7 @@ import Stripe from 'stripe';
import { BillingPlanKey } from 'src/engine/core-modules/billing/enums/billing-plan-key.enum';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
import { User } from 'src/engine/core-modules/user/user.entity';
@Injectable()
@ -15,14 +15,14 @@ export class StripeCheckoutService {
private readonly stripe: Stripe;
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly stripeSDKService: StripeSDKService,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}
this.stripe = this.stripeSDKService.getStripe(
this.environmentService.get('BILLING_STRIPE_API_KEY'),
this.twentyConfigService.get('BILLING_STRIPE_API_KEY'),
);
}
@ -57,7 +57,7 @@ export class StripeCheckoutService {
},
...(withTrialPeriod
? {
trial_period_days: this.environmentService.get(
trial_period_days: this.twentyConfigService.get(
requirePaymentMethod
? 'BILLING_FREE_TRIAL_WITH_CREDIT_CARD_DURATION_IN_DAYS'
: 'BILLING_FREE_TRIAL_WITHOUT_CREDIT_CARD_DURATION_IN_DAYS',

View File

@ -5,7 +5,7 @@ import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
@Injectable()
export class StripeCustomerService {
@ -13,14 +13,14 @@ export class StripeCustomerService {
private readonly stripe: Stripe;
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly stripeSDKService: StripeSDKService,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}
this.stripe = this.stripeSDKService.getStripe(
this.environmentService.get('BILLING_STRIPE_API_KEY'),
this.twentyConfigService.get('BILLING_STRIPE_API_KEY'),
);
}

View File

@ -5,7 +5,7 @@ import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
@Injectable()
export class StripePriceService {
@ -13,14 +13,14 @@ export class StripePriceService {
private readonly stripe: Stripe;
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly stripeSDKService: StripeSDKService,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}
this.stripe = this.stripeSDKService.getStripe(
this.environmentService.get('BILLING_STRIPE_API_KEY'),
this.twentyConfigService.get('BILLING_STRIPE_API_KEY'),
);
}

View File

@ -5,7 +5,7 @@ import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
@Injectable()
export class StripeProductService {
@ -13,14 +13,14 @@ export class StripeProductService {
private readonly stripe: Stripe;
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly stripeSDKService: StripeSDKService,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}
this.stripe = this.stripeSDKService.getStripe(
this.environmentService.get('BILLING_STRIPE_API_KEY'),
this.twentyConfigService.get('BILLING_STRIPE_API_KEY'),
);
}

View File

@ -5,7 +5,7 @@ import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
@Injectable()
export class StripeSubscriptionItemService {
@ -13,14 +13,14 @@ export class StripeSubscriptionItemService {
private readonly stripe: Stripe;
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly stripeSDKService: StripeSDKService,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}
this.stripe = this.stripeSDKService.getStripe(
this.environmentService.get('BILLING_STRIPE_API_KEY'),
this.twentyConfigService.get('BILLING_STRIPE_API_KEY'),
);
}

View File

@ -6,7 +6,7 @@ import Stripe from 'stripe';
import { BillingSubscriptionItem } from 'src/engine/core-modules/billing/entities/billing-subscription-item.entity';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
@Injectable()
export class StripeSubscriptionService {
@ -14,14 +14,14 @@ export class StripeSubscriptionService {
private readonly stripe: Stripe;
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly stripeSDKService: StripeSDKService,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}
this.stripe = this.stripeSDKService.getStripe(
this.environmentService.get('BILLING_STRIPE_API_KEY'),
this.twentyConfigService.get('BILLING_STRIPE_API_KEY'),
);
}

View File

@ -5,26 +5,26 @@ import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
@Injectable()
export class StripeWebhookService {
protected readonly logger = new Logger(StripeWebhookService.name);
private stripe: Stripe;
constructor(
private readonly environmentService: EnvironmentService,
private readonly twentyConfigService: TwentyConfigService,
private readonly stripeSDKService: StripeSDKService,
) {
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
if (!this.twentyConfigService.get('IS_BILLING_ENABLED')) {
return;
}
this.stripe = this.stripeSDKService.getStripe(
this.environmentService.get('BILLING_STRIPE_API_KEY'),
this.twentyConfigService.get('BILLING_STRIPE_API_KEY'),
);
}
constructEventFromPayload(signature: string, payload: Buffer) {
const webhookSecret = this.environmentService.get(
const webhookSecret = this.twentyConfigService.get(
'BILLING_STRIPE_WEBHOOK_SECRET',
);