From a6da69ee36c89b2b093a6194460b1e3e230b41d1 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 18 Oct 2026 18:44:02 +0200 Subject: [PATCH] refactor(trips): the member departure port in common/, where both sides may import it Declared in trip-members, the port gave journey an edge into the roster, which reaches journey through other domains: the cycle again, the other way round. In the shared kernel neither domain owns it. --- .../{trip-members => common}/trip-member-departure.types.ts | 3 ++- server/src/nest/journey/trip-journal-link.service.ts | 2 +- server/src/nest/journey/trip-member-departure.module.ts | 2 +- server/src/nest/trip-members/trip-members.service.ts | 2 +- server/tests/helpers/journey-share-repos.ts | 5 +---- 5 files changed, 6 insertions(+), 8 deletions(-) rename server/src/nest/{trip-members => common}/trip-member-departure.types.ts (81%) diff --git a/server/src/nest/trip-members/trip-member-departure.types.ts b/server/src/nest/common/trip-member-departure.types.ts similarity index 81% rename from server/src/nest/trip-members/trip-member-departure.types.ts rename to server/src/nest/common/trip-member-departure.types.ts index 6fa6dc5f1..e1fcfc4a3 100644 --- a/server/src/nest/trip-members/trip-member-departure.types.ts +++ b/server/src/nest/common/trip-member-departure.types.ts @@ -3,7 +3,8 @@ * * A port rather than the journal link service itself: the journey domain * already depends on the trip roster through others, so reaching into it from - * here closed a cycle. The journey domain binds the token + * the roster closed a cycle. It lives in common/ because either domain owning + * it would draw that edge again. The journey domain binds the token * (TripMemberDepartureModule), and the roster calls it inside the transaction * that removes the member. */ diff --git a/server/src/nest/journey/trip-journal-link.service.ts b/server/src/nest/journey/trip-journal-link.service.ts index 1ce2bf83c..7eee10b75 100644 --- a/server/src/nest/journey/trip-journal-link.service.ts +++ b/server/src/nest/journey/trip-journal-link.service.ts @@ -4,10 +4,10 @@ import type { JourneyContributorsRepository } from '../../db/repositories/Journe import type { TripJournalLinksRepository, TripPersonRow } from '../../db/repositories/TripJournalLinks.repository'; import { avatarUrl } from '../common/avatarUrl'; import { forbidden, notFound } from '../common/domain-error'; +import type { TripMemberDeparture } from '../common/trip-member-departure.types'; import { UnitOfWork } from '../database/unit-of-work'; import { PermissionsService } from '../permissions/permissions.service'; import { RealtimeService } from '../realtime/realtime.service'; -import type { TripMemberDeparture } from '../trip-members/trip-member-departure.types'; import { TripAccessService } from '../trip-membership/trip-access.service'; import { JourneyDomainService } from './journey-domain.service'; import { InjectRepository } from '@mikro-orm/nestjs'; diff --git a/server/src/nest/journey/trip-member-departure.module.ts b/server/src/nest/journey/trip-member-departure.module.ts index 1d232b349..c5f37709f 100644 --- a/server/src/nest/journey/trip-member-departure.module.ts +++ b/server/src/nest/journey/trip-member-departure.module.ts @@ -1,4 +1,4 @@ -import { TRIP_MEMBER_DEPARTURE } from '../trip-members/trip-member-departure.types'; +import { TRIP_MEMBER_DEPARTURE } from '../common/trip-member-departure.types'; import { TripJournalLinkModule } from './trip-journal-link.module'; import { TripJournalLinkService } from './trip-journal-link.service'; import { Global, Module } from '@nestjs/common'; diff --git a/server/src/nest/trip-members/trip-members.service.ts b/server/src/nest/trip-members/trip-members.service.ts index d9866e94d..72202fabc 100644 --- a/server/src/nest/trip-members/trip-members.service.ts +++ b/server/src/nest/trip-members/trip-members.service.ts @@ -10,11 +10,11 @@ import { UserCleanupService } from '../auth/user-cleanup.service'; import { BudgetService } from '../budget/budget.service'; import { avatarUrl } from '../common/avatarUrl'; import { NotFoundError, ValidationError } from '../common/domain-errors'; +import { TRIP_MEMBER_DEPARTURE, type TripMemberDeparture } from '../common/trip-member-departure.types'; import { UnitOfWork } from '../database/unit-of-work'; import { NotificationsService } from '../notifications/notifications.service'; import { PermissionsService } from '../permissions/permissions.service'; import { RealtimeService } from '../realtime/realtime.service'; -import { TRIP_MEMBER_DEPARTURE, type TripMemberDeparture } from './trip-member-departure.types'; import { InjectRepository } from '@mikro-orm/nestjs'; import { Inject, Injectable } from '@nestjs/common'; import type { TrekWsPayload, TrekWsTripEventName } from '@trek/shared'; diff --git a/server/tests/helpers/journey-share-repos.ts b/server/tests/helpers/journey-share-repos.ts index 1fd12ee27..c97ae39bb 100644 --- a/server/tests/helpers/journey-share-repos.ts +++ b/server/tests/helpers/journey-share-repos.ts @@ -2,10 +2,7 @@ import { JourneyBooks } from '../../src/db/entities/JourneyBooks.entity'; import { JourneyShareTokens } from '../../src/db/entities/JourneyShareTokens.entity'; import type { JourneyBooksRepository } from '../../src/db/repositories/JourneyBooks.repository'; import type { JourneyShareTokensRepository } from '../../src/db/repositories/JourneyShareTokens.repository'; -import { - TRIP_MEMBER_DEPARTURE, - type TripMemberDeparture, -} from '../../src/nest/trip-members/trip-member-departure.types'; +import { TRIP_MEMBER_DEPARTURE, type TripMemberDeparture } from '../../src/nest/common/trip-member-departure.types'; import { sharedTestOrm } from './test-uow'; import { Global, Module } from '@nestjs/common';