mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
ci(server): ratchet the open shapes in every schema a DTO binds
contracts:open in shared only counts exports named *RequestSchema, but the name is a convention: 37 body DTOs wrap a schema called *BodySchema, *InputSchema or plain *Schema, and tags.dto.ts declares its schemas locally. pluginInstanceConfigUpdateSchema (a record of unknown behind PluginConfigDto), createAlbumLinkSchema with five open shapes and a dozen more were never counted, and a new open body under one of those names passed both checks. tests/unit/contracts/dto-open-shapes.test.ts walks the other way round. It finds every class that extends createZodDto under src/, imports it, and counts the open shapes in the schema the Zod pipe validates with shared's walk. Each class is held to scripts/dto-open-shapes-baseline.json, 61 DTOs with 101 open shapes today, and a new DTO may hold none. It fails closed: a createZodDto call that is not an exported class, two DTO classes with one name, an empty tree or an unreadable baseline stop it. It runs with the unit tests; npm run contracts:dto-open runs it on its own and --update only lowers the baseline. The five DTO classes declared inside roadtrip controllers are exported so the walk can reach their schemas. The selector test picks up prettier's wrapping of the cases added before.
This commit is contained in:
@@ -9,7 +9,7 @@ import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.g
|
||||
import { RealtimeService } from '../realtime/realtime.service';
|
||||
import { DayBoundariesService } from './day-boundaries.service';
|
||||
|
||||
class DayBoundaryDto extends createZodDto(roadtripDayBoundarySchema) {}
|
||||
export class DayBoundaryDto extends createZodDto(roadtripDayBoundarySchema) {}
|
||||
|
||||
@Controller('api/trips/:tripId/roadtrip/day-boundaries')
|
||||
@UseGuards(AddonGuard, JwtAuthGuard, TripAccessGuard)
|
||||
|
||||
@@ -9,8 +9,8 @@ import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { TripAccessGuard } from '../permissions/trip-access.guard';
|
||||
import { GoogleRouteService } from './google-route.service';
|
||||
|
||||
class PreviewDto extends createZodDto(googleRoutePreviewRequestSchema) {}
|
||||
class ImportDto extends createZodDto(googleRouteImportSchema) {}
|
||||
export class PreviewDto extends createZodDto(googleRoutePreviewRequestSchema) {}
|
||||
export class ImportDto extends createZodDto(googleRouteImportSchema) {}
|
||||
|
||||
@Controller('api')
|
||||
@UseGuards(AddonGuard, JwtAuthGuard)
|
||||
|
||||
@@ -9,7 +9,7 @@ import { roadtripPreferencesUpdateSchema } from '@trek/shared';
|
||||
|
||||
import { createZodDto } from 'nestjs-zod';
|
||||
|
||||
class PreferencesDto extends createZodDto(roadtripPreferencesUpdateSchema) {}
|
||||
export class PreferencesDto extends createZodDto(roadtripPreferencesUpdateSchema) {}
|
||||
|
||||
@Controller('api/trips/:tripId/roadtrip/preferences')
|
||||
@UseGuards(AddonGuard, JwtAuthGuard, TripAccessGuard)
|
||||
|
||||
@@ -8,7 +8,7 @@ import { RequireAddon } from '../addons/require-addon.decorator';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { RoadtripSearchService } from './roadtrip-search.service';
|
||||
|
||||
class SearchAreaDto extends createZodDto(roadtripSearchAreaSchema) {}
|
||||
export class SearchAreaDto extends createZodDto(roadtripSearchAreaSchema) {}
|
||||
|
||||
@Controller('api/roadtrip/search-area')
|
||||
@UseGuards(JwtAuthGuard, AddonGuard)
|
||||
|
||||
Reference in New Issue
Block a user