From 96577e119fe1b560c483b5853605e93a0e4d26eb Mon Sep 17 00:00:00 2001 From: sbriat Date: Wed, 26 Apr 2023 14:14:46 +0200 Subject: [PATCH] refactor --- .../primaries/ad-messager.controller.ts | 1 + .../ad/domain/dtos/create-ad.request.ts | 8 ++-- src/modules/ad/domain/entities/ad.ts | 12 ++--- .../configuration-messager.controller.ts | 2 +- .../secondaries/prisma-repository.abstract.ts | 6 +-- .../secondaries/geo-timezone-finder.ts | 2 +- .../interfaces/timezone-finder.interface.ts | 2 +- .../domain/types/coordinates.type.ts | 21 +++++++- .../secondaries/graphhopper-georouter.ts | 48 +++++++++---------- .../adapters/secondaries/timezone-finder.ts | 2 +- .../matcher/domain/dtos/match.request.ts | 4 +- .../domain/entities/ecosystem/geography.ts | 17 +++---- .../domain/entities/ecosystem/person.ts | 4 +- .../domain/entities/ecosystem/route.ts | 14 +++--- .../domain/entities/ecosystem/waypoint.ts | 2 +- .../factory/algorithm-factory.abstract.ts | 4 +- .../domain/entities/engine/factory/classic.ts | 2 +- .../matcher/domain/entities/engine/matcher.ts | 4 +- .../classic-waypoint.completer.processor.ts | 2 +- .../processor/completer/completer.abstract.ts | 5 +- .../completer/journey.completer.processor.ts | 2 +- .../completer/route.completer.processor.ts | 2 +- .../processor/filter/filter.abstract.ts | 5 +- .../geofilter/classic.filter.processor.ts | 2 +- .../timefilter/classic.filter.processor.ts | 2 +- .../engine/processor/processor.abstract.ts | 2 +- .../engine/selector/classic.selector.ts | 2 +- .../engine/selector/selector.abstract.ts | 2 +- .../interfaces/geography-request.interface.ts | 2 +- .../domain/interfaces/georouter.interface.ts | 5 +- src/modules/matcher/domain/types/path.type.ts | 2 +- src/modules/matcher/domain/types/waypoint.ts | 2 +- .../matcher/domain/usecases/match.usecase.ts | 2 +- src/modules/matcher/queries/match.query.ts | 4 +- 34 files changed, 100 insertions(+), 98 deletions(-) diff --git a/src/modules/ad/adapters/primaries/ad-messager.controller.ts b/src/modules/ad/adapters/primaries/ad-messager.controller.ts index 24bef87..7dc19ce 100644 --- a/src/modules/ad/adapters/primaries/ad-messager.controller.ts +++ b/src/modules/ad/adapters/primaries/ad-messager.controller.ts @@ -22,6 +22,7 @@ export class AdMessagerController { try { // parse message to conform to CreateAdRequest (not a real instance yet) const parsedMessage: CreateAdRequest = JSON.parse(message); + console.log(parsedMessage); // create a real instance of CreateAdRequest from parsed message const createAdRequest: CreateAdRequest = this.mapper.map( parsedMessage, diff --git a/src/modules/ad/domain/dtos/create-ad.request.ts b/src/modules/ad/domain/dtos/create-ad.request.ts index dd4ea53..f05c67f 100644 --- a/src/modules/ad/domain/dtos/create-ad.request.ts +++ b/src/modules/ad/domain/dtos/create-ad.request.ts @@ -8,11 +8,10 @@ import { IsNumber, IsOptional, IsString, - ValidateNested, } from 'class-validator'; import { PointType } from '../../../geography/domain/types/point-type.enum'; import { Frequency } from '../types/frequency.enum'; -import { Point } from '../../../geography/domain/types/point.type'; +import { Coordinates } from '../../../geography/domain/types/coordinates.type'; export class CreateAdRequest { @IsString() @@ -114,9 +113,8 @@ export class CreateAdRequest { @IsArray() @ArrayMinSize(2) - @ValidateNested({ each: true }) - @AutoMap() - waypoints: Array; + @AutoMap(() => [Coordinates]) + waypoints: Coordinates[]; @IsNumber() @AutoMap() diff --git a/src/modules/ad/domain/entities/ad.ts b/src/modules/ad/domain/entities/ad.ts index 817738e..98771fb 100644 --- a/src/modules/ad/domain/entities/ad.ts +++ b/src/modules/ad/domain/entities/ad.ts @@ -1,7 +1,6 @@ import { AutoMap } from '@automapper/classes'; -import { ArrayMinSize, IsArray, IsEnum, ValidateNested } from 'class-validator'; import { PointType } from '../../../geography/domain/types/point-type.enum'; -import { Point } from '../../../geography/domain/types/point.type'; +import { Coordinates } from '../../../geography/domain/types/coordinates.type'; export class Ad { @AutoMap() @@ -76,19 +75,14 @@ export class Ad { @AutoMap() passengerDistance: number; - @IsEnum(PointType) @AutoMap() originType: PointType; - @IsEnum(PointType) @AutoMap() destinationType: PointType; - @IsArray() - @ArrayMinSize(2) - @ValidateNested({ each: true }) - @AutoMap() - waypoints: Array; + @AutoMap(() => [Coordinates]) + waypoints: Coordinates[]; @AutoMap() direction: string; diff --git a/src/modules/configuration/adapters/primaries/configuration-messager.controller.ts b/src/modules/configuration/adapters/primaries/configuration-messager.controller.ts index c9408ca..d41e817 100644 --- a/src/modules/configuration/adapters/primaries/configuration-messager.controller.ts +++ b/src/modules/configuration/adapters/primaries/configuration-messager.controller.ts @@ -57,7 +57,7 @@ export class ConfigurationMessagerController { name: 'propagateConfiguration', }) public async propagateConfigurationsHandler(message: string) { - const configurations: Array = JSON.parse(message); + const configurations: Configuration[] = JSON.parse(message); configurations.forEach(async (configuration) => { if ( configuration.domain == diff --git a/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts b/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts index e93f896..dee142c 100644 --- a/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts +++ b/src/modules/database/src/adapters/secondaries/prisma-repository.abstract.ts @@ -187,13 +187,13 @@ export abstract class PrismaRepository implements IRepository { } async findAllByQuery( - include: Array, - where: Array, + include: string[], + where: string[], ): Promise> { const query = `SELECT ${include.join(',')} FROM ${ this._model } WHERE ${where.join(' AND ')}`; - const data: Array = await this._prisma.$queryRawUnsafe(query); + const data: T[] = await this._prisma.$queryRawUnsafe(query); return Promise.resolve({ data, total: data.length, diff --git a/src/modules/geography/adapters/secondaries/geo-timezone-finder.ts b/src/modules/geography/adapters/secondaries/geo-timezone-finder.ts index 1ca02c2..bce0097 100644 --- a/src/modules/geography/adapters/secondaries/geo-timezone-finder.ts +++ b/src/modules/geography/adapters/secondaries/geo-timezone-finder.ts @@ -4,5 +4,5 @@ import { find } from 'geo-tz'; @Injectable() export class GeoTimezoneFinder implements IFindTimezone { - timezones = (lon: number, lat: number): Array => find(lat, lon); + timezones = (lon: number, lat: number): string[] => find(lat, lon); } diff --git a/src/modules/geography/domain/interfaces/timezone-finder.interface.ts b/src/modules/geography/domain/interfaces/timezone-finder.interface.ts index 6f22169..61016f7 100644 --- a/src/modules/geography/domain/interfaces/timezone-finder.interface.ts +++ b/src/modules/geography/domain/interfaces/timezone-finder.interface.ts @@ -1,3 +1,3 @@ export interface IFindTimezone { - timezones(lon: number, lat: number): Array; + timezones(lon: number, lat: number): string[]; } diff --git a/src/modules/geography/domain/types/coordinates.type.ts b/src/modules/geography/domain/types/coordinates.type.ts index 8e149ed..80872c6 100644 --- a/src/modules/geography/domain/types/coordinates.type.ts +++ b/src/modules/geography/domain/types/coordinates.type.ts @@ -1,4 +1,21 @@ -export type Coordinates = { +import { AutoMap } from '@automapper/classes'; +import { IsNumber, Max, Min } from 'class-validator'; + +export class Coordinates { + constructor(lon: number, lat: number) { + this.lon = lon; + this.lat = lat; + } + + @IsNumber() + @Min(-180) + @Max(180) + @AutoMap() lon: number; + + @IsNumber() + @Min(-90) + @Max(90) + @AutoMap() lat: number; -}; +} diff --git a/src/modules/matcher/adapters/secondaries/graphhopper-georouter.ts b/src/modules/matcher/adapters/secondaries/graphhopper-georouter.ts index 2475a43..935eddb 100644 --- a/src/modules/matcher/adapters/secondaries/graphhopper-georouter.ts +++ b/src/modules/matcher/adapters/secondaries/graphhopper-georouter.ts @@ -17,11 +17,11 @@ import { @Injectable() export class GraphhopperGeorouter implements IGeorouter { private url: string; - private urlArgs: Array; + private urlArgs: string[]; private withTime: boolean; private withPoints: boolean; private withDistance: boolean; - private paths: Array; + private paths: Path[]; private httpService: HttpService; private geodesic: IGeodesic; @@ -32,9 +32,9 @@ export class GraphhopperGeorouter implements IGeorouter { } route = async ( - paths: Array, + paths: Path[], settings: GeorouterSettings, - ): Promise> => { + ): Promise => { this.setDefaultUrlArgs(); this.setWithTime(settings.withTime); this.setWithPoints(settings.withPoints); @@ -70,7 +70,7 @@ export class GraphhopperGeorouter implements IGeorouter { } }; - private getRoutes = async (): Promise> => { + private getRoutes = async (): Promise => { const routes = Promise.all( this.paths.map(async (path) => { const url: string = [ @@ -125,7 +125,7 @@ export class GraphhopperGeorouter implements IGeorouter { shortestPath.snapped_waypoints && shortestPath.snapped_waypoints.coordinates ) { - let instructions: Array = []; + let instructions: GraphhopperInstruction[] = []; if (shortestPath.instructions) instructions = shortestPath.instructions; route.setSpacetimePoints( @@ -143,11 +143,11 @@ export class GraphhopperGeorouter implements IGeorouter { }; private generateSpacetimePoints = ( - points: Array>, - snappedWaypoints: Array>, - durations: Array>, - instructions: Array, - ): Array => { + points: Array, + snappedWaypoints: Array, + durations: Array, + instructions: GraphhopperInstruction[], + ): SpacetimePoint[] => { const indices = this.getIndices(points, snappedWaypoints); const times = this.getTimes(durations, indices); const distances = this.getDistances(instructions, indices); @@ -162,9 +162,9 @@ export class GraphhopperGeorouter implements IGeorouter { }; private getIndices = ( - points: Array>, - snappedWaypoints: Array>, - ): Array => { + points: Array, + snappedWaypoints: Array, + ): number[] => { const indices = snappedWaypoints.map((waypoint) => points.findIndex( (point) => point[0] == waypoint[0] && point[1] == waypoint[1], @@ -178,7 +178,7 @@ export class GraphhopperGeorouter implements IGeorouter { { index: number; originIndex: number; - waypoint: Array; + waypoint: number[]; nearest: number; distance: number; } @@ -212,8 +212,8 @@ export class GraphhopperGeorouter implements IGeorouter { }; private getTimes = ( - durations: Array>, - indices: Array, + durations: Array, + indices: number[], ): Array<{ index: number; duration: number }> => { const times: Array<{ index: number; duration: number }> = []; let duration = 0; @@ -262,8 +262,8 @@ export class GraphhopperGeorouter implements IGeorouter { }; private getDistances = ( - instructions: Array, - indices: Array, + instructions: GraphhopperInstruction[], + indices: number[], ): Array<{ index: number; distance: number }> => { let distance = 0; const distances: Array<{ index: number; distance: number }> = [ @@ -296,26 +296,26 @@ type GraphhopperResponse = { weight: number; time: number; points_encoded: boolean; - bbox: Array; + bbox: number[]; points: GraphhopperCoordinates; snapped_waypoints: GraphhopperCoordinates; details: { - time: Array>; + time: Array; }; - instructions: Array; + instructions: GraphhopperInstruction[]; }, ]; }; type GraphhopperCoordinates = { - coordinates: Array>; + coordinates: Array; }; type GraphhopperInstruction = { distance: number; heading: number; sign: GraphhopperSign; - interval: Array; + interval: number[]; text: string; }; diff --git a/src/modules/matcher/adapters/secondaries/timezone-finder.ts b/src/modules/matcher/adapters/secondaries/timezone-finder.ts index 5ce3306..8459661 100644 --- a/src/modules/matcher/adapters/secondaries/timezone-finder.ts +++ b/src/modules/matcher/adapters/secondaries/timezone-finder.ts @@ -6,6 +6,6 @@ import { IFindTimezone } from '../../../geography/domain/interfaces/timezone-fin export class TimezoneFinder implements IFindTimezone { constructor(private readonly geoTimezoneFinder: GeoTimezoneFinder) {} - timezones = (lon: number, lat: number): Array => + timezones = (lon: number, lat: number): string[] => this.geoTimezoneFinder.timezones(lon, lat); } diff --git a/src/modules/matcher/domain/dtos/match.request.ts b/src/modules/matcher/domain/dtos/match.request.ts index 0ce4127..5ffea23 100644 --- a/src/modules/matcher/domain/dtos/match.request.ts +++ b/src/modules/matcher/domain/dtos/match.request.ts @@ -30,7 +30,7 @@ export class MatchRequest { @IsArray() @AutoMap() - waypoints: Array; + waypoints: Point[]; @IsOptional() @IsString() @@ -138,7 +138,7 @@ export class MatchRequest @IsOptional() @IsArray() - exclusions: Array; + exclusions: number[]; @IsOptional() @IsInt() diff --git a/src/modules/matcher/domain/entities/ecosystem/geography.ts b/src/modules/matcher/domain/entities/ecosystem/geography.ts index 59af204..68d1a39 100644 --- a/src/modules/matcher/domain/entities/ecosystem/geography.ts +++ b/src/modules/matcher/domain/entities/ecosystem/geography.ts @@ -19,10 +19,10 @@ import { Timezoner } from './timezoner'; export class Geography { private geographyRequest: IRequestGeography; private person: Person; - private points: Array; + private points: Point[]; originType: PointType; destinationType: PointType; - timezones: Array; + timezones: string[]; driverRoute: Route; passengerRoute: Route; timezoneFinder: IFindTimezone; @@ -48,12 +48,12 @@ export class Geography { }; createRoutes = async ( - roles: Array, + roles: Role[], georouter: IGeorouter, ): Promise => { - let driverWaypoints: Array = []; - let passengerWaypoints: Array = []; - const paths: Array = []; + let driverWaypoints: Waypoint[] = []; + let passengerWaypoints: Waypoint[] = []; + const paths: Path[] = []; if (roles.includes(Role.DRIVER) && roles.includes(Role.PASSENGER)) { if (this.points.length == 2) { // 2 points => same route for driver and passenger @@ -174,10 +174,7 @@ export class Geography { private isValidLatitude = (latitude: number): boolean => latitude >= -90 && latitude <= 90; - private createWaypoints = ( - points: Array, - role: Role, - ): Array => { + private createWaypoints = (points: Point[], role: Role): Waypoint[] => { return points.map((point, index) => { const waypoint = new Waypoint(point); if (index == 0) { diff --git a/src/modules/matcher/domain/entities/ecosystem/person.ts b/src/modules/matcher/domain/entities/ecosystem/person.ts index c6baa02..2f0906c 100644 --- a/src/modules/matcher/domain/entities/ecosystem/person.ts +++ b/src/modules/matcher/domain/entities/ecosystem/person.ts @@ -5,7 +5,7 @@ export class Person { private defaultIdentifier: number; private defaultMarginDuration: number; identifier: number; - marginDurations: Array; + marginDurations: number[]; constructor( personRequest: IRequestPerson, @@ -34,7 +34,7 @@ export class Person { this.identifier = identifier; }; - setMarginDurations = (marginDurations: Array): void => { + setMarginDurations = (marginDurations: number[]): void => { this.marginDurations = marginDurations; }; } diff --git a/src/modules/matcher/domain/entities/ecosystem/route.ts b/src/modules/matcher/domain/entities/ecosystem/route.ts index f9670e4..c42dba9 100644 --- a/src/modules/matcher/domain/entities/ecosystem/route.ts +++ b/src/modules/matcher/domain/entities/ecosystem/route.ts @@ -9,9 +9,9 @@ export class Route { fwdAzimuth: number; backAzimuth: number; distanceAzimuth: number; - waypoints: Array; - points: Array; - spacetimePoints: Array; + waypoints: Waypoint[]; + points: Point[]; + spacetimePoints: SpacetimePoint[]; private geodesic: IGeodesic; constructor(geodesic: IGeodesic) { @@ -26,21 +26,21 @@ export class Route { this.geodesic = geodesic; } - setWaypoints = (waypoints: Array): void => { + setWaypoints = (waypoints: Waypoint[]): void => { this.waypoints = waypoints; this.setAzimuth(waypoints.map((waypoint) => waypoint.point)); }; - setPoints = (points: Array): void => { + setPoints = (points: Point[]): void => { this.points = points; this.setAzimuth(points); }; - setSpacetimePoints = (spacetimePoints: Array): void => { + setSpacetimePoints = (spacetimePoints: SpacetimePoint[]): void => { this.spacetimePoints = spacetimePoints; }; - private setAzimuth = (points: Array): void => { + private setAzimuth = (points: Point[]): void => { const inverse = this.geodesic.inverse( points[0].lon, points[0].lat, diff --git a/src/modules/matcher/domain/entities/ecosystem/waypoint.ts b/src/modules/matcher/domain/entities/ecosystem/waypoint.ts index 3695dc2..48c0899 100644 --- a/src/modules/matcher/domain/entities/ecosystem/waypoint.ts +++ b/src/modules/matcher/domain/entities/ecosystem/waypoint.ts @@ -3,7 +3,7 @@ import { Actor } from './actor'; export class Waypoint { point: Point; - actors: Array; + actors: Actor[]; constructor(point: Point) { this.point = point; diff --git a/src/modules/matcher/domain/entities/engine/factory/algorithm-factory.abstract.ts b/src/modules/matcher/domain/entities/engine/factory/algorithm-factory.abstract.ts index 0cc876d..9405266 100644 --- a/src/modules/matcher/domain/entities/engine/factory/algorithm-factory.abstract.ts +++ b/src/modules/matcher/domain/entities/engine/factory/algorithm-factory.abstract.ts @@ -5,7 +5,7 @@ import { Selector } from '../selector/selector.abstract'; export abstract class AlgorithmFactory { protected matchQuery: MatchQuery; - private candidates: Array; + private candidates: Candidate[]; constructor(matchQuery: MatchQuery) { this.matchQuery = matchQuery; @@ -13,5 +13,5 @@ export abstract class AlgorithmFactory { } abstract createSelector(): Selector; - abstract createProcessors(): Array; + abstract createProcessors(): Processor[]; } diff --git a/src/modules/matcher/domain/entities/engine/factory/classic.ts b/src/modules/matcher/domain/entities/engine/factory/classic.ts index 54880b0..fc06888 100644 --- a/src/modules/matcher/domain/entities/engine/factory/classic.ts +++ b/src/modules/matcher/domain/entities/engine/factory/classic.ts @@ -10,7 +10,7 @@ import { ClassicSelector } from '../selector/classic.selector'; export class ClassicAlgorithmFactory extends AlgorithmFactory { createSelector = (): Selector => new ClassicSelector(this.matchQuery); - createProcessors = (): Array => [ + createProcessors = (): Processor[] => [ new ClassicWaypointsCompleter(this.matchQuery), new RouteCompleter(this.matchQuery, true, true, true), new ClassicGeoFilter(this.matchQuery), diff --git a/src/modules/matcher/domain/entities/engine/matcher.ts b/src/modules/matcher/domain/entities/engine/matcher.ts index 48648af..923b69f 100644 --- a/src/modules/matcher/domain/entities/engine/matcher.ts +++ b/src/modules/matcher/domain/entities/engine/matcher.ts @@ -11,10 +11,10 @@ export class Matcher { private readonly algorithmFactoryCreator: AlgorithmFactoryCreator, ) {} - match = async (matchQuery: MatchQuery): Promise> => { + match = async (matchQuery: MatchQuery): Promise => { const algorithmFactory: AlgorithmFactory = this.algorithmFactoryCreator.create(matchQuery); - let candidates: Array = await algorithmFactory + let candidates: Candidate[] = await algorithmFactory .createSelector() .select(); for (const processor of algorithmFactory.createProcessors()) { diff --git a/src/modules/matcher/domain/entities/engine/processor/completer/classic-waypoint.completer.processor.ts b/src/modules/matcher/domain/entities/engine/processor/completer/classic-waypoint.completer.processor.ts index baccba9..dee2a2f 100644 --- a/src/modules/matcher/domain/entities/engine/processor/completer/classic-waypoint.completer.processor.ts +++ b/src/modules/matcher/domain/entities/engine/processor/completer/classic-waypoint.completer.processor.ts @@ -2,7 +2,7 @@ import { Candidate } from '../../candidate'; import { Completer } from './completer.abstract'; export class ClassicWaypointsCompleter extends Completer { - complete = (candidates: Array): Array => { + complete = (candidates: Candidate[]): Candidate[] => { return candidates; }; } diff --git a/src/modules/matcher/domain/entities/engine/processor/completer/completer.abstract.ts b/src/modules/matcher/domain/entities/engine/processor/completer/completer.abstract.ts index e11bfee..b72064f 100644 --- a/src/modules/matcher/domain/entities/engine/processor/completer/completer.abstract.ts +++ b/src/modules/matcher/domain/entities/engine/processor/completer/completer.abstract.ts @@ -2,8 +2,7 @@ import { Candidate } from '../../candidate'; import { Processor } from '../processor.abstract'; export abstract class Completer extends Processor { - execute = (candidates: Array): Array => - this.complete(candidates); + execute = (candidates: Candidate[]): Candidate[] => this.complete(candidates); - abstract complete(candidates: Array): Array; + abstract complete(candidates: Candidate[]): Candidate[]; } diff --git a/src/modules/matcher/domain/entities/engine/processor/completer/journey.completer.processor.ts b/src/modules/matcher/domain/entities/engine/processor/completer/journey.completer.processor.ts index 69042b9..d1a028c 100644 --- a/src/modules/matcher/domain/entities/engine/processor/completer/journey.completer.processor.ts +++ b/src/modules/matcher/domain/entities/engine/processor/completer/journey.completer.processor.ts @@ -2,7 +2,7 @@ import { Candidate } from '../../candidate'; import { Completer } from './completer.abstract'; export class JourneyCompleter extends Completer { - complete = (candidates: Array): Array => { + complete = (candidates: Candidate[]): Candidate[] => { return candidates; }; } diff --git a/src/modules/matcher/domain/entities/engine/processor/completer/route.completer.processor.ts b/src/modules/matcher/domain/entities/engine/processor/completer/route.completer.processor.ts index 582bc03..38ca7b1 100644 --- a/src/modules/matcher/domain/entities/engine/processor/completer/route.completer.processor.ts +++ b/src/modules/matcher/domain/entities/engine/processor/completer/route.completer.processor.ts @@ -19,7 +19,7 @@ export class RouteCompleter extends Completer { this.withDistance = withDistance; } - complete = (candidates: Array): Array => { + complete = (candidates: Candidate[]): Candidate[] => { return candidates; }; } diff --git a/src/modules/matcher/domain/entities/engine/processor/filter/filter.abstract.ts b/src/modules/matcher/domain/entities/engine/processor/filter/filter.abstract.ts index 87cd490..1198383 100644 --- a/src/modules/matcher/domain/entities/engine/processor/filter/filter.abstract.ts +++ b/src/modules/matcher/domain/entities/engine/processor/filter/filter.abstract.ts @@ -2,8 +2,7 @@ import { Candidate } from '../../candidate'; import { Processor } from '../processor.abstract'; export abstract class Filter extends Processor { - execute = (candidates: Array): Array => - this.filter(candidates); + execute = (candidates: Candidate[]): Candidate[] => this.filter(candidates); - abstract filter(candidates: Array): Array; + abstract filter(candidates: Candidate[]): Candidate[]; } diff --git a/src/modules/matcher/domain/entities/engine/processor/filter/geofilter/classic.filter.processor.ts b/src/modules/matcher/domain/entities/engine/processor/filter/geofilter/classic.filter.processor.ts index dc0dc66..77b4663 100644 --- a/src/modules/matcher/domain/entities/engine/processor/filter/geofilter/classic.filter.processor.ts +++ b/src/modules/matcher/domain/entities/engine/processor/filter/geofilter/classic.filter.processor.ts @@ -2,7 +2,7 @@ import { Candidate } from '../../../candidate'; import { Filter } from '../filter.abstract'; export class ClassicGeoFilter extends Filter { - filter = (candidates: Array): Array => { + filter = (candidates: Candidate[]): Candidate[] => { return candidates; }; } diff --git a/src/modules/matcher/domain/entities/engine/processor/filter/timefilter/classic.filter.processor.ts b/src/modules/matcher/domain/entities/engine/processor/filter/timefilter/classic.filter.processor.ts index b69c32e..2d48c49 100644 --- a/src/modules/matcher/domain/entities/engine/processor/filter/timefilter/classic.filter.processor.ts +++ b/src/modules/matcher/domain/entities/engine/processor/filter/timefilter/classic.filter.processor.ts @@ -2,7 +2,7 @@ import { Candidate } from '../../../candidate'; import { Filter } from '../filter.abstract'; export class ClassicTimeFilter extends Filter { - filter = (candidates: Array): Array => { + filter = (candidates: Candidate[]): Candidate[] => { return candidates; }; } diff --git a/src/modules/matcher/domain/entities/engine/processor/processor.abstract.ts b/src/modules/matcher/domain/entities/engine/processor/processor.abstract.ts index eee4c0c..d4eeabc 100644 --- a/src/modules/matcher/domain/entities/engine/processor/processor.abstract.ts +++ b/src/modules/matcher/domain/entities/engine/processor/processor.abstract.ts @@ -8,5 +8,5 @@ export abstract class Processor { this.matchQuery = matchQuery; } - abstract execute(candidates: Array): Array; + abstract execute(candidates: Candidate[]): Candidate[]; } diff --git a/src/modules/matcher/domain/entities/engine/selector/classic.selector.ts b/src/modules/matcher/domain/entities/engine/selector/classic.selector.ts index e87403c..5b1d2da 100644 --- a/src/modules/matcher/domain/entities/engine/selector/classic.selector.ts +++ b/src/modules/matcher/domain/entities/engine/selector/classic.selector.ts @@ -2,7 +2,7 @@ import { Candidate } from '../candidate'; import { Selector } from './selector.abstract'; export class ClassicSelector extends Selector { - select = async (): Promise> => { + select = async (): Promise => { return []; }; } diff --git a/src/modules/matcher/domain/entities/engine/selector/selector.abstract.ts b/src/modules/matcher/domain/entities/engine/selector/selector.abstract.ts index b2b722e..c1b58bf 100644 --- a/src/modules/matcher/domain/entities/engine/selector/selector.abstract.ts +++ b/src/modules/matcher/domain/entities/engine/selector/selector.abstract.ts @@ -8,5 +8,5 @@ export abstract class Selector { this.matchQuery = matchQuery; } - abstract select(): Promise>; + abstract select(): Promise; } diff --git a/src/modules/matcher/domain/interfaces/geography-request.interface.ts b/src/modules/matcher/domain/interfaces/geography-request.interface.ts index 6cf3673..8a58ac1 100644 --- a/src/modules/matcher/domain/interfaces/geography-request.interface.ts +++ b/src/modules/matcher/domain/interfaces/geography-request.interface.ts @@ -1,5 +1,5 @@ import { Point } from '../../../geography/domain/types/point.type'; export interface IRequestGeography { - waypoints: Array; + waypoints: Point[]; } diff --git a/src/modules/matcher/domain/interfaces/georouter.interface.ts b/src/modules/matcher/domain/interfaces/georouter.interface.ts index 5f09b23..7c64cc2 100644 --- a/src/modules/matcher/domain/interfaces/georouter.interface.ts +++ b/src/modules/matcher/domain/interfaces/georouter.interface.ts @@ -3,8 +3,5 @@ import { GeorouterSettings } from '../types/georouter-settings.type'; import { Path } from '../types/path.type'; export interface IGeorouter { - route( - paths: Array, - settings: GeorouterSettings, - ): Promise>; + route(paths: Path[], settings: GeorouterSettings): Promise; } diff --git a/src/modules/matcher/domain/types/path.type.ts b/src/modules/matcher/domain/types/path.type.ts index 49437bd..44e03b6 100644 --- a/src/modules/matcher/domain/types/path.type.ts +++ b/src/modules/matcher/domain/types/path.type.ts @@ -2,5 +2,5 @@ import { Point } from '../../../geography/domain/types/point.type'; export type Path = { key: string; - points: Array; + points: Point[]; }; diff --git a/src/modules/matcher/domain/types/waypoint.ts b/src/modules/matcher/domain/types/waypoint.ts index 8628fd1..bc15ea5 100644 --- a/src/modules/matcher/domain/types/waypoint.ts +++ b/src/modules/matcher/domain/types/waypoint.ts @@ -3,5 +3,5 @@ import { Point } from '../../../geography/domain/types/point.type'; export type Waypoint = { point: Point; - actors: Array; + actors: Actor[]; }; diff --git a/src/modules/matcher/domain/usecases/match.usecase.ts b/src/modules/matcher/domain/usecases/match.usecase.ts index fbb6952..c834224 100644 --- a/src/modules/matcher/domain/usecases/match.usecase.ts +++ b/src/modules/matcher/domain/usecases/match.usecase.ts @@ -17,7 +17,7 @@ export class MatchUseCase { execute = async (matchQuery: MatchQuery): Promise> => { try { - const data: Array = await this._matcher.match(matchQuery); + const data: Match[] = await this._matcher.match(matchQuery); this._messager.publish('matcher.match', 'match !'); return { data, diff --git a/src/modules/matcher/queries/match.query.ts b/src/modules/matcher/queries/match.query.ts index 3f7c8dd..7de0009 100644 --- a/src/modules/matcher/queries/match.query.ts +++ b/src/modules/matcher/queries/match.query.ts @@ -15,10 +15,10 @@ export class MatchQuery { private readonly defaultParams: IDefaultParams; private readonly georouterCreator: ICreateGeorouter; person: Person; - roles: Array; + roles: Role[]; time: Time; geography: Geography; - exclusions: Array; + exclusions: number[]; requirement: Requirement; algorithmSettings: AlgorithmSettings; georouter: IGeorouter;