mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
feat(api): expose shortlisted places, detached bookings and the bucket list
Reading the surface back against real data turned up three things it dropped without saying so. Places with no day were invisible, because the payload only reached places through day_assignments. On a live instance that is half of them, and they are the ones carrying a coordinate and no claim about when — exactly what an integration can act on. They come back under `unplanned_places`, minus the hotel, which is already reported as an accommodation. Bookings with no day were dropped by the day filter. reservations.day_id is nullable and deleting a day detaches its bookings rather than removing them, so this is not a hypothetical. The bucket list had no endpoint at all. It hangs off the user rather than a trip, so it gets its own, and it answers whether or not the Atlas addon is switched on: the addon decides what TREK shows, not what a key can read. Also fixes ?include=notes returning the bare trip: places, notes and reservations are reported on days, so asking for one now implies days instead of quietly answering with nothing. The module stays a leaf. Reaching for AtlasService pulled AuthModule and the storage registry in behind it and broke the surface's own boot, so the one SELECT lives here like every other query in the file.
This commit is contained in:
@@ -3,6 +3,7 @@ import type { Request } from 'express';
|
||||
import {
|
||||
PUBLIC_API_INCLUDES,
|
||||
publicApiIncludeQuerySchema,
|
||||
type PublicApiBucketList,
|
||||
type PublicApiInclude,
|
||||
type PublicApiTrip,
|
||||
type PublicApiTripList,
|
||||
@@ -63,6 +64,19 @@ export class PublicApiController {
|
||||
return { trips: this.api.listTrips(requireUserId(req)) };
|
||||
}
|
||||
|
||||
/**
|
||||
* The caller's bucket list: places they want to reach, with no trip attached.
|
||||
*
|
||||
* Its own endpoint rather than an `include`, because it hangs off the user and
|
||||
* not off any trip. For a consumer that knows where someone has actually been,
|
||||
* this is the one list in TREK it can answer questions about.
|
||||
*/
|
||||
@Get('bucket-list')
|
||||
listBucketList(@Req() req: Request): PublicApiBucketList {
|
||||
this.limit(req);
|
||||
return { items: this.api.listBucketList(requireUserId(req)) };
|
||||
}
|
||||
|
||||
/**
|
||||
* One trip, with the sections named in `?include=`.
|
||||
*
|
||||
@@ -122,6 +136,10 @@ function parseTripId(raw: string): number {
|
||||
* An unknown section is a 400 rather than being ignored: silently dropping a typo
|
||||
* would hand the caller a payload that is missing exactly what they asked for, and
|
||||
* they would debug their own code for it.
|
||||
*
|
||||
* `places`, `notes` and `reservations` are reported on days, so asking for one of
|
||||
* them brings `days` along; the service handles that rather than this parser, so
|
||||
* the echo of what the caller asked for stays honest.
|
||||
*/
|
||||
function parseInclude(raw?: string): PublicApiInclude[] {
|
||||
if (raw === undefined || raw.trim() === '') return [...PUBLIC_API_INCLUDES];
|
||||
|
||||
Reference in New Issue
Block a user