Align trip tags and desktop UI with CI contracts

This commit is contained in:
Maurice
2026-12-05 12:24:04 +01:00
parent 3cd22b91ff
commit 53198b4d58
47 changed files with 685 additions and 515 deletions
+2 -2
View File
@@ -54,7 +54,6 @@ 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';
@@ -66,6 +65,7 @@ export class Trips {
updated_at?: string | null;
reminder_sent_for?: string | null;
costs_mode: TTripsCostsMode & Opt = TripsCostsMode.SPLIT;
tags_json?: string | null;
assistant_attachments_collection = new Collection<AssistantAttachments>(this);
assistant_threads_collection = new Collection<AssistantThreads>(this);
budget_category_order_collection = new Collection<BudgetCategoryOrder>(this);
@@ -136,7 +136,6 @@ 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(),
@@ -148,6 +147,7 @@ export const TripsSchema = defineEntity({
updated_at: p.type(DbTimestampType).nullable().defaultRaw(`CURRENT_TIMESTAMP`),
reminder_sent_for: p.text().nullable(),
costs_mode: p.enum(() => TripsCostsMode).default('split'),
tags_json: p.text().nullable(),
assistant_attachments_collection: () => p.oneToMany(AssistantAttachments).mappedBy('trip').hidden(),
assistant_threads_collection: () => p.oneToMany(AssistantThreads).mappedBy('trip').hidden(),
budget_category_order_collection: () => p.oneToMany(BudgetCategoryOrder).mappedBy('trip').hidden(),
@@ -1,5 +1,5 @@
import { Migration } from '@mikro-orm/migrations';
import { engineDdl } from '../migration-utils';
import { Migration } from '@mikro-orm/migrations';
export class Migration20200101046650_trips_can_carry_custom_tags extends Migration {
override name = 'Migration20200101046650_trips_can_carry_custom_tags';
@@ -67,10 +67,10 @@ export const PLUGIN_ENTITY_CONTRACT = {
'reminder_sent_for',
'costs_mode',
],
// The sole credential of the anonymous calendar feed.
withheld: ['feed_token'],
// Keep the calendar credential and internal tag serialization out of the plugin API.
withheld: ['feed_token', 'tags_json'],
wholeRow: true,
derived: ['day_count', 'place_count', 'is_owner', 'owner_username', 'shared_count'],
derived: ['day_count', 'place_count', 'is_owner', 'owner_username', 'shared_count', 'tags'],
},
place: {
table: 'places',
+10 -1
View File
@@ -35,7 +35,16 @@ export function withoutFeedToken<T>(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', 'tags', '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
+21 -5
View File
@@ -262,9 +262,21 @@ 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'),
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' },
@@ -329,7 +341,9 @@ export class TripsMcp {
};
// 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, tags: tags ?? add_tags ?? remove_tags }).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))
@@ -425,7 +439,9 @@ export class TripsMcp {
const notice = ctx.getDeprecationNotice ? ctx.getDeprecationNotice() : null;
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;
const trips = tagKey
? accessible.filter((trip) => trip.tags?.some((name) => tripTagKey(name) === tagKey))
: accessible;
if (notice)
return {
isError: true as const,