mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 23:16:46 +00:00
Give accommodations one home instead of two halves
The routes lived in reservations/ while the SQL lived on DaysService, so the controller delegated every call across a domain boundary to reach its own data, and neither module owned the thing outright. The seven statements move into AccommodationsService unchanged and the domain gets its own directory, module, DTO, RPC and MCP surface. What stays in days/ is the reorder side: assertNoInvertedAccommodation and resyncAccommodationDays are about re-dating day rows, and the stay is the thing being carried, not the thing doing the carrying. Two edges fall out of this. AccommodationsService drops its DaysService dependency, and DaysMcp drops DatabaseService and PlacesService, because create_place_accommodation was their only user - which lets DaysModule stop importing PlacesModule and closes one leg of the latent Days -> Places -> Assignments -> Days cycle. DAY-SVC-016..026, 029 and 035 move to accommodations.service.test.ts with their case ids intact. The reservations e2e container assembles both modules now: it builds a single domain module on purpose, which is exactly what catches a move like this, and it caught it.
This commit is contained in:
@@ -18,7 +18,7 @@ import { PlacesRpc } from '../../../src/nest/places/places.rpc';
|
||||
import { PackingRpc } from '../../../src/nest/packing/packing.rpc';
|
||||
import { FilesRpc } from '../../../src/nest/files/files.rpc';
|
||||
import { TripsRpc } from '../../../src/nest/trips/trips.rpc';
|
||||
import { AccommodationsRpc } from '../../../src/nest/days/accommodations.rpc';
|
||||
import { AccommodationsRpc } from '../../../src/nest/accommodations/accommodations.rpc';
|
||||
import { ReservationsRpc } from '../../../src/nest/reservations/reservations.rpc';
|
||||
import { DaysRpc } from '../../../src/nest/days/days.rpc';
|
||||
import { VacayRpc } from '../../../src/nest/vacay/vacay.rpc';
|
||||
@@ -124,13 +124,13 @@ describe('a service that says no becomes a refusal, not a crash', () => {
|
||||
|
||||
it('FALLBACK-008 an accommodation whose refs do not validate is refused with the validator message', async () => {
|
||||
const { guards } = guardsFor();
|
||||
const days = {
|
||||
const accommodations = {
|
||||
validateAccommodationRefs: vi.fn(() => [{ message: 'day 9 is not on this trip' }]),
|
||||
getAccommodation: vi.fn(() => ({ id: 11 })),
|
||||
createAccommodation: vi.fn(),
|
||||
updateAccommodation: vi.fn(),
|
||||
} as never;
|
||||
const host = new PluginRpcHost('p', ALL, makeDeps(), createTestPluginRegistry([new AccommodationsRpc(days, realtime(), guards)]));
|
||||
const host = new PluginRpcHost('p', ALL, makeDeps(), createTestPluginRegistry([new AccommodationsRpc(accommodations, realtime(), guards)]));
|
||||
expect(err(await host.dispatch(req('accommodations.update', { tripId: 1, accommodationId: 11, input: { start_day_id: 9 } }), 42)).message)
|
||||
.toBe('day 9 is not on this trip');
|
||||
});
|
||||
@@ -145,7 +145,7 @@ describe('service errors are translated into the RPC taxonomy', () => {
|
||||
create: vi.fn(() => { if (createThrows) throw createThrows; return { trip: { id: 99 } }; }),
|
||||
removeMember: vi.fn(),
|
||||
} as never;
|
||||
const rpc = new TripsRpc(trips, {} as never, {} as never, {} as never, db, realtime(), guards);
|
||||
const rpc = new TripsRpc(trips, {} as never, {} as never, {} as never, db, realtime(), guards, {} as never);
|
||||
return new PluginRpcHost('p', ALL, makeDeps(), createTestPluginRegistry([rpc]));
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ describe('every schema-validated method rejects a payload its schema refuses', (
|
||||
new PlacesRpc(anything, anything, realtime(), guards),
|
||||
new DaysRpc(anything, realtime(), guards),
|
||||
new PackingRpc(anything, realtime(), guards),
|
||||
new TripsRpc(anything, anything, anything, anything, db, realtime(), guards),
|
||||
new TripsRpc(anything, anything, anything, anything, db, realtime(), guards, anything),
|
||||
new AccommodationsRpc(anything, realtime(), guards),
|
||||
new ReservationsRpc(anything, realtime(), guards),
|
||||
]);
|
||||
|
||||
@@ -32,7 +32,7 @@ const tripsRegistry = () => {
|
||||
} as unknown as DatabaseService;
|
||||
const guards = new PluginGuards(db, {} as never, {} as never);
|
||||
return createTestPluginRegistry([
|
||||
new TripsRpc({} as never, {} as never, {} as never, {} as never, db, {} as never, guards),
|
||||
new TripsRpc({} as never, {} as never, {} as never, {} as never, db, {} as never, guards, {} as never),
|
||||
]);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user