chore: journey type fields for the test typecheck, prettier on the new shared schemas

This commit is contained in:
Maurice
2026-10-01 14:37:06 +02:00
parent b6b4904664
commit d694fc68f3
5 changed files with 18 additions and 10 deletions
+4
View File
@@ -387,6 +387,10 @@ export interface Journey {
status: 'draft' | 'active' | 'completed' | 'archived';
/** Draw the linked trips' GPX tracks on this journey's map (#2194). 0 by default. */
show_trip_tracks?: number;
/** The state the owner set by hand (#762); null follows the trip dates. */
status_override?: 'draft' | 'live' | 'completed' | null;
/** Entries without a place take the spot of their first geotagged photo (#1003). 0 by default. */
photo_location?: number;
created_at: number;
updated_at: number;
}
+4 -2
View File
@@ -1,8 +1,10 @@
import { describe, expect, it } from 'vitest';
import { hasPlaceHours, parsePlaceHours, placeEmailField, placeOpeningHoursField } from './place-hours';
import { placeCreateRequestSchema, placeUpdateRequestSchema } from './place.schema';
const WEEK = '[{"closed":false,"open":"09:00","close":"17:00"},{"closed":false},{"closed":false},{"closed":false},{"closed":false},{"closed":true},{"closed":true}]';
import { describe, expect, it } from 'vitest';
const WEEK =
'[{"closed":false,"open":"09:00","close":"17:00"},{"closed":false},{"closed":false},{"closed":false},{"closed":false},{"closed":true},{"closed":true}]';
describe('place hours and e-mail (#2472)', () => {
it('parses seven days and refuses anything else', () => {
+3 -3
View File
@@ -36,14 +36,14 @@ export function parsePlaceHours(raw: unknown): PlaceOpeningHours | null {
/** Whether a week says anything: a day that is closed or has a time. */
export function hasPlaceHours(hours: PlaceOpeningHours | null): boolean {
return !!hours && hours.some(d => d.closed || !!d.open || !!d.close);
return !!hours && hours.some((d) => d.closed || !!d.open || !!d.close);
}
/** The request field: the JSON text, empty or null to clear it. */
export const placeOpeningHoursField = z
.string()
.max(1000)
.refine(v => v === '' || parsePlaceHours(v) !== null, { message: 'opening_hours must be seven days, Monday first' })
.refine((v) => v === '' || parsePlaceHours(v) !== null, { message: 'opening_hours must be seven days, Monday first' })
.nullable()
.optional();
@@ -53,6 +53,6 @@ const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
export const placeEmailField = z
.string()
.max(254)
.refine(v => v === '' || EMAIL.test(v.trim()), { message: 'email must be an e-mail address' })
.refine((v) => v === '' || EMAIL.test(v.trim()), { message: 'email must be an e-mail address' })
.nullable()
.optional();
+1 -1
View File
@@ -1,6 +1,6 @@
import { tagSchema } from '../tag/tag.schema';
import { PLACE_WEBSITE_MAX_LENGTH, normalizePlaceWebsite } from './place-website';
import { placeEmailField, placeOpeningHoursField } from './place-hours';
import { PLACE_WEBSITE_MAX_LENGTH, normalizePlaceWebsite } from './place-website';
import { z } from 'zod';
+6 -4
View File
@@ -169,9 +169,11 @@ export type ActiveTripResponse = z.infer<typeof activeTripResponseSchema>;
* along for the card; title and date matching stays on the client.
*/
export const tripSearchResponseSchema = z.object({
matches: z.array(z.object({
trip_id: z.number(),
places: z.array(z.string()),
})),
matches: z.array(
z.object({
trip_id: z.number(),
places: z.array(z.string()),
}),
),
});
export type TripSearchResponse = z.infer<typeof tripSearchResponseSchema>;