mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
feat(calendar): let a feed leave out the per-day summary events (#2602)
Both feed routes and the one-off export.ics take ?days=0, validated by a shared query contract, and then skip the all-day "Day N" event per day; the default is unchanged. The subscribe dialog gets a Day overview events switch that adds the parameter to its links, export_trip_ics takes dayEvents and the feed tools explain the parameter.
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
tripUpdateRequestSchema,
|
||||
tripAddMemberRequestSchema,
|
||||
activeTripResponseSchema,
|
||||
tripCalendarQuerySchema,
|
||||
tripSchema,
|
||||
} from './trip.schema';
|
||||
|
||||
@@ -96,3 +97,21 @@ describe('activeTripResponseSchema', () => {
|
||||
expect(activeTripResponseSchema.safeParse({ trip: { title: 'Japan' } }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('tripCalendarQuerySchema', () => {
|
||||
it('takes days=0 or days=1, or nothing (#2602)', () => {
|
||||
expect(tripCalendarQuerySchema.parse({})).toEqual({});
|
||||
expect(tripCalendarQuerySchema.parse({ days: '0' })).toEqual({ days: '0' });
|
||||
expect(tripCalendarQuerySchema.parse({ days: '1' })).toEqual({ days: '1' });
|
||||
});
|
||||
|
||||
it('refuses any other days value', () => {
|
||||
for (const days of ['false', '2', '', 0]) {
|
||||
expect(tripCalendarQuerySchema.safeParse({ days }).success).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it('drops keys a calendar app adds of its own', () => {
|
||||
expect(tripCalendarQuerySchema.parse({ days: '0', client: 'ios' })).toEqual({ days: '0' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -193,3 +193,16 @@ export const tripSearchResponseSchema = z.object({
|
||||
),
|
||||
});
|
||||
export type TripSearchResponse = z.infer<typeof tripSearchResponseSchema>;
|
||||
|
||||
/**
|
||||
* Query of the trip calendars: the one-time download (GET
|
||||
* /api/trips/:id/export.ics) and both subscribable feeds (GET
|
||||
* /api/feed/{trip,user}/:token.ics). `days=0` leaves out the all-day summary
|
||||
* each day with untimed stops or notes gets (#2602); `days=1` or no value keeps
|
||||
* it. Other keys are dropped rather than refused, so a calendar app that adds
|
||||
* its own still gets the feed.
|
||||
*/
|
||||
export const tripCalendarQuerySchema = z.object({
|
||||
days: z.enum(['0', '1']).optional(),
|
||||
});
|
||||
export type TripCalendarQuery = z.infer<typeof tripCalendarQuerySchema>;
|
||||
|
||||
Reference in New Issue
Block a user