rename core-module environment to twenty-config (#11445)
closes https://github.com/twentyhq/core-team-issues/issues/759
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';
|
||||
import { TwentyConfigModule } from 'src/engine/core-modules/twenty-config/twenty-config.module';
|
||||
import { GoogleCalendarClientProvider } from 'src/modules/calendar/calendar-event-import-manager/drivers/google-calendar/providers/google-calendar.provider';
|
||||
import { GoogleCalendarGetEventsService } from 'src/modules/calendar/calendar-event-import-manager/drivers/google-calendar/services/google-calendar-get-events.service';
|
||||
import { OAuth2ClientManagerModule } from 'src/modules/connected-account/oauth2-client-manager/oauth2-client-manager.module';
|
||||
|
||||
@Module({
|
||||
imports: [EnvironmentModule, OAuth2ClientManagerModule],
|
||||
imports: [TwentyConfigModule, OAuth2ClientManagerModule],
|
||||
providers: [GoogleCalendarClientProvider, GoogleCalendarGetEventsService],
|
||||
exports: [GoogleCalendarGetEventsService],
|
||||
})
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';
|
||||
import { TwentyConfigModule } from 'src/engine/core-modules/twenty-config/twenty-config.module';
|
||||
import { MicrosoftCalendarGetEventsService } from 'src/modules/calendar/calendar-event-import-manager/drivers/microsoft-calendar/services/microsoft-calendar-get-events.service';
|
||||
import { MicrosoftCalendarImportEventsService } from 'src/modules/calendar/calendar-event-import-manager/drivers/microsoft-calendar/services/microsoft-calendar-import-events.service';
|
||||
import { MicrosoftOAuth2ClientManagerService } from 'src/modules/connected-account/oauth2-client-manager/drivers/microsoft/microsoft-oauth2-client-manager.service';
|
||||
|
||||
@Module({
|
||||
imports: [EnvironmentModule],
|
||||
imports: [TwentyConfigModule],
|
||||
providers: [
|
||||
MicrosoftCalendarGetEventsService,
|
||||
MicrosoftCalendarImportEventsService,
|
||||
|
||||
@ -3,15 +3,15 @@ import { Injectable } from '@nestjs/common';
|
||||
import { OAuth2Client } from 'google-auth-library';
|
||||
import { google } from 'googleapis';
|
||||
|
||||
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 GoogleOAuth2ClientManagerService {
|
||||
constructor(private readonly environmentService: EnvironmentService) {}
|
||||
constructor(private readonly twentyConfigService: TwentyConfigService) {}
|
||||
|
||||
public async getOAuth2Client(refreshToken: string): Promise<OAuth2Client> {
|
||||
const gmailClientId = this.environmentService.get('AUTH_GOOGLE_CLIENT_ID');
|
||||
const gmailClientSecret = this.environmentService.get(
|
||||
const gmailClientId = this.twentyConfigService.get('AUTH_GOOGLE_CLIENT_ID');
|
||||
const gmailClientSecret = this.twentyConfigService.get(
|
||||
'AUTH_GOOGLE_CLIENT_SECRET',
|
||||
);
|
||||
|
||||
|
||||
@ -6,11 +6,11 @@ import {
|
||||
Client,
|
||||
} from '@microsoft/microsoft-graph-client';
|
||||
|
||||
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 MicrosoftOAuth2ClientManagerService {
|
||||
constructor(private readonly environmentService: EnvironmentService) {}
|
||||
constructor(private readonly twentyConfigService: TwentyConfigService) {}
|
||||
|
||||
public async getOAuth2Client(refreshToken: string): Promise<Client> {
|
||||
const authProvider: AuthProvider = async (
|
||||
@ -21,13 +21,13 @@ export class MicrosoftOAuth2ClientManagerService {
|
||||
|
||||
urlData.append(
|
||||
'client_id',
|
||||
this.environmentService.get('AUTH_MICROSOFT_CLIENT_ID'),
|
||||
this.twentyConfigService.get('AUTH_MICROSOFT_CLIENT_ID'),
|
||||
);
|
||||
urlData.append('scope', 'https://graph.microsoft.com/.default');
|
||||
urlData.append('refresh_token', refreshToken);
|
||||
urlData.append(
|
||||
'client_secret',
|
||||
this.environmentService.get('AUTH_MICROSOFT_CLIENT_SECRET'),
|
||||
this.twentyConfigService.get('AUTH_MICROSOFT_CLIENT_SECRET'),
|
||||
);
|
||||
urlData.append('grant_type', 'refresh_token');
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import axios from 'axios';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
|
||||
export type GoogleTokens = {
|
||||
accessToken: string;
|
||||
@ -18,14 +18,16 @@ interface GoogleRefreshTokenResponse {
|
||||
}
|
||||
@Injectable()
|
||||
export class GoogleAPIRefreshAccessTokenService {
|
||||
constructor(private readonly environmentService: EnvironmentService) {}
|
||||
constructor(private readonly twentyConfigService: TwentyConfigService) {}
|
||||
|
||||
async refreshAccessToken(refreshToken: string): Promise<GoogleTokens> {
|
||||
const response = await axios.post<GoogleRefreshTokenResponse>(
|
||||
'https://oauth2.googleapis.com/token',
|
||||
{
|
||||
client_id: this.environmentService.get('AUTH_GOOGLE_CLIENT_ID'),
|
||||
client_secret: this.environmentService.get('AUTH_GOOGLE_CLIENT_SECRET'),
|
||||
client_id: this.twentyConfigService.get('AUTH_GOOGLE_CLIENT_ID'),
|
||||
client_secret: this.twentyConfigService.get(
|
||||
'AUTH_GOOGLE_CLIENT_SECRET',
|
||||
),
|
||||
refresh_token: refreshToken,
|
||||
grant_type: 'refresh_token',
|
||||
},
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';
|
||||
import { TwentyConfigModule } from 'src/engine/core-modules/twenty-config/twenty-config.module';
|
||||
import { MicrosoftAPIRefreshAccessTokenService } from 'src/modules/connected-account/refresh-tokens-manager/drivers/microsoft/services/microsoft-api-refresh-tokens.service';
|
||||
|
||||
@Module({
|
||||
imports: [EnvironmentModule],
|
||||
imports: [TwentyConfigModule],
|
||||
providers: [MicrosoftAPIRefreshAccessTokenService],
|
||||
exports: [MicrosoftAPIRefreshAccessTokenService],
|
||||
})
|
||||
|
||||
@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import axios from 'axios';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
|
||||
export type MicrosoftTokens = {
|
||||
accessToken: string;
|
||||
@ -20,14 +20,14 @@ interface MicrosoftRefreshTokenResponse {
|
||||
}
|
||||
@Injectable()
|
||||
export class MicrosoftAPIRefreshAccessTokenService {
|
||||
constructor(private readonly environmentService: EnvironmentService) {}
|
||||
constructor(private readonly twentyConfigService: TwentyConfigService) {}
|
||||
|
||||
async refreshTokens(refreshToken: string): Promise<MicrosoftTokens> {
|
||||
const response = await axios.post<MicrosoftRefreshTokenResponse>(
|
||||
'https://login.microsoftonline.com/common/oauth2/v2.0/token',
|
||||
new URLSearchParams({
|
||||
client_id: this.environmentService.get('AUTH_MICROSOFT_CLIENT_ID'),
|
||||
client_secret: this.environmentService.get(
|
||||
client_id: this.twentyConfigService.get('AUTH_MICROSOFT_CLIENT_ID'),
|
||||
client_secret: this.twentyConfigService.get(
|
||||
'AUTH_MICROSOFT_CLIENT_SECRET',
|
||||
),
|
||||
refresh_token: refreshToken,
|
||||
|
||||
@ -2,9 +2,9 @@ import { HttpModule } from '@nestjs/axios';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
|
||||
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';
|
||||
import { FeatureFlag } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
|
||||
import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-flag.module';
|
||||
import { TwentyConfigModule } from 'src/engine/core-modules/twenty-config/twenty-config.module';
|
||||
import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
|
||||
import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
|
||||
import { BlocklistWorkspaceEntity } from 'src/modules/blocklist/standard-objects/blocklist.workspace-entity';
|
||||
@ -24,7 +24,7 @@ import { MessageParticipantManagerModule } from 'src/modules/messaging/message-p
|
||||
HttpModule.register({
|
||||
baseURL: 'https://www.googleapis.com/batch/gmail/v1',
|
||||
}),
|
||||
EnvironmentModule,
|
||||
TwentyConfigModule,
|
||||
ObjectMetadataRepositoryModule.forFeature([BlocklistWorkspaceEntity]),
|
||||
MessagingCommonModule,
|
||||
TypeOrmModule.forFeature([FeatureFlag], 'core'),
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';
|
||||
import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-flag.module';
|
||||
import { TwentyConfigModule } from 'src/engine/core-modules/twenty-config/twenty-config.module';
|
||||
import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
|
||||
import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module';
|
||||
import { MicrosoftOAuth2ClientManagerService } from 'src/modules/connected-account/oauth2-client-manager/drivers/microsoft/microsoft-oauth2-client-manager.service';
|
||||
@ -16,7 +16,7 @@ import { MicrosoftGetMessageListService } from './services/microsoft-get-message
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
EnvironmentModule,
|
||||
TwentyConfigModule,
|
||||
MessagingCommonModule,
|
||||
FeatureFlagModule,
|
||||
OAuth2ClientManagerModule,
|
||||
|
||||
@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { ConnectedAccountProvider } from 'twenty-shared/types';
|
||||
|
||||
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';
|
||||
import { TwentyConfigModule } from 'src/engine/core-modules/twenty-config/twenty-config.module';
|
||||
import { MicrosoftOAuth2ClientManagerService } from 'src/modules/connected-account/oauth2-client-manager/drivers/microsoft/microsoft-oauth2-client-manager.service';
|
||||
import { MessageChannelWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-channel.workspace-entity';
|
||||
import { MessageFolderWorkspaceEntity } from 'src/modules/messaging/common/standard-objects/message-folder.workspace-entity';
|
||||
@ -28,7 +28,7 @@ xdescribe('Microsoft dev tests : get message list service', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
imports: [EnvironmentModule.forRoot({})],
|
||||
imports: [TwentyConfigModule.forRoot({})],
|
||||
providers: [
|
||||
MicrosoftGetMessageListService,
|
||||
MicrosoftClientProvider,
|
||||
@ -118,7 +118,7 @@ xdescribe('Microsoft dev tests : get full message list service for folders', ()
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
imports: [EnvironmentModule.forRoot({})],
|
||||
imports: [TwentyConfigModule.forRoot({})],
|
||||
providers: [
|
||||
MicrosoftGetMessageListService,
|
||||
MicrosoftClientProvider,
|
||||
@ -207,7 +207,7 @@ xdescribe('Microsoft dev tests : get partial message list service for folders',
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
imports: [EnvironmentModule.forRoot({})],
|
||||
imports: [TwentyConfigModule.forRoot({})],
|
||||
providers: [
|
||||
MicrosoftGetMessageListService,
|
||||
MicrosoftClientProvider,
|
||||
|
||||
@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { ConnectedAccountProvider } from 'twenty-shared/types';
|
||||
|
||||
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';
|
||||
import { TwentyConfigModule } from 'src/engine/core-modules/twenty-config/twenty-config.module';
|
||||
import { MicrosoftOAuth2ClientManagerService } from 'src/modules/connected-account/oauth2-client-manager/drivers/microsoft/microsoft-oauth2-client-manager.service';
|
||||
import { MicrosoftClientProvider } from 'src/modules/messaging/message-import-manager/drivers/microsoft/providers/microsoft-client.provider';
|
||||
import { MicrosoftFetchByBatchService } from 'src/modules/messaging/message-import-manager/drivers/microsoft/services/microsoft-fetch-by-batch.service';
|
||||
@ -23,7 +23,7 @@ xdescribe('Microsoft dev tests : get messages service', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
imports: [EnvironmentModule.forRoot({})],
|
||||
imports: [TwentyConfigModule.forRoot({})],
|
||||
providers: [
|
||||
MicrosoftGetMessagesService,
|
||||
MicrosoftHandleErrorService,
|
||||
|
||||
@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
import { ConnectedAccountProvider } from 'twenty-shared/types';
|
||||
|
||||
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';
|
||||
import { TwentyConfigModule } from 'src/engine/core-modules/twenty-config/twenty-config.module';
|
||||
import { MicrosoftOAuth2ClientManagerService } from 'src/modules/connected-account/oauth2-client-manager/drivers/microsoft/microsoft-oauth2-client-manager.service';
|
||||
import {
|
||||
microsoftGraphBatchWithHtmlMessagesResponse,
|
||||
@ -21,7 +21,7 @@ describe('Microsoft get messages service', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
imports: [EnvironmentModule.forRoot({})],
|
||||
imports: [TwentyConfigModule.forRoot({})],
|
||||
providers: [
|
||||
MicrosoftGetMessagesService,
|
||||
MicrosoftHandleErrorService,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { AnalyticsService } from 'src/engine/core-modules/analytics/analytics.service';
|
||||
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
|
||||
type MessagingTelemetryTrackInput = {
|
||||
eventName: string;
|
||||
@ -16,7 +16,7 @@ type MessagingTelemetryTrackInput = {
|
||||
export class MessagingTelemetryService {
|
||||
constructor(
|
||||
private readonly analyticsService: AnalyticsService,
|
||||
private readonly environmentService: EnvironmentService,
|
||||
private readonly twentyConfigService: TwentyConfigService,
|
||||
) {}
|
||||
|
||||
public async track({
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { Scope } from '@nestjs/common';
|
||||
|
||||
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
|
||||
import { Process } from 'src/engine/core-modules/message-queue/decorators/process.decorator';
|
||||
import { Processor } from 'src/engine/core-modules/message-queue/decorators/processor.decorator';
|
||||
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
|
||||
import { ThrottlerService } from 'src/engine/core-modules/throttler/throttler.service';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
|
||||
import { WorkflowRunStatus } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';
|
||||
import { WorkflowCommonWorkspaceService } from 'src/modules/workflow/common/workspace-services/workflow-common.workspace-service';
|
||||
@ -30,7 +30,7 @@ export class RunWorkflowJob {
|
||||
private readonly workflowExecutorWorkspaceService: WorkflowExecutorWorkspaceService,
|
||||
private readonly workflowRunWorkspaceService: WorkflowRunWorkspaceService,
|
||||
private readonly throttlerService: ThrottlerService,
|
||||
private readonly environmentService: EnvironmentService,
|
||||
private readonly twentyConfigService: TwentyConfigService,
|
||||
private readonly twentyORMManager: TwentyORMManager,
|
||||
) {}
|
||||
|
||||
@ -182,8 +182,8 @@ export class RunWorkflowJob {
|
||||
try {
|
||||
await this.throttlerService.throttle(
|
||||
`${workflowId}-workflow-execution`,
|
||||
this.environmentService.get('WORKFLOW_EXEC_THROTTLE_LIMIT'),
|
||||
this.environmentService.get('WORKFLOW_EXEC_THROTTLE_TTL'),
|
||||
this.twentyConfigService.get('WORKFLOW_EXEC_THROTTLE_LIMIT'),
|
||||
this.twentyConfigService.get('WORKFLOW_EXEC_THROTTLE_TTL'),
|
||||
);
|
||||
} catch (error) {
|
||||
throw new WorkflowRunException(
|
||||
|
||||
Reference in New Issue
Block a user