Files
Maurice 382ba79584 feat(places): visits read from trips, change history, linked tours and bookings, personal tags
A visit is a place planned on a day of one of the reader's trips; nothing is kept
or confirmed by hand. A place keeps a log of changes to its details, links the
tours and bookings it is about, and carries tags private to the reader, which a
copy into a trip takes along only when picked. Contracts, routes, MCP tools and
migrations for both engines.
2026-11-29 21:16:50 +01:00

47 lines
1.5 KiB
TypeScript

/**
* PLC-18: the bookings and tours a place names, and the tours a list keeps
* for a saved place to name, seeded through the ORM like the app writes them.
*/
import { CollectionTours } from '../../../src/db/entities/CollectionTours.entity';
import { PlaceActivityLinks } from '../../../src/db/entities/PlaceActivityLinks.entity';
import type { FactoryOrm } from './context';
import { createRow } from './rows';
import type { EntityDTO, EntityData } from '@mikro-orm/core';
export type KeptTourRow = EntityDTO<CollectionTours>;
export type PlaceActivityLinkRow = EntityDTO<PlaceActivityLinks>;
/** A hike kept in the list `collectionId`, with no line and no points. */
export function makeKeptTour(
orm: FactoryOrm,
collectionId: number,
overrides: EntityData<CollectionTours> = {},
): Promise<KeptTourRow> {
return createRow(
orm,
CollectionTours,
{
collection: collectionId,
name: 'Kept ridge',
waypoints: '[]',
tourTypeRef: 'hike',
origin: 'trek',
source_trip_title: 'Alps',
source_tour_name: 'Ridge',
},
overrides,
);
}
/** A link of a trip place to a booking or a tour (its place), or of a saved place to a kept tour. */
export function linkPlaceActivity(
orm: FactoryOrm,
link:
| { place: number; reservation: number }
| { place: number; tourPlace: number }
| { collectionPlace: number; collectionTour: number },
linkedBy: number | null = null,
): Promise<PlaceActivityLinkRow> {
return createRow(orm, PlaceActivityLinks, { ...link, linkedByRef: linkedBy });
}