Files
TREK/server/src/nest/admin/admin.dto.ts
T
Konstantinos Thermos 2a0ceb2687 feat(transit): let an admin route transit search through Google
Transitous has no GTFS coverage for much of Asia, so a search between two
Osaka subway stops finds nothing — the stops are not in the feed at all.
Add Google as an optional backend behind an admin setting, reusing the
install's existing Places key, and fall back to Transitous whenever no
key resolves.

Uses the Routes API rather than the legacy Directions endpoint the
request named: every other Google call here already speaks the
v1/X-Goog-Api-Key family, and Google closed the legacy endpoint to Cloud
projects created after March 2025.

Google returns walking as turn-by-turn navigation steps where MOTIS
returns one leg per walking segment, so consecutive walk steps are
coalesced into a single leg — otherwise a finely-sliced walk pushed a
real journey past the 20-leg cap and the whole itinerary was dropped.

Both responses now name the backend that answered. The fallback is
silent by design, which left an empty result ambiguous between "no data
here" and "the provider you picked never ran", and the admin panel warns
when Google is selected but no key resolves — or when only the admin's
own key is set, which serves them and nobody else.

Cost shaped the implementation, since Google bills where Transitous does
not: both field masks are cut to the cheapest SKU tier that still
answers the question, cache TTLs are longer than the Transitous path's,
and route alternatives ride along inside the already-billed request.

Addresses #1699
2026-09-07 09:01:56 +02:00

41 lines
2.2 KiB
TypeScript

import { createZodDto } from 'nestjs-zod';
import {
adminUserCreateRequestSchema,
adminUserUpdateRequestSchema,
adminPermissionsRequestSchema,
adminInviteCreateRequestSchema,
adminFeatureToggleRequestSchema,
adminTemplateNameRequestSchema,
adminOidcUpdateRequestSchema,
adminAddonUpdateRequestSchema,
adminCollabFeaturesRequestSchema,
adminNotificationPreferencesRequestSchema,
adminDefaultUserSettingsRequestSchema,
adminTestNotificationRequestSchema,
adminTransitProviderRequestSchema,
} from '@trek/shared';
/**
* Server-side createZodDto wrappers over the @trek/shared admin contracts. The
* global ZodValidationPipe (APP_PIPE in app.module.ts) validates any @Body()
* parameter typed with one of these classes by metatype — the Zod schemas in
* shared/ remain the single source of truth for the wire contract.
*
* Thirteen classes cover the AdminController body contracts:
* the four feature toggles share AdminFeatureToggleDto and the six
* packing-template create/update routes share AdminTemplateNameDto.
*/
export class AdminUserCreateDto extends createZodDto(adminUserCreateRequestSchema) {}
export class AdminUserUpdateDto extends createZodDto(adminUserUpdateRequestSchema) {}
export class AdminPermissionsDto extends createZodDto(adminPermissionsRequestSchema) {}
export class AdminInviteCreateDto extends createZodDto(adminInviteCreateRequestSchema) {}
export class AdminFeatureToggleDto extends createZodDto(adminFeatureToggleRequestSchema) {}
export class AdminTemplateNameDto extends createZodDto(adminTemplateNameRequestSchema) {}
export class AdminOidcUpdateDto extends createZodDto(adminOidcUpdateRequestSchema) {}
export class AdminAddonUpdateDto extends createZodDto(adminAddonUpdateRequestSchema) {}
export class AdminCollabFeaturesDto extends createZodDto(adminCollabFeaturesRequestSchema) {}
export class AdminNotificationPreferencesDto extends createZodDto(adminNotificationPreferencesRequestSchema) {}
export class AdminDefaultUserSettingsDto extends createZodDto(adminDefaultUserSettingsRequestSchema) {}
export class AdminTestNotificationDto extends createZodDto(adminTestNotificationRequestSchema) {}
export class AdminTransitProviderDto extends createZodDto(adminTransitProviderRequestSchema) {}