diff --git a/packages/twenty-server/src/database/commands/0-22-add-new-address-field-to-views-with-deprecated-address.command.ts b/packages/twenty-server/src/database/commands/0-22-add-new-address-field-to-views-with-deprecated-address.command.ts index a21b43975a35..e624a4d8694a 100644 --- a/packages/twenty-server/src/database/commands/0-22-add-new-address-field-to-views-with-deprecated-address.command.ts +++ b/packages/twenty-server/src/database/commands/0-22-add-new-address-field-to-views-with-deprecated-address.command.ts @@ -7,19 +7,11 @@ import { Command, CommandRunner, Option } from 'nest-commander'; import { Repository } from 'typeorm'; import { TypeORMService } from 'src/database/typeorm/typeorm.service'; -import { - BillingSubscription, - SubscriptionStatus, -} from 'src/engine/core-modules/billing/entities/billing-subscription.entity'; -import { - FeatureFlagEntity, - FeatureFlagKeys, -} from 'src/engine/core-modules/feature-flag/feature-flag.entity'; -import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service'; import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; import { WorkspaceCacheVersionService } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.service'; import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager'; +import { WorkspaceStatusService } from 'src/engine/workspace-manager/workspace-status/services/workspace-status.service'; import { COMPANY_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids'; import { ViewFieldWorkspaceEntity } from 'src/modules/view/standard-objects/view-field.workspace-entity'; @@ -36,18 +28,13 @@ export class AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand extends AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand.name, ); constructor( - @InjectRepository(Workspace, 'core') - private readonly workspaceRepository: Repository, - @InjectRepository(BillingSubscription, 'core') - private readonly billingSubscriptionRepository: Repository, - @InjectRepository(FeatureFlagEntity, 'core') - private readonly featureFlagRepository: Repository, @InjectRepository(FieldMetadataEntity, 'metadata') private readonly fieldMetadataRepository: Repository, private readonly typeORMService: TypeORMService, private readonly dataSourceService: DataSourceService, private readonly workspaceCacheVersionService: WorkspaceCacheVersionService, private readonly twentyORMManager: TwentyORMManager, + private readonly workspaceStatusService: WorkspaceStatusService, ) { super(); } @@ -76,19 +63,8 @@ export class AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand extends if (options.workspaceId) { workspaceIds = [options.workspaceId]; } else { - const workspaces = await this.workspaceRepository.find(); - - const activeWorkspaceIds = ( - await Promise.all( - workspaces.map(async (workspace) => { - const isActive = await this.workspaceIsActive(workspace); - - return { workspace, isActive }; - }), - ) - ) - .filter((result) => result.isActive) - .map((result) => result.workspace.id); + const activeWorkspaceIds = + await this.workspaceStatusService.getActiveWorkspaceIds(); workspaceIds = activeWorkspaceIds; } @@ -198,33 +174,4 @@ export class AddNewAddressFieldToViewsWithDeprecatedAddressFieldCommand extends this.logger.log(chalk.green(`Command completed!`)); } - - private async workspaceIsActive(workspace: Workspace): Promise { - const billingSupscriptionForWorkspace = - await this.billingSubscriptionRepository.findOne({ - where: { workspaceId: workspace.id }, - }); - - if ( - billingSupscriptionForWorkspace?.status && - [ - SubscriptionStatus.PastDue, - SubscriptionStatus.Active, - SubscriptionStatus.Trialing, - ].includes(billingSupscriptionForWorkspace.status as SubscriptionStatus) - ) { - return true; - } - - const freeAccessEnabledFeatureFlagForWorkspace = - await this.featureFlagRepository.findOne({ - where: { - workspaceId: workspace.id, - key: FeatureFlagKeys.IsFreeAccessEnabled, - value: true, - }, - }); - - return !!freeAccessEnabledFeatureFlagForWorkspace; - } } diff --git a/packages/twenty-server/src/database/commands/database-command.module.ts b/packages/twenty-server/src/database/commands/database-command.module.ts index 1c4286859930..99e40ed5554a 100644 --- a/packages/twenty-server/src/database/commands/database-command.module.ts +++ b/packages/twenty-server/src/database/commands/database-command.module.ts @@ -24,6 +24,7 @@ import { ObjectMetadataModule } from 'src/engine/metadata-modules/object-metadat import { WorkspaceCacheVersionModule } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.module'; import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module'; import { WorkspaceManagerModule } from 'src/engine/workspace-manager/workspace-manager.module'; +import { WorkspaceStatusModule } from 'src/engine/workspace-manager/workspace-status/workspace-manager.module'; import { WorkspaceSyncMetadataModule } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.module'; @Module({ @@ -42,10 +43,10 @@ import { WorkspaceSyncMetadataModule } from 'src/engine/workspace-manager/worksp WorkspaceModule, WorkspaceDataSourceModule, WorkspaceSyncMetadataModule, + WorkspaceStatusModule, ObjectMetadataModule, DataSeedDemoWorkspaceModule, WorkspaceCacheVersionModule, - // Upgrades UpgradeTo0_22CommandModule, ], diff --git a/packages/twenty-server/src/engine/core-modules/workspace/services/workspace.service.ts b/packages/twenty-server/src/engine/core-modules/workspace/services/workspace.service.ts index 38a259cb2c71..e94a3596fd3d 100644 --- a/packages/twenty-server/src/engine/core-modules/workspace/services/workspace.service.ts +++ b/packages/twenty-server/src/engine/core-modules/workspace/services/workspace.service.ts @@ -1,24 +1,24 @@ -import { InjectRepository } from '@nestjs/typeorm'; import { BadRequestException } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; import assert from 'assert'; import { TypeOrmQueryService } from '@ptc-org/nestjs-query-typeorm'; -import { Repository } from 'typeorm'; -import { SendInviteLinkEmail } from 'twenty-emails'; import { render } from '@react-email/render'; +import { SendInviteLinkEmail } from 'twenty-emails'; +import { Repository } from 'typeorm'; -import { WorkspaceManagerService } from 'src/engine/workspace-manager/workspace-manager.service'; -import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; -import { User } from 'src/engine/core-modules/user/user.entity'; -import { ActivateWorkspaceInput } from 'src/engine/core-modules/workspace/dtos/activate-workspace-input'; +import { BillingWorkspaceService } from 'src/engine/core-modules/billing/billing.workspace-service'; +import { OnboardingService } from 'src/engine/core-modules/onboarding/onboarding.service'; import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity'; import { UserWorkspaceService } from 'src/engine/core-modules/user-workspace/user-workspace.service'; -import { BillingWorkspaceService } from 'src/engine/core-modules/billing/billing.workspace-service'; +import { User } from 'src/engine/core-modules/user/user.entity'; +import { ActivateWorkspaceInput } from 'src/engine/core-modules/workspace/dtos/activate-workspace-input'; import { SendInviteLink } from 'src/engine/core-modules/workspace/dtos/send-invite-link.entity'; +import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; import { EmailService } from 'src/engine/integrations/email/email.service'; import { EnvironmentService } from 'src/engine/integrations/environment/environment.service'; -import { OnboardingService } from 'src/engine/core-modules/onboarding/onboarding.service'; +import { WorkspaceManagerService } from 'src/engine/workspace-manager/workspace-manager.service'; export class WorkspaceService extends TypeOrmQueryService { constructor( diff --git a/packages/twenty-server/src/engine/core-modules/workspace/workspace.module.ts b/packages/twenty-server/src/engine/core-modules/workspace/workspace.module.ts index 86f416fc4101..5e9668cabbd8 100644 --- a/packages/twenty-server/src/engine/core-modules/workspace/workspace.module.ts +++ b/packages/twenty-server/src/engine/core-modules/workspace/workspace.module.ts @@ -3,20 +3,20 @@ import { Module } from '@nestjs/common'; import { NestjsQueryGraphQLModule } from '@ptc-org/nestjs-query-graphql'; import { NestjsQueryTypeOrmModule } from '@ptc-org/nestjs-query-typeorm'; -import { WorkspaceManagerModule } from 'src/engine/workspace-manager/workspace-manager.module'; -import { WorkspaceResolver } from 'src/engine/core-modules/workspace/workspace.resolver'; import { TypeORMModule } from 'src/database/typeorm/typeorm.module'; +import { BillingModule } from 'src/engine/core-modules/billing/billing.module'; import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity'; +import { FileUploadModule } from 'src/engine/core-modules/file/file-upload/file-upload.module'; +import { OnboardingModule } from 'src/engine/core-modules/onboarding/onboarding.module'; import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity'; import { UserWorkspaceModule } from 'src/engine/core-modules/user-workspace/user-workspace.module'; -import { BillingModule } from 'src/engine/core-modules/billing/billing.module'; -import { FileUploadModule } from 'src/engine/core-modules/file/file-upload/file-upload.module'; -import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module'; +import { UserWorkspaceResolver } from 'src/engine/core-modules/user-workspace/user-workspace.resolver'; +import { User } from 'src/engine/core-modules/user/user.entity'; import { WorkspaceWorkspaceMemberListener } from 'src/engine/core-modules/workspace/workspace-workspace-member.listener'; +import { WorkspaceResolver } from 'src/engine/core-modules/workspace/workspace.resolver'; +import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module'; import { WorkspaceCacheVersionModule } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.module'; -import { User } from 'src/engine/core-modules/user/user.entity'; -import { UserWorkspaceResolver } from 'src/engine/core-modules/user-workspace/user-workspace.resolver'; -import { OnboardingModule } from 'src/engine/core-modules/onboarding/onboarding.module'; +import { WorkspaceManagerModule } from 'src/engine/workspace-manager/workspace-manager.module'; import { workspaceAutoResolverOpts } from './workspace.auto-resolver-opts'; import { Workspace } from './workspace.entity'; diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-manager.module.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-manager.module.ts index a3afeb00cc42..f901179fb9aa 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-manager.module.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-manager.module.ts @@ -4,8 +4,9 @@ import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-s import { ObjectMetadataModule } from 'src/engine/metadata-modules/object-metadata/object-metadata.module'; import { WorkspaceMigrationModule } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.module'; import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module'; -import { WorkspaceSyncMetadataModule } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.module'; import { WorkspaceHealthModule } from 'src/engine/workspace-manager/workspace-health/workspace-health.module'; +import { WorkspaceStatusModule } from 'src/engine/workspace-manager/workspace-status/workspace-manager.module'; +import { WorkspaceSyncMetadataModule } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.module'; import { WorkspaceManagerService } from './workspace-manager.service'; @@ -17,6 +18,7 @@ import { WorkspaceManagerService } from './workspace-manager.service'; DataSourceModule, WorkspaceSyncMetadataModule, WorkspaceHealthModule, + WorkspaceStatusModule, ], exports: [WorkspaceManagerService], providers: [WorkspaceManagerService], diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-manager.service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-manager.service.ts index c7d75b6440e8..2d4f95b259bf 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-manager.service.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-manager.service.ts @@ -1,12 +1,12 @@ import { Injectable } from '@nestjs/common'; +import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity'; import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service'; import { ObjectMetadataService } from 'src/engine/metadata-modules/object-metadata/object-metadata.service'; import { WorkspaceMigrationService } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.service'; -import { standardObjectsPrefillData } from 'src/engine/workspace-manager/standard-objects-prefill-data/standard-objects-prefill-data'; -import { demoObjectsPrefillData } from 'src/engine/workspace-manager/demo-objects-prefill-data/demo-objects-prefill-data'; import { WorkspaceDataSourceService } from 'src/engine/workspace-datasource/workspace-datasource.service'; -import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity'; +import { demoObjectsPrefillData } from 'src/engine/workspace-manager/demo-objects-prefill-data/demo-objects-prefill-data'; +import { standardObjectsPrefillData } from 'src/engine/workspace-manager/standard-objects-prefill-data/standard-objects-prefill-data'; import { WorkspaceSyncMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.service'; @Injectable() diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-status/services/workspace-status.service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-status/services/workspace-status.service.ts new file mode 100644 index 000000000000..4792e62edd8f --- /dev/null +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-status/services/workspace-status.service.ts @@ -0,0 +1,74 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; + +import { Any, Repository } from 'typeorm'; + +import { + BillingSubscription, + SubscriptionStatus, +} from 'src/engine/core-modules/billing/entities/billing-subscription.entity'; +import { + FeatureFlagEntity, + FeatureFlagKeys, +} from 'src/engine/core-modules/feature-flag/feature-flag.entity'; +import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; +import { EnvironmentService } from 'src/engine/integrations/environment/environment.service'; + +@Injectable() +export class WorkspaceStatusService { + constructor( + private readonly environmentService: EnvironmentService, + @InjectRepository(Workspace, 'core') + private readonly workspaceRepository: Repository, + @InjectRepository(BillingSubscription, 'core') + private readonly billingSubscriptionRepository: Repository, + @InjectRepository(FeatureFlagEntity, 'core') + private readonly featureFlagRepository: Repository, + ) {} + + async getActiveWorkspaceIds(): Promise { + const workspaces = await this.workspaceRepository.find(); + const workspaceIds = workspaces.map((workspace) => workspace.id); + + if (!this.environmentService.get('IS_BILLING_ENABLED')) { + return workspaceIds; + } + + const billingSubscriptionForWorkspaces = + await this.billingSubscriptionRepository.find({ + where: { + workspaceId: Any(workspaceIds), + status: Any([ + SubscriptionStatus.PastDue, + SubscriptionStatus.Active, + SubscriptionStatus.Trialing, + ]), + }, + }); + + const workspaceIdsWithActiveSubscription = + billingSubscriptionForWorkspaces.map( + (billingSubscription) => billingSubscription.workspaceId, + ); + + const freeAccessEnabledFeatureFlagForWorkspace = + await this.featureFlagRepository.find({ + where: { + workspaceId: Any(workspaceIds), + key: FeatureFlagKeys.IsFreeAccessEnabled, + value: true, + }, + }); + + const workspaceIdsWithFreeAccessEnabled = + freeAccessEnabledFeatureFlagForWorkspace.map( + (featureFlag) => featureFlag.workspaceId, + ); + + return workspaceIds.filter( + (workspaceId) => + workspaceIdsWithActiveSubscription.includes(workspaceId) || + workspaceIdsWithFreeAccessEnabled.includes(workspaceId), + ); + } +} diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-status/workspace-manager.module.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-status/workspace-manager.module.ts new file mode 100644 index 000000000000..ac39a9e0c322 --- /dev/null +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-status/workspace-manager.module.ts @@ -0,0 +1,21 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; + +import { BillingSubscription } from 'src/engine/core-modules/billing/entities/billing-subscription.entity'; +import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity'; +import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; +import { EnvironmentModule } from 'src/engine/integrations/environment/environment.module'; +import { WorkspaceStatusService } from 'src/engine/workspace-manager/workspace-status/services/workspace-status.service'; + +@Module({ + imports: [ + EnvironmentModule, + TypeOrmModule.forFeature( + [Workspace, BillingSubscription, FeatureFlagEntity], + 'core', + ), + ], + exports: [WorkspaceStatusService], + providers: [WorkspaceStatusService], +}) +export class WorkspaceStatusModule {} diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command.ts index 106a0d876045..46313f69571d 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command.ts @@ -1,18 +1,20 @@ import { Logger } from '@nestjs/common'; +import isEmpty from 'lodash.isempty'; import { Command, CommandRunner, Option } from 'nest-commander'; import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service'; -import { WorkspaceSyncMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.service'; import { WorkspaceHealthService } from 'src/engine/workspace-manager/workspace-health/workspace-health.service'; +import { WorkspaceStatusService } from 'src/engine/workspace-manager/workspace-status/services/workspace-status.service'; +import { WorkspaceSyncMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.service'; import { SyncWorkspaceLoggerService } from './services/sync-workspace-logger.service'; // TODO: implement dry-run interface RunWorkspaceMigrationsOptions { - workspaceId?: string; dryRun?: boolean; force?: boolean; + workspaceId?: string; } @Command({ @@ -27,6 +29,7 @@ export class SyncWorkspaceMetadataCommand extends CommandRunner { private readonly workspaceHealthService: WorkspaceHealthService, private readonly dataSourceService: DataSourceService, private readonly syncWorkspaceLoggerService: SyncWorkspaceLoggerService, + private readonly workspaceStatusService: WorkspaceStatusService, ) { super(); } @@ -36,7 +39,19 @@ export class SyncWorkspaceMetadataCommand extends CommandRunner { options: RunWorkspaceMigrationsOptions, ): Promise { // TODO: re-implement load index from workspaceService, this is breaking the logger - const workspaceIds = options.workspaceId ? [options.workspaceId] : []; + let workspaceIds = options.workspaceId ? [options.workspaceId] : []; + + if (isEmpty(workspaceIds)) { + const activeWorkspaceIds = + await this.workspaceStatusService.getActiveWorkspaceIds(); + + workspaceIds = activeWorkspaceIds; + this.logger.log( + `Attempting to sync ${activeWorkspaceIds.length} workspaces.`, + ); + } + + const errorsDuringSync: string[] = []; for (const workspaceId of workspaceIds) { try { @@ -57,7 +72,7 @@ export class SyncWorkspaceMetadataCommand extends CommandRunner { 'Please use `workspace:health` command to check issues and fix them before running this command.', ); - return; + continue; } this.logger.warn( @@ -75,34 +90,52 @@ export class SyncWorkspaceMetadataCommand extends CommandRunner { ); } - const dataSourceMetadata = - await this.dataSourceService.getLastDataSourceMetadataFromWorkspaceIdOrFail( - workspaceId, - ); + try { + const dataSourceMetadata = + await this.dataSourceService.getLastDataSourceMetadataFromWorkspaceIdOrFail( + workspaceId, + ); - const { storage, workspaceMigrations } = - await this.workspaceSyncMetadataService.synchronize( - { + const { storage, workspaceMigrations } = + await this.workspaceSyncMetadataService.synchronize( + { + workspaceId, + dataSourceId: dataSourceMetadata.id, + }, + { applyChanges: !options.dryRun }, + ); + + if (options.dryRun) { + await this.syncWorkspaceLoggerService.saveLogs( workspaceId, - dataSourceId: dataSourceMetadata.id, - }, - { applyChanges: !options.dryRun }, + storage, + workspaceMigrations, + ); + } + } catch (error) { + errorsDuringSync.push( + `Failed to synchronize workspace ${workspaceId}: ${error.message}`, ); - if (options.dryRun) { - await this.syncWorkspaceLoggerService.saveLogs( - workspaceId, - storage, - workspaceMigrations, - ); + continue; } } + + this.logger.log( + `Finished synchronizing all active workspaces (${ + workspaceIds.length + } workspaces). ${ + errorsDuringSync.length > 0 + ? 'Errors during sync:\n' + errorsDuringSync.join('.\n') + : '' + }`, + ); } @Option({ flags: '-w, --workspace-id [workspace_id]', description: 'workspace id', - required: true, + required: false, }) parseWorkspaceId(value: string): string { return value; diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module.ts index 8e30f0c418fb..1178966443ab 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/workspace-sync-metadata-commands.module.ts @@ -1,12 +1,15 @@ import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; +import { WorkspaceModule } from 'src/engine/core-modules/workspace/workspace.module'; import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module'; -import { WorkspaceSyncMetadataModule } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.module'; +import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module'; import { WorkspaceHealthModule } from 'src/engine/workspace-manager/workspace-health/workspace-health.module'; -import { WorkspaceModule } from 'src/engine/core-modules/workspace/workspace.module'; +import { WorkspaceStatusModule } from 'src/engine/workspace-manager/workspace-status/workspace-manager.module'; import { AddStandardIdCommand } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/add-standard-id.command'; import { ConvertRecordPositionsToIntegers } from 'src/engine/workspace-manager/workspace-sync-metadata/commands/convert-record-positions-to-integers.command'; -import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module'; +import { WorkspaceSyncMetadataModule } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.module'; import { SyncWorkspaceMetadataCommand } from './sync-workspace-metadata.command'; @@ -19,6 +22,8 @@ import { SyncWorkspaceLoggerService } from './services/sync-workspace-logger.ser WorkspaceModule, DataSourceModule, WorkspaceDataSourceModule, + TypeOrmModule.forFeature([Workspace], 'core'), + WorkspaceStatusModule, ], providers: [ SyncWorkspaceMetadataCommand, diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.module.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.module.ts index 951d9e74a0b0..e6f2d15a1858 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.module.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.module.ts @@ -5,18 +5,18 @@ import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature- import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity'; import { RelationMetadataEntity } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity'; +import { WorkspaceCacheVersionModule } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.module'; import { WorkspaceMigrationEntity } from 'src/engine/metadata-modules/workspace-migration/workspace-migration.entity'; +import { WorkspaceMigrationBuilderModule } from 'src/engine/workspace-manager/workspace-migration-builder/workspace-migration-builder.module'; import { WorkspaceMigrationRunnerModule } from 'src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.module'; -import { WorkspaceSyncMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.service'; -import { workspaceSyncMetadataFactories } from 'src/engine/workspace-manager/workspace-sync-metadata/factories'; import { workspaceSyncMetadataComparators } from 'src/engine/workspace-manager/workspace-sync-metadata/comparators'; +import { workspaceSyncMetadataFactories } from 'src/engine/workspace-manager/workspace-sync-metadata/factories'; import { WorkspaceMetadataUpdaterService } from 'src/engine/workspace-manager/workspace-sync-metadata/services/workspace-metadata-updater.service'; -import { WorkspaceSyncObjectMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-object-metadata.service'; -import { WorkspaceSyncRelationMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-relation-metadata.service'; import { WorkspaceSyncFieldMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-field-metadata.service'; -import { WorkspaceMigrationBuilderModule } from 'src/engine/workspace-manager/workspace-migration-builder/workspace-migration-builder.module'; -import { WorkspaceCacheVersionModule } from 'src/engine/metadata-modules/workspace-cache-version/workspace-cache-version.module'; import { WorkspaceSyncIndexMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-index-metadata.service'; +import { WorkspaceSyncObjectMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-object-metadata.service'; +import { WorkspaceSyncRelationMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-relation-metadata.service'; +import { WorkspaceSyncMetadataService } from 'src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.service'; @Module({ imports: [