Merge branch 'updatePackages' into 'main'

Update packages

See merge request v3/service/matcher!27
This commit is contained in:
Sylvain Briat 2024-01-17 08:07:07 +00:00
commit c392d87f43
14 changed files with 2750 additions and 1821 deletions

4344
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@mobicoop/matcher", "name": "@mobicoop/matcher",
"version": "1.5.2", "version": "1.5.3",
"description": "Mobicoop V3 Matcher", "description": "Mobicoop V3 Matcher",
"author": "sbriat", "author": "sbriat",
"private": true, "private": true,
@ -30,63 +30,62 @@
"migrate:deploy": "npx prisma migrate deploy" "migrate:deploy": "npx prisma migrate deploy"
}, },
"dependencies": { "dependencies": {
"@grpc/grpc-js": "^1.9.9", "@grpc/grpc-js": "^1.9.14",
"@grpc/proto-loader": "^0.7.10", "@grpc/proto-loader": "^0.7.10",
"@songkeys/nestjs-redis": "^10.0.0", "@songkeys/nestjs-redis": "^10.0.0",
"@mobicoop/configuration-module": "^7.2.1", "@mobicoop/configuration-module": "^8.0.0",
"@mobicoop/ddd-library": "^2.1.1", "@mobicoop/ddd-library": "^2.4.3",
"@mobicoop/health-module": "^2.3.1", "@mobicoop/health-module": "^2.3.2",
"@mobicoop/message-broker-module": "^2.1.1", "@mobicoop/message-broker-module": "^2.1.2",
"@nestjs/axios": "^3.0.1", "@nestjs/axios": "^3.0.1",
"@nestjs/cache-manager": "^2.1.0", "@nestjs/cache-manager": "^2.2.0",
"@nestjs/common": "^10.2.7", "@nestjs/common": "^10.3.0",
"@nestjs/config": "^3.1.1", "@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.2.7", "@nestjs/core": "^10.3.0",
"@nestjs/cqrs": "^10.2.6", "@nestjs/cqrs": "^10.2.6",
"@nestjs/event-emitter": "^2.0.2", "@nestjs/event-emitter": "^2.0.3",
"@nestjs/microservices": "^10.2.7", "@nestjs/microservices": "^10.3.0",
"@nestjs/platform-express": "^10.2.7", "@nestjs/platform-express": "^10.3.0",
"@nestjs/terminus": "^10.1.1", "@nestjs/terminus": "^10.2.0",
"@prisma/client": "^5.5.2", "@prisma/client": "^5.8.1",
"axios": "^1.6.0", "axios": "^1.6.5",
"cache-manager": "^5.2.4", "cache-manager": "^5.3.2",
"cache-manager-ioredis-yet": "^1.2.2", "cache-manager-ioredis-yet": "^1.2.2",
"class-transformer": "^0.5.1", "class-transformer": "^0.5.1",
"class-validator": "^0.14.0", "class-validator": "^0.14.1",
"geo-tz": "^7.0.7", "geo-tz": "^8.0.0",
"geographiclib-geodesic": "^2.0.0", "geographiclib-geodesic": "^2.0.0",
"got": "^13.0.0", "got": "^14.0.0",
"ioredis": "^5.3.2", "ioredis": "^5.3.2",
"nestjs-request-context": "^3.0.0", "nestjs-request-context": "^3.0.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1", "rxjs": "^7.8.1",
"timezonecomplete": "^5.12.4" "timezonecomplete": "^5.12.4"
}, },
"devDependencies": { "devDependencies": {
"@nestjs/cli": "^10.2.1", "@nestjs/cli": "^10.3.0",
"@nestjs/schematics": "^10.0.3", "@nestjs/schematics": "^10.1.0",
"@nestjs/testing": "^10.2.7", "@nestjs/testing": "^10.3.0",
"@types/express": "^4.17.20", "@types/express": "^4.17.21",
"@types/jest": "29.5.7", "@types/jest": "29.5.11",
"@types/node": "20.8.10", "@types/node": "20.11.5",
"@types/supertest": "^2.0.15", "@types/supertest": "^6.0.2",
"@types/uuid": "^9.0.6", "@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.9.1", "@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.9.1", "@typescript-eslint/parser": "^6.19.0",
"dotenv-cli": "^7.3.0", "dotenv-cli": "^7.3.0",
"eslint": "^8.52.0", "eslint": "^8.56.0",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.1", "eslint-plugin-prettier": "^5.1.3",
"jest": "29.7.0", "jest": "29.7.0",
"prettier": "^3.0.3", "prettier": "^3.2.3",
"prisma": "^5.5.2", "prisma": "^5.8.1",
"source-map-support": "^0.5.21", "source-map-support": "^0.5.21",
"supertest": "^6.3.3", "supertest": "^6.3.4",
"ts-jest": "29.1.1", "ts-jest": "29.1.1",
"ts-loader": "^9.5.0", "ts-loader": "^9.5.1",
"ts-node": "^10.9.1", "ts-node": "^10.9.2",
"tsconfig-paths": "4.2.0", "tsconfig-paths": "4.2.0",
"typescript": "^5.2.2" "typescript": "^5.3.3"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [

View File

@ -1,7 +1,4 @@
import { import { KeyType, Type } from '@mobicoop/configuration-module';
ConfigurationDomainGet,
ConfigurationType,
} from '@mobicoop/configuration-module';
export const CARPOOL_CONFIG_ROLE = 'role'; export const CARPOOL_CONFIG_ROLE = 'role';
export const CARPOOL_CONFIG_SEATS_PROPOSED = 'seatsProposed'; export const CARPOOL_CONFIG_SEATS_PROPOSED = 'seatsProposed';
@ -9,25 +6,25 @@ export const CARPOOL_CONFIG_SEATS_REQUESTED = 'seatsRequested';
export const CARPOOL_CONFIG_DEPARTURE_TIME_MARGIN = 'departureTimeMargin'; export const CARPOOL_CONFIG_DEPARTURE_TIME_MARGIN = 'departureTimeMargin';
export const CARPOOL_CONFIG_STRICT_FREQUENCY = 'strictFrequency'; export const CARPOOL_CONFIG_STRICT_FREQUENCY = 'strictFrequency';
export const CarpoolConfig: ConfigurationDomainGet[] = [ export const CarpoolKeyTypes: KeyType[] = [
{ {
key: CARPOOL_CONFIG_ROLE, key: CARPOOL_CONFIG_ROLE,
type: ConfigurationType.STRING, type: Type.STRING,
}, },
{ {
key: CARPOOL_CONFIG_SEATS_PROPOSED, key: CARPOOL_CONFIG_SEATS_PROPOSED,
type: ConfigurationType.INT, type: Type.INT,
}, },
{ {
key: CARPOOL_CONFIG_SEATS_REQUESTED, key: CARPOOL_CONFIG_SEATS_REQUESTED,
type: ConfigurationType.INT, type: Type.INT,
}, },
{ {
key: CARPOOL_CONFIG_DEPARTURE_TIME_MARGIN, key: CARPOOL_CONFIG_DEPARTURE_TIME_MARGIN,
type: ConfigurationType.INT, type: Type.INT,
}, },
{ {
key: CARPOOL_CONFIG_STRICT_FREQUENCY, key: CARPOOL_CONFIG_STRICT_FREQUENCY,
type: ConfigurationType.BOOLEAN, type: Type.BOOLEAN,
}, },
]; ];

View File

@ -17,7 +17,7 @@ import { Paginator } from '@mobicoop/ddd-library';
import { MatchingEntity } from '@modules/ad/core/domain/matching.entity'; import { MatchingEntity } from '@modules/ad/core/domain/matching.entity';
import { MatchingRepositoryPort } from '../../ports/matching.repository.port'; import { MatchingRepositoryPort } from '../../ports/matching.repository.port';
import { import {
ConfigurationDomain, Domain,
Configurator, Configurator,
GetConfigurationRepositoryPort, GetConfigurationRepositoryPort,
} from '@mobicoop/configuration-module'; } from '@mobicoop/configuration-module';
@ -27,7 +27,7 @@ import {
CARPOOL_CONFIG_SEATS_PROPOSED, CARPOOL_CONFIG_SEATS_PROPOSED,
CARPOOL_CONFIG_SEATS_REQUESTED, CARPOOL_CONFIG_SEATS_REQUESTED,
CARPOOL_CONFIG_STRICT_FREQUENCY, CARPOOL_CONFIG_STRICT_FREQUENCY,
CarpoolConfig, CarpoolKeyTypes,
} from '@modules/ad/ad.constants'; } from '@modules/ad/ad.constants';
import { import {
MATCH_CONFIG_ALGORITHM, MATCH_CONFIG_ALGORITHM,
@ -57,18 +57,12 @@ export class MatchQueryHandler implements IQueryHandler {
execute = async (query: MatchQuery): Promise<MatchingResult> => { execute = async (query: MatchQuery): Promise<MatchingResult> => {
const carpoolConfigurator: Configurator = const carpoolConfigurator: Configurator =
await this.configurationRepository.mget( await this.configurationRepository.mget(Domain.CARPOOL, CarpoolKeyTypes);
ConfigurationDomain.CARPOOL,
CarpoolConfig,
);
const matchConfigurator: Configurator = const matchConfigurator: Configurator =
await this.configurationRepository.mget( await this.configurationRepository.mget(Domain.MATCH, MatchConfig);
ConfigurationDomain.MATCH,
MatchConfig,
);
const paginationConfigurator: Configurator = const paginationConfigurator: Configurator =
await this.configurationRepository.mget( await this.configurationRepository.mget(
ConfigurationDomain.PAGINATION, Domain.PAGINATION,
PaginationConfig, PaginationConfig,
); );
query query

View File

@ -235,8 +235,8 @@ export class CarpoolPathCreator {
index == 0 index == 0
? Target.START ? Target.START
: index == waypoints.length - 1 : index == waypoints.length - 1
? Target.FINISH ? Target.FINISH
: Target.INTERMEDIATE; : Target.INTERMEDIATE;
/** /**
* Consolidate carpoolPath by removing duplicate actors (eg. driver with neutral and start or finish target) * Consolidate carpoolPath by removing duplicate actors (eg. driver with neutral and start or finish target)

View File

@ -1,7 +1,4 @@
import { import { KeyType, Type } from '@mobicoop/configuration-module';
ConfigurationDomainGet,
ConfigurationType,
} from '@mobicoop/configuration-module';
export const MATCH_CONFIG_ALGORITHM = 'algorithm'; export const MATCH_CONFIG_ALGORITHM = 'algorithm';
export const MATCH_CONFIG_REMOTENESS = 'remoteness'; export const MATCH_CONFIG_REMOTENESS = 'remoteness';
@ -13,44 +10,44 @@ export const MATCH_CONFIG_MAX_DETOUR_DISTANCE_RATIO = 'maxDetourDistanceRatio';
export const MATCH_CONFIG_MAX_DETOUR_DURATION_RATIO = 'maxDetourDurationRatio'; export const MATCH_CONFIG_MAX_DETOUR_DURATION_RATIO = 'maxDetourDurationRatio';
export const PAGINATION_CONFIG_PER_PAGE = 'perPage'; export const PAGINATION_CONFIG_PER_PAGE = 'perPage';
export const MatchConfig: ConfigurationDomainGet[] = [ export const MatchConfig: KeyType[] = [
{ {
key: MATCH_CONFIG_ALGORITHM, key: MATCH_CONFIG_ALGORITHM,
type: ConfigurationType.STRING, type: Type.STRING,
}, },
{ {
key: MATCH_CONFIG_REMOTENESS, key: MATCH_CONFIG_REMOTENESS,
type: ConfigurationType.INT, type: Type.INT,
}, },
{ {
key: MATCH_CONFIG_USE_PROPORTION, key: MATCH_CONFIG_USE_PROPORTION,
type: ConfigurationType.BOOLEAN, type: Type.BOOLEAN,
}, },
{ {
key: MATCH_CONFIG_PROPORTION, key: MATCH_CONFIG_PROPORTION,
type: ConfigurationType.FLOAT, type: Type.FLOAT,
}, },
{ {
key: MATCH_CONFIG_USE_AZIMUTH, key: MATCH_CONFIG_USE_AZIMUTH,
type: ConfigurationType.BOOLEAN, type: Type.BOOLEAN,
}, },
{ {
key: MATCH_CONFIG_AZIMUTH_MARGIN, key: MATCH_CONFIG_AZIMUTH_MARGIN,
type: ConfigurationType.INT, type: Type.INT,
}, },
{ {
key: MATCH_CONFIG_MAX_DETOUR_DISTANCE_RATIO, key: MATCH_CONFIG_MAX_DETOUR_DISTANCE_RATIO,
type: ConfigurationType.FLOAT, type: Type.FLOAT,
}, },
{ {
key: MATCH_CONFIG_MAX_DETOUR_DURATION_RATIO, key: MATCH_CONFIG_MAX_DETOUR_DURATION_RATIO,
type: ConfigurationType.FLOAT, type: Type.FLOAT,
}, },
]; ];
export const PaginationConfig: ConfigurationDomainGet[] = [ export const PaginationConfig: KeyType[] = [
{ {
key: PAGINATION_CONFIG_PER_PAGE, key: PAGINATION_CONFIG_PER_PAGE,
type: ConfigurationType.INT, type: Type.INT,
}, },
]; ];

View File

@ -54,6 +54,7 @@ const mockAdRepository: AdRepositoryPort = {
findOneById: jest.fn(), findOneById: jest.fn(),
findOne: jest.fn(), findOne: jest.fn(),
findAll: jest.fn(), findAll: jest.fn(),
findAllByIds: jest.fn(),
insert: jest.fn(), insert: jest.fn(),
update: jest.fn(), update: jest.fn(),
updateWhere: jest.fn(), updateWhere: jest.fn(),

View File

@ -1,6 +1,6 @@
import { import {
ConfigurationDomain, Domain,
ConfigurationDomainGet, KeyType,
Configurator, Configurator,
GetConfigurationRepositoryPort, GetConfigurationRepositoryPort,
} from '@mobicoop/configuration-module'; } from '@mobicoop/configuration-module';
@ -258,83 +258,83 @@ const mockConfigurationRepository: GetConfigurationRepositoryPort = {
get: jest.fn(), get: jest.fn(),
mget: jest.fn().mockImplementation( mget: jest.fn().mockImplementation(
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(domain: ConfigurationDomain, configs: ConfigurationDomainGet[]) => { (domain: Domain, keyTypes: KeyType[]) => {
switch (domain) { switch (domain) {
case ConfigurationDomain.CARPOOL: case Domain.CARPOOL:
return new Configurator(ConfigurationDomain.CARPOOL, [ return new Configurator(Domain.CARPOOL, [
{ {
domain: ConfigurationDomain.CARPOOL, domain: Domain.CARPOOL,
key: CARPOOL_CONFIG_DEPARTURE_TIME_MARGIN, key: CARPOOL_CONFIG_DEPARTURE_TIME_MARGIN,
value: 900, value: 900,
}, },
{ {
domain: ConfigurationDomain.CARPOOL, domain: Domain.CARPOOL,
key: CARPOOL_CONFIG_ROLE, key: CARPOOL_CONFIG_ROLE,
value: 'passenger', value: 'passenger',
}, },
{ {
domain: ConfigurationDomain.CARPOOL, domain: Domain.CARPOOL,
key: CARPOOL_CONFIG_SEATS_PROPOSED, key: CARPOOL_CONFIG_SEATS_PROPOSED,
value: 3, value: 3,
}, },
{ {
domain: ConfigurationDomain.CARPOOL, domain: Domain.CARPOOL,
key: CARPOOL_CONFIG_SEATS_REQUESTED, key: CARPOOL_CONFIG_SEATS_REQUESTED,
value: 1, value: 1,
}, },
{ {
domain: ConfigurationDomain.CARPOOL, domain: Domain.CARPOOL,
key: CARPOOL_CONFIG_STRICT_FREQUENCY, key: CARPOOL_CONFIG_STRICT_FREQUENCY,
value: false, value: false,
}, },
]); ]);
case ConfigurationDomain.MATCH: case Domain.MATCH:
return new Configurator(ConfigurationDomain.MATCH, [ return new Configurator(Domain.MATCH, [
{ {
domain: ConfigurationDomain.MATCH, domain: Domain.MATCH,
key: MATCH_CONFIG_ALGORITHM, key: MATCH_CONFIG_ALGORITHM,
value: 'PASSENGER_ORIENTED', value: 'PASSENGER_ORIENTED',
}, },
{ {
domain: ConfigurationDomain.MATCH, domain: Domain.MATCH,
key: MATCH_CONFIG_REMOTENESS, key: MATCH_CONFIG_REMOTENESS,
value: 15000, value: 15000,
}, },
{ {
domain: ConfigurationDomain.MATCH, domain: Domain.MATCH,
key: MATCH_CONFIG_USE_PROPORTION, key: MATCH_CONFIG_USE_PROPORTION,
value: true, value: true,
}, },
{ {
domain: ConfigurationDomain.MATCH, domain: Domain.MATCH,
key: MATCH_CONFIG_PROPORTION, key: MATCH_CONFIG_PROPORTION,
value: 0.3, value: 0.3,
}, },
{ {
domain: ConfigurationDomain.MATCH, domain: Domain.MATCH,
key: MATCH_CONFIG_USE_AZIMUTH, key: MATCH_CONFIG_USE_AZIMUTH,
value: true, value: true,
}, },
{ {
domain: ConfigurationDomain.MATCH, domain: Domain.MATCH,
key: MATCH_CONFIG_AZIMUTH_MARGIN, key: MATCH_CONFIG_AZIMUTH_MARGIN,
value: 10, value: 10,
}, },
{ {
domain: ConfigurationDomain.MATCH, domain: Domain.MATCH,
key: MATCH_CONFIG_MAX_DETOUR_DISTANCE_RATIO, key: MATCH_CONFIG_MAX_DETOUR_DISTANCE_RATIO,
value: 0.3, value: 0.3,
}, },
{ {
domain: ConfigurationDomain.MATCH, domain: Domain.MATCH,
key: MATCH_CONFIG_MAX_DETOUR_DURATION_RATIO, key: MATCH_CONFIG_MAX_DETOUR_DURATION_RATIO,
value: 0.3, value: 0.3,
}, },
]); ]);
case ConfigurationDomain.PAGINATION: case Domain.PAGINATION:
return new Configurator(ConfigurationDomain.PAGINATION, [ return new Configurator(Domain.PAGINATION, [
{ {
domain: ConfigurationDomain.PAGINATION, domain: Domain.PAGINATION,
key: PAGINATION_CONFIG_PER_PAGE, key: PAGINATION_CONFIG_PER_PAGE,
value: 10, value: 10,
}, },

View File

@ -55,6 +55,7 @@ const mockMatcherRepository: AdRepositoryPort = {
findOneById: jest.fn(), findOneById: jest.fn(),
findOne: jest.fn(), findOne: jest.fn(),
findAll: jest.fn(), findAll: jest.fn(),
findAllByIds: jest.fn(),
insert: jest.fn(), insert: jest.fn(),
update: jest.fn(), update: jest.fn(),
updateWhere: jest.fn(), updateWhere: jest.fn(),

View File

@ -100,6 +100,7 @@ const mockMatcherRepository: AdRepositoryPort = {
findOneById: jest.fn(), findOneById: jest.fn(),
findOne: jest.fn(), findOne: jest.fn(),
findAll: jest.fn(), findAll: jest.fn(),
findAllByIds: jest.fn(),
insert: jest.fn(), insert: jest.fn(),
update: jest.fn(), update: jest.fn(),
updateWhere: jest.fn(), updateWhere: jest.fn(),

View File

@ -1,18 +1,15 @@
import { import { KeyType, Type } from '@mobicoop/configuration-module';
ConfigurationDomainGet,
ConfigurationType,
} from '@mobicoop/configuration-module';
export const GEOGRAPHY_CONFIG_GEOROUTER_TYPE = 'georouterType'; export const GEOGRAPHY_CONFIG_GEOROUTER_TYPE = 'georouterType';
export const GEOGRAPHY_CONFIG_GEOROUTER_URL = 'georouterUrl'; export const GEOGRAPHY_CONFIG_GEOROUTER_URL = 'georouterUrl';
export const GeographyConfig: ConfigurationDomainGet[] = [ export const GeographyKeyTypes: KeyType[] = [
{ {
key: GEOGRAPHY_CONFIG_GEOROUTER_TYPE, key: GEOGRAPHY_CONFIG_GEOROUTER_TYPE,
type: ConfigurationType.STRING, type: Type.STRING,
}, },
{ {
key: GEOGRAPHY_CONFIG_GEOROUTER_URL, key: GEOGRAPHY_CONFIG_GEOROUTER_URL,
type: ConfigurationType.STRING, type: Type.STRING,
}, },
]; ];

View File

@ -15,13 +15,13 @@ import {
} from '../core/domain/route.errors'; } from '../core/domain/route.errors';
import { GeodesicPort } from '../core/application/ports/geodesic.port'; import { GeodesicPort } from '../core/application/ports/geodesic.port';
import { import {
ConfigurationDomain, Domain,
Configurator, Configurator,
GetConfigurationRepositoryPort, GetConfigurationRepositoryPort,
} from '@mobicoop/configuration-module'; } from '@mobicoop/configuration-module';
import { import {
GEOGRAPHY_CONFIG_GEOROUTER_URL, GEOGRAPHY_CONFIG_GEOROUTER_URL,
GeographyConfig, GeographyKeyTypes,
} from '../geography.constants'; } from '../geography.constants';
@Injectable() @Injectable()
@ -42,8 +42,8 @@ export class GraphhopperGeorouter implements GeorouterPort {
): Promise<Route> => { ): Promise<Route> => {
const geographyConfigurator: Configurator = const geographyConfigurator: Configurator =
await this.configurationRepository.mget( await this.configurationRepository.mget(
ConfigurationDomain.GEOGRAPHY, Domain.GEOGRAPHY,
GeographyConfig, GeographyKeyTypes,
); );
this.url = [ this.url = [
geographyConfigurator.get<string>(GEOGRAPHY_CONFIG_GEOROUTER_URL), geographyConfigurator.get<string>(GEOGRAPHY_CONFIG_GEOROUTER_URL),

View File

@ -1,6 +1,6 @@
import { import {
ConfigurationDomain, Domain,
ConfigurationDomainGet, KeyType,
Configurator, Configurator,
GetConfigurationRepositoryPort, GetConfigurationRepositoryPort,
} from '@mobicoop/configuration-module'; } from '@mobicoop/configuration-module';
@ -272,12 +272,12 @@ const mockConfigurationRepository: GetConfigurationRepositoryPort = {
get: jest.fn(), get: jest.fn(),
mget: jest.fn().mockImplementation( mget: jest.fn().mockImplementation(
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(domain: ConfigurationDomain, configs: ConfigurationDomainGet[]) => { (domain: Domain, keyTypes: KeyType[]) => {
switch (domain) { switch (domain) {
case ConfigurationDomain.GEOGRAPHY: case Domain.GEOGRAPHY:
return new Configurator(ConfigurationDomain.GEOGRAPHY, [ return new Configurator(Domain.GEOGRAPHY, [
{ {
domain: ConfigurationDomain.GEOGRAPHY, domain: Domain.GEOGRAPHY,
key: GEOGRAPHY_CONFIG_GEOROUTER_URL, key: GEOGRAPHY_CONFIG_GEOROUTER_URL,
value: 'http://localhost:8989', value: 'http://localhost:8989',
}, },

View File

@ -20,7 +20,7 @@
"paths": { "paths": {
"@libs/*": ["src/libs/*"], "@libs/*": ["src/libs/*"],
"@modules/*": ["src/modules/*"], "@modules/*": ["src/modules/*"],
"@src/*": ["src/*"] "@src/*": ["src/*"],
} },
} },
} }