fix: message queue injection issue (#6126)
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
import { Injectable, Type } from '@nestjs/common';
|
||||
import { Injectable, Optional, Type } from '@nestjs/common';
|
||||
|
||||
import { ObjectLiteral } from 'typeorm';
|
||||
|
||||
import { EntitySchemaFactory } from 'src/engine/twenty-orm/factories/entity-schema.factory';
|
||||
import { InjectWorkspaceDatasource } from 'src/engine/twenty-orm/decorators/inject-workspace-datasource.decorator';
|
||||
import { WorkspaceDataSource } from 'src/engine/twenty-orm/datasource/workspace.datasource';
|
||||
import { WorkspaceRepository } from 'src/engine/twenty-orm/repository/workspace.repository';
|
||||
import { WorkspaceDatasourceFactory } from 'src/engine/twenty-orm/factories/workspace-datasource.factory';
|
||||
@ -12,8 +11,8 @@ import { ObjectLiteralStorage } from 'src/engine/twenty-orm/storage/object-liter
|
||||
@Injectable()
|
||||
export class TwentyORMManager {
|
||||
constructor(
|
||||
@InjectWorkspaceDatasource()
|
||||
private readonly workspaceDataSource: WorkspaceDataSource,
|
||||
@Optional()
|
||||
private readonly workspaceDataSource: WorkspaceDataSource | null,
|
||||
private readonly entitySchemaFactory: EntitySchemaFactory,
|
||||
private readonly workspaceDataSourceFactory: WorkspaceDatasourceFactory,
|
||||
) {}
|
||||
@ -23,6 +22,10 @@ export class TwentyORMManager {
|
||||
): WorkspaceRepository<T> {
|
||||
const entitySchema = this.entitySchemaFactory.create(entityClass);
|
||||
|
||||
if (!this.workspaceDataSource) {
|
||||
throw new Error('Workspace data source not found');
|
||||
}
|
||||
|
||||
return this.workspaceDataSource.getRepository<T>(entitySchema);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user