Skip to content

Commit

Permalink
Move term view things
Browse files Browse the repository at this point in the history
  • Loading branch information
mapeveri committed Jan 29, 2024
1 parent eccf340 commit 8dcc724
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/languages/_dependencyInjection/repositories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TypeOrmAuthSessionRepository from '../infrastructure/persistence/typeOrm/
import { COUNTRY_REPOSITORY } from '@src/languages/domain/country/countryRepository';
import TypeOrmCountryRepository from '../infrastructure/persistence/typeOrm/repositories/typeOrmCountryRepository';
import TypeOrmUserRepository from '../infrastructure/persistence/typeOrm/repositories/typeOrmUserRepository';
import { TERM_REPOSITORY as READ_LAYER_TERM_REPOSITORY } from '@src/languages/application/term/projection/termViewRepository';
import { TERM_VIEW_READ_LAYER as READ_LAYER_TERM_REPOSITORY } from '@src/languages/application/term/query/termViewReadLayer';
import MongoTermViewRepository from '../infrastructure/persistence/mongo/repositories/mongoTermViewRepository';
import { USER_REPOSITORY } from '@src/languages/domain/user/userRepository';
import { TERM_REPOSITORY } from '@src/languages/domain/term/termRepository';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { COMMAND_BUS, CommandBus } from '@src/shared/domain/bus/commandBus/comma
import { Inject } from '@src/shared/domain/injector/inject.decorator';
import { EventsHandler, IEventHandler } from '@src/shared/domain/bus/eventBus/eventsHandler';
import TermType from '@src/languages/domain/term/termType';
import TermViewCreatedFailedEvent from '@src/languages/application/term/projection/termViewCreatedFailedEvent';
import TermViewCreatedFailedEvent from '@src/languages/application/term/query/termViewCreatedFailedEvent';
import DeleteExpressionCommand from '@src/languages/application/term/command/delete/deleteExpressionCommand';

@EventsHandler(TermViewCreatedFailedEvent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { COMMAND_BUS, CommandBus } from '@src/shared/domain/bus/commandBus/comma
import { Inject } from '@src/shared/domain/injector/inject.decorator';
import { EventsHandler, IEventHandler } from '@src/shared/domain/bus/eventBus/eventsHandler';
import TermType from '@src/languages/domain/term/termType';
import TermViewCreatedFailedEvent from '@src/languages/application/term/projection/termViewCreatedFailedEvent';
import TermViewCreatedFailedEvent from '@src/languages/application/term/query/termViewCreatedFailedEvent';
import DeleteWordCommand from '../../command/delete/deleteWordCommand';

@EventsHandler(TermViewCreatedFailedEvent)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import TermViewRepository, { TERM_REPOSITORY } from '@src/languages/application/term/projection/termViewRepository';
import TermViewReadLayer, { TERM_VIEW_READ_LAYER } from '@src/languages/application/term/query/termViewReadLayer';
import CreateTermProjection from './createTermProjection';
import TermView from '@src/languages/application/term/projection/termView';
import TermView from '@src/languages/application/term/query/termView';
import { Inject } from '@src/shared/domain/injector/inject.decorator';
import TermType from '@src/languages/domain/term/termType';
import { EVENT_BUS, EventBus } from '@src/shared/domain/bus/eventBus/eventBus';
import TermViewCreatedFailedEvent from '@src/languages/application/term/projection/termViewCreatedFailedEvent';
import TermViewCreatedFailedEvent from '@src/languages/application/term/query/termViewCreatedFailedEvent';
import { IProjectionHandler, ProjectionHandler } from '@src/shared/domain/bus/projectionBus/projectionHandler';

@ProjectionHandler(CreateTermProjection)
export default class CreateTermProjectionHandler implements IProjectionHandler<CreateTermProjection> {
constructor(
@Inject(TERM_REPOSITORY) private readonly termRepository: TermViewRepository,
@Inject(TERM_VIEW_READ_LAYER) private readonly termRepository: TermViewReadLayer,
@Inject(EVENT_BUS) private readonly eventBus: EventBus,
) {}

Expand Down
12 changes: 0 additions & 12 deletions src/languages/application/term/projection/termViewRepository.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import QueryResponse from '@src/shared/domain/bus/queryBus/queryResponse';
import SearchTermQuery from './searchTermQuery';
import TermViewRepository, { TERM_REPOSITORY } from '@src/languages/application/term/projection/termViewRepository';
import TermViewReadLayer, { TERM_VIEW_READ_LAYER } from '@src/languages/application/term/query/termViewReadLayer';
import SearchTermResponse from './searchTermResponse';
import { Inject } from '@src/shared/domain/injector/inject.decorator';
import { IQueryHandler, QueryHandler } from '@src/shared/domain/bus/queryBus/queryHandler';
import TermViewCriteria, { TermCriteriaParams } from '@src/languages/application/term/projection/termViewCriteria';
import TermViewCriteria, { TermCriteriaParams } from '@src/languages/application/term/query/termViewCriteria';

@QueryHandler(SearchTermQuery)
export default class SearchTermQueryHandler implements IQueryHandler<SearchTermQuery> {
constructor(@Inject(TERM_REPOSITORY) private readonly termRepository: TermViewRepository) {}
constructor(@Inject(TERM_VIEW_READ_LAYER) private readonly termRepository: TermViewReadLayer) {}

async execute(query: SearchTermQuery): Promise<QueryResponse> {
const criteria: TermCriteriaParams = { term: query.term, size: query.size, page: query.page };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TermView from '@src/languages/application/term/projection/termView';
import TermView from '@src/languages/application/term/query/termView';
import QueryResponse from '@src/shared/domain/bus/queryBus/queryResponse';

export default class SearchTermResponse extends QueryResponse {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TermView from '@src/languages/application/term/projection/termView';
import TermView from '@src/languages/application/term/query/termView';
import QueryResponse from '@src/shared/domain/bus/queryBus/queryResponse';

export default class FindSuggestionsTermQueryResponse extends QueryResponse {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TermView from '@src/languages/application/term/projection/termView';
import TermView from '@src/languages/application/term/query/termView';
import UserId from '@src/languages/domain/user/valueObjects/userId';

interface FindSuggestionsTermReadLayer {
Expand Down
12 changes: 12 additions & 0 deletions src/languages/application/term/query/termViewReadLayer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import TermView from './termView';
import TermViewCriteria from '@src/languages/application/term/query/termViewCriteria';

interface TermViewReadLayer {
search(criteria: TermViewCriteria): Promise<TermView[]>;

save(term: TermView): Promise<void>;
}

export default TermViewReadLayer;

export const TERM_VIEW_READ_LAYER = Symbol('TermViewReadLayer');
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import FindSuggestionsTermReadLayer from '@src/languages/application/term/query/suggestion/findSuggestionsTermReadLayer';
import UserId from '@src/languages/domain/user/valueObjects/userId';
import TermView from '@src/languages/application/term/projection/termView';
import TermView from '@src/languages/application/term/query/termView';
import UserRepository, { USER_REPOSITORY } from '@src/languages/domain/user/userRepository';
import { Inject } from '@src/shared/domain/injector/inject.decorator';
import TermViewRepository, { TERM_REPOSITORY } from '@src/languages/application/term/projection/termViewRepository';
import TermViewReadLayer, { TERM_VIEW_READ_LAYER } from '@src/languages/application/term/query/termViewReadLayer';
import UserFinder from '@src/languages/domain/user/services/userFinder';
import TermViewCriteria from '@src/languages/application/term/projection/termViewCriteria';
import TermViewCriteria from '@src/languages/application/term/query/termViewCriteria';

export default class MongoFindSuggestionsTermReadLayer implements FindSuggestionsTermReadLayer {
private readonly userFinder: UserFinder;

constructor(
@Inject(TERM_REPOSITORY) private readonly termRepository: TermViewRepository,
@Inject(TERM_VIEW_READ_LAYER) private readonly termRepository: TermViewReadLayer,
@Inject(USER_REPOSITORY) userRepository: UserRepository,
) {
this.userFinder = new UserFinder(userRepository);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Injectable } from '@nestjs/common';
import TermView from '@src/languages/application/term/projection/termView';
import TermViewRepository from '@src/languages/application/term/projection/termViewRepository';
import TermView from '@src/languages/application/term/query/termView';
import TermViewReadLayer from '@src/languages/application/term/query/termViewReadLayer';
import MongoRepository from '@src/shared/infrastructure/persistence/mongo/mongoRepository';
import { Document } from 'mongodb';
import TermViewCriteria from '@src/languages/application/term/projection/termViewCriteria';
import TermViewCriteria from '@src/languages/application/term/query/termViewCriteria';
import { SortDirection } from 'typeorm';

@Injectable()
export default class MongoTermViewRepository extends MongoRepository<TermView> implements TermViewRepository {
export default class MongoTermViewRepository extends MongoRepository<TermView> implements TermViewReadLayer {
constructor() {
super('terms');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it } from '@jest/globals';
import { SearchTermQueryMother } from './searchTermQueryMother';
import SearchTermQueryHandler from '@src/languages/application/term/query/search/searchTermQueryHandler';
import { TermViewMother } from '@test/languages/domain/term/termViewMother';
import TermView from '@src/languages/application/term/projection/termView';
import TermView from '@src/languages/application/term/query/termView';
import { TermViewRepositoryMock } from '@test/languages/domain/term/termViewRepositoryMock';

describe('SearchTermQueryHandler', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jest } from '@jest/globals';
import TermView from '@src/languages/application/term/projection/termView';
import TermView from '@src/languages/application/term/query/termView';
import UserId from '@src/languages/domain/user/valueObjects/userId';
import FindSuggestionsTermReadLayer from '@src/languages/application/term/query/suggestion/findSuggestionsTermReadLayer';

Expand Down
2 changes: 1 addition & 1 deletion test/languages/domain/term/termViewMother.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TermView from '@src/languages/application/term/projection/termView';
import TermView from '@src/languages/application/term/query/termView';
import faker from 'faker';
import TermTypeMother from './termTypeMother';

Expand Down
8 changes: 4 additions & 4 deletions test/languages/domain/term/termViewRepositoryMock.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { jest } from '@jest/globals';
import TermView from '@src/languages/application/term/projection/termView';
import TermViewRepository from '@src/languages/application/term/projection/termViewRepository';
import TermViewCriteria from '@src/languages/application/term/projection/termViewCriteria';
import TermView from '@src/languages/application/term/query/termView';
import TermViewReadLayer from '@src/languages/application/term/query/termViewReadLayer';
import TermViewCriteria from '@src/languages/application/term/query/termViewCriteria';

export class TermViewRepositoryMock implements TermViewRepository {
export class TermViewRepositoryMock implements TermViewReadLayer {
private searchMock: jest.Mock;
private saveMock: jest.Mock;
private terms: TermView[];
Expand Down

0 comments on commit 8dcc724

Please sign in to comment.