From c32c17ca17be3227ec742778a2398ce8aa03ea07 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 5 Dec 2026 01:34:47 +0100 Subject: [PATCH] feat(trips): support custom tags and MCP tag management --- server/src/db/entities/Trips.entity.ts | 2 + server/src/db/kysely/Trips.table.ts | 1 + ...00101046650_trips_can_carry_custom_tags.ts | 13 +++++ .../src/db/repositories/Trips.repository.ts | 53 ++++++++++++++----- server/src/nest/trips/trips.controller.ts | 4 +- server/src/nest/trips/trips.helpers.ts | 2 +- server/src/nest/trips/trips.mcp.ts | 31 +++++++++-- server/src/nest/trips/trips.service.ts | 31 +++++++++-- server/src/types.ts | 6 +-- server/tests/unit/mcp/tools-trips.test.ts | 16 ++++++ shared/src/trip/trip.schema.ts | 21 ++++++++ 11 files changed, 151 insertions(+), 29 deletions(-) create mode 100644 server/src/db/migrations/Migration20200101046650_trips_can_carry_custom_tags.ts diff --git a/server/src/db/entities/Trips.entity.ts b/server/src/db/entities/Trips.entity.ts index 0eab1a23a..40cb93c2c 100644 --- a/server/src/db/entities/Trips.entity.ts +++ b/server/src/db/entities/Trips.entity.ts @@ -54,6 +54,7 @@ export class Trips { user_id!: number; title!: string; description?: string | null; + tags_json?: string | null; start_date?: string | null; end_date?: string | null; currency?: string | null = 'EUR'; @@ -135,6 +136,7 @@ export const TripsSchema = defineEntity({ user_id: p.integer().persist(false).index('idx_trips_user_id'), title: p.text(), description: p.text().nullable(), + tags_json: p.text().nullable(), start_date: p.text().nullable(), end_date: p.text().nullable(), currency: p.text().nullable(), diff --git a/server/src/db/kysely/Trips.table.ts b/server/src/db/kysely/Trips.table.ts index 9eb90fcec..ae7d2d995 100644 --- a/server/src/db/kysely/Trips.table.ts +++ b/server/src/db/kysely/Trips.table.ts @@ -18,4 +18,5 @@ export interface TripsTable { updated_at: InsertOptional; reminder_sent_for: InsertOptional; costs_mode: InsertOptional; + tags_json: InsertOptional; } diff --git a/server/src/db/migrations/Migration20200101046650_trips_can_carry_custom_tags.ts b/server/src/db/migrations/Migration20200101046650_trips_can_carry_custom_tags.ts new file mode 100644 index 000000000..326a9a81a --- /dev/null +++ b/server/src/db/migrations/Migration20200101046650_trips_can_carry_custom_tags.ts @@ -0,0 +1,13 @@ +import { Migration } from '@mikro-orm/migrations'; +import { engineDdl } from '../migration-utils'; + +export class Migration20200101046650_trips_can_carry_custom_tags extends Migration { + override name = 'Migration20200101046650_trips_can_carry_custom_tags'; + + override up(): void { + engineDdl(this, { + sqlite: ['ALTER TABLE trips ADD COLUMN tags_json TEXT'], + postgres: ['ALTER TABLE "trips" ADD COLUMN "tags_json" text'], + }); + } +} diff --git a/server/src/db/repositories/Trips.repository.ts b/server/src/db/repositories/Trips.repository.ts index 4a73ab670..69d857be3 100644 --- a/server/src/db/repositories/Trips.repository.ts +++ b/server/src/db/repositories/Trips.repository.ts @@ -1,4 +1,5 @@ import { QueryFlag } from '@mikro-orm/core'; +import { tripTagNamesSchema, uniqueTripTags } from '@trek/shared'; import type { TTripsCostsMode, Trips } from '../entities/Trips.entity'; import { coalesceParam, currentTimestamp, ilike, nowDateOffset } from '../dialect/sql-functions'; import type { AssertRowKeys } from './_shared/rows'; @@ -22,11 +23,12 @@ export interface TripAccess { * SERVICE (TR-B's ruling), so this repository method must hand the column * back intact for that strip to have something to delete. */ -export interface TripRawRow { +interface TripDatabaseRow { id: number; user_id: number; title: string; description: string | null; + tags_json: string | null; start_date: string | null; end_date: string | null; currency: string | null; @@ -40,7 +42,28 @@ export interface TripRawRow { costs_mode: TTripsCostsMode; } -const _tripRawRowKeys: AssertRowKeys = true; +const _tripRawRowKeys: AssertRowKeys = true; + +export type TripRawRow = Omit & { tags?: string[] }; + +function decodeTags({ tags_json, ...row }: T) { + let tags: string[] = []; + if (tags_json) { + try { + const parsed = tripTagNamesSchema.safeParse(JSON.parse(tags_json)); + if (parsed.success) tags = parsed.data; + } catch { + // Older import tools may have written invalid JSON. Keep the trip readable. + } + } + return { ...row, tags }; +} + +function encodeTags(tags: string[] | undefined): { tags_json?: string | null } { + if (tags === undefined) return {}; + const unique = uniqueTripTags(tags); + return { tags_json: unique.length ? JSON.stringify(unique) : null }; +} /** * `TRIP_SELECT`'s output row (inventory §11a) — every `TripRawRow` column @@ -350,8 +373,8 @@ export class TripsRepository extends TrekRepository { const row = await this.qb('t') .select(['t.*']) .where('t.id = ?', [id]) - .execute('get', false); - return row ?? null; + .execute('get', false); + return row ? decodeTags(row) : null; } // --------------------------------------------------------------------------- @@ -405,7 +428,7 @@ export class TripsRepository extends TrekRepository { const id = toRowId(trip_id); if (id === null) return undefined; const row = await this.tripSelectQuery(user_id).where('t.id', '=', id).executeTakeFirst(); - return row as TripSelectRow | undefined; + return row ? decodeTags(row) as TripSelectRow : undefined; } /** @@ -432,7 +455,7 @@ export class TripsRepository extends TrekRepository { .where('t.id', '=', id) .where((eb) => tripAccessExpr(eb, 't.user_id', 'm.user_id', user_id)) .executeTakeFirst(); - return row as TripSelectRow | undefined; + return row ? decodeTags(row) as TripSelectRow : undefined; } /** @@ -447,7 +470,7 @@ export class TripsRepository extends TrekRepository { .where((eb) => tripAccessExpr(eb, 't.user_id', 'm.user_id', user_id)); if (archived !== null) query = query.where('t.is_archived', '=', archived); const rows = await query.orderBy('t.created_at', 'desc').execute(); - return rows as TripSelectRow[]; + return rows.map(decodeTags) as TripSelectRow[]; } /** @@ -525,6 +548,7 @@ export class TripsRepository extends TrekRepository { user_id: number; title: string; description: string | null; + tags?: string[]; start_date: string | null; end_date: string | null; currency: string; @@ -534,6 +558,7 @@ export class TripsRepository extends TrekRepository { user: input.user_id, title: input.title, description: input.description, + ...encodeTags(input.tags), start_date: input.start_date, end_date: input.end_date, currency: input.currency, @@ -562,6 +587,7 @@ export class TripsRepository extends TrekRepository { user_id: number; title: string; description: string | null; + tags?: string[]; start_date: string | null; end_date: string | null; currency: string | null; @@ -573,6 +599,7 @@ export class TripsRepository extends TrekRepository { user: input.user_id, title: input.title, description: input.description, + ...encodeTags(input.tags), start_date: input.start_date, end_date: input.end_date, currency: input.currency, @@ -605,11 +632,12 @@ export class TripsRepository extends TrekRepository { */ async updateTripRow( id: number, - data: Pick - & { currency: string; reminder_days: number }, + data: Partial + & { currency: string; reminder_days: number; tags: string[] }>, ): Promise { const platform = this.getEntityManager().getPlatform(); - await this.nativeUpdate({ id }, { ...data, updated_at: currentTimestamp(platform) }); + const { tags, ...fields } = data; + await this.nativeUpdate({ id }, { ...fields, ...encodeTags(tags), updated_at: currentTimestamp(platform) }); } /** TP35 (`trips.service.ts::updateCoverImage`) — `UPDATE trips SET cover_image=?, updated_at=CURRENT_TIMESTAMP WHERE id=?`. */ @@ -910,10 +938,11 @@ export class TripsRepository extends TrekRepository { * the join can never fan a `t` row out to more than one result row. */ async listOwnedOrMember(user_id: number): Promise { - return await this.accessibleTripsQuery(user_id) + const rows = await this.accessibleTripsQuery(user_id) .select(['t.*']) .orderBy({ 't.start_date': 'desc' }) - .execute('all', false); + .execute('all', false); + return rows.map(decodeTags); } /** diff --git a/server/src/nest/trips/trips.controller.ts b/server/src/nest/trips/trips.controller.ts index 0f30e4106..6891e699d 100644 --- a/server/src/nest/trips/trips.controller.ts +++ b/server/src/nest/trips/trips.controller.ts @@ -136,7 +136,7 @@ export class TripsController { throw new HttpException({ error: 'No permission to create trips' }, 403); } // Presence/shape validation happens in the ZodValidationPipe (tripCreateRequestSchema). - const { title, description, currency, reminder_days, day_count } = body; + const { title, description, tags, currency, reminder_days, day_count } = body; const start_date: string | null = body.start_date || null; const end_date: string | null = body.end_date || null; if (start_date && end_date && new Date(end_date) < new Date(start_date)) { @@ -145,7 +145,7 @@ export class TripsController { const parsedDayCount = day_count ? Math.min(Math.max(Number(day_count) || 7, 1), MAX_TRIP_DAYS) : undefined; try { const { trip, tripId, reminderDays } = await this.tripWrites.create( - { title, description, start_date, end_date, currency, reminder_days, day_count: parsedDayCount }, + { title, description, tags, start_date, end_date, currency, reminder_days, day_count: parsedDayCount }, { userId: user.id, role: user.role, socketId }, ); await this.audit.writeAudit({ diff --git a/server/src/nest/trips/trips.helpers.ts b/server/src/nest/trips/trips.helpers.ts index 10956f5e4..5fe0c7a26 100644 --- a/server/src/nest/trips/trips.helpers.ts +++ b/server/src/nest/trips/trips.helpers.ts @@ -35,7 +35,7 @@ export function withoutFeedToken(row: T): T { } /** The fields of a trip update that count as an edit, as against archiving it or changing its cover. */ -const TRIP_EDIT_FIELDS = ['title', 'description', 'start_date', 'end_date', 'currency', 'reminder_days', 'day_count']; +const TRIP_EDIT_FIELDS = ['title', 'description', 'tags', 'start_date', 'end_date', 'currency', 'reminder_days', 'day_count']; /** * The permissions a trip update needs, in the order PUT /api/trips/:id checks diff --git a/server/src/nest/trips/trips.mcp.ts b/server/src/nest/trips/trips.mcp.ts index b18b67a3a..9a5edb357 100644 --- a/server/src/nest/trips/trips.mcp.ts +++ b/server/src/nest/trips/trips.mcp.ts @@ -35,6 +35,9 @@ import { MAX_TRIP_DAYS, tripCalendarDayEventsSchema, tripUpdateRequestSchema, + tripTagNamesSchema, + tripTagNameSchema, + tripTagKey, type TripCostsMode, } from '@trek/shared'; @@ -149,6 +152,7 @@ export class TripsMcp { .max(30) .optional() .describe('How many days before departure the pre-trip reminder fires (default 3). 0 turns the reminder off.'), + tags: tripTagNamesSchema.optional().describe('Custom tags for the trip itself, such as City break or Work'), }, annotations: TOOL_ANNOTATIONS_NON_IDEMPOTENT, access: { group: 'trips', mode: 'write' }, @@ -162,6 +166,7 @@ export class TripsMcp { currency, day_count, reminder_days, + tags, }: { title: string; description?: string; @@ -170,6 +175,7 @@ export class TripsMcp { currency?: string; day_count?: number; reminder_days?: number; + tags?: string[]; }, ctx: McpContext, ) { @@ -191,7 +197,7 @@ export class TripsMcp { } try { const { trip } = await this.tripWrites.create( - { title, description, start_date, end_date, currency, day_count, reminder_days }, + { title, description, start_date, end_date, currency, day_count, reminder_days, ...(tags ? { tags } : {}) }, await this.listWriter(ctx.userId), ); return ok({ trip }); @@ -256,6 +262,9 @@ export class TripsMcp { costs_mode: tripUpdateRequestSchema.shape.costs_mode.describe( 'How the trip keeps its costs: split (who paid and who shares each expense, with settling up) or totals (what the trip costs, nothing split). Who paid and the shares stay stored either way. Needs the budget_edit permission rather than trip_edit', ), + tags: tripTagNamesSchema.optional().describe('Replace all custom tags on the trip. Send an empty array to clear them. Cannot be combined with add_tags or remove_tags'), + add_tags: tripTagNamesSchema.optional().describe('Assign existing or new custom tags to the trip, keeping its other tags. Tag names are matched case-insensitively'), + remove_tags: tripTagNamesSchema.optional().describe('Remove these custom tags from this trip only. Other tags stay assigned. Removals apply before additions'), }, annotations: TOOL_ANNOTATIONS_WRITE, access: { group: 'trips', mode: 'write' }, @@ -275,6 +284,9 @@ export class TripsMcp { reminder_days, date_shift_mode, costs_mode, + tags, + add_tags, + remove_tags, }: { tripId: number; title?: string; @@ -289,6 +301,9 @@ export class TripsMcp { reminder_days?: number; date_shift_mode?: 'keep_bookings' | 'shift_all'; costs_mode?: TripCostsMode; + tags?: string[]; + add_tags?: string[]; + remove_tags?: string[]; }, ctx: McpContext, ) { @@ -310,12 +325,15 @@ export class TripsMcp { day_count, reminder_days, costs_mode, + ...(tags ? { tags } : {}), }; // The rights PUT /api/trips/:id asks for, field by field: archiving, the cover and the costs mode have their own. const granted = await Promise.all( - tripUpdatePermissions(fields).map(({ action }) => this.guards.hasTripPermission(action, tripId, ctx.userId)), + tripUpdatePermissions({ ...fields, tags: tags ?? add_tags ?? remove_tags }).map(({ action }) => this.guards.hasTripPermission(action, tripId, ctx.userId)), ); if (granted.includes(false)) return permissionDenied(); + if (tags !== undefined && (add_tags !== undefined || remove_tags !== undefined)) + return errorResult('tags cannot be combined with add_tags or remove_tags.'); if (clear_dates && (start_date || end_date)) return errorResult('clear_dates cannot be combined with start_date or end_date.'); if (start_date) { @@ -339,7 +357,7 @@ export class TripsMcp { const { updatedTrip, removedDays, boundaries } = await this.trips.update( tripId, ctx.userId, - { ...fields, date_shift_mode }, + { ...fields, date_shift_mode, add_tags, remove_tags }, role, ); this.guards.safeBroadcast(tripId, 'trip:updated', { trip: updatedTrip }); @@ -399,12 +417,15 @@ export class TripsMcp { 'List all trips the current user owns or is a member of. Use this for trip discovery before calling get_trip_summary.', inputSchema: { include_archived: z.boolean().optional().describe('Include archived trips (default false)'), + tag: tripTagNameSchema.optional().describe('Only include trips with this custom tag, matched case-insensitively'), }, annotations: TOOL_ANNOTATIONS_READONLY, }) - async listTrips({ include_archived }: { include_archived?: boolean }, ctx: McpContext) { + async listTrips({ include_archived, tag }: { include_archived?: boolean; tag?: string }, ctx: McpContext) { const notice = ctx.getDeprecationNotice ? ctx.getDeprecationNotice() : null; - const trips = await this.trips.list(ctx.userId, include_archived ? null : 0); + const accessible = await this.trips.list(ctx.userId, include_archived ? null : 0); + const tagKey = tag ? tripTagKey(tag) : null; + const trips = tagKey ? accessible.filter(trip => trip.tags?.some(name => tripTagKey(name) === tagKey)) : accessible; if (notice) return { isError: true as const, diff --git a/server/src/nest/trips/trips.service.ts b/server/src/nest/trips/trips.service.ts index d6d7f0bd8..c56d7f46e 100644 --- a/server/src/nest/trips/trips.service.ts +++ b/server/src/nest/trips/trips.service.ts @@ -27,6 +27,7 @@ import { TourWaypoints } from '../../db/entities/TourWaypoints.entity'; import type { TourWaypointRow } from '../../db/repositories/TourWaypoints.repository'; import { addIsoDays, + MAX_TRIP_TAGS, planDayGrid, resolveDayGridRange, type ActiveTrip, @@ -36,6 +37,8 @@ import { type TrekWsPayload, type TrekWsTripEventName, type TripUpdateRequest, + tripTagKey, + uniqueTripTags, } from '@trek/shared'; import { RealtimeService } from '../realtime/realtime.service'; import { PermissionsService } from '../permissions/permissions.service'; @@ -59,6 +62,7 @@ import { assertTripSpan, leaveStartFor } from './trips.helpers'; interface CreateTripData { title: string; description?: string | null; + tags?: string[]; start_date?: string | null; end_date?: string | null; currency?: string; @@ -68,7 +72,7 @@ interface CreateTripData { // The wire contract of PUT /api/trips/:id (tripUpdateRequestSchema), which // update_trip hands on as well; nullable where it is, as null always arrived. -type UpdateTripData = TripUpdateRequest; +type UpdateTripData = TripUpdateRequest & { add_tags?: string[]; remove_tags?: string[] }; export interface UpdateTripResult { updatedTrip: any; @@ -366,6 +370,7 @@ export class TripsService { user_id: userId, title: data.title, description: data.description || null, + ...(data.tags === undefined ? {} : { tags: data.tags }), start_date: startDate, end_date: endDate, currency, @@ -422,7 +427,7 @@ export class TripsService { /** TP22 — `TripsRepository.findRaw` (shared with `TripReadModelService.getTripSummary`, TR-B, per the inventory's own note that they are the identical statement). */ async getRaw(tripId: string | number): Promise { const row = await this.tripsRepo.findRaw(tripId); - return (row ?? undefined) as Trip | undefined; + return row ?? undefined; } async searchCoverImages(query: string, userId: number) { @@ -442,10 +447,14 @@ export class TripsService { * are one transaction, so a failing `generateDays` or booking resync leaves all of them as they were. */ async updateTrip(tripId: string | number, userId: number, data: UpdateTripData, userRole: string, rebase: CurrencyRebase | null = null): Promise { - const trip = await this.tripsRepo.findRaw(tripId) as (Trip & { reminder_days?: number }) | null; // TP24 + const trip = await this.tripsRepo.findRaw(tripId); // TP24 if (!trip) throw new NotFoundError('Trip not found'); const { title, description, currency, is_archived, cover_image, reminder_days, costs_mode } = data; + const { add_tags, remove_tags, date_shift_mode, ...details } = data; + const patchTags = !!(add_tags?.length || remove_tags?.length); + const onlyPatchingTags = patchTags && Object.values(details).every(value => value === undefined); + let tags = data.tags === undefined ? undefined : uniqueTripTags(data.tags); const { newStart, newEnd, dayCount, regenerate } = this.resolveRange(trip, data); const newTitle = title || trip.title; @@ -468,11 +477,21 @@ export class TripsService { let boundaries: RoadtripDayBoundary[] | null = null; // the road trip day boundaries, when they moved with their days let vacayId: number | undefined; // the vacay plan whose leave days moved along (#2604) await this.uow.transactional(async () => { + if (patchTags) { + // Read within the serialized write transaction so concurrent tag edits + // merge against the latest tags and keep each other's changes. + const current = (await this.tripsRepo.findRaw(tripIdNum))?.tags ?? []; + const removed = new Set(remove_tags?.map(tripTagKey)); + tags = uniqueTripTags([...current.filter(tag => !removed.has(tripTagKey(tag))), ...(add_tags ?? [])]); + if (tags.length > MAX_TRIP_TAGS) throw new ValidationError(`A trip can have up to ${MAX_TRIP_TAGS} tags.`); + } + // Before the row: the rebase reads the outgoing currency off it (#1543). if (rebase) await this.budget.applyCurrencyRebase(tripId, rebase); - await this.tripsRepo.updateTripRow(tripIdNum, { // TP25 + await this.tripsRepo.updateTripRow(tripIdNum, onlyPatchingTags ? { tags } : { // TP25 title: newTitle, description: newDesc ?? null, + ...(tags === undefined ? {} : { tags }), start_date: newStart || null, end_date: newEnd || null, currency: newCurrency, @@ -495,7 +514,7 @@ export class TripsService { // Unless everything shifts, a range that still holds every day (one more day // before the start or after the end) leaves each day, and all on it, on its // date (#3119); only a moved or shorter range re-dates the days by position. - const shiftAll = data.date_shift_mode === 'shift_all'; + const shiftAll = date_shift_mode === 'shift_all'; const grid = await this.generateDays(tripId, newStart || null, newEnd || null, dayCount, !shiftAll); removedDays = grid.removed; boundaries = grid.boundaries; @@ -523,6 +542,7 @@ export class TripsService { const changes: Record = {}; if (title && title !== trip.title) changes.title = title; + if (tags && JSON.stringify(tags) !== JSON.stringify(trip.tags)) changes.tags = tags; if (newStart !== trip.start_date) changes.start_date = newStart; if (newEnd !== trip.end_date) changes.end_date = newEnd; if (newReminder !== oldReminder) changes.reminder_days = newReminder === 0 ? 'none' : `${newReminder} days`; @@ -637,6 +657,7 @@ export class TripsService { user_id: newOwnerId, title: newTitle, description: src.description, + ...(src.tags?.length ? { tags: src.tags } : {}), start_date: src.start_date, end_date: src.end_date, currency: src.currency, diff --git a/server/src/types.ts b/server/src/types.ts index e218f2780..67e8610fa 100644 --- a/server/src/types.ts +++ b/server/src/types.ts @@ -31,11 +31,9 @@ export interface User { } /** - * A trips row as the database holds it, derived from the generated table type - * so it cannot drift from the schema (currency, is_archived and reminder_days - * are nullable columns, and feed_token and reminder_sent_for exist). + * A trip row with its custom tags decoded from storage. */ -export type Trip = Selectable; +export type Trip = Omit, 'tags_json'> & { tags?: string[] }; export interface Day { id: number; diff --git a/server/tests/unit/mcp/tools-trips.test.ts b/server/tests/unit/mcp/tools-trips.test.ts index 4b3178e0d..decbffb90 100644 --- a/server/tests/unit/mcp/tools-trips.test.ts +++ b/server/tests/unit/mcp/tools-trips.test.ts @@ -298,6 +298,22 @@ describe('Tool: update_trip', () => { }); }); + it('updates dashboard tags by name while preserving unrelated tags', async () => { + const { user } = await makeUser(orm); + const trip = await makeTrip(orm, user.id, { title: 'Weekend' }); + await withHarness(user.id, async (h) => { + await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, tags: ['Work', 'Family'] } }); + const result = await h.client.callTool({ + name: 'update_trip', + arguments: { tripId: trip.id, remove_tags: ['work'], add_tags: [' FAMILY ', 'City break'] }, + }); + expect(parseToolResult(result)).toMatchObject({ trip: { title: 'Weekend', tags: ['Family', 'City break'] } }); + expect(broadcastMock).toHaveBeenCalledWith(trip.id, 'trip:updated', expect.objectContaining({ + trip: expect.objectContaining({ tags: ['Family', 'City break'] }), + })); + }); + }); + it('broadcasts trip:updated event', async () => { const { user } = await makeUser(orm); const trip = await makeTrip(orm, user.id); diff --git a/shared/src/trip/trip.schema.ts b/shared/src/trip/trip.schema.ts index c54d2a9bc..fcf10fc9e 100644 --- a/shared/src/trip/trip.schema.ts +++ b/shared/src/trip/trip.schema.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; +import { tripTagNameSchema } from '../tag/trip-tag.schema'; /** * Trip API contract — single source of truth for the /api/trips aggregate-root @@ -42,6 +43,23 @@ export const TRIP_COSTS_MODES = ['split', 'totals'] as const; export const tripCostsModeSchema = z.enum(TRIP_COSTS_MODES); export type TripCostsMode = z.infer; +export const MAX_TRIP_TAGS = 20; + +export function tripTagKey(tag: string): string { + return tag.trim().normalize('NFC').toLowerCase(); +} + +export function uniqueTripTags(tags: readonly string[]): string[] { + const byKey = new Map(); + for (const tag of tags) { + const key = tripTagKey(tag); + if (key && !byKey.has(key)) byKey.set(key, tag.trim()); + } + return [...byKey.values()]; +} + +export const tripTagNamesSchema = z.array(tripTagNameSchema).max(MAX_TRIP_TAGS); + /** * Trip entity as returned by the trip list / get / create / update endpoints * (server/src/services/tripService.ts -> TRIP_SELECT). Columns of the `trips` @@ -53,6 +71,7 @@ export const tripSchema = z.object({ user_id: z.number(), title: z.string(), description: z.string().nullable().optional(), + tags: tripTagNamesSchema.optional(), start_date: z.string().nullable().optional(), end_date: z.string().nullable().optional(), currency: z.string(), @@ -105,6 +124,7 @@ export type TripRenameGuestRequest = z.infer; export const tripUpdateRequestSchema = z.object({ title: z.string().optional(), description: z.string().nullable().optional(), + tags: tripTagNamesSchema.optional(), start_date: z.string().nullable().optional(), end_date: z.string().nullable().optional(), /**