divide domain to ecosystem / engine
This commit is contained in:
parent
0a4c4bdf5a
commit
a54694c5a9
|
@ -6,11 +6,11 @@ import { GrpcMethod, RpcException } from '@nestjs/microservices';
|
|||
import { RpcValidationPipe } from 'src/modules/utils/pipes/rpc.validation-pipe';
|
||||
import { MatchRequest } from '../../domain/dtos/match.request';
|
||||
import { ICollection } from 'src/modules/database/src/interfaces/collection.interface';
|
||||
import { Match } from '../../domain/entities/match';
|
||||
import { MatchQuery } from '../../queries/match.query';
|
||||
import { MatchPresenter } from '../secondaries/match.presenter';
|
||||
import { DefaultParamsProvider } from '../secondaries/default-params.provider';
|
||||
import { GeorouterCreator } from '../secondaries/georouter-creator';
|
||||
import { Match } from '../../domain/entities/ecosystem/match';
|
||||
|
||||
@UsePipes(
|
||||
new RpcValidationPipe({
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { MatcherRepository } from '../../../database/src/domain/matcher-repository';
|
||||
import { Ad } from '../../domain/entities/ad';
|
||||
import { Ad } from '../../domain/entities/ecosystem/ad';
|
||||
|
||||
@Injectable()
|
||||
export class AdRepository extends MatcherRepository<Ad> {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { HttpService } from '@nestjs/axios';
|
||||
import { NamedRoute } from '../../domain/entities/named-route';
|
||||
import { IGeorouter } from '../../domain/interfaces/georouter.interface';
|
||||
import { GeorouterSettings } from '../../domain/types/georouter-settings.type';
|
||||
import { Path } from '../../domain/types/path.type';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { catchError, lastValueFrom, map } from 'rxjs';
|
||||
import { AxiosError, AxiosResponse } from 'axios';
|
||||
import { Route } from '../../domain/entities/route';
|
||||
import { SpacetimePoint } from '../../domain/entities/spacetime-point';
|
||||
import { IGeodesic } from '../../domain/interfaces/geodesic.interface';
|
||||
import { NamedRoute } from '../../domain/entities/ecosystem/named-route';
|
||||
import { Route } from '../../domain/entities/ecosystem/route';
|
||||
import { SpacetimePoint } from '../../domain/entities/ecosystem/spacetime-point';
|
||||
|
||||
@Injectable()
|
||||
export class GraphhopperGeorouter implements IGeorouter {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Role } from '../types/role.enum';
|
||||
import { Step } from '../types/step.enum';
|
||||
import { Role } from '../../types/role.enum';
|
||||
import { Step } from '../../types/step.enum';
|
||||
import { Person } from './person';
|
||||
|
||||
export class Actor {
|
|
@ -1,9 +1,9 @@
|
|||
import { IRequestAlgorithmSettings } from '../interfaces/algorithm-settings-request.interface';
|
||||
import { DefaultAlgorithmSettings } from '../types/default-algorithm-settings.type';
|
||||
import { Algorithm } from '../types/algorithm.enum';
|
||||
import { TimingFrequency } from '../types/timing';
|
||||
import { ICreateGeorouter } from '../interfaces/georouter-creator.interface';
|
||||
import { IGeorouter } from '../interfaces/georouter.interface';
|
||||
import { IRequestAlgorithmSettings } from '../../interfaces/algorithm-settings-request.interface';
|
||||
import { DefaultAlgorithmSettings } from '../../types/default-algorithm-settings.type';
|
||||
import { Algorithm } from '../../types/algorithm.enum';
|
||||
import { TimingFrequency } from '../../types/timing';
|
||||
import { ICreateGeorouter } from '../../interfaces/georouter-creator.interface';
|
||||
import { IGeorouter } from '../../interfaces/georouter.interface';
|
||||
|
||||
export class AlgorithmSettings {
|
||||
_algorithmSettingsRequest: IRequestAlgorithmSettings;
|
|
@ -1,16 +1,16 @@
|
|||
import { MatcherException } from '../../exceptions/matcher.exception';
|
||||
import { IRequestGeography } from '../interfaces/geography-request.interface';
|
||||
import { PointType } from '../types/geography.enum';
|
||||
import { Point } from '../types/point.type';
|
||||
import { MatcherException } from '../../../exceptions/matcher.exception';
|
||||
import { IRequestGeography } from '../../interfaces/geography-request.interface';
|
||||
import { PointType } from '../../types/geography.enum';
|
||||
import { Point } from '../../types/point.type';
|
||||
import { find } from 'geo-tz';
|
||||
import { Route } from './route';
|
||||
import { Role } from '../types/role.enum';
|
||||
import { IGeorouter } from '../interfaces/georouter.interface';
|
||||
import { Role } from '../../types/role.enum';
|
||||
import { IGeorouter } from '../../interfaces/georouter.interface';
|
||||
import { Waypoint } from './waypoint';
|
||||
import { Actor } from './actor';
|
||||
import { Person } from './person';
|
||||
import { Step } from '../types/step.enum';
|
||||
import { Path } from '../types/path.type';
|
||||
import { Step } from '../../types/step.enum';
|
||||
import { Path } from '../../types/path.type';
|
||||
|
||||
export class Geography {
|
||||
_geographyRequest: IRequestGeography;
|
|
@ -1,4 +1,4 @@
|
|||
import { IRequestPerson } from '../interfaces/person-request.interface';
|
||||
import { IRequestPerson } from '../../interfaces/person-request.interface';
|
||||
|
||||
export class Person {
|
||||
_personRequest: IRequestPerson;
|
|
@ -1,4 +1,4 @@
|
|||
import { IRequestRequirement } from '../interfaces/requirement-request.interface';
|
||||
import { IRequestRequirement } from '../../interfaces/requirement-request.interface';
|
||||
|
||||
export class Requirement {
|
||||
_requirementRequest: IRequestRequirement;
|
|
@ -1,5 +1,5 @@
|
|||
import { IGeodesic } from '../interfaces/geodesic.interface';
|
||||
import { Point } from '../types/point.type';
|
||||
import { IGeodesic } from '../../interfaces/geodesic.interface';
|
||||
import { Point } from '../../types/point.type';
|
||||
import { SpacetimePoint } from './spacetime-point';
|
||||
import { Waypoint } from './waypoint';
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import { MatcherException } from '../../exceptions/matcher.exception';
|
||||
import { MarginDurations } from '../types/margin-durations.type';
|
||||
import { IRequestTime } from '../interfaces/time-request.interface';
|
||||
import { TimingDays, TimingFrequency, Days } from '../types/timing';
|
||||
import { Schedule } from '../types/schedule.type';
|
||||
import { MatcherException } from '../../../exceptions/matcher.exception';
|
||||
import { MarginDurations } from '../../types/margin-durations.type';
|
||||
import { IRequestTime } from '../../interfaces/time-request.interface';
|
||||
import { TimingDays, TimingFrequency, Days } from '../../types/timing';
|
||||
import { Schedule } from '../../types/schedule.type';
|
||||
|
||||
export class Time {
|
||||
_timeRequest: IRequestTime;
|
|
@ -1,4 +1,4 @@
|
|||
import { Point } from '../types/point.type';
|
||||
import { Point } from '../../types/point.type';
|
||||
import { Actor } from './actor';
|
||||
|
||||
export class Waypoint {
|
|
@ -0,0 +1,5 @@
|
|||
import { Person } from '../ecosystem/person';
|
||||
|
||||
export class Candidate {
|
||||
person: Person;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import { MatchQuery } from 'src/modules/matcher/queries/match.query';
|
||||
import { Processor } from '../processor.abstract';
|
||||
import { Candidate } from '../candidate';
|
||||
|
||||
export abstract class AlgorithmFactory {
|
||||
_matchQuery: MatchQuery;
|
||||
_candidates: Array<Candidate>;
|
||||
|
||||
constructor(matchQuery: MatchQuery) {
|
||||
this._matchQuery = matchQuery;
|
||||
this._candidates = [];
|
||||
}
|
||||
|
||||
abstract createProcessors(): Array<Processor>;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import { AlgorithmFactory } from './algorithm-factory.abstract';
|
||||
import { Processor } from '../processor.abstract';
|
||||
import { ClassicWaypointsCompleter } from '../processor/completer/classic-waypoint.completer.processor';
|
||||
|
||||
export class ClassicAlgorithmFactory extends AlgorithmFactory {
|
||||
createProcessors(): Array<Processor> {
|
||||
return [new ClassicWaypointsCompleter(this._matchQuery)];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
import { MatchQuery } from '../../../queries/match.query';
|
||||
import { Algorithm } from '../../types/algorithm.enum';
|
||||
import { Match } from '../ecosystem/match';
|
||||
import { Candidate } from './candidate';
|
||||
import { AlgorithmFactory } from './factory/algorithm-factory.abstract';
|
||||
import { ClassicAlgorithmFactory } from './factory/classic';
|
||||
|
||||
export class Matcher {
|
||||
match = (matchQuery: MatchQuery): Array<Match> => {
|
||||
let algorithm: AlgorithmFactory;
|
||||
switch (matchQuery.algorithmSettings.algorithm) {
|
||||
case Algorithm.CLASSIC:
|
||||
algorithm = new ClassicAlgorithmFactory(matchQuery);
|
||||
}
|
||||
let candidates: Array<Candidate> = [];
|
||||
for (const processor of algorithm.createProcessors()) {
|
||||
candidates = processor.execute(candidates);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
import { MatchQuery } from 'src/modules/matcher/queries/match.query';
|
||||
import { Candidate } from './candidate';
|
||||
|
||||
export abstract class Processor {
|
||||
_matchQuery: MatchQuery;
|
||||
|
||||
constructor(matchQuery: MatchQuery) {
|
||||
this._matchQuery = matchQuery;
|
||||
}
|
||||
|
||||
abstract execute(candidates: Array<Candidate>): Array<Candidate>;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
import { Candidate } from '../../candidate';
|
||||
import { Completer } from './completer.abstract';
|
||||
|
||||
export class ClassicWaypointsCompleter extends Completer {
|
||||
complete(candidates: Array<Candidate>): Array<Candidate> {
|
||||
return [];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import { Candidate } from '../../candidate';
|
||||
import { Processor } from '../../processor.abstract';
|
||||
|
||||
export abstract class Completer extends Processor {
|
||||
execute = (candidates: Array<Candidate>): Array<Candidate> =>
|
||||
this.complete(candidates);
|
||||
|
||||
abstract complete(candidates: Array<Candidate>): Array<Candidate>;
|
||||
}
|
|
@ -4,8 +4,8 @@ import { QueryHandler } from '@nestjs/cqrs';
|
|||
import { Messager } from '../../adapters/secondaries/messager';
|
||||
import { MatchQuery } from '../../queries/match.query';
|
||||
import { AdRepository } from '../../adapters/secondaries/ad.repository';
|
||||
import { Match } from '../entities/match';
|
||||
import { ICollection } from 'src/modules/database/src/interfaces/collection.interface';
|
||||
import { Match } from '../entities/ecosystem/match';
|
||||
import { ICollection } from '../../../database/src/interfaces/collection.interface';
|
||||
|
||||
@QueryHandler(MatchQuery)
|
||||
export class MatchUseCase {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { MatchRequest } from '../domain/dtos/match.request';
|
||||
import { Geography } from '../domain/entities/geography';
|
||||
import { Person } from '../domain/entities/person';
|
||||
import { Requirement } from '../domain/entities/requirement';
|
||||
import { Geography } from '../domain/entities/ecosystem/geography';
|
||||
import { Person } from '../domain/entities/ecosystem/person';
|
||||
import { Requirement } from '../domain/entities/ecosystem/requirement';
|
||||
import { Role } from '../domain/types/role.enum';
|
||||
import { AlgorithmSettings } from '../domain/entities/algorithm-settings';
|
||||
import { Time } from '../domain/entities/time';
|
||||
import { AlgorithmSettings } from '../domain/entities/ecosystem/algorithm-settings';
|
||||
import { Time } from '../domain/entities/ecosystem/time';
|
||||
import { IDefaultParams } from '../domain/types/default-params.type';
|
||||
import { IGeorouter } from '../domain/interfaces/georouter.interface';
|
||||
import { ICreateGeorouter } from '../domain/interfaces/georouter-creator.interface';
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import { Person } from '../../../domain/entities/person';
|
||||
import { Geography, RouteKey } from '../../../domain/entities/geography';
|
||||
import { Role } from '../../../domain/types/role.enum';
|
||||
import { NamedRoute } from '../../../domain/entities/named-route';
|
||||
import { Route } from '../../../domain/entities/route';
|
||||
import { IGeodesic } from '../../../domain/interfaces/geodesic.interface';
|
||||
import { PointType } from '../../../domain/types/geography.enum';
|
||||
import { Person } from '../../../../domain/entities/ecosystem/person';
|
||||
import {
|
||||
Geography,
|
||||
RouteKey,
|
||||
} from '../../../../domain/entities/ecosystem/geography';
|
||||
import { Role } from '../../../../domain/types/role.enum';
|
||||
import { NamedRoute } from '../../../../domain/entities/ecosystem/named-route';
|
||||
import { Route } from '../../../../domain/entities/ecosystem/route';
|
||||
import { IGeodesic } from '../../../../domain/interfaces/geodesic.interface';
|
||||
import { PointType } from '../../../../domain/types/geography.enum';
|
||||
|
||||
const person: Person = new Person(
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
import { Person } from '../../../domain/entities/person';
|
||||
import { Person } from '../../../../domain/entities/ecosystem/person';
|
||||
|
||||
const DEFAULT_IDENTIFIER = 0;
|
||||
const MARGIN_DURATION = 900;
|
|
@ -1,6 +1,6 @@
|
|||
import { Route } from '../../../domain/entities/route';
|
||||
import { SpacetimePoint } from '../../../domain/entities/spacetime-point';
|
||||
import { Waypoint } from '../../../domain/entities/waypoint';
|
||||
import { Route } from '../../../../domain/entities/ecosystem/route';
|
||||
import { SpacetimePoint } from '../../../../domain/entities/ecosystem/spacetime-point';
|
||||
import { Waypoint } from '../../../../domain/entities/ecosystem/waypoint';
|
||||
|
||||
const mockGeodesic = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@ -1,4 +1,4 @@
|
|||
import { Time } from '../../../domain/entities/time';
|
||||
import { Time } from '../../../../domain/entities/ecosystem/time';
|
||||
|
||||
const MARGIN_DURATION = 900;
|
||||
const VALIDITY_DURATION = 365;
|
Loading…
Reference in New Issue