The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(api): parse path ids with a rowId pipe that answers like an unknown id
Maurice3eac508baf66
diff --git a/server/src/nest/atlas/atlas.controller.ts b/server/src/nest/atlas/atlas.controller.tsindex 1f4830e61..b2b2fcbdf 100644--- a/server/src/nest/atlas/atlas.controller.ts+++ b/server/src/nest/atlas/atlas.controller.ts@@ -1,6 +1,7 @@import type { User } from '../../types';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';+import { rowId } from '../common/row-id.pipe';import { ZodValidationPipe } from '../common/zod-validation.pipe';import { getRegionGeoGz, getRegionGeoJson } from './atlas-geo';import { AtlasWritesService } from './atlas-writes.service';@@ -227,7 +228,7 @@ export class AtlasController {@Put('bucket-list/:id')async updateBucketItem(@CurrentUser() user: User,- @Param('id') id: string,+ @Param('id', rowId('Item not found')) id: number,@Body() body: AtlasUpdateBucketItemDto,@Headers('x-socket-id') socketId?: string,): Promise<{ item: unknown }> {@@ -253,7 +254,7 @@ export class AtlasController {@Delete('bucket-list/:id')async deleteBucketItem(@CurrentUser() user: User,- @Param('id') id: string,+ @Param('id', rowId('Item not found')) id: number,@Headers('x-socket-id') socketId?: string,): Promise<{ success: boolean }> {if (!(await this.writes.deleteBucketItem(user.id, id, socketId))) {diff --git a/server/src/nest/collections/collections.controller.ts b/server/src/nest/collections/collections.controller.tsindex ebe93db44..82f6e3a0e 100644--- a/server/src/nest/collections/collections.controller.ts+++ b/server/src/nest/collections/collections.controller.ts@@ -8,6 +8,8 @@ import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { isDemoWriteBlocked, DEMO_WRITE_ERROR } from '../common/demo-write';import { PLACE_IMAGE_FILE_FILTER } from '../common/place-image-upload';import { ResponseContract } from '../common/response-contract';+import { rowId } from '../common/row-id.pipe';+import { SpoolCleanupInterceptor } from '../common/spool-cleanup.interceptor';import { CollectionGpxError } from '../place-import/place-import.types';import { placeImageUrl } from '../places/place-image';import { PlaceRatingDto } from '../places/places.dto';@@ -193,45 +195,49 @@ export class CollectionsController {@Patch('places/:pid')updatePlace(@CurrentUser() user: User,- @Param('pid') pid: string,+ @Param('pid', rowId('Place not found')) pid: number,@Body() body: CollectionPlaceUpdateDto,@Headers('x-socket-id') socketId?: string,) {- return this.collections.updatePlace(user.id, Number(pid), body, socketId);+ return this.collections.updatePlace(user.id, pid, body, socketId);}@Post('places/:pid/status')@HttpCode(200)setStatus(@CurrentUser() user: User,- @Param('pid') pid: string,+ @Param('pid', rowId('Place not found')) pid: number,@Body() body: CollectionSetStatusDto,@Headers('x-socket-id') socketId?: string,) {- return this.collections.setStatus(user.id, Number(pid), body.status, socketId);+ return this.collections.setStatus(user.id, pid, body.status, socketId);}@Put('places/:pid/rating')setRating(@CurrentUser() user: User,- @Param('pid') pid: string,+ @Param('pid', rowId('Place not found')) pid: number,@Body() body: PlaceRatingDto,@Headers('x-socket-id') socketId?: string,) {- return this.collections.setRating(user.id, Number(pid), body.rating, socketId);+ return this.collections.setRating(user.id, pid, body.rating, socketId);}@Delete('places/:pid/rating')- clearRating(@CurrentUser() user: User, @Param('pid') pid: string, @Headers('x-socket-id') socketId?: string) {- return this.collections.setRating(user.id, Number(pid), null, socketId);+ clearRating(+ @CurrentUser() user: User,+ @Param('pid', rowId('Place not found')) pid: number,+ @Headers('x-socket-id') socketId?: string,+ ) {+ return this.collections.setRating(user.id, pid, null, socketId);}@Post('places/:pid/image')@HttpCode(200)- @UseInterceptors(FileInterceptor('image', { fileFilter: PLACE_IMAGE_FILE_FILTER }))+ @UseInterceptors(FileInterceptor('image', { fileFilter: PLACE_IMAGE_FILE_FILTER }), SpoolCleanupInterceptor)async uploadPlaceImage(@CurrentUser() user: User,- @Param('pid') pid: string,+ @Param('pid', rowId('Place not found')) pid: number,@UploadedFile() file: Express.Multer.File | undefined,@Headers('x-socket-id') socketId?: string,) {@@ -242,12 +248,16 @@ export class CollectionsController {// Commit the spooled upload to its final storage location (atomic// same-volume rename) before the DB row references the final path.await this.storage.put('places', file.filename, { tmpPath: file.path });- return this.collections.setPlaceImage(user.id, Number(pid), placeImageUrl(file.filename), socketId);+ return this.collections.setPlaceImage(user.id, pid, placeImageUrl(file.filename), socketId);}@Delete('places/:pid')- async deletePlace(@CurrentUser() user: User, @Param('pid') pid: string, @Headers('x-socket-id') socketId?: string) {- await this.collections.deletePlace(user.id, Number(pid), socketId);+ async deletePlace(+ @CurrentUser() user: User,+ @Param('pid', rowId('Place not found')) pid: number,+ @Headers('x-socket-id') socketId?: string,+ ) {+ await this.collections.deletePlace(user.id, pid, socketId);return { success: true };}@@ -309,16 +319,20 @@ export class CollectionsController {@Patch('labels/:lid')updateLabel(@CurrentUser() user: User,- @Param('lid') lid: string,+ @Param('lid', rowId('Label not found')) lid: number,@Body() body: CollectionLabelUpdateDto,@Headers('x-socket-id') socketId?: string,) {- return this.collections.updateLabel(user.id, Number(lid), body, socketId);+ return this.collections.updateLabel(user.id, lid, body, socketId);}@Delete('labels/:lid')- async deleteLabel(@CurrentUser() user: User, @Param('lid') lid: string, @Headers('x-socket-id') socketId?: string) {- await this.collections.deleteLabel(user.id, Number(lid), socketId);+ async deleteLabel(+ @CurrentUser() user: User,+ @Param('lid', rowId('Label not found')) lid: number,+ @Headers('x-socket-id') socketId?: string,+ ) {+ await this.collections.deleteLabel(user.id, lid, socketId);return { success: true };}@@ -450,19 +464,19 @@ export class CollectionsController {// ── /:id (declared last so static prefixes win) ─────────────────────────────@Get(':id/available-users')- async availableUsers(@CurrentUser() user: User, @Param('id') id: string) {- await this.collections.assertAccess(user.id, Number(id)); // 404 if not visible (no enumeration)- if (!(await this.collections.isOwner(user.id, Number(id)))) {+ async availableUsers(@CurrentUser() user: User, @Param('id', rowId('Collection not found')) id: number) {+ await this.collections.assertAccess(user.id, id); // 404 if not visible (no enumeration)+ if (!(await this.collections.isOwner(user.id, id))) {throw new HttpException({ error: 'Only the owner can manage members' }, 403);}- return { users: await this.collections.availableUsers(user.id, Number(id)) };+ return { users: await this.collections.availableUsers(user.id, id) };}@Post(':id/cover')- @UseInterceptors(FileInterceptor('cover', { fileFilter: COVER_FILE_FILTER }))+ @UseInterceptors(FileInterceptor('cover', { fileFilter: COVER_FILE_FILTER }), SpoolCleanupInterceptor)async uploadCover(@CurrentUser() user: User,- @Param('id') id: string,+ @Param('id', rowId('Collection not found')) id: number,@UploadedFile() file: Express.Multer.File | undefined,@Headers('x-socket-id') socketId?: string,) {@@ -474,7 +488,7 @@ export class CollectionsController {// same-volume rename) before the DB row references the final path.await this.storage.put('covers', file.filename, { tmpPath: file.path });const coverUrl = `/uploads/covers/${file.filename}`;- return this.collections.setCollectionCover(user.id, Number(id), coverUrl, socketId);+ return this.collections.setCollectionCover(user.id, id, coverUrl, socketId);}/** Preview for the bulk trip import: the trip's places plus, per place, the same@@ -486,8 +500,8 @@ export class CollectionsController {* filename decided by the server.*/@Get(':id/export')- exportCollection(@CurrentUser() user: User, @Param('id') id: string) {- return this.collections.exportCollection(user.id, Number(id));+ exportCollection(@CurrentUser() user: User, @Param('id', rowId('Collection not found')) id: number) {+ return this.collections.exportCollection(user.id, id);}/**@@ -497,15 +511,15 @@ export class CollectionsController {* no coordinates and were left out.*/@Get(':id/export/gpx')- exportCollectionGpx(@CurrentUser() user: User, @Param('id') id: string) {- return this.collections.exportCollectionGpx(user.id, Number(id));+ exportCollectionGpx(@CurrentUser() user: User, @Param('id', rowId('Collection not found')) id: number) {+ return this.collections.exportCollectionGpx(user.id, id);}/** The list as KML for Google My Maps (#1866), wrapped in JSON like the GPX above, for the same reasons. */@Get(':id/export/kml')@ResponseContract(collectionKmlExportSchema)- exportCollectionKml(@CurrentUser() user: User, @Param('id') id: string) {- return this.collections.exportCollectionKml(user.id, Number(id));+ exportCollectionKml(@CurrentUser() user: User, @Param('id', rowId('Collection not found')) id: number) {+ return this.collections.exportCollectionKml(user.id, id);}/**@@ -519,36 +533,44 @@ export class CollectionsController {@HttpCode(200)importIntoCollection(@CurrentUser() user: User,- @Param('id') id: string,+ @Param('id', rowId('Collection not found')) id: number,@Body() body: CollectionImportIntoDto,@Headers('x-socket-id') socketId?: string,) {- return this.collections.importIntoCollection(user.id, Number(id), body, socketId);+ return this.collections.importIntoCollection(user.id, id, body, socketId);}@Get(':id/importable/:tripId')- importable(@CurrentUser() user: User, @Param('id') id: string, @Param('tripId') tripId: string) {- return this.collections.importablePlaces(user.id, Number(id), Number(tripId));+ importable(+ @CurrentUser() user: User,+ @Param('id', rowId('Collection not found')) id: number,+ @Param('tripId', rowId('Trip not found')) tripId: number,+ ) {+ return this.collections.importablePlaces(user.id, id, tripId);}@Get(':id')- get(@CurrentUser() user: User, @Param('id') id: string) {- return this.collections.getCollection(user.id, Number(id));+ get(@CurrentUser() user: User, @Param('id', rowId('Collection not found')) id: number) {+ return this.collections.getCollection(user.id, id);}@Patch(':id')update(@CurrentUser() user: User,- @Param('id') id: string,+ @Param('id', rowId('Collection not found')) id: number,@Body() body: CollectionUpdateDto,@Headers('x-socket-id') socketId?: string,) {- return this.collections.updateCollection(user.id, Number(id), body, socketId);+ return this.collections.updateCollection(user.id, id, body, socketId);}@Delete(':id')- async remove(@CurrentUser() user: User, @Param('id') id: string, @Headers('x-socket-id') socketId?: string) {- await this.collections.deleteCollection(user.id, Number(id), socketId);+ async remove(+ @CurrentUser() user: User,+ @Param('id', rowId('Collection not found')) id: number,+ @Headers('x-socket-id') socketId?: string,+ ) {+ await this.collections.deleteCollection(user.id, id, socketId);return { success: true };}}diff --git a/server/src/nest/common/row-id.pipe.ts b/server/src/nest/common/row-id.pipe.tsnew file mode 100644index 000000000..2ffbd55fe--- /dev/null+++ b/server/src/nest/common/row-id.pipe.ts@@ -0,0 +1,57 @@+import { toRowId } from './row-id';+import { HttpException, Injectable, type PipeTransform } from '@nestjs/common';++/** What a route answers for a path id that names no row: its own status and error text. */+interface RowIdRefusal {+ status: number;+ error: string;+}++/**+ * Parses a route's row id param with `toRowId` before the handler sees it, and+ * answers a spelling it refuses the way the route answers an id that names no+ * row. `Number(id)` read '0x1', '1e0', '1.0' and '+1' as row 1 and 'abc' as+ * NaN, which Postgres refuses with an error while SQLite matches nothing; a+ * string handed on unparsed reached SQL, where Postgres 14 and 15 refuse the+ * cast and 16 and later read hex and underscores as a number. Through this pipe+ * every such spelling gets the same answer on every engine, and the handler+ * receives a number.+ *+ * `tests/e2e/route-row-ids.e2e.test.ts` sends those spellings to every route.+ */+@Injectable()+class RowIdPipe implements PipeTransform<unknown, number> {+ constructor(private readonly refusal: RowIdRefusal) {}++ transform(value: unknown): number {+ const id = toRowId(value);+ if (id === null) throw new HttpException({ error: this.refusal.error }, this.refusal.status);+ return id;+ }+}++/** `@Param('id', rowId('Journey not found')) id: number`: the route's not-found answer for a malformed id. */+export function rowId(error: string, status = 404): RowIdPipe {+ return new RowIdPipe({ status, error });+}++/**+ * In place of Nest's `ParseIntPipe`, which reads '-1', '-0' and a number past+ * 2^53 as integers, and Postgres refuses the last as out of range: its 400 and+ * message, with `toRowId`'s parse. `@Param('id', ParseRowIdPipe) id: number`.+ */+@Injectable()+export class ParseRowIdPipe extends RowIdPipe {+ constructor() {+ super({ status: 400, error: 'Validation failed (numeric string is expected)' });+ }+}++/**+ * The same parse for a whole number in the path that is not a row id but is+ * compared with an integer column all the same (a year, a day number):+ * `@Param('year', intParam('Invalid year', 400)) year: number`.+ */+export function intParam(error: string, status = 400): RowIdPipe {+ return new RowIdPipe({ status, error });+}diff --git a/server/src/nest/doc-sync/doc-sync.controller.ts b/server/src/nest/doc-sync/doc-sync.controller.tsindex b7d103ce7..600316afc 100644--- a/server/src/nest/doc-sync/doc-sync.controller.ts+++ b/server/src/nest/doc-sync/doc-sync.controller.ts@@ -4,6 +4,7 @@ import { AddonGuard } from '../addons/addon.guard';import { RequireAddon } from '../addons/require-addon.decorator';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';+import { rowId } from '../common/row-id.pipe';import { withRequestContext } from '../database/request-context';import { TripAccessGuard } from '../permissions/trip-access.guard';import { RealtimeService } from '../realtime/realtime.service';@@ -208,11 +209,11 @@ export class DocSyncController {@HttpCode(200)async deleteConnection(@Param('tripId') tripId: string,- @Param('connectionId') connectionId: string,+ @Param('connectionId', rowId('Connection not found')) connectionId: number,@CurrentUser() user: User,) {await this.assertCanManage(tripId, user);- const conn = await this.config.getConnection(Number(connectionId));+ const conn = await this.config.getConnection(connectionId);if (!conn || conn.trip_id !== Number(tripId)) throw new HttpException('Connection not found', 404);// Its bindings go with it (ON DELETE CASCADE), so read them first. Every// subscription TREK registered for one of them is taken down while the@@ -238,12 +239,12 @@ export class DocSyncController {@Get('connections/:connectionId/scopes')async listScopes(@Param('tripId') tripId: string,- @Param('connectionId') connectionId: string,+ @Param('connectionId', rowId('Connection not found')) connectionId: number,@CurrentUser() user: User,@Query('q') q?: string,) {await this.assertCanManage(tripId, user);- const conn = await this.config.getConnection(Number(connectionId));+ const conn = await this.config.getConnection(connectionId);if (!conn || conn.trip_id !== Number(tripId)) throw new HttpException('Connection not found', 404);const provider = this.registry.get(conn.provider_id);if (!provider) throw new HttpException('Provider not available', 400);@@ -255,12 +256,12 @@ export class DocSyncController {@Post('connections/:connectionId/scopes')async createScope(@Param('tripId') tripId: string,- @Param('connectionId') connectionId: string,+ @Param('connectionId', rowId('Connection not found')) connectionId: number,@CurrentUser() user: User,@Body() body: DocsyncScopeCreateDto,) {await this.assertCanManage(tripId, user);- const conn = await this.config.getConnection(Number(connectionId));+ const conn = await this.config.getConnection(connectionId);if (!conn || conn.trip_id !== Number(tripId)) throw new HttpException('Connection not found', 404);const provider = this.registry.get(conn.provider_id);if (!provider) throw new HttpException('Provider not available', 400);@@ -343,13 +344,13 @@ export class DocSyncController {@HttpCode(200)async updateLink(@Param('tripId') tripId: string,- @Param('linkId') linkId: string,+ @Param('linkId', rowId('Link not found')) linkId: number,@CurrentUser() user: User,@Body() body: DocsyncLinkUpdateDto,@Req() req: Request,) {await this.assertCanManage(tripId, user);- const link = await this.config.getLink(Number(linkId));+ const link = await this.config.getLink(linkId);if (!link || link.trip_id !== Number(tripId)) throw new HttpException('Link not found', 404);const updated = await this.config.updateLink(link.id, body);return await this.config.publicLink(updated ?? link, publicOrigin(req));@@ -357,9 +358,13 @@ export class DocSyncController {@Delete('links/:linkId')@HttpCode(200)- async deleteLink(@Param('tripId') tripId: string, @Param('linkId') linkId: string, @CurrentUser() user: User) {+ async deleteLink(+ @Param('tripId') tripId: string,+ @Param('linkId', rowId('Link not found')) linkId: number,+ @CurrentUser() user: User,+ ) {await this.assertCanManage(tripId, user);- const link = await this.config.getLink(Number(linkId));+ const link = await this.config.getLink(linkId);if (!link || link.trip_id !== Number(tripId)) throw new HttpException('Link not found', 404);const conn = await this.config.getConnection(link.connection_id);@@ -375,8 +380,12 @@ export class DocSyncController {@Post('links/:linkId/sync')@HttpCode(200)- async syncNow(@Param('tripId') tripId: string, @Param('linkId') linkId: string, @Body() body: DocsyncSyncNowDto) {- const link = await this.config.getLink(Number(linkId));+ async syncNow(+ @Param('tripId') tripId: string,+ @Param('linkId', rowId('Link not found')) linkId: number,+ @Body() body: DocsyncSyncNowDto,+ ) {+ const link = await this.config.getLink(linkId);if (!link || link.trip_id !== Number(tripId)) throw new HttpException('Link not found', 404);// An orphaned binding stays orphaned: its credential belongs to somebody who// is no longer on this trip. The run itself would stand down as well; this@@ -413,12 +422,12 @@ export class DocSyncController {@HttpCode(200)async resolve(@Param('tripId') tripId: string,- @Param('itemId') itemId: string,+ @Param('itemId', rowId('Item is not in conflict', 400)) itemId: number,@CurrentUser() user: User,@Body() body: DocsyncResolveConflictDto,) {await this.assertCanManage(tripId, user);- const ok = await this.sync.resolveConflict(Number(itemId), body.keep, Number(tripId));+ const ok = await this.sync.resolveConflict(itemId, body.keep, Number(tripId));if (!ok) throw new HttpException('Item is not in conflict', 400);return { success: true };}diff --git a/server/src/nest/journey-recordings/journey-day-import.controller.ts b/server/src/nest/journey-recordings/journey-day-import.controller.tsindex 82919406c..a132cd1e5 100644--- a/server/src/nest/journey-recordings/journey-day-import.controller.ts+++ b/server/src/nest/journey-recordings/journey-day-import.controller.ts@@ -5,6 +5,7 @@ import { RequireAddon } from '../addons/require-addon.decorator';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { ResponseContract } from '../common/response-contract';+import { rowId } from '../common/row-id.pipe';import { JourneyDayImportService } from './journey-day-import.service';import { dateParam } from './journey-recordings.controller';import { JourneyDayImportDto } from './journey-recordings.dto';@@ -27,8 +28,12 @@ export class JourneyDayImportController {@Post(':date/stays/review')@HttpCode(200)@ResponseContract(journeyDayStaysSchema)- async review(@CurrentUser() user: User, @Param('id') id: string, @Param('date') date: string) {- return await this.dayImport.review(user.id, Number(id), dateParam(date));+ async review(+ @CurrentUser() user: User,+ @Param('id', rowId('Journey not found')) id: number,+ @Param('date') date: string,+ ) {+ return await this.dayImport.review(user.id, id, dateParam(date));}@Post(':date/stays/import')@@ -36,11 +41,11 @@ export class JourneyDayImportController {@ResponseContract(journeyDayImportResultSchema)async takeOver(@CurrentUser() user: User,- @Param('id') id: string,+ @Param('id', rowId('Journey not found')) id: number,@Param('date') date: string,@Body() body: JourneyDayImportDto,@Headers('x-socket-id') socketId?: string,) {- return await this.dayImport.takeOver(user.id, Number(id), dateParam(date), body, socketId);+ return await this.dayImport.takeOver(user.id, id, dateParam(date), body, socketId);}}diff --git a/server/src/nest/journey-recordings/journey-recordings.controller.ts b/server/src/nest/journey-recordings/journey-recordings.controller.tsindex f50e363ae..b35f871af 100644--- a/server/src/nest/journey-recordings/journey-recordings.controller.ts+++ b/server/src/nest/journey-recordings/journey-recordings.controller.ts@@ -5,6 +5,7 @@ import { RequireAddon } from '../addons/require-addon.decorator';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { ResponseContract } from '../common/response-contract';+import { rowId } from '../common/row-id.pipe';import { JourneyRecordingPreviewDto, JourneyRecordingSaveDto } from './journey-recordings.dto';import { JourneyRecordingsService } from './journey-recordings.service';import {@@ -43,34 +44,38 @@ export class JourneyRecordingsController {@Get()@ResponseContract(journeyRecordedDaysResponseSchema)- async list(@CurrentUser() user: User, @Param('id') id: string) {- return { days: await this.recordings.list(user.id, Number(id)) };+ async list(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number) {+ return { days: await this.recordings.list(user.id, id) };}/** JRN-03: whether the journey prepares its recorded days, and how the caller's last runs went. */@Get('prep')@ResponseContract(journeyRecordingPrepSchema)- async prep(@CurrentUser() user: User, @Param('id') id: string) {- return await this.recordings.prepStatus(user.id, Number(id));+ async prep(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number) {+ return await this.recordings.prepStatus(user.id, id);}@Post('preview')@HttpCode(200)@ResponseContract(journeyRecordingPreviewSchema)- async preview(@CurrentUser() user: User, @Param('id') id: string, @Body() body: JourneyRecordingPreviewDto) {- return await this.recordings.preview(user.id, Number(id), body);+ async preview(+ @CurrentUser() user: User,+ @Param('id', rowId('Journey not found')) id: number,+ @Body() body: JourneyRecordingPreviewDto,+ ) {+ return await this.recordings.preview(user.id, id, body);}@Put(':date')@ResponseContract(journeyRecordingSaveResultSchema)async save(@CurrentUser() user: User,- @Param('id') id: string,+ @Param('id', rowId('Journey not found')) id: number,@Param('date') date: string,@Body() body: JourneyRecordingSaveDto,@Headers('x-socket-id') socketId?: string,) {- return await this.recordings.save(user.id, Number(id), dateParam(date), body, socketId);+ return await this.recordings.save(user.id, id, dateParam(date), body, socketId);}@Delete(':date')@@ -78,11 +83,11 @@ export class JourneyRecordingsController {@ResponseContract(successResponseSchema)async remove(@CurrentUser() user: User,- @Param('id') id: string,+ @Param('id', rowId('Journey not found')) id: number,@Param('date') date: string,@Headers('x-socket-id') socketId?: string,) {- await this.recordings.remove(user.id, Number(id), dateParam(date), socketId);+ await this.recordings.remove(user.id, id, dateParam(date), socketId);return { success: true as const };}}diff --git a/server/src/nest/journey/journey-book-design.controller.ts b/server/src/nest/journey/journey-book-design.controller.tsindex bea64e70d..11615cc71 100644--- a/server/src/nest/journey/journey-book-design.controller.ts+++ b/server/src/nest/journey/journey-book-design.controller.ts@@ -5,6 +5,7 @@ import { RequireAddon } from '../addons/require-addon.decorator';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { ResponseContract } from '../common/response-contract';+import { rowId } from '../common/row-id.pipe';import { BookDesignSelectionDto } from './journey-book-design.dto';import { JourneyBookDesignService } from './journey-book-design.service';import { Body, Controller, Get, HttpCode, Param, Put, UseGuards } from '@nestjs/common';@@ -27,8 +28,12 @@ export class JourneyBookDesignController {@Get(':designId')@ResponseContract(bookDesignDraftResponseSchema)- async draft(@CurrentUser() user: User, @Param('journeyId') journeyId: string, @Param('designId') designId: string) {- return this.designs.draftView(Number(journeyId), user.id, designId);+ async draft(+ @CurrentUser() user: User,+ @Param('journeyId', rowId('Journey not found')) journeyId: number,+ @Param('designId') designId: string,+ ) {+ return this.designs.draftView(journeyId, user.id, designId);}@Put(':designId/selection')@@ -36,10 +41,10 @@ export class JourneyBookDesignController {@ResponseContract(bookDesignSelectionResponseSchema)async select(@CurrentUser() user: User,- @Param('journeyId') journeyId: string,+ @Param('journeyId', rowId('Journey not found')) journeyId: number,@Param('designId') designId: string,@Body() body: BookDesignSelectionDto,) {- return this.designs.select(Number(journeyId), user.id, designId, body.spreadIds);+ return this.designs.select(journeyId, user.id, designId, body.spreadIds);}}diff --git a/server/src/nest/journey/journey-map.controller.ts b/server/src/nest/journey/journey-map.controller.tsindex 189c76095..b7ae64981 100644--- a/server/src/nest/journey/journey-map.controller.ts+++ b/server/src/nest/journey/journey-map.controller.ts@@ -5,6 +5,7 @@ import { RequireAddon } from '../addons/require-addon.decorator';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { ResponseContract } from '../common/response-contract';+import { rowId } from '../common/row-id.pipe';import { JourneyMapService } from './journey-map.service';import { Controller, Get, Param, UseGuards } from '@nestjs/common';import { journeyMapLayersResponseSchema } from '@trek/shared';@@ -23,7 +24,7 @@ export class JourneyMapController {@Get(':id/map-layers')@ResponseContract(journeyMapLayersResponseSchema)- async layers(@CurrentUser() user: User, @Param('id') id: string) {- return this.map.mapLayers(Number(id), user.id);+ async layers(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number) {+ return this.map.mapLayers(id, user.id);}}diff --git a/server/src/nest/journey/journey-public.controller.ts b/server/src/nest/journey/journey-public.controller.tsindex 5331cb7e9..d4f0116b1 100644--- a/server/src/nest/journey/journey-public.controller.ts+++ b/server/src/nest/journey/journey-public.controller.ts@@ -3,6 +3,7 @@ import { AddonGuard } from '../addons/addon.guard';import { RequireAddon } from '../addons/require-addon.decorator';import { Public } from '../auth-core/public.decorator';import { ResponseContract } from '../common/response-contract';+import { rowId } from '../common/row-id.pipe';import { StorageService } from '../storage/storage.service';import { JourneyService } from './journey.service';import { Controller, Get, HttpException, Param, Res, UseGuards } from '@nestjs/common';@@ -61,20 +62,15 @@ export class JourneyPublicController {@Get(':token/photos/:photoId/:kind')async photo(@Param('token') token: string,- @Param('photoId') photoId: string,+ @Param('photoId', rowId('Not found')) photoId: number,@Param('kind') kind: string,@Res() res: Response,): Promise<void> {- const valid = await this.journey.validateShareTokenForPhoto(token, Number(photoId));+ const valid = await this.journey.validateShareTokenForPhoto(token, photoId);if (!valid) {throw new HttpException({ error: 'Not found' }, 404);}- await this.journey.streamPhoto(- res,- valid.ownerId,- Number(photoId),- kind === 'thumbnail' ? 'thumbnail' : 'original',- );+ await this.journey.streamPhoto(res, valid.ownerId, photoId, kind === 'thumbnail' ? 'thumbnail' : 'original');}@Get(':token/photo/:provider/:assetId/:ownerId/:kind')diff --git a/server/src/nest/journey/journey.controller.ts b/server/src/nest/journey/journey.controller.tsindex 0d137747b..c61142a01 100644--- a/server/src/nest/journey/journey.controller.ts+++ b/server/src/nest/journey/journey.controller.ts@@ -47,6 +47,8 @@ import { isVideoMime, isVideoExtension, MAX_VIDEO_SIZE } from '../files/files.coimport { AllowedFileTypesService } from '../files/allowed-file-types.service';import { logError } from '../audit/audit-log.logger';import { ResponseContract } from '../common/response-contract';+import { rowId } from '../common/row-id.pipe';+import { toRowId, withRowId } from '../common/row-id';import {emptyResponseSchema,journeyListResponseSchema,@@ -248,7 +250,8 @@ export class JourneyController {// permissive so that guard keeps answering, not the pipe.title: (body.title as string).trim(),subtitle: body.subtitle as string | undefined,- trip_ids: Array.isArray(body.trip_ids) ? body.trip_ids.map(Number) : [],+ // A trip id toRowId refuses names no trip, so it links none, like an id the user cannot open.+ trip_ids: Array.isArray(body.trip_ids) ? body.trip_ids.map(toRowId).filter((id): id is number => id !== null) : [],}, socketId);}@@ -264,8 +267,8 @@ export class JourneyController {// ── Entries (prefix /entries — before /:id) ─────────────────────────────@Patch('entries/:entryId')- async updateEntry(@CurrentUser() user: User, @Param('entryId') entryId: string, @Body() body: JourneyEntryUpdateDto, @Headers('x-socket-id') socketId?: string) {- const result = await this.journey.updateEntry(Number(entryId), user.id, body, socketId);+ async updateEntry(@CurrentUser() user: User, @Param('entryId', rowId('Entry not found')) entryId: number, @Body() body: JourneyEntryUpdateDto, @Headers('x-socket-id') socketId?: string) {+ const result = await this.journey.updateEntry(entryId, user.id, body, socketId);if (!result) {throw new HttpException({ error: 'Entry not found' }, 404);}@@ -274,8 +277,8 @@ export class JourneyController {@Put('entries/:entryId/photos/reorder')@ResponseContract(successResponseSchema)- async reorderEntryPhotos(@CurrentUser() user: User, @Param('entryId') entryId: string, @Body() body: JourneyReorderEntryPhotosDto, @Headers('x-socket-id') socketId?: string) {- if (!(await this.journey.reorderEntryPhotos(Number(entryId), user.id, body.orderedIds, socketId))) {+ async reorderEntryPhotos(@CurrentUser() user: User, @Param('entryId', rowId('Entry not found')) entryId: number, @Body() body: JourneyReorderEntryPhotosDto, @Headers('x-socket-id') socketId?: string) {+ if (!(await this.journey.reorderEntryPhotos(entryId, user.id, body.orderedIds, socketId))) {throw new HttpException({ error: 'Entry not found' }, 404);}return { success: true };@@ -283,8 +286,8 @@ export class JourneyController {@Delete('entries/:entryId')@ResponseContract(successResponseSchema)- async deleteEntry(@CurrentUser() user: User, @Param('entryId') entryId: string, @Headers('x-socket-id') socketId?: string) {- if (!(await this.journey.deleteEntry(Number(entryId), user.id, socketId))) {+ async deleteEntry(@CurrentUser() user: User, @Param('entryId', rowId('Entry not found')) entryId: number, @Headers('x-socket-id') socketId?: string) {+ if (!(await this.journey.deleteEntry(entryId, user.id, socketId))) {throw new HttpException({ error: 'Entry not found' }, 404);}return { success: true };@@ -304,7 +307,7 @@ export class JourneyController {const refused: Express.Multer.File[] = [];for (const file of files) {const relativePath = `journey/${file.filename}`;- const photo = await this.journey.addPhoto(Number(entryId), user.id, relativePath, undefined, body?.caption as string | undefined);+ const photo = await withRowId(entryId, (id) => this.journey.addPhoto(id, user.id, relativePath, undefined, body?.caption as string | undefined));if (!photo) {// No row points at this file, so nothing would ever clean it up.refused.push(file);@@ -372,14 +375,14 @@ export class JourneyController {}await this.commitJourneyUploads(poster ? [video, poster] : [video]);const durationMs = body?.duration_ms != null ? Number(body.duration_ms) : null;- const photo = await this.journey.addPhoto(- Number(entryId),+ const photo = await withRowId(entryId, (id) => this.journey.addPhoto(+ id,user.id,`journey/${video.filename}`,poster ? `journey/${poster.filename}` : undefined,undefined,{ mediaType: 'video', durationMs: durationMs != null && Number.isFinite(durationMs) ? durationMs : null },- );+ ));if (!photo) {// Committed already, so the pre-commit unlink would orphan the bytes.await this.storage.delete('journey', video.filename).catch(() => {});@@ -390,8 +393,8 @@ export class JourneyController {}@Post('entries/:entryId/provider-photos')- async providerPhotos(@CurrentUser() user: User, @Param('entryId') entryId: string, @Body() body: JourneyProviderPhotosDto, @Headers('x-socket-id') socketId?: string) {- return this.addProviderPhotos({ entryId: Number(entryId) }, user, body, socketId);+ async providerPhotos(@CurrentUser() user: User, @Param('entryId', rowId('Not allowed or duplicate', 403)) entryId: number, @Body() body: JourneyProviderPhotosDto, @Headers('x-socket-id') socketId?: string) {+ return this.addProviderPhotos({ entryId: entryId }, user, body, socketId);}/**@@ -421,12 +424,12 @@ export class JourneyController {}@Post('entries/:entryId/link-photo')- async linkPhoto(@CurrentUser() user: User, @Param('entryId') entryId: string, @Body() body: JourneyLinkPhotoDto, @Headers('x-socket-id') socketId?: string) {- const journeyPhotoId = body.journey_photo_id ?? body.photo_id;+ async linkPhoto(@CurrentUser() user: User, @Param('entryId', rowId('Not allowed', 403)) entryId: number, @Body() body: JourneyLinkPhotoDto, @Headers('x-socket-id') socketId?: string) {+ const journeyPhotoId = toRowId(body.journey_photo_id ?? body.photo_id);if (!journeyPhotoId) {throw new HttpException({ error: 'journey_photo_id required' }, 400);}- const result = await this.photoLinks.link(Number(entryId), Number(journeyPhotoId), user.id, socketId);+ const result = await this.photoLinks.link(entryId, journeyPhotoId, user.id, socketId);if (!result) {throw new HttpException({ error: 'Not allowed' }, 403);}@@ -437,22 +440,22 @@ export class JourneyController {@Post('entries/:entryId/photos/move')@HttpCode(200)@ResponseContract(journeyPhotosMoveResponseSchema)- async movePhotos(@CurrentUser() user: User, @Param('entryId') entryId: string, @Body() body: JourneyPhotosMoveDto, @Headers('x-socket-id') socketId?: string) {- return this.photoLinks.move(Number(entryId), body, user.id, socketId);+ async movePhotos(@CurrentUser() user: User, @Param('entryId', rowId('Entry not found')) entryId: number, @Body() body: JourneyPhotosMoveDto, @Headers('x-socket-id') socketId?: string) {+ return this.photoLinks.move(entryId, body, user.id, socketId);}@Delete('entries/:entryId/photos/:journeyPhotoId')@HttpCode(204)@ResponseContract(emptyResponseSchema)- async unlinkPhoto(@CurrentUser() user: User, @Param('entryId') entryId: string, @Param('journeyPhotoId') journeyPhotoId: string, @Headers('x-socket-id') socketId?: string): Promise<void> {- if (!(await this.photoLinks.unlink(Number(entryId), Number(journeyPhotoId), user.id, socketId))) {+ async unlinkPhoto(@CurrentUser() user: User, @Param('entryId', rowId('Not found or not allowed')) entryId: number, @Param('journeyPhotoId', rowId('Not found or not allowed')) journeyPhotoId: number, @Headers('x-socket-id') socketId?: string): Promise<void> {+ if (!(await this.photoLinks.unlink(entryId, journeyPhotoId, user.id, socketId))) {throw new HttpException({ error: 'Not found or not allowed' }, 404);}}@Patch('photos/:photoId')- async updatePhoto(@CurrentUser() user: User, @Param('photoId') photoId: string, @Body() body: JourneyPhotoUpdateDto, @Headers('x-socket-id') socketId?: string) {- const result = await this.photoLinks.updatePhoto(Number(photoId), user.id, body, socketId);+ async updatePhoto(@CurrentUser() user: User, @Param('photoId', rowId('Photo not found')) photoId: number, @Body() body: JourneyPhotoUpdateDto, @Headers('x-socket-id') socketId?: string) {+ const result = await this.photoLinks.updatePhoto(photoId, user.id, body, socketId);if (!result) {throw new HttpException({ error: 'Photo not found' }, 404);}@@ -461,8 +464,8 @@ export class JourneyController {@Delete('photos/:photoId')@ResponseContract(successResponseSchema)- async deletePhoto(@CurrentUser() user: User, @Param('photoId') photoId: string) {- const photo = await this.journey.deletePhoto(Number(photoId), user.id);+ async deletePhoto(@CurrentUser() user: User, @Param('photoId', rowId('Photo not found')) photoId: number) {+ const photo = await this.journey.deletePhoto(photoId, user.id);if (!photo) {throw new HttpException({ error: 'Photo not found' }, 404);}@@ -490,7 +493,7 @@ export class JourneyController {}await this.commitJourneyUploads(files);const filePaths = files.map((f) => ({ path: `journey/${f.filename}` }));- const photos = await this.journey.uploadGalleryPhotos(Number(id), user.id, filePaths);+ const photos = (await withRowId(id, (journeyId) => this.journey.uploadGalleryPhotos(journeyId, user.id, filePaths))) ?? [];if (!photos.length) {await this.discardJourneyUploads(files);throw new HttpException({ error: 'Not allowed' }, 403);@@ -531,12 +534,12 @@ export class JourneyController {}await this.commitJourneyUploads(poster ? [video, poster] : [video]);const durationMs = body?.duration_ms != null ? Number(body.duration_ms) : null;- const photos = await this.journey.uploadGalleryPhotos(Number(id), user.id, [{+ const photos = (await withRowId(id, (journeyId) => this.journey.uploadGalleryPhotos(journeyId, user.id, [{path: `journey/${video.filename}`,thumbnail: poster ? `journey/${poster.filename}` : undefined,mediaType: 'video',durationMs: durationMs != null && Number.isFinite(durationMs) ? durationMs : null,- }]);+ }]))) ?? [];if (!photos.length) {// The parts are already committed (file.path is consumed), so the// pre-commit unlink cleanup would silently orphan them — delete the@@ -549,15 +552,15 @@ export class JourneyController {}@Post(':id/gallery/provider-photos')- async galleryProviderPhotos(@CurrentUser() user: User, @Param('id') id: string, @Body() body: JourneyProviderPhotosDto, @Headers('x-socket-id') socketId?: string) {- return this.addProviderPhotos({ journeyId: Number(id) }, user, body, socketId);+ async galleryProviderPhotos(@CurrentUser() user: User, @Param('id', rowId('Not allowed or duplicate', 403)) id: number, @Body() body: JourneyProviderPhotosDto, @Headers('x-socket-id') socketId?: string) {+ return this.addProviderPhotos({ journeyId: id }, user, body, socketId);}@Delete(':id/gallery/:journeyPhotoId')@HttpCode(204)@ResponseContract(emptyResponseSchema)- async deleteGalleryPhoto(@CurrentUser() user: User, @Param('journeyPhotoId') journeyPhotoId: string): Promise<void> {- const photo = await this.journey.deleteGalleryPhoto(Number(journeyPhotoId), user.id);+ async deleteGalleryPhoto(@CurrentUser() user: User, @Param('journeyPhotoId', rowId('Photo not found or not allowed')) journeyPhotoId: number): Promise<void> {+ const photo = await this.journey.deleteGalleryPhoto(journeyPhotoId, user.id);if (!photo) {throw new HttpException({ error: 'Photo not found or not allowed' }, 404);}@@ -566,8 +569,8 @@ export class JourneyController {// ── Journeys /:id ───────────────────────────────────────────────────────@Get(':id')- async get(@CurrentUser() user: User, @Param('id') id: string) {- const data = await this.journey.getJourneyFull(Number(id), user.id);+ async get(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number) {+ const data = await this.journey.getJourneyFull(id, user.id);if (!data) {throw new HttpException({ error: 'Journey not found' }, 404);}@@ -575,8 +578,8 @@ export class JourneyController {}@Patch(':id')- async update(@CurrentUser() user: User, @Param('id') id: string, @Body() body: JourneyUpdateDto, @Headers('x-socket-id') socketId?: string) {- const result = await this.journey.updateJourney(Number(id), user.id, body, socketId);+ async update(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number, @Body() body: JourneyUpdateDto, @Headers('x-socket-id') socketId?: string) {+ const result = await this.journey.updateJourney(id, user.id, body, socketId);if (!result) {throw new HttpException({ error: 'Journey not found' }, 404);}@@ -592,7 +595,7 @@ export class JourneyController {throw new HttpException({ error: 'No file uploaded' }, 400);}await this.commitJourneyUploads([file]);- const result = await this.journey.updateJourney(Number(id), user.id, { cover_image: `journey/${file.filename}` }, socketId);+ const result = await withRowId(id, (journeyId) => this.journey.updateJourney(journeyId, user.id, { cover_image: `journey/${file.filename}` }, socketId));if (!result) {await this.discardJourneyUploads([file]);throw new HttpException({ error: 'Journey not found' }, 404);@@ -602,8 +605,8 @@ export class JourneyController {@Delete(':id')@ResponseContract(successResponseSchema)- async remove(@CurrentUser() user: User, @Param('id') id: string, @Headers('x-socket-id') socketId?: string) {- if (!(await this.journey.deleteJourney(Number(id), user.id, socketId))) {+ async remove(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number, @Headers('x-socket-id') socketId?: string) {+ if (!(await this.journey.deleteJourney(id, user.id, socketId))) {throw new HttpException({ error: 'Journey not found' }, 404);}return { success: true };@@ -613,11 +616,13 @@ export class JourneyController {@Post(':id/trips')@HttpCode(200) // Express answers with res.json (200).@ResponseContract(successResponseSchema)- async addTrip(@CurrentUser() user: User, @Param('id') id: string, @Body() body: JourneyAddTripDto) {- if (!body.trip_id) {+ async addTrip(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number, @Body() body: JourneyAddTripDto) {+ // A body id toRowId refuses ('5e0', '0x5') is no id, as on every route.+ const tripId = toRowId(body.trip_id);+ if (!tripId) {throw new HttpException({ error: 'trip_id required' }, 400);}- if (!(await this.journey.addTripToJourney(Number(id), Number(body.trip_id), user.id))) {+ if (!(await this.journey.addTripToJourney(id, tripId, user.id))) {throw new HttpException({ error: 'Not allowed' }, 403);}return { success: true };@@ -625,8 +630,8 @@ export class JourneyController {@Delete(':id/trips/:tripId')@ResponseContract(successResponseSchema)- async removeTrip(@CurrentUser() user: User, @Param('id') id: string, @Param('tripId') tripId: string, @Headers('x-socket-id') socketId?: string) {- if (!(await this.journey.removeTripFromJourney(Number(id), Number(tripId), user.id, socketId))) {+ async removeTrip(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number, @Param('tripId', rowId('Not allowed', 403)) tripId: number, @Headers('x-socket-id') socketId?: string) {+ if (!(await this.journey.removeTripFromJourney(id, tripId, user.id, socketId))) {throw new HttpException({ error: 'Not allowed' }, 403);}return { success: true };@@ -634,8 +639,8 @@ export class JourneyController {// ── Entries under journey ───────────────────────────────────────────────@Get(':id/entries')- async listEntries(@CurrentUser() user: User, @Param('id') id: string) {- const entries = await this.journey.listEntries(Number(id), user.id);+ async listEntries(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number) {+ const entries = await this.journey.listEntries(id, user.id);if (!entries) {throw new HttpException({ error: 'Journey not found' }, 404);}@@ -649,8 +654,8 @@ export class JourneyController {*/@Get(':id/tracks')@ResponseContract(journeyTracksResponseSchema)- async listTracks(@CurrentUser() user: User, @Param('id') id: string) {- const tracks = await this.journey.journeyTracks(Number(id), user.id);+ async listTracks(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number) {+ const tracks = await this.journey.journeyTracks(id, user.id);if (!tracks) {throw new HttpException({ error: 'Journey not found' }, 404);}@@ -668,8 +673,8 @@ export class JourneyController {*/@Get(':id/stats')@ResponseContract(journeyStatsSchema)- async stats(@CurrentUser() user: User, @Param('id') id: string) {- const stats = await this.journey.journeyStats(Number(id), user.id);+ async stats(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number) {+ const stats = await this.journey.journeyStats(id, user.id);if (!stats) {throw new HttpException({ error: 'Journey not found' }, 404);}@@ -685,9 +690,9 @@ export class JourneyController {*/@Get(':id/book')- async getBook(@CurrentUser() user: User, @Param('id') id: string) {- const book = await this.books.getBook(Number(id), user.id);- if (book === null && !(await this.books.canOpen(Number(id), user.id))) {+ async getBook(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number) {+ const book = await this.books.getBook(id, user.id);+ if (book === null && !(await this.books.canOpen(id, user.id))) {throw new HttpException({ error: 'Journey not found' }, 404);}// A journey with no book yet is not an error: Studio opens, lays one out@@ -700,19 +705,19 @@ export class JourneyController {@HttpCode(200)async saveBook(@CurrentUser() user: User,- @Param('id') id: string,+ @Param('id', rowId('Journey not found')) id: number,@Body() body: BookSaveDto,@Headers('x-socket-id') socketId?: string,) {// The service announces the save after its commit, leaving out this tab.const result = await this.books.saveBook(- Number(id),+ id,user.id,{ title: body.title ?? '', document: body.document, baseVersion: body.baseVersion },{ socketId },);if (result === null) {- throw await this.bookRefusal(Number(id), user.id);+ throw await this.bookRefusal(id, user.id);}if ('conflict' in result) {/*@@ -734,10 +739,10 @@ export class JourneyController {@Delete(':id/book')@HttpCode(204)@ResponseContract(emptyResponseSchema)- async deleteBook(@CurrentUser() user: User, @Param('id') id: string) {- const removed = await this.books.deleteBook(Number(id), user.id);+ async deleteBook(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number) {+ const removed = await this.books.deleteBook(id, user.id);if (removed === null) {- throw await this.bookRefusal(Number(id), user.id);+ throw await this.bookRefusal(id, user.id);}}@@ -756,11 +761,11 @@ export class JourneyController {}@Post(':id/entries')- async createEntry(@CurrentUser() user: User, @Param('id') id: string, @Body() body: JourneyEntryCreateDto, @Headers('x-socket-id') socketId?: string) {+ async createEntry(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number, @Body() body: JourneyEntryCreateDto, @Headers('x-socket-id') socketId?: string) {if (!body.entry_date) {throw new HttpException({ error: 'entry_date is required' }, 400);}- const entry = await this.journey.createEntry(Number(id), user.id, body, socketId);+ const entry = await this.journey.createEntry(id, user.id, body, socketId);if (!entry) {throw new HttpException({ error: 'Journey not found' }, 404);}@@ -769,12 +774,13 @@ export class JourneyController {@Put(':id/entries/reorder')@ResponseContract(successResponseSchema)- async reorderEntries(@CurrentUser() user: User, @Param('id') id: string, @Body() body: JourneyReorderEntriesDto, @Headers('x-socket-id') socketId?: string) {+ async reorderEntries(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number, @Body() body: JourneyReorderEntriesDto, @Headers('x-socket-id') socketId?: string) {const orderedIds = body.orderedIds;- if (!Array.isArray(orderedIds) || !orderedIds.every((v) => Number.isFinite(Number(v)))) {+ const entryIds = Array.isArray(orderedIds) ? orderedIds.map(toRowId) : null;+ if (!entryIds?.every((v) => v !== null)) {throw new HttpException({ error: 'orderedIds must be an array of numbers' }, 400);}- if (!(await this.journey.reorderEntries(Number(id), user.id, orderedIds.map(Number), socketId))) {+ if (!(await this.journey.reorderEntries(id, user.id, entryIds as number[], socketId))) {throw new HttpException({ error: 'Not allowed' }, 403);}return { success: true };@@ -783,11 +789,12 @@ export class JourneyController {// ── Contributors ────────────────────────────────────────────────────────@Post(':id/contributors')@ResponseContract(successResponseSchema)- async addContributor(@CurrentUser() user: User, @Param('id') id: string, @Body() body: JourneyContributorAddDto) {- if (!body.user_id) {+ async addContributor(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number, @Body() body: JourneyContributorAddDto) {+ const contributorId = toRowId(body.user_id);+ if (!contributorId) {throw new HttpException({ error: 'user_id required' }, 400);}- if (!(await this.journey.addContributor(Number(id), user.id, Number(body.user_id), (body.role as 'editor' | 'viewer') || 'viewer'))) {+ if (!(await this.journey.addContributor(id, user.id, contributorId, (body.role as 'editor' | 'viewer') || 'viewer'))) {throw new HttpException({ error: 'Not allowed' }, 403);}return { success: true };@@ -795,8 +802,8 @@ export class JourneyController {@Patch(':id/contributors/:userId')@ResponseContract(successResponseSchema)- async updateContributor(@CurrentUser() user: User, @Param('id') id: string, @Param('userId') userId: string, @Body() body: JourneyContributorUpdateDto) {- if (!(await this.journey.updateContributorRole(Number(id), user.id, Number(userId), body.role as 'editor' | 'viewer'))) {+ async updateContributor(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number, @Param('userId', rowId('Not allowed', 403)) userId: number, @Body() body: JourneyContributorUpdateDto) {+ if (!(await this.journey.updateContributorRole(id, user.id, userId, body.role as 'editor' | 'viewer'))) {throw new HttpException({ error: 'Not allowed' }, 403);}return { success: true };@@ -804,8 +811,8 @@ export class JourneyController {@Delete(':id/contributors/:userId')@ResponseContract(successResponseSchema)- async removeContributor(@CurrentUser() user: User, @Param('id') id: string, @Param('userId') userId: string) {- if (!(await this.journey.removeContributor(Number(id), user.id, Number(userId)))) {+ async removeContributor(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number, @Param('userId', rowId('Not allowed', 403)) userId: number) {+ if (!(await this.journey.removeContributor(id, user.id, userId))) {throw new HttpException({ error: 'Not allowed' }, 403);}return { success: true };@@ -814,8 +821,8 @@ export class JourneyController {// ── Suggestions ─────────────────────────────────────────────────────────@Post(':id/suggestions/restore')@HttpCode(200)- async restoreSuggestions(@CurrentUser() user: User, @Param('id') id: string, @Headers('x-socket-id') socketId?: string) {- const result = await this.journey.restoreDismissedSuggestions(Number(id), user.id, socketId);+ async restoreSuggestions(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number, @Headers('x-socket-id') socketId?: string) {+ const result = await this.journey.restoreDismissedSuggestions(id, user.id, socketId);if (!result) {throw new HttpException({ error: 'Not allowed' }, 403);}@@ -824,8 +831,8 @@ export class JourneyController {// ── User Preferences ────────────────────────────────────────────────────@Patch(':id/preferences')- async preferences(@CurrentUser() user: User, @Param('id') id: string, @Body() body: JourneyPreferencesDto, @Headers('x-socket-id') socketId?: string) {- const result = await this.journey.updateJourneyPreferences(Number(id), user.id, body, socketId);+ async preferences(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number, @Body() body: JourneyPreferencesDto, @Headers('x-socket-id') socketId?: string) {+ const result = await this.journey.updateJourneyPreferences(id, user.id, body, socketId);if (!result) {throw new HttpException({ error: 'Not allowed' }, 403);}@@ -835,12 +842,12 @@ export class JourneyController {// ── Share Link ──────────────────────────────────────────────────────────@Get(':id/share-link')@ResponseContract(journeyShareLinkResponseSchema)- async getShareLink(@CurrentUser() user: User, @Param('id') id: string) {+ async getShareLink(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number) {// Reading the token is owner-only. It refuses like its siblings rather than// answering with a null link: "not published" and "not yours to see" are// different answers, and a client told the first one offers a create button// that the POST below then refuses.- const result = await this.journey.getJourneyShareLink(Number(id), user.id);+ const result = await this.journey.getJourneyShareLink(id, user.id);if (!result.allowed) {throw new HttpException({ error: 'Not allowed' }, 403);}@@ -850,8 +857,8 @@ export class JourneyController {@Post(':id/share-link')@HttpCode(200) // Express answers with res.json (200).@ResponseContract(journeyShareLinkSetResponseSchema)- async setShareLink(@CurrentUser() user: User, @Param('id') id: string, @Body() body: JourneyShareLinkDto) {- const result = await this.journey.createOrUpdateJourneyShareLink(Number(id), user.id, {+ async setShareLink(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number, @Body() body: JourneyShareLinkDto) {+ const result = await this.journey.createOrUpdateJourneyShareLink(id, user.id, {share_timeline: body.share_timeline as boolean | undefined,share_gallery: body.share_gallery as boolean | undefined,share_map: body.share_map as boolean | undefined,@@ -867,8 +874,8 @@ export class JourneyController {@Delete(':id/share-link')@ResponseContract(successResponseSchema)- async deleteShareLink(@CurrentUser() user: User, @Param('id') id: string) {- if (!(await this.journey.deleteJourneyShareLink(Number(id), user.id))) {+ async deleteShareLink(@CurrentUser() user: User, @Param('id', rowId('Not allowed', 403)) id: number) {+ if (!(await this.journey.deleteJourneyShareLink(id, user.id))) {throw new HttpException({ error: 'Not allowed' }, 403);}return { success: true };diff --git a/server/src/nest/plugins/plugins.controller.ts b/server/src/nest/plugins/plugins.controller.tsindex 5516d23b9..34e42a138 100644--- a/server/src/nest/plugins/plugins.controller.ts+++ b/server/src/nest/plugins/plugins.controller.ts@@ -8,6 +8,7 @@ import { AdminGuard } from '../auth-core/admin.guard';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { ManagedForbidden, isManagedBlocked, MANAGED_FORBIDDEN_ERROR } from '../common/managed';+import { rowId } from '../common/row-id.pipe';import { DependencyCycleError } from './dependencies';import { devLinkEnabled } from './dev-link';import { pluginsEnabled } from './kill-switch';@@ -430,9 +431,8 @@ export class PluginsController {* user, for an admin fulfilling a data-access request. Literal-prefixed path, so it* never collides with the :id routes. */@Get('user-data/:userId/export')- async exportUserData(@Param('userId') userId: string) {- const id = Number(userId);- if (!Number.isInteger(id) || id <= 0) throw new HttpException({ error: 'invalid user id' }, 400);+ async exportUserData(@Param('userId', rowId('invalid user id', 400)) id: number) {+ if (id <= 0) throw new HttpException({ error: 'invalid user id' }, 400);return { userId: id, plugins: await this.runtime.exportUserData(id) };}diff --git a/server/src/nest/roadtrip/charging.controller.ts b/server/src/nest/roadtrip/charging.controller.tsindex 3c25941a0..04886c53c 100644--- a/server/src/nest/roadtrip/charging.controller.ts+++ b/server/src/nest/roadtrip/charging.controller.ts@@ -2,9 +2,10 @@ import { ADDON_IDS } from '../../addons';import { AddonGuard } from '../addons/addon.guard';import { RequireAddon } from '../addons/require-addon.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';+import { ParseRowIdPipe } from '../common/row-id.pipe';import { TripAccessGuard } from '../permissions/trip-access.guard';import { ChargingService } from './charging.service';-import { Controller, Get, Param, ParseIntPipe, UseGuards } from '@nestjs/common';+import { Controller, Get, Param, UseGuards } from '@nestjs/common';@Controller('api/trips/:tripId/roadtrip/charging')@UseGuards(AddonGuard, JwtAuthGuard, TripAccessGuard)@@ -12,7 +13,7 @@ import { Controller, Get, Param, ParseIntPipe, UseGuards } from '@nestjs/common'export class ChargingController {constructor(private readonly charging: ChargingService) {}@Get(':placeId')- read(@Param('tripId', ParseIntPipe) tripId: number, @Param('placeId', ParseIntPipe) placeId: number) {+ read(@Param('tripId', ParseRowIdPipe) tripId: number, @Param('placeId', ParseRowIdPipe) placeId: number) {return this.charging.read(tripId, placeId);}}diff --git a/server/src/nest/roadtrip/day-boundaries.controller.ts b/server/src/nest/roadtrip/day-boundaries.controller.tsindex 0a3af3943..b16a998ab 100644--- a/server/src/nest/roadtrip/day-boundaries.controller.ts+++ b/server/src/nest/roadtrip/day-boundaries.controller.ts@@ -2,10 +2,11 @@ import { ADDON_IDS } from '../../addons';import { AddonGuard } from '../addons/addon.guard';import { RequireAddon } from '../addons/require-addon.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';+import { ParseRowIdPipe } from '../common/row-id.pipe';import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.guard';import { RealtimeService } from '../realtime/realtime.service';import { DayBoundariesService } from './day-boundaries.service';-import { Body, Controller, Delete, Get, Headers, Param, ParseIntPipe, Put, UseGuards } from '@nestjs/common';+import { Body, Controller, Delete, Get, Headers, Param, Put, UseGuards } from '@nestjs/common';import { roadtripDayBoundarySchema } from '@trek/shared';import { createZodDto } from 'nestjs-zod';@@ -38,7 +39,7 @@ export class DayBoundariesController {@RequirePermission('day_edit')async remove(@Param('tripId') tripId: string,- @Param('dayNumber', ParseIntPipe) dayNumber: number,+ @Param('dayNumber', ParseRowIdPipe) dayNumber: number,@Headers('x-socket-id') socketId?: string,) {const boundaries = await this.boundaries.remove(tripId, dayNumber);diff --git a/server/src/nest/school-holidays/school-holidays.controller.ts b/server/src/nest/school-holidays/school-holidays.controller.tsindex 992c44308..7a68a307a 100644--- a/server/src/nest/school-holidays/school-holidays.controller.ts+++ b/server/src/nest/school-holidays/school-holidays.controller.ts@@ -1,19 +1,8 @@import { AdminGuard } from '../auth-core/admin.guard';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';+import { ParseRowIdPipe } from '../common/row-id.pipe';import { SchoolHolidaysService } from './school-holidays.service';-import {- Body,- Controller,- Delete,- Get,- Param,- ParseIntPipe,- Post,- Put,- Query,- UseGuards,- BadRequestException,-} from '@nestjs/common';+import { Body, Controller, Delete, Get, Param, Post, Put, Query, UseGuards, BadRequestException } from '@nestjs/common';import { schoolHolidayCountryRequestSchema, schoolHolidayRegionRequestSchema } from '@trek/shared';import { createZodDto } from 'nestjs-zod';@@ -32,12 +21,12 @@ export class SchoolHolidaysController {}@Get('regions/:id')- async region(@Param('id', ParseIntPipe) id: number) {+ async region(@Param('id', ParseRowIdPipe) id: number) {return this.holidays.region(id);}@Get('regions/:id/holidays/:year')- async forYear(@Param('id', ParseIntPipe) id: number, @Param('year') year: string) {+ async forYear(@Param('id', ParseRowIdPipe) id: number, @Param('year') year: string) {if (!/^\d{4}$/.test(year)) throw new BadRequestException('Invalid year');return this.holidays.holidays(id, year);}@@ -62,13 +51,13 @@ export class SchoolHolidaysController {@Put('regions/:id')@UseGuards(AdminGuard)- async updateRegion(@Param('id', ParseIntPipe) id: number, @Body() body: SchoolHolidayRegionDto) {+ async updateRegion(@Param('id', ParseRowIdPipe) id: number, @Body() body: SchoolHolidayRegionDto) {return this.holidays.updateRegion(id, body);}@Delete('regions/:id')@UseGuards(AdminGuard)- async deleteRegion(@Param('id', ParseIntPipe) id: number, @Query('revision', ParseIntPipe) revision: number) {+ async deleteRegion(@Param('id', ParseRowIdPipe) id: number, @Query('revision', ParseRowIdPipe) revision: number) {return this.holidays.deleteRegion(id, revision);}}diff --git a/server/src/nest/tours/tour-activities.controller.ts b/server/src/nest/tours/tour-activities.controller.tsindex 70eaa8d97..c3c37443b 100644--- a/server/src/nest/tours/tour-activities.controller.ts+++ b/server/src/nest/tours/tour-activities.controller.ts@@ -5,10 +5,11 @@ import { RequireAddon } from '../addons/require-addon.decorator';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { ResponseContract } from '../common/response-contract';+import { ParseRowIdPipe } from '../common/row-id.pipe';import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.guard';import { TourActivityAssignDto } from './dto/tour-activity.dto';import { TourActivitiesService } from './tour-activities.service';-import { Body, Controller, Delete, Headers, Param, ParseIntPipe, Put, UseGuards } from '@nestjs/common';+import { Body, Controller, Delete, Headers, Param, Put, UseGuards } from '@nestjs/common';import { tourDetailResponseSchema } from '@trek/shared';/**@@ -44,7 +45,7 @@ export class TourActivitiesController {async unassign(@Param('tripId') tripId: string,@Param('placeId') placeId: string,- @Param('activityId', ParseIntPipe) activityId: number,+ @Param('activityId', ParseRowIdPipe) activityId: number,@Headers('x-socket-id') socketId?: string,) {return await this.activities.unassign(tripId, placeId, activityId, socketId);diff --git a/server/src/nest/tours/tour-drafts.controller.ts b/server/src/nest/tours/tour-drafts.controller.tsindex 8742b807c..7f2c157f9 100644--- a/server/src/nest/tours/tour-drafts.controller.ts+++ b/server/src/nest/tours/tour-drafts.controller.ts@@ -5,10 +5,11 @@ import { RequireAddon } from '../addons/require-addon.decorator';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { ResponseContract } from '../common/response-contract';+import { ParseRowIdPipe } from '../common/row-id.pipe';import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.guard';import { TourDraftPutDto } from './dto/tour-draft.dto';import { TourDraftsService } from './tour-drafts.service';-import { Body, Controller, Delete, Get, Param, ParseIntPipe, Put, UseGuards } from '@nestjs/common';+import { Body, Controller, Delete, Get, Param, Put, UseGuards } from '@nestjs/common';import { successResponseSchema, tourDraftResponseSchema } from '@trek/shared';/**@@ -25,20 +26,24 @@ export class TourDraftsController {@Get()@ResponseContract(tourDraftResponseSchema)- async read(@CurrentUser() user: User, @Param('tripId', ParseIntPipe) tripId: number) {+ async read(@CurrentUser() user: User, @Param('tripId', ParseRowIdPipe) tripId: number) {return await this.drafts.read(tripId, user.id);}@RequirePermission('place_edit')@Put()@ResponseContract(tourDraftResponseSchema)- async keep(@CurrentUser() user: User, @Param('tripId', ParseIntPipe) tripId: number, @Body() body: TourDraftPutDto) {+ async keep(+ @CurrentUser() user: User,+ @Param('tripId', ParseRowIdPipe) tripId: number,+ @Body() body: TourDraftPutDto,+ ) {return await this.drafts.keep(tripId, user.id, body);}@Delete()@ResponseContract(successResponseSchema)- async forget(@CurrentUser() user: User, @Param('tripId', ParseIntPipe) tripId: number) {+ async forget(@CurrentUser() user: User, @Param('tripId', ParseRowIdPipe) tripId: number) {return await this.drafts.forget(tripId, user.id);}}diff --git a/server/src/nest/tours/tour-visits.controller.ts b/server/src/nest/tours/tour-visits.controller.tsindex 6d3b0e3a4..47247676f 100644--- a/server/src/nest/tours/tour-visits.controller.ts+++ b/server/src/nest/tours/tour-visits.controller.ts@@ -3,20 +3,11 @@ import { AddonGuard } from '../addons/addon.guard';import { RequireAddon } from '../addons/require-addon.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { ResponseContract } from '../common/response-contract';+import { ParseRowIdPipe } from '../common/row-id.pipe';import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.guard';import { TourVisitUpdateDto } from './dto/tour-visit.dto';import { TourVisitsService } from './tour-visits.service';-import {- BadRequestException,- Body,- Controller,- Get,- Headers,- Param,- ParseIntPipe,- Put,- UseGuards,-} from '@nestjs/common';+import { BadRequestException, Body, Controller, Get, Headers, Param, Put, UseGuards } from '@nestjs/common';import { stationKeySchema, tourVisitListResponseSchema } from '@trek/shared';/**@@ -42,7 +33,7 @@ export class TourVisitsController {@ResponseContract(tourVisitListResponseSchema)async update(@Param('tripId') tripId: string,- @Param('assignmentId', ParseIntPipe) assignmentId: number,+ @Param('assignmentId', ParseRowIdPipe) assignmentId: number,@Param('stationKey') stationKey: string,@Body() body: TourVisitUpdateDto,@Headers('x-socket-id') socketId?: string,diff --git a/server/src/nest/vacay/vacay.controller.ts b/server/src/nest/vacay/vacay.controller.tsindex b2eb14bcb..6e86b12b5 100644--- a/server/src/nest/vacay/vacay.controller.ts+++ b/server/src/nest/vacay/vacay.controller.ts@@ -2,6 +2,8 @@ import type { User } from '../../types';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { ResponseContract } from '../common/response-contract';+import { toRowId } from '../common/row-id';+import { intParam, rowId } from '../common/row-id.pipe';import {VacayAddHolidayCalendarDto,VacayAddYearDto,@@ -112,11 +114,10 @@ export class VacayController {@ResponseContract(vacayHolidayCalendarResponseSchema)async updateHolidayCalendar(@CurrentUser() user: User,- @Param('id') idParam: string,+ @Param('id', rowId('Calendar not found')) id: number,@Body() body: VacayUpdateHolidayCalendarDto,@Headers('x-socket-id') socketId?: string,) {- const id = Number.parseInt(idParam);const planId = await this.vacay.getActivePlanId(user.id);const calendar = await this.vacay.updateHolidayCalendar(id, planId, body, socketId);if (!calendar) {@@ -129,10 +130,9 @@ export class VacayController {@ResponseContract(successResponseSchema)async deleteHolidayCalendar(@CurrentUser() user: User,- @Param('id') idParam: string,+ @Param('id', rowId('Calendar not found')) id: number,@Headers('x-socket-id') socketId?: string,) {- const id = Number.parseInt(idParam);const planId = await this.vacay.getActivePlanId(user.id);if (!(await this.vacay.deleteHolidayCalendar(id, planId, socketId))) {throw new HttpException({ error: 'Calendar not found' }, 404);@@ -144,8 +144,9 @@ export class VacayController {@ResponseContract(successResponseSchema)async setColor(@CurrentUser() user: User, @Body() body: VacaySetColorDto, @Headers('x-socket-id') socketId?: string) {const planId = await this.vacay.getActivePlanId(user.id);- const userId = body.target_user_id ? Number.parseInt(String(body.target_user_id)) : user.id;- if (!(await this.vacay.getPlanUsers(planId)).find((u) => u.id === userId)) {+ // toRowId: a spelling it refuses names nobody, so it is no user of the plan.+ const userId = body.target_user_id ? toRowId(body.target_user_id) : user.id;+ if (userId === null || !(await this.vacay.getPlanUsers(planId)).find((u) => u.id === userId)) {throw new HttpException({ error: 'User not in plan' }, 403);}await this.vacay.setUserColor(userId, planId, body.color, socketId);@@ -156,11 +157,12 @@ export class VacayController {@HttpCode(200)@ResponseContract(successResponseSchema)async invite(@CurrentUser() user: User, @Body() body: VacayInviteDto, @Headers('x-socket-id') socketId?: string) {- if (!body.user_id) {+ const invitee = toRowId(body.user_id);+ if (!invitee) {throw new HttpException({ error: 'user_id required' }, 400);}const plan = await this.vacay.getActivePlan(user.id);- await this.vacay.sendInvite(plan.id, user.id, user.username, body.user_id as number, socketId);+ await this.vacay.sendInvite(plan.id, user.id, user.username, invitee, socketId);return { success: true };}@@ -197,7 +199,9 @@ export class VacayController {@Headers('x-socket-id') socketId?: string,) {const plan = await this.vacay.getActivePlan(user.id);- await this.vacay.cancelInvite(plan.id, body.user_id as number, socketId);+ // A user id toRowId refuses names nobody, so there is no invite to cancel.+ const invitee = toRowId(body.user_id);+ if (invitee !== null) await this.vacay.cancelInvite(plan.id, invitee, socketId);return { success: true };}@@ -227,21 +231,21 @@ export class VacayController {@HttpCode(200)@ResponseContract(vacayYearsResponseSchema)async addYear(@CurrentUser() user: User, @Body() body: VacayAddYearDto, @Headers('x-socket-id') socketId?: string) {- if (!body.year) {+ const year = toRowId(body.year);+ if (!year) {throw new HttpException({ error: 'Year required' }, 400);}const planId = await this.vacay.getActivePlanId(user.id);- return { years: await this.vacay.addYear(planId, body.year as number, socketId) };+ return { years: await this.vacay.addYear(planId, year, socketId) };}@Delete('years/:year')@ResponseContract(vacayYearsResponseSchema)async deleteYear(@CurrentUser() user: User,- @Param('year') yearParam: string,+ @Param('year', intParam('Invalid year')) year: number,@Headers('x-socket-id') socketId?: string,) {- const year = Number.parseInt(yearParam);const planId = await this.vacay.getActivePlanId(user.id);return { years: await this.vacay.deleteYear(planId, year, socketId) };}@@ -277,12 +281,13 @@ export class VacayController {) {const planId = await this.vacay.getActivePlanId(user.id);let userId = user.id;- if (body.target_user_id && Number.parseInt(String(body.target_user_id)) !== user.id) {- const tid = Number.parseInt(String(body.target_user_id));- if (!(await this.vacay.getPlanUsers(planId)).find((u) => u.id === tid)) {+ const tid = toRowId(body.target_user_id);+ if (body.target_user_id && tid !== user.id) {+ const member = (await this.vacay.getPlanUsers(planId)).find((u) => u.id === tid);+ if (!member) {throw new HttpException({ error: 'User not in plan' }, 403);}- userId = tid;+ userId = member.id;}const result = await this.vacay.toggleEntry(userId, planId, body.date, body.fraction, body.kind, socketId);if (result.error === 'weekend_blocked') {@@ -305,8 +310,7 @@ export class VacayController {@Get('stats/:year')@ResponseContract(vacayStatsResponseSchema)- async stats(@CurrentUser() user: User, @Param('year') yearParam: string) {- const year = Number.parseInt(yearParam);+ async stats(@CurrentUser() user: User, @Param('year', intParam('Invalid year')) year: number) {const planId = await this.vacay.getActivePlanId(user.id);return { stats: await this.vacay.getStats(planId, year) };}@@ -315,14 +319,13 @@ export class VacayController {@ResponseContract(successResponseSchema)async updateStats(@CurrentUser() user: User,- @Param('year') yearParam: string,+ @Param('year', intParam('Invalid year')) year: number,@Body() body: VacayUpdateStatsDto,@Headers('x-socket-id') socketId?: string,) {- const year = Number.parseInt(yearParam);const planId = await this.vacay.getActivePlanId(user.id);- const userId = body.target_user_id ? Number.parseInt(String(body.target_user_id)) : user.id;- if (!(await this.vacay.getPlanUsers(planId)).find((u) => u.id === userId)) {+ const userId = body.target_user_id ? toRowId(body.target_user_id) : user.id;+ if (userId === null || !(await this.vacay.getPlanUsers(planId)).find((u) => u.id === userId)) {throw new HttpException({ error: 'User not in plan' }, 403);}await this.vacay.updateStats(userId, planId, year, body.vacation_days as number, socketId);@@ -339,10 +342,11 @@ export class VacayController {@HttpCode(200)@ResponseContract(successResponseSchema)async share(@CurrentUser() user: User, @Body() body: VacayShareDto, @Headers('x-socket-id') socketId?: string) {- if (!body.user_id) {+ const shareWith = toRowId(body.user_id);+ if (!shareWith) {throw new HttpException({ error: 'user_id required' }, 400);}- await this.vacay.shareCalendar(user.id, user.username, Number.parseInt(String(body.user_id)), socketId);+ await this.vacay.shareCalendar(user.id, user.username, shareWith, socketId);return { success: true };}@@ -362,11 +366,11 @@ export class VacayController {@ResponseContract(successResponseSchema)async updateShare(@CurrentUser() user: User,- @Param('id') idParam: string,+ @Param('id', rowId('Share not found')) id: number,@Body() body: VacayShareUpdateDto,@Headers('x-socket-id') socketId?: string,) {- if (!(await this.vacay.setShareHidden(Number.parseInt(idParam), user.id, body.hidden, socketId))) {+ if (!(await this.vacay.setShareHidden(id, user.id, body.hidden, socketId))) {throw new HttpException({ error: 'Share not found' }, 404);}return { success: true };@@ -376,10 +380,10 @@ export class VacayController {@ResponseContract(successResponseSchema)async deleteShare(@CurrentUser() user: User,- @Param('id') idParam: string,+ @Param('id', rowId('Share not found')) id: number,@Headers('x-socket-id') socketId?: string,) {- if (!(await this.vacay.removeShare(Number.parseInt(idParam), user.id, socketId))) {+ if (!(await this.vacay.removeShare(id, user.id, socketId))) {throw new HttpException({ error: 'Share not found' }, 404);}return { success: true };diff --git a/server/src/nest/wallet-pass/wallet-pass.controller.ts b/server/src/nest/wallet-pass/wallet-pass.controller.tsindex e0dce547b..e3b0105d2 100644--- a/server/src/nest/wallet-pass/wallet-pass.controller.ts+++ b/server/src/nest/wallet-pass/wallet-pass.controller.ts@@ -2,10 +2,11 @@ import type { User } from '../../types';import { CurrentUser } from '../auth-core/current-user.decorator';import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';import { ResponseContract } from '../common/response-contract';+import { ParseRowIdPipe } from '../common/row-id.pipe';import { TripAccessGuard } from '../permissions/trip-access.guard';import { WalletPassService } from './wallet-pass.service';import { walletLanguage } from './wallet-pass.words';-import { Controller, Get, Param, ParseIntPipe, Query, Res, UseGuards } from '@nestjs/common';+import { Controller, Get, Param, Query, Res, UseGuards } from '@nestjs/common';import {googleWalletAvailabilityResponseSchema,googleWalletSaveResponseSchema,@@ -32,8 +33,8 @@ export class WalletPassController {@Get(':id/wallet-pass')async pass(@CurrentUser() user: User,- @Param('tripId', ParseIntPipe) tripId: number,- @Param('id', ParseIntPipe) id: number,+ @Param('tripId', ParseRowIdPipe) tripId: number,+ @Param('id', ParseRowIdPipe) id: number,@Query('lang') lang: string | undefined,@Res() res: Response,): Promise<void> {@@ -53,8 +54,8 @@ export class WalletPassController {@ResponseContract(googleWalletSaveResponseSchema)async google(@CurrentUser() user: User,- @Param('tripId', ParseIntPipe) tripId: number,- @Param('id', ParseIntPipe) id: number,+ @Param('tripId', ParseRowIdPipe) tripId: number,+ @Param('id', ParseRowIdPipe) id: number,@Query('lang') lang: string | undefined,): Promise<GoogleWalletSaveResponse> {return { saveUrl: await this.passes.googleSaveUrlFor(user.id, tripId, id, walletLanguage(lang)) };diff --git a/server/tests/unit/nest/collections.controller.test.ts b/server/tests/unit/nest/collections.controller.test.tsindex c67856241..54cad11e3 100644--- a/server/tests/unit/nest/collections.controller.test.ts+++ b/server/tests/unit/nest/collections.controller.test.ts@@ -83,10 +83,10 @@ describe('CollectionsController', () => {expect(await c.list(user)).toEqual({ collections: [], incomingInvites: [] });expect(await c.create(user, { name: 'Italy' } as never, 'sock')).toEqual({ id: 7 });expect(svc.createCollection).toHaveBeenCalledWith(1, { name: 'Italy' }, 'sock');- expect(await c.get(user, '3')).toEqual({ collection: { id: 3 }, places: [] });- expect(await c.update(user, '3', { name: 'x' } as never, 'sock')).toEqual({ id: 3 });+ expect(await c.get(user, 3)).toEqual({ collection: { id: 3 }, places: [] });+ expect(await c.update(user, 3, { name: 'x' } as never, 'sock')).toEqual({ id: 3 });expect(svc.updateCollection).toHaveBeenCalledWith(1, 3, { name: 'x' }, 'sock');- expect(await c.remove(user, '3', 'sock')).toEqual({ success: true });+ expect(await c.remove(user, 3, 'sock')).toEqual({ success: true });expect(svc.deleteCollection).toHaveBeenCalledWith(1, 3, 'sock');});@@ -113,11 +113,11 @@ describe('CollectionsController', () => {const c = new CollectionsController(svc, new RuntimeEnvService(), storageStub);await c.savePlace(user, { collection_id: 3, name: 'A' } as never, 'sid');expect(svc.savePlace).toHaveBeenCalledWith(1, { collection_id: 3, name: 'A' }, 'sid');- await c.updatePlace(user, '9', { name: 'B' } as never, 'sid');+ await c.updatePlace(user, 9, { name: 'B' } as never, 'sid');expect(svc.updatePlace).toHaveBeenCalledWith(1, 9, { name: 'B' }, 'sid');- await c.setStatus(user, '9', { status: 'want' } as never, 'sid');+ await c.setStatus(user, 9, { status: 'want' } as never, 'sid');expect(svc.setStatus).toHaveBeenCalledWith(1, 9, 'want', 'sid');- expect(await c.deletePlace(user, '9', 'sid')).toEqual({ success: true });+ expect(await c.deletePlace(user, 9, 'sid')).toEqual({ success: true });expect(svc.deletePlace).toHaveBeenCalledWith(1, 9, 'sid');await c.saveFromTrip(user, { collection_id: 3, source_trip_id: 5, source_place_id: 8 } as never, 'sid');expect(svc.saveFromTripPlace).toHaveBeenCalledWith(1, 3, 5, 8, undefined, 'sid');@@ -287,11 +287,11 @@ describe('CollectionsController', () => {const notOwner = makeService({ isOwner: vi.fn().mockResolvedValue(false) });expect(await thrownAsync(() =>- new CollectionsController(notOwner, new RuntimeEnvService(), storageStub).availableUsers(user, '3'),+ new CollectionsController(notOwner, new RuntimeEnvService(), storageStub).availableUsers(user, 3),),).toEqual({ status: 403, body: { error: 'Only the owner can manage members' } });expect(- await new CollectionsController(makeService(), new RuntimeEnvService(), storageStub).availableUsers(user, '3'),+ await new CollectionsController(makeService(), new RuntimeEnvService(), storageStub).availableUsers(user, 3),).toEqual({ users: [{ id: 2 }] });});});@@ -303,7 +303,7 @@ describe('CollectionsController', () => {const demo = { ...user, email: '[email protected]' } as User;expect(await thrownAsync(() =>- new CollectionsController(makeService(), new RuntimeEnvService(), storageStub).uploadCover(demo, '3', file),+ new CollectionsController(makeService(), new RuntimeEnvService(), storageStub).uploadCover(demo, 3, file),),).toEqual({status: 403,@@ -315,7 +315,7 @@ describe('CollectionsController', () => {await thrownAsync(() =>new CollectionsController(makeService(), new RuntimeEnvService(), storageStub).uploadCover(user,- '3',+ 3,undefined,),),@@ -324,7 +324,7 @@ describe('CollectionsController', () => {it('commits + stores the cover and forwards the socket id', async () => {const svc = makeService();expect(- await new CollectionsController(svc, new RuntimeEnvService(), storageStub).uploadCover(user, '3', file, 'sid'),+ await new CollectionsController(svc, new RuntimeEnvService(), storageStub).uploadCover(user, 3, file, 'sid'),).toEqual({ id: 3 });expect(storageStub.put).toHaveBeenCalledWith('covers', 'x.jpg', { tmpPath: undefined });expect(svc.setCollectionCover).toHaveBeenCalledWith(1, 3, '/uploads/covers/x.jpg', 'sid');@@ -340,7 +340,7 @@ describe('CollectionsController', () => {await thrownAsync(() =>new CollectionsController(makeService(), new RuntimeEnvService(), storageStub).uploadPlaceImage(demo,- '9',+ 9,file,),),@@ -354,7 +354,7 @@ describe('CollectionsController', () => {await thrownAsync(() =>new CollectionsController(makeService(), new RuntimeEnvService(), storageStub).uploadPlaceImage(user,- '9',+ 9,undefined,),),@@ -365,7 +365,7 @@ describe('CollectionsController', () => {expect(await new CollectionsController(svc, new RuntimeEnvService(), storageStub).uploadPlaceImage(user,- '9',+ 9,file,'sid',),@@ -383,10 +383,10 @@ describe('CollectionsController', () => {await c.createLabel(user, { collection_id: 3, name: 'Berlin', color: '#ff0000' } as never, 'sock');expect(svc.createLabel).toHaveBeenCalledWith(1, 3, 'Berlin', '#ff0000', 'sock');- await c.updateLabel(user, '5', { name: 'Hamburg' } as never, 'sock');+ await c.updateLabel(user, 5, { name: 'Hamburg' } as never, 'sock');expect(svc.updateLabel).toHaveBeenCalledWith(1, 5, { name: 'Hamburg' }, 'sock');- expect(await c.deleteLabel(user, '5', 'sock')).toEqual({ success: true });+ expect(await c.deleteLabel(user, 5, 'sock')).toEqual({ success: true });expect(svc.deleteLabel).toHaveBeenCalledWith(1, 5, 'sock');await c.assignLabels(user, { label_ids: [5], place_ids: [9, 10] } as never, 'sock');@@ -403,7 +403,7 @@ describe('CollectionsController', () => {const svc = makeService({ exportCollectionGpx: vi.fn().mockResolvedValue(exported) });const c = new CollectionsController(svc, new RuntimeEnvService(), storageStub);- expect(await c.exportCollectionGpx(user, '3')).toBe(exported);+ expect(await c.exportCollectionGpx(user, 3)).toBe(exported);expect(svc.exportCollectionGpx).toHaveBeenCalledWith(1, 3);});@@ -412,7 +412,7 @@ describe('CollectionsController', () => {const svc = makeService({ exportCollectionKml: vi.fn().mockResolvedValue(exported) });const c = new CollectionsController(svc, new RuntimeEnvService(), storageStub);- expect(await c.exportCollectionKml(user, '3')).toBe(exported);+ expect(await c.exportCollectionKml(user, 3)).toBe(exported);expect(svc.exportCollectionKml).toHaveBeenCalledWith(1, 3);});diff --git a/server/tests/unit/nest/common/row-id.pipe.test.ts b/server/tests/unit/nest/common/row-id.pipe.test.tsnew file mode 100644index 000000000..d3e415d46--- /dev/null+++ b/server/tests/unit/nest/common/row-id.pipe.test.ts@@ -0,0 +1,52 @@+import { intParam, ParseRowIdPipe, rowId } from '../../../../src/nest/common/row-id.pipe';+import { HttpException } from '@nestjs/common';++import { describe, expect, it } from 'vitest';++/** The status and body a pipe answers `value` with, or the id it hands on. */+function answer(+ pipe: { transform(value: unknown): number },+ value: unknown,+): number | { status: number; body: unknown } {+ try {+ return pipe.transform(value);+ } catch (err) {+ if (!(err instanceof HttpException)) throw err;+ return { status: err.getStatus(), body: err.getResponse() };+ }+}++const MALFORMED = ['0x5', '5e0', '5.0', '+5', '5_0', ' 5', '-5', 'abc', '', '99999999999999999999'];++describe('RowIdPipe', () => {+ it('ROWIDPIPE-001: hands the handler the id as a number', () => {+ expect(answer(rowId('Journey not found'), '5')).toBe(5);+ expect(answer(rowId('Journey not found'), '007')).toBe(7);+ });++ it("ROWIDPIPE-002: answers every spelling toRowId refuses with the route's own not-found", () => {+ for (const value of MALFORMED) {+ expect(answer(rowId('Journey not found'), value), value).toEqual({+ status: 404,+ body: { error: 'Journey not found' },+ });+ }+ expect(answer(rowId('Not allowed', 403), '0x5')).toEqual({ status: 403, body: { error: 'Not allowed' } });+ });++ it("ROWIDPIPE-003: ParseRowIdPipe keeps ParseIntPipe's 400 and message and refuses what it let through", () => {+ const pipe = new ParseRowIdPipe();+ expect(answer(pipe, '12')).toBe(12);+ for (const value of ['-1', '99999999999999999999', '1.5', 'abc']) {+ expect(answer(pipe, value), value).toEqual({+ status: 400,+ body: { error: 'Validation failed (numeric string is expected)' },+ });+ }+ });++ it('ROWIDPIPE-004: intParam answers 400 with its message for a whole number that is not one', () => {+ expect(answer(intParam('Invalid year'), '2026')).toBe(2026);+ expect(answer(intParam('Invalid year'), '2026.0')).toEqual({ status: 400, body: { error: 'Invalid year' } });+ });+});diff --git a/server/tests/unit/nest/doc-sync/doc-sync.controller.test.ts b/server/tests/unit/nest/doc-sync/doc-sync.controller.test.tsindex 805d41016..8c9a94d92 100644--- a/server/tests/unit/nest/doc-sync/doc-sync.controller.test.ts+++ b/server/tests/unit/nest/doc-sync/doc-sync.controller.test.ts@@ -270,23 +270,23 @@ async function storedPaperless(credentials: Record<string, string> = { api_tokendescribe('who may change a trip binding', () => {it('lets the trip owner through', async () => {- await expect(controller.resolve(String(tripId), '1', owner, { keep: 'trek' })).resolves.toEqual({ success: true });+ await expect(controller.resolve(String(tripId), 1, owner, { keep: 'trek' })).resolves.toEqual({ success: true });});it('lets an instance admin through on a trip they neither own nor joined', async () => {- await expect(controller.resolve(String(otherTripId), '1', admin, { keep: 'trek' })).resolves.toEqual({+ await expect(controller.resolve(String(otherTripId), 1, admin, { keep: 'trek' })).resolves.toEqual({success: true,});});it('refuses a plain member with the message the client renders', async () => {- const err = await thrown(() => controller.resolve(String(tripId), '1', member, { keep: 'trek' }));+ const err = await thrown(() => controller.resolve(String(tripId), 1, member, { keep: 'trek' }));expect(err.getStatus()).toBe(403);expect(err.message).toBe('Only the trip owner can change document sync');});it('answers 404 for a trip that does not exist, rather than the 403 that would confirm it', async () => {- const err = await thrown(() => controller.resolve('999999', '1', member, { keep: 'trek' }));+ const err = await thrown(() => controller.resolve('999999', 1, member, { keep: 'trek' }));expect(err.getStatus()).toBe(404);expect(err.message).toBe('Trip not found');});@@ -997,7 +997,7 @@ describe('the document list', () => {describe('resolving a conflict', () => {it('refuses an item that is not in conflict rather than pretending it did something', async () => {sync.resolveConflict.mockResolvedValueOnce(false);- const err = await thrown(() => controller.resolve(String(tripId), '5', owner, { keep: 'provider' }));+ const err = await thrown(() => controller.resolve(String(tripId), 5, owner, { keep: 'provider' }));expect(err.getStatus()).toBe(400);expect(err.message).toBe('Item is not in conflict');});@@ -1161,7 +1161,7 @@ describe('a manual run and the shelved rows', () => {describe('resolving a conflict carries its trip', () => {it('passes the trip from the URL to the service', async () => {sync.resolveConflict.mockClear();- await controller.resolve(String(tripId), '42', owner, { keep: 'trek' } as never);+ await controller.resolve(String(tripId), 42, owner, { keep: 'trek' } as never);expect(sync.resolveConflict).toHaveBeenCalledWith(42, 'trek', tripId);});});diff --git a/server/tests/unit/nest/journey-day-import.controller.test.ts b/server/tests/unit/nest/journey-day-import.controller.test.tsindex 8955d9fd8..bbd588033 100644--- a/server/tests/unit/nest/journey-day-import.controller.test.ts+++ b/server/tests/unit/nest/journey-day-import.controller.test.ts@@ -52,11 +52,11 @@ describe('JourneyDayImportController', () => {it('JRNDAY-CTL-002: hands the caller, the journey, the day, the body and the socket id to the service', async () => {const { service, controller } = controllerWith();- expect(await controller.review(user, '9', '2026-05-14')).toEqual({ date: '2026-05-14', stays: [] });+ expect(await controller.review(user, 9, '2026-05-14')).toEqual({ date: '2026-05-14', stays: [] });expect(service.review).toHaveBeenCalledExactlyOnceWith(4, 9, '2026-05-14');const body = { groups: [{ kind: 'single' as const, stays: [{ suggestionId: 3 }] }], skipSuggestionIds: [5] };- expect(await controller.takeOver(user, '9', '2026-05-14', body, 'sock-1')).toEqual({+ expect(await controller.takeOver(user, 9, '2026-05-14', body, 'sock-1')).toEqual({entries: [],alreadyTaken: [],skipped: [],@@ -67,14 +67,14 @@ describe('JourneyDayImportController', () => {it('JRNDAY-CTL-003: a day that is no calendar day is a 400 before the service is asked', async () => {const { service, controller } = controllerWith();const refusals = await Promise.all(- ['2026-02-30', 'today'].map((date) => controller.review(user, '9', date).catch((e: unknown) => e)),+ ['2026-02-30', 'today'].map((date) => controller.review(user, 9, date).catch((e: unknown) => e)),);for (const err of refusals) {expect(err).toBeInstanceOf(HttpException);expect((err as HttpException).getResponse()).toEqual({ error: 'Invalid date' });}await expect(- controller.takeOver(user, '9', 'nope', { groups: [{ kind: 'single', stays: [{ suggestionId: 1 }] }] }),+ controller.takeOver(user, 9, 'nope', { groups: [{ kind: 'single', stays: [{ suggestionId: 1 }] }] }),).rejects.toBeInstanceOf(HttpException);expect(service.review).not.toHaveBeenCalled();expect(service.takeOver).not.toHaveBeenCalled();diff --git a/server/tests/unit/nest/journey-map.controller.test.ts b/server/tests/unit/nest/journey-map.controller.test.tsindex cbce41978..9ccd510a1 100644--- a/server/tests/unit/nest/journey-map.controller.test.ts+++ b/server/tests/unit/nest/journey-map.controller.test.ts@@ -34,7 +34,7 @@ describe('JourneyMapController', () => {const mapLayers = vi.fn(async () => layers);const controller = new JourneyMapController({ mapLayers } as unknown as JourneyMapService);- expect(await controller.layers({ id: 4 } as User, '9')).toBe(layers);+ expect(await controller.layers({ id: 4 } as User, 9)).toBe(layers);expect(mapLayers).toHaveBeenCalledWith(9, 4);});});diff --git a/server/tests/unit/nest/journey-recordings.controller.test.ts b/server/tests/unit/nest/journey-recordings.controller.test.tsindex 823ae3321..e749db9c1 100644--- a/server/tests/unit/nest/journey-recordings.controller.test.ts+++ b/server/tests/unit/nest/journey-recordings.controller.test.ts@@ -59,18 +59,18 @@ describe('JourneyRecordingsController', () => {it('JRNREC-CTL-002: hands the caller, the journey, the day, the body and the socket id to the service', async () => {const { service, controller } = controllerWith();- expect(await controller.list(user, '9')).toEqual({ days: [] });+ expect(await controller.list(user, 9)).toEqual({ days: [] });expect(service.list).toHaveBeenCalledExactlyOnceWith(4, 9);const preview = { date: '2026-05-14', utcOffsetMinutes: 120, useSourceOffset: true };- expect(await controller.preview(user, '9', preview)).toEqual({ date: '2026-05-14' });+ expect(await controller.preview(user, 9, preview)).toEqual({ date: '2026-05-14' });expect(service.preview).toHaveBeenCalledExactlyOnceWith(4, 9, preview);const save = { utcOffsetMinutes: 120, expectedHash: HASH, replace: true };- expect(await controller.save(user, '9', '2026-05-14', save, 'sock-1')).toEqual({ outcome: 'created' });+ expect(await controller.save(user, 9, '2026-05-14', save, 'sock-1')).toEqual({ outcome: 'created' });expect(service.save).toHaveBeenCalledExactlyOnceWith(4, 9, '2026-05-14', save, 'sock-1');- expect(await controller.remove(user, '9', '2026-05-14', 'sock-1')).toEqual({ success: true });+ expect(await controller.remove(user, 9, '2026-05-14', 'sock-1')).toEqual({ success: true });expect(service.remove).toHaveBeenCalledExactlyOnceWith(4, 9, '2026-05-14', 'sock-1');});@@ -78,7 +78,7 @@ describe('JourneyRecordingsController', () => {const { service, controller } = controllerWith();const refusals = await Promise.all(['2026-02-30', '14.05.2026', 'today'].map((date) =>- controller.remove(user, '9', date).catch((err: unknown) => err),+ controller.remove(user, 9, date).catch((err: unknown) => err),),);for (const err of refusals) {@@ -86,9 +86,9 @@ describe('JourneyRecordingsController', () => {expect((err as HttpException).getStatus()).toBe(400);expect((err as HttpException).getResponse()).toEqual({ error: 'Invalid date' });}- await expect(- controller.save(user, '9', 'nope', { utcOffsetMinutes: 0, expectedHash: HASH }),- ).rejects.toBeInstanceOf(HttpException);+ await expect(controller.save(user, 9, 'nope', { utcOffsetMinutes: 0, expectedHash: HASH })).rejects.toBeInstanceOf(+ HttpException,+ );expect(service.remove).not.toHaveBeenCalled();expect(service.save).not.toHaveBeenCalled();});@@ -96,7 +96,7 @@ describe('JourneyRecordingsController', () => {it('JRNREC-CTL-004: asks the service how the journey is prepared for the caller (JRN-03)', async () => {const { service, controller } = controllerWith();- expect(await controller.prep(user, '9')).toEqual({ enabled: true });+ expect(await controller.prep(user, 9)).toEqual({ enabled: true });expect(service.prepStatus).toHaveBeenCalledExactlyOnceWith(4, 9);});});diff --git a/server/tests/unit/nest/journey.controller.test.ts b/server/tests/unit/nest/journey.controller.test.tsindex 4949fa9a7..49195581c 100644--- a/server/tests/unit/nest/journey.controller.test.ts+++ b/server/tests/unit/nest/journey.controller.test.ts@@ -135,41 +135,42 @@ describe('JourneyController', () => {it('PATCH/DELETE entries map 404', async () => {expect(await thrownAsync(() =>- ctl(svc({ updateEntry: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).updateEntry(user, '3', {}),+ ctl(svc({ updateEntry: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).updateEntry(user, 3, {}),),).toEqual({ status: 404, body: { error: 'Entry not found' } });expect(await ctl(svc({ updateEntry: vi.fn().mockReturnValue({ id: 3 }) } as Partial<JourneyService>)).updateEntry(user,- '3',+ 3,{ title: 'x' },),).toEqual({ id: 3 });expect(await thrownAsync(() =>- ctl(svc({ deleteEntry: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).deleteEntry(user, '3'),+ ctl(svc({ deleteEntry: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).deleteEntry(user, 3),),).toEqual({ status: 404, body: { error: 'Entry not found' } });expect(- await ctl(svc({ deleteEntry: vi.fn().mockReturnValue(true) } as Partial<JourneyService>)).deleteEntry(user, '3'),+ await ctl(svc({ deleteEntry: vi.fn().mockReturnValue(true) } as Partial<JourneyService>)).deleteEntry(user, 3),).toEqual({ success: true });});it('provider-photos: batch, single 400/403, success', async () => {addProviderPhotos.mockResolvedValueOnce([{ id: 1 }, { id: 1 }]);- expect(await ctl(svc()).providerPhotos(user, '3', { provider: 'immich', asset_ids: ['a', 'b'] })).toEqual({+ expect(await ctl(svc()).providerPhotos(user, 3, { provider: 'immich', asset_ids: ['a', 'b'] })).toEqual({photos: [{ id: 1 }, { id: 1 }],added: 2,});- expect(await thrownAsync(() => ctl(svc()).providerPhotos(user, '3', { provider: 'immich' }))).toEqual({+ expect(await thrownAsync(() => ctl(svc()).providerPhotos(user, 3, { provider: 'immich' }))).toEqual({status: 400,body: { error: 'provider and asset_id required' },});expect(addProviderPhotos).toHaveBeenCalledTimes(1);addProviderPhotos.mockResolvedValueOnce([]);- expect(- await thrownAsync(() => ctl(svc()).providerPhotos(user, '3', { provider: 'immich', asset_id: 'a' })),- ).toEqual({ status: 403, body: { error: 'Not allowed or duplicate' } });+ expect(await thrownAsync(() => ctl(svc()).providerPhotos(user, 3, { provider: 'immich', asset_id: 'a' }))).toEqual({+ status: 403,+ body: { error: 'Not allowed or duplicate' },+ });});it('provider-photos go through the one use case, by entry or by journey, with the socket id; uploads only backfill (#1587)', async () => {@@ -186,11 +187,11 @@ describe('JourneyController', () => {} as Partial<JourneyService>),);- await c.providerPhotos(user, '3', { provider: 'immich', asset_ids: ['a'] }, 'sock-1');- await c.providerPhotos(user, '3', { provider: 'immich', asset_id: 'b' });+ await c.providerPhotos(user, 3, { provider: 'immich', asset_ids: ['a'] }, 'sock-1');+ await c.providerPhotos(user, 3, { provider: 'immich', asset_id: 'b' });await c.uploadEntryPhotos(user, '3', [{ filename: 'a.jpg', originalname: 'a.jpg' } as Express.Multer.File], {});- await c.galleryProviderPhotos(user, '9', { provider: 'immich', asset_ids: ['a'] }, 'sock-1');- await c.galleryProviderPhotos(user, '9', { provider: 'immich', asset_id: 'b' });+ await c.galleryProviderPhotos(user, 9, { provider: 'immich', asset_ids: ['a'] }, 'sock-1');+ await c.galleryProviderPhotos(user, 9, { provider: 'immich', asset_id: 'b' });await c.uploadGalleryPhotos(user, '9', [{ filename: 'g.jpg' } as Express.Multer.File]);expect(addProviderPhotos.mock.calls.map(([target, userId, , sid]) => [target, userId, sid])).toEqual([@@ -208,18 +209,18 @@ describe('JourneyController', () => {});it('link-photo: 400 without id (accepts legacy photo_id), 403, success, and the asking tab is skipped', async () => {- expect(await thrownAsync(() => ctl(svc()).linkPhoto(user, '3', {}))).toEqual({+ expect(await thrownAsync(() => ctl(svc()).linkPhoto(user, 3, {}))).toEqual({status: 400,body: { error: 'journey_photo_id required' },});const link = vi.fn().mockResolvedValue({ id: 5 });const c = ctl(svc(), {}, { link });- expect(await c.linkPhoto(user, '3', { photo_id: 5 }, 'sock-1')).toEqual({ id: 5 });+ expect(await c.linkPhoto(user, 3, { photo_id: 5 }, 'sock-1')).toEqual({ id: 5 });expect(link).toHaveBeenCalledWith(3, 5, 1, 'sock-1');// accepts the canonical journey_photo_id, 403 when the service refusesexpect(await thrownAsync(() =>- ctl(svc(), {}, { link: vi.fn().mockResolvedValue(null) }).linkPhoto(user, '3', { journey_photo_id: 9 }),+ ctl(svc(), {}, { link: vi.fn().mockResolvedValue(null) }).linkPhoto(user, 3, { journey_photo_id: 9 }),),).toEqual({ status: 403, body: { error: 'Not allowed' } });});@@ -228,26 +229,26 @@ describe('JourneyController', () => {const moved = { moved: [5], fromEntryId: 3, toEntryId: 4, kept: false };const move = vi.fn().mockResolvedValue(moved);const c = ctl(svc(), {}, { move });- expect(await c.movePhotos(user, '3', { toEntryId: 4, photoIds: [5] }, 'sock-1')).toEqual(moved);+ expect(await c.movePhotos(user, 3, { toEntryId: 4, photoIds: [5] }, 'sock-1')).toEqual(moved);expect(move).toHaveBeenCalledWith(3, { toEntryId: 4, photoIds: [5] }, 1, 'sock-1');});it('unlink photo (204) maps 404; delete photo 404 then removes the object', async () => {expect(- await thrownAsync(() => ctl(svc(), {}, { unlink: vi.fn().mockResolvedValue(false) }).unlinkPhoto(user, '3', '7')),+ await thrownAsync(() => ctl(svc(), {}, { unlink: vi.fn().mockResolvedValue(false) }).unlinkPhoto(user, 3, 7)),).toEqual({ status: 404, body: { error: 'Not found or not allowed' } });const unlink = vi.fn().mockResolvedValue(true);- expect(await ctl(svc(), {}, { unlink }).unlinkPhoto(user, '3', '7', 'sock-1')).toBeUndefined();+ expect(await ctl(svc(), {}, { unlink }).unlinkPhoto(user, 3, 7, 'sock-1')).toBeUndefined();expect(unlink).toHaveBeenCalledWith(3, 7, 1, 'sock-1');expect(await thrownAsync(() =>- ctl(svc({ deletePhoto: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).deletePhoto(user, '7'),+ ctl(svc({ deletePhoto: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).deletePhoto(user, 7),),).toEqual({ status: 404, body: { error: 'Photo not found' } });expect(await ctl(svc({ deletePhoto: vi.fn().mockReturnValue({ id: 7, file_path: null }) } as Partial<JourneyService>),- ).deletePhoto(user, '7'),+ ).deletePhoto(user, 7),).toEqual({ success: true });});@@ -325,21 +326,21 @@ describe('JourneyController', () => {it('provider-photos forwards per-asset media_types for gallery and entries (#823)', async () => {addProviderPhotos.mockResolvedValue([{ id: 1 }]);- await ctl(svc()).galleryProviderPhotos(user, '9', {+ await ctl(svc()).galleryProviderPhotos(user, 9, {provider: 'immich',asset_ids: ['a', 'b'],media_types: ['video', 'image'],});- await ctl(svc()).galleryProviderPhotos(user, '9', { provider: 'immich', asset_id: 'c', media_type: 'video' });+ await ctl(svc()).galleryProviderPhotos(user, 9, { provider: 'immich', asset_id: 'c', media_type: 'video' });// Entry path mirrors the gallery path, and only an entry keeps the caption.- await ctl(svc()).providerPhotos(user, '4', {+ await ctl(svc()).providerPhotos(user, 4, {provider: 'immich',asset_ids: ['x'],media_types: ['video'],caption: 'c',});- await ctl(svc()).providerPhotos(user, '4', { provider: 'immich', asset_id: 'y', media_type: 'video' });- await ctl(svc()).galleryProviderPhotos(user, '9', { provider: 'immich', asset_ids: ['z'], caption: 'dropped' });+ await ctl(svc()).providerPhotos(user, 4, { provider: 'immich', asset_id: 'y', media_type: 'video' });+ await ctl(svc()).galleryProviderPhotos(user, 9, { provider: 'immich', asset_ids: ['z'], caption: 'dropped' });expect(addProviderPhotos.mock.calls.map(([target, , batch]) => [target, batch])).toEqual([[{ journeyId: 9 }, { provider: 'immich', assetIds: ['a', 'b'], mediaTypes: ['video', 'image'] }],@@ -353,49 +354,47 @@ describe('JourneyController', () => {it('GET/PATCH/DELETE /:id map 404', async () => {expect(await thrownAsync(() =>- ctl(svc({ getJourneyFull: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).get(user, '9'),+ ctl(svc({ getJourneyFull: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).get(user, 9),),).toEqual({ status: 404, body: { error: 'Journey not found' } });expect(- await ctl(svc({ getJourneyFull: vi.fn().mockReturnValue({ id: 9 }) } as Partial<JourneyService>)).get(user, '9'),+ await ctl(svc({ getJourneyFull: vi.fn().mockReturnValue({ id: 9 }) } as Partial<JourneyService>)).get(user, 9),).toEqual({ id: 9 });expect(await thrownAsync(() =>- ctl(svc({ updateJourney: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).update(user, '9', {}),+ ctl(svc({ updateJourney: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).update(user, 9, {}),),).toEqual({ status: 404, body: { error: 'Journey not found' } });expect(await thrownAsync(() =>- ctl(svc({ deleteJourney: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).remove(user, '9'),+ ctl(svc({ deleteJourney: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).remove(user, 9),),).toEqual({ status: 404, body: { error: 'Journey not found' } });});it('trips: POST 400 without trip_id / 403, DELETE 403', async () => {- expect(await thrownAsync(() => ctl(svc()).addTrip(user, '9', {}))).toEqual({+ expect(await thrownAsync(() => ctl(svc()).addTrip(user, 9, {}))).toEqual({status: 400,body: { error: 'trip_id required' },});expect(await thrownAsync(() =>- ctl(svc({ addTripToJourney: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).addTrip(user, '9', {+ ctl(svc({ addTripToJourney: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).addTrip(user, 9, {trip_id: 2,}),),).toEqual({ status: 403, body: { error: 'Not allowed' } });expect(- await ctl(svc({ addTripToJourney: vi.fn().mockReturnValue(true) } as Partial<JourneyService>)).addTrip(- user,- '9',- { trip_id: 2 },- ),+ await ctl(svc({ addTripToJourney: vi.fn().mockReturnValue(true) } as Partial<JourneyService>)).addTrip(user, 9, {+ trip_id: 2,+ }),).toEqual({ success: true });expect(await thrownAsync(() =>ctl(svc({ removeTripFromJourney: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).removeTrip(user,- '9',- '2',+ 9,+ 2,),),).toEqual({ status: 403, body: { error: 'Not allowed' } });@@ -404,27 +403,27 @@ describe('JourneyController', () => {it('entries under journey: list 404, create 400/404, reorder 400/403', async () => {expect(await thrownAsync(() =>- ctl(svc({ listEntries: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).listEntries(user, '9'),+ ctl(svc({ listEntries: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).listEntries(user, 9),),).toEqual({ status: 404, body: { error: 'Journey not found' } });expect(await ctl(svc({ listEntries: vi.fn().mockReturnValue([{ id: 1 }]) } as Partial<JourneyService>)).listEntries(user,- '9',+ 9,),).toEqual({ entries: [{ id: 1 }] });- expect(await thrownAsync(() => ctl(svc()).createEntry(user, '9', {}))).toEqual({+ expect(await thrownAsync(() => ctl(svc()).createEntry(user, 9, {}))).toEqual({status: 400,body: { error: 'entry_date is required' },});expect(await thrownAsync(() =>- ctl(svc({ createEntry: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).createEntry(user, '9', {+ ctl(svc({ createEntry: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).createEntry(user, 9, {entry_date: '2026-01-01',}),),).toEqual({ status: 404, body: { error: 'Journey not found' } });- expect(await thrownAsync(() => ctl(svc()).reorderEntries(user, '9', { orderedIds: 'no' }))).toEqual({+ expect(await thrownAsync(() => ctl(svc()).reorderEntries(user, 9, { orderedIds: 'no' }))).toEqual({status: 400,body: { error: 'orderedIds must be an array of numbers' },});@@ -432,7 +431,7 @@ describe('JourneyController', () => {await thrownAsync(() =>ctl(svc({ reorderEntries: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).reorderEntries(user,- '9',+ 9,{ orderedIds: [1, 2] },),),@@ -440,7 +439,7 @@ describe('JourneyController', () => {});it('contributors: add 400/403, update 403, remove 403', async () => {- expect(await thrownAsync(() => ctl(svc()).addContributor(user, '9', {}))).toEqual({+ expect(await thrownAsync(() => ctl(svc()).addContributor(user, 9, {}))).toEqual({status: 400,body: { error: 'user_id required' },});@@ -448,7 +447,7 @@ describe('JourneyController', () => {await thrownAsync(() =>ctl(svc({ addContributor: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).addContributor(user,- '9',+ 9,{ user_id: 2 },),),@@ -456,7 +455,7 @@ describe('JourneyController', () => {expect(await ctl(svc({ addContributor: vi.fn().mockReturnValue(true) } as Partial<JourneyService>)).addContributor(user,- '9',+ 9,{ user_id: 2 },),).toEqual({ success: true });@@ -464,15 +463,15 @@ describe('JourneyController', () => {await thrownAsync(() =>ctl(svc({ updateContributorRole: vi.fn().mockReturnValue(false) } as Partial<JourneyService>),- ).updateContributor(user, '9', '2', { role: 'editor' }),+ ).updateContributor(user, 9, 2, { role: 'editor' }),),).toEqual({ status: 403, body: { error: 'Not allowed' } });expect(await thrownAsync(() =>ctl(svc({ removeContributor: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).removeContributor(user,- '9',- '2',+ 9,+ 2,),),).toEqual({ status: 403, body: { error: 'Not allowed' } });@@ -483,7 +482,7 @@ describe('JourneyController', () => {await thrownAsync(() =>ctl(svc({ updateJourneyPreferences: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).preferences(user,- '9',+ 9,{},),),@@ -493,32 +492,32 @@ describe('JourneyController', () => {svc({getJourneyShareLink: vi.fn().mockReturnValue({ allowed: true, link: { token: 'abc' } }),} as Partial<JourneyService>),- ).getShareLink(user, '9'),+ ).getShareLink(user, 9),).toEqual({ link: { token: 'abc' } });// An owner whose journey has no link gets the null; a non-owner gets the// same refusal set/delete give, so the client can tell the two apart.expect(await ctl(svc({ getJourneyShareLink: vi.fn().mockReturnValue({ allowed: true, link: null }) } as Partial<JourneyService>),- ).getShareLink(user, '9'),+ ).getShareLink(user, 9),).toEqual({ link: null });expect(await thrownAsync(() =>ctl(svc({ getJourneyShareLink: vi.fn().mockReturnValue({ allowed: false }) } as Partial<JourneyService>),- ).getShareLink(user, '9'),+ ).getShareLink(user, 9),),).toEqual({ status: 403, body: { error: 'Not allowed' } });expect(await thrownAsync(() =>ctl(svc({ createOrUpdateJourneyShareLink: vi.fn().mockReturnValue(null) } as Partial<JourneyService>),- ).setShareLink(user, '9', {}),+ ).setShareLink(user, 9, {}),),).toEqual({ status: 403, body: { error: 'Not allowed' } });const setLink = vi.fn().mockReturnValue({ token: 'abc' });expect(- await ctl(svc({ createOrUpdateJourneyShareLink: setLink } as Partial<JourneyService>)).setShareLink(user, '9', {+ await ctl(svc({ createOrUpdateJourneyShareLink: setLink } as Partial<JourneyService>)).setShareLink(user, 9, {share_timeline: true,}),).toEqual({ token: 'abc' });@@ -531,7 +530,7 @@ describe('JourneyController', () => {newest_first: undefined,});const withOrder = vi.fn().mockReturnValue({ token: 'abc' });- await ctl(svc({ createOrUpdateJourneyShareLink: withOrder } as Partial<JourneyService>)).setShareLink(user, '9', {+ await ctl(svc({ createOrUpdateJourneyShareLink: withOrder } as Partial<JourneyService>)).setShareLink(user, 9, {newest_first: true,});expect(withOrder).toHaveBeenCalledWith(9, 1, {@@ -544,7 +543,7 @@ describe('JourneyController', () => {await thrownAsync(() =>ctl(svc({ deleteJourneyShareLink: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).deleteShareLink(user,- '9',+ 9,),),).toEqual({ status: 403, body: { error: 'Not allowed' } });@@ -689,7 +688,7 @@ describe('JourneyController', () => {it('provider-photos batch passes the passphrase through when present', async () => {addProviderPhotos.mockResolvedValueOnce([{ id: 1 }]);- await ctl(svc()).providerPhotos(user, '3', {+ await ctl(svc()).providerPhotos(user, 3, {provider: 'immich',asset_ids: ['a'],caption: 'cap',@@ -703,17 +702,17 @@ describe('JourneyController', () => {);// single-photo success pathaddProviderPhotos.mockResolvedValueOnce([{ id: 2 }]);- expect(await ctl(svc()).providerPhotos(user, '3', { provider: 'immich', asset_id: 'a' })).toEqual({ id: 2 });+ expect(await ctl(svc()).providerPhotos(user, 3, { provider: 'immich', asset_id: 'a' })).toEqual({ id: 2 });});it('PATCH photos: 404 then returns the updated photo', async () => {expect(await thrownAsync(() =>- ctl(svc(), {}, { updatePhoto: vi.fn().mockResolvedValue(null) }).updatePhoto(user, '7', { caption: 'x' }),+ ctl(svc(), {}, { updatePhoto: vi.fn().mockResolvedValue(null) }).updatePhoto(user, 7, { caption: 'x' }),),).toEqual({ status: 404, body: { error: 'Photo not found' } });const updatePhoto = vi.fn().mockResolvedValue({ id: 7 });- expect(await ctl(svc(), {}, { updatePhoto }).updatePhoto(user, '7', { caption: 'x' }, 'sock-1')).toEqual({ id: 7 });+ expect(await ctl(svc(), {}, { updatePhoto }).updatePhoto(user, 7, { caption: 'x' }, 'sock-1')).toEqual({ id: 7 });expect(updatePhoto).toHaveBeenCalledWith(7, 1, { caption: 'x' }, 'sock-1');});@@ -721,7 +720,7 @@ describe('JourneyController', () => {(storageStub.delete as ReturnType<typeof vi.fn>).mockClear();releaseValues.mockClear();const deletePhoto = vi.fn().mockReturnValue({ id: 7, file_path: 'journey/a.jpg', thumbnail_path: 'journey/p.jpg' });- expect(await ctl(svc({ deletePhoto } as Partial<JourneyService>)).deletePhoto(user, '7')).toEqual({+ expect(await ctl(svc({ deletePhoto } as Partial<JourneyService>)).deletePhoto(user, 7)).toEqual({success: true,});expect(deletePhoto).toHaveBeenCalledWith(7, 1);@@ -735,7 +734,7 @@ describe('JourneyController', () => {(storageStub.delete as ReturnType<typeof vi.fn>).mockClear();releaseValues.mockClear();const outside = vi.fn().mockReturnValue({ id: 9, file_path: 'elsewhere/x.jpg' });- await ctl(svc({ deletePhoto: outside } as Partial<JourneyService>)).deletePhoto(user, '9');+ await ctl(svc({ deletePhoto: outside } as Partial<JourneyService>)).deletePhoto(user, 9);expect(releaseValues).toHaveBeenCalledWith(['elsewhere/x.jpg', undefined], { bare: 'journey' });expect(storageStub.delete).not.toHaveBeenCalled();});@@ -743,7 +742,7 @@ describe('JourneyController', () => {it('gallery provider-photos: batch (with passphrase), single 400/403, success', async () => {addProviderPhotos.mockResolvedValueOnce([{ id: 1 }, { id: 1 }]);expect(- await ctl(svc()).galleryProviderPhotos(user, '9', {+ await ctl(svc()).galleryProviderPhotos(user, 9, {provider: 'immich',asset_ids: ['a', 'b'],passphrase: 'pw',@@ -755,16 +754,16 @@ describe('JourneyController', () => {{ provider: 'immich', assetIds: ['a', 'b'], mediaTypes: undefined, caption: undefined, passphrase: 'pw' },undefined,);- expect(await thrownAsync(() => ctl(svc()).galleryProviderPhotos(user, '9', { provider: 'immich' }))).toEqual({+ expect(await thrownAsync(() => ctl(svc()).galleryProviderPhotos(user, 9, { provider: 'immich' }))).toEqual({status: 400,body: { error: 'provider and asset_id required' },});addProviderPhotos.mockResolvedValueOnce([]);expect(- await thrownAsync(() => ctl(svc()).galleryProviderPhotos(user, '9', { provider: 'immich', asset_id: 'a' })),+ await thrownAsync(() => ctl(svc()).galleryProviderPhotos(user, 9, { provider: 'immich', asset_id: 'a' })),).toEqual({ status: 403, body: { error: 'Not allowed or duplicate' } });addProviderPhotos.mockResolvedValueOnce([{ id: 3 }]);- expect(await ctl(svc()).galleryProviderPhotos(user, '9', { provider: 'immich', asset_id: 'a' })).toEqual({ id: 3 });+ expect(await ctl(svc()).galleryProviderPhotos(user, 9, { provider: 'immich', asset_id: 'a' })).toEqual({ id: 3 });});it('DELETE gallery photo: 404, then queues the video and its poster for release', async () => {@@ -772,7 +771,7 @@ describe('JourneyController', () => {await thrownAsync(() =>ctl(svc({ deleteGalleryPhoto: vi.fn().mockReturnValue(null) } as Partial<JourneyService>)).deleteGalleryPhoto(user,- '7',+ 7,),),).toEqual({ status: 404, body: { error: 'Photo not found or not allowed' } });@@ -782,7 +781,7 @@ describe('JourneyController', () => {.fn().mockReturnValue({ id: 10, file_path: 'journey/clip.mp4', thumbnail_path: 'journey/poster.jpg' });expect(- await ctl(svc({ deleteGalleryPhoto } as Partial<JourneyService>)).deleteGalleryPhoto(user, '10'),+ await ctl(svc({ deleteGalleryPhoto } as Partial<JourneyService>)).deleteGalleryPhoto(user, 10),).toBeUndefined();expect(deleteGalleryPhoto).toHaveBeenCalledWith(10, 1);expect(releaseValues).toHaveBeenCalledWith(['journey/clip.mp4', 'journey/poster.jpg'], { bare: 'journey' });@@ -791,11 +790,9 @@ describe('JourneyController', () => {it('PATCH /:id returns the updated journey on success', async () => {expect(- await ctl(svc({ updateJourney: vi.fn().mockReturnValue({ id: 9 }) } as Partial<JourneyService>)).update(- user,- '9',- { title: 'x' },- ),+ await ctl(svc({ updateJourney: vi.fn().mockReturnValue({ id: 9 }) } as Partial<JourneyService>)).update(user, 9, {+ title: 'x',+ }),).toEqual({ id: 9 });});@@ -823,32 +820,32 @@ describe('JourneyController', () => {it('DELETE /:id and trips/contributors success paths', async () => {expect(- await ctl(svc({ deleteJourney: vi.fn().mockReturnValue(true) } as Partial<JourneyService>)).remove(user, '9'),+ await ctl(svc({ deleteJourney: vi.fn().mockReturnValue(true) } as Partial<JourneyService>)).remove(user, 9),).toEqual({ success: true });expect(await ctl(svc({ removeTripFromJourney: vi.fn().mockReturnValue(true) } as Partial<JourneyService>)).removeTrip(user,- '9',- '2',+ 9,+ 2,),).toEqual({ success: true });expect(await ctl(svc({ updateContributorRole: vi.fn().mockReturnValue(true) } as Partial<JourneyService>),- ).updateContributor(user, '9', '2', { role: 'editor' }),+ ).updateContributor(user, 9, 2, { role: 'editor' }),).toEqual({ success: true });expect(await ctl(svc({ removeContributor: vi.fn().mockReturnValue(true) } as Partial<JourneyService>)).removeContributor(user,- '9',- '2',+ 9,+ 2,),).toEqual({ success: true });});it('addContributor defaults the role to viewer when omitted', async () => {const addContributor = vi.fn().mockReturnValue(true);- await ctl(svc({ addContributor } as Partial<JourneyService>)).addContributor(user, '9', { user_id: 2 });+ await ctl(svc({ addContributor } as Partial<JourneyService>)).addContributor(user, 9, { user_id: 2 });expect(addContributor).toHaveBeenCalledWith(9, 1, 2, 'viewer');});@@ -856,7 +853,7 @@ describe('JourneyController', () => {expect(await ctl(svc({ createEntry: vi.fn().mockReturnValue({ id: 4 }) } as Partial<JourneyService>)).createEntry(user,- '9',+ 9,{ entry_date: '2026-01-01' },),).toEqual({ id: 4 });@@ -866,7 +863,7 @@ describe('JourneyController', () => {expect(await ctl(svc({ reorderEntries: vi.fn().mockReturnValue(true) } as Partial<JourneyService>)).reorderEntries(user,- '9',+ 9,{ orderedIds: [3, 1, 2] },),).toEqual({ success: true });@@ -877,7 +874,7 @@ describe('JourneyController', () => {expect(await ctl(svc({ reorderEntryPhotos } as Partial<JourneyService>)).reorderEntryPhotos(user,- '12',+ 12,{ orderedIds: [3, 1] },'sock',),@@ -887,7 +884,7 @@ describe('JourneyController', () => {await thrownAsync(() =>ctl(svc({ reorderEntryPhotos: vi.fn().mockReturnValue(false) } as Partial<JourneyService>)).reorderEntryPhotos(user,- '12',+ 12,{ orderedIds: [3] },),),@@ -897,14 +894,14 @@ describe('JourneyController', () => {it('restoreSuggestions answers with the count, and refuses a viewer the same way its siblings do', async () => {const restore = vi.fn().mockReturnValue({ restored: 3 });expect(- await ctl(svc({ restoreDismissedSuggestions: restore } as Partial<JourneyService>)).restoreSuggestions(user, '9'),+ await ctl(svc({ restoreDismissedSuggestions: restore } as Partial<JourneyService>)).restoreSuggestions(user, 9),).toEqual({ restored: 3 });expect(restore).toHaveBeenCalledWith(9, 1, undefined);expect(await thrownAsync(() =>ctl(svc({ restoreDismissedSuggestions: vi.fn().mockReturnValue(null) } as Partial<JourneyService>),- ).restoreSuggestions(user, '9'),+ ).restoreSuggestions(user, 9),),).toEqual({ status: 403, body: { error: 'Not allowed' } });});@@ -913,7 +910,7 @@ describe('JourneyController', () => {expect(await ctl(svc({ updateJourneyPreferences: vi.fn().mockReturnValue({ ok: true }) } as Partial<JourneyService>),- ).preferences(user, '9', { theme: 'dark' }),+ ).preferences(user, 9, { theme: 'dark' }),).toEqual({ ok: true });});@@ -921,7 +918,7 @@ describe('JourneyController', () => {expect(await ctl(svc({ deleteJourneyShareLink: vi.fn().mockReturnValue(true) } as Partial<JourneyService>),- ).deleteShareLink(user, '9'),+ ).deleteShareLink(user, 9),).toEqual({ success: true });});/*@@ -937,22 +934,19 @@ describe('JourneyController', () => {expect(await ctl(svc(), { getBook: vi.fn().mockReturnValue(null), canOpen: vi.fn().mockReturnValue(true) }).getBook(user,- '9',+ 9,),).toEqual({ book: null });expect(await thrownAsync(() =>ctl(svc(), { getBook: vi.fn().mockReturnValue(null), canOpen: vi.fn().mockReturnValue(false) }).getBook(user,- '9',+ 9,),),).toEqual({ status: 404, body: { error: 'Journey not found' } });expect(- await ctl(svc(), { getBook: vi.fn().mockReturnValue({ id: 3, version: 4 }), canOpen: vi.fn() }).getBook(- user,- '9',- ),+ await ctl(svc(), { getBook: vi.fn().mockReturnValue({ id: 3, version: 4 }), canOpen: vi.fn() }).getBook(user, 9),).toEqual({ book: { id: 3, version: 4 } });// A refused save says which refusal it was. Out of reach entirely is still@@ -962,7 +956,7 @@ describe('JourneyController', () => {await thrownAsync(() =>ctl(svc(), { saveBook: vi.fn().mockReturnValue(null), canOpen: vi.fn().mockReturnValue(false) }).saveBook(user,- '9',+ 9,{ document: {} } as never,),),@@ -971,7 +965,7 @@ describe('JourneyController', () => {await thrownAsync(() =>ctl(svc(), { saveBook: vi.fn().mockReturnValue(null), canOpen: vi.fn().mockReturnValue(true) }).saveBook(user,- '9',+ 9,{ document: {} } as never,),),@@ -983,7 +977,7 @@ describe('JourneyController', () => {expect(await ctl(svc(), { saveBook }).saveBook(user,- '9',+ 9,{ title: 'T', document: { v: 1 }, baseVersion: 4 } as never,'sock-7',),@@ -1000,7 +994,7 @@ describe('JourneyController', () => {// A missing title is '' rather than undefined: the column is NOT NULL and// an untitled book is an ordinary thing to have.const untitled = vi.fn().mockReturnValue({ record: { id: 3, version: 1 } });- await ctl(svc(), { saveBook: untitled }).saveBook(user, '9', { document: {} } as never);+ await ctl(svc(), { saveBook: untitled }).saveBook(user, 9, { document: {} } as never);expect(untitled.mock.calls[0][2].title).toBe('');});@@ -1012,7 +1006,7 @@ describe('JourneyController', () => {*/const saveBook = vi.fn().mockReturnValue({ conflict: { id: 3, version: 6, title: 'Theirs' } });expect(- await thrownAsync(() => ctl(svc(), { saveBook }).saveBook(user, '9', { document: {}, baseVersion: 4 } as never)),+ await thrownAsync(() => ctl(svc(), { saveBook }).saveBook(user, 9, { document: {}, baseVersion: 4 } as never)),).toEqual({status: 409,body: { error: 'Book was changed by someone else', current: { id: 3, version: 6, title: 'Theirs' } },@@ -1020,15 +1014,15 @@ describe('JourneyController', () => {});it('book: delete answers 204, 403 for a viewer, or 404 out of reach', async () => {- expect(await ctl(svc(), { deleteBook: vi.fn().mockReturnValue(true) }).deleteBook(user, '9')).toBeUndefined();+ expect(await ctl(svc(), { deleteBook: vi.fn().mockReturnValue(true) }).deleteBook(user, 9)).toBeUndefined();// False means there was nothing to delete, which is still a 204 — deleting// a book that is already gone is not a failure.- expect(await ctl(svc(), { deleteBook: vi.fn().mockReturnValue(false) }).deleteBook(user, '9')).toBeUndefined();+ expect(await ctl(svc(), { deleteBook: vi.fn().mockReturnValue(false) }).deleteBook(user, 9)).toBeUndefined();expect(await thrownAsync(() =>ctl(svc(), { deleteBook: vi.fn().mockReturnValue(null), canOpen: vi.fn().mockReturnValue(false) }).deleteBook(user,- '9',+ 9,),),).toEqual({ status: 404, body: { error: 'Journey not found' } });@@ -1036,7 +1030,7 @@ describe('JourneyController', () => {await thrownAsync(() =>ctl(svc(), { deleteBook: vi.fn().mockReturnValue(null), canOpen: vi.fn().mockReturnValue(true) }).deleteBook(user,- '9',+ 9,),),).toEqual({ status: 403, body: { error: 'Not allowed' } });@@ -1165,7 +1159,7 @@ describe('JourneyPublicController', () => {new JourneyPublicController(svc({ validateShareTokenForPhoto: vi.fn().mockReturnValue(null) } as Partial<JourneyService>),storageStub,- ).photo('tok', '7', 'thumbnail', {} as Response),+ ).photo('tok', 7, 'thumbnail', {} as Response),),).toEqual({ status: 404, body: { error: 'Not found' } });const streamPhoto = vi.fn().mockResolvedValue(undefined);@@ -1173,7 +1167,7 @@ describe('JourneyPublicController', () => {validateShareTokenForPhoto: vi.fn().mockReturnValue({ ownerId: 2 }),streamPhoto,} as Partial<JourneyService>);- await new JourneyPublicController(s, storageStub).photo('tok', '7', 'original', {} as Response);+ await new JourneyPublicController(s, storageStub).photo('tok', 7, 'original', {} as Response);expect(streamPhoto).toHaveBeenCalledWith({}, 2, 7, 'original');});@@ -1208,7 +1202,7 @@ describe('JourneyPublicController', () => {validateShareTokenForPhoto: vi.fn().mockReturnValue({ ownerId: 3 }),streamPhoto,} as Partial<JourneyService>);- await new JourneyPublicController(s, storageStub).photo('tok', '7', 'thumbnail', {} as Response);+ await new JourneyPublicController(s, storageStub).photo('tok', 7, 'thumbnail', {} as Response);expect(streamPhoto).toHaveBeenCalledWith({}, 3, 7, 'thumbnail');});diff --git a/server/tests/unit/nest/journey/journey-book-design.controller.test.ts b/server/tests/unit/nest/journey/journey-book-design.controller.test.tsindex c6b9983fd..699f07702 100644--- a/server/tests/unit/nest/journey/journey-book-design.controller.test.ts+++ b/server/tests/unit/nest/journey/journey-book-design.controller.test.ts@@ -41,9 +41,9 @@ describe('JourneyBookDesignController', () => {const controller = new JourneyBookDesignController({ draftView, select } as unknown as JourneyBookDesignService);const user = { id: 4 } as User;- expect(await controller.draft(user, '9', 'd-1')).toBe(view);+ expect(await controller.draft(user, 9, 'd-1')).toBe(view);expect(draftView).toHaveBeenCalledWith(9, 4, 'd-1');- expect(await controller.select(user, '9', 'd-1', { spreadIds: ['sp-b'] })).toBe(chosen);+ expect(await controller.select(user, 9, 'd-1', { spreadIds: ['sp-b'] })).toBe(chosen);expect(select).toHaveBeenCalledWith(9, 4, 'd-1', ['sp-b']);});});diff --git a/server/tests/unit/nest/vacay.controller.test.ts b/server/tests/unit/nest/vacay.controller.test.tsindex 01eb3fd46..db3208029 100644--- a/server/tests/unit/nest/vacay.controller.test.ts+++ b/server/tests/unit/nest/vacay.controller.test.ts@@ -55,13 +55,13 @@ describe('VacayController (parity with the legacy /api/addons/vacay route)', ()it('404 on update of a missing calendar', () => {const updateHolidayCalendar = vi.fn().mockReturnValue(null);return thrown(() =>- makeController({ ...planBase, updateHolidayCalendar }).updateHolidayCalendar(user, '9', {}),+ makeController({ ...planBase, updateHolidayCalendar }).updateHolidayCalendar(user, 9, {}),).then((r) => expect(r).toEqual({ status: 404, body: { error: 'Calendar not found' } }));});it('404 on delete of a missing calendar', () => {const deleteHolidayCalendar = vi.fn().mockReturnValue(false);- return thrown(() => makeController({ ...planBase, deleteHolidayCalendar }).deleteHolidayCalendar(user, '9')).then(+ return thrown(() => makeController({ ...planBase, deleteHolidayCalendar }).deleteHolidayCalendar(user, 9)).then((r) => expect(r).toEqual({ status: 404, body: { error: 'Calendar not found' } }),);});@@ -144,7 +144,7 @@ describe('VacayController (parity with the legacy /api/addons/vacay route)', ()expect(await makeController({ ...planBase, addYear }).addYear(user, { year: 2026 }, 'sock')).toEqual({years: [2026],});- expect(await makeController({ ...planBase, deleteYear }).deleteYear(user, '2026', 'sock')).toEqual({ years: [] });+ expect(await makeController({ ...planBase, deleteYear }).deleteYear(user, 2026, 'sock')).toEqual({ years: [] });});});@@ -224,13 +224,13 @@ describe('VacayController (parity with the legacy /api/addons/vacay route)', ()describe('stats', () => {it('GET wraps stats', async () => {const getStats = vi.fn().mockReturnValue({ used: 5 });- expect(await makeController({ ...planBase, getStats }).stats(user, '2026')).toEqual({ stats: { used: 5 } });+ expect(await makeController({ ...planBase, getStats }).stats(user, 2026)).toEqual({ stats: { used: 5 } });});it('403 on updateStats for a user not in the plan', () => {const getPlanUsers = vi.fn().mockReturnValue([{ id: 1 }]);return thrown(() =>- makeController({ ...planBase, getPlanUsers }).updateStats(user, '2026', {+ makeController({ ...planBase, getPlanUsers }).updateStats(user, 2026, {vacation_days: 30,target_user_id: 99,}),@@ -305,7 +305,7 @@ describe('VacayController (parity with the legacy /api/addons/vacay route)', ()it('PUT /shares/:id forwards the socket id and the hidden flag', async () => {const setShareHidden = vi.fn().mockReturnValue(true);- expect(await makeController({ setShareHidden }).updateShare(user, '7', { hidden: true }, 'sock-1')).toEqual({+ expect(await makeController({ setShareHidden }).updateShare(user, 7, { hidden: true }, 'sock-1')).toEqual({success: true,});expect(setShareHidden).toHaveBeenCalledWith(7, 1, true, 'sock-1');@@ -313,20 +313,20 @@ describe('VacayController (parity with the legacy /api/addons/vacay route)', ()it('404 on PUT when the share is not toggleable by the caller', () => {const setShareHidden = vi.fn().mockReturnValue(false);- return thrown(() => makeController({ setShareHidden }).updateShare(user, '9', { hidden: true })).then((r) =>+ return thrown(() => makeController({ setShareHidden }).updateShare(user, 9, { hidden: true })).then((r) =>expect(r).toEqual({ status: 404, body: { error: 'Share not found' } }),);});it('DELETE /shares/:id forwards the socket id', async () => {const removeShare = vi.fn().mockReturnValue(true);- expect(await makeController({ removeShare }).deleteShare(user, '7', 'sock-1')).toEqual({ success: true });+ expect(await makeController({ removeShare }).deleteShare(user, 7, 'sock-1')).toEqual({ success: true });expect(removeShare).toHaveBeenCalledWith(7, 1, 'sock-1');});it('404 on DELETE of a foreign share', () => {const removeShare = vi.fn().mockReturnValue(false);- return thrown(() => makeController({ removeShare }).deleteShare(user, '9')).then((r) =>+ return thrown(() => makeController({ removeShare }).deleteShare(user, 9)).then((r) =>expect(r).toEqual({ status: 404, body: { error: 'Share not found' } }),);});