activity-sport-type: schema, contract, write/read paths, federation
Implements the activity-sport-type change (specs/activity-sport-type): - db: nullable `sport_type` column on journal.activities + SportType / SPORT_TYPES (text().$type<> convention). - api: optional sportType on the activity read + create schemas (mirrored SPORT_TYPES; @trails-cool/api stays zod-only). - write: ActivityInput + createActivity persist it; mapSportType() normalizes provider strings (Komoot bulk import passes tour.sport; Garmin unset); threaded through the unified importActivity. - read/display: sportType added to the detail/feed/profile loaders and the v1 REST endpoints; shared SportBadge (glyph + i18n label) on detail, feed, and profile; sport-aware feed verb; create-form <select>. - i18n: journal.activities.sport.* (labels + verbs) in en + de. - federation: `sport` PropertyValue on the Note when set. Tests: mapSportType unit table; federation asserts the sport attachment is present when set and omitted when unset. typecheck + lint + unit all green. E2E (create→badge) still to add. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ee76945f20
commit
2cb32cd2d3
25 changed files with 328 additions and 18 deletions
|
|
@ -1,10 +1,29 @@
|
|||
import { z } from "zod";
|
||||
|
||||
/**
|
||||
* Sport / activity type. Must stay in sync with `SPORT_TYPES` in
|
||||
* `@trails-cool/db` (schema/journal.ts) — this package is intentionally
|
||||
* standalone (zod only), so the wire enum is mirrored here.
|
||||
*/
|
||||
export const SPORT_TYPES = [
|
||||
"hike",
|
||||
"walk",
|
||||
"run",
|
||||
"ride",
|
||||
"gravel",
|
||||
"mtb",
|
||||
"ski",
|
||||
"other",
|
||||
] as const;
|
||||
export const SportTypeSchema = z.enum(SPORT_TYPES);
|
||||
export type SportType = z.infer<typeof SportTypeSchema>;
|
||||
|
||||
/** Activity summary for list views */
|
||||
export const ActivitySummarySchema = z.object({
|
||||
id: z.uuid(),
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
sportType: SportTypeSchema.nullable(),
|
||||
routeId: z.uuid().nullable(),
|
||||
routeName: z.string().nullable(),
|
||||
distance: z.number().nullable(),
|
||||
|
|
@ -32,6 +51,7 @@ export const ActivityListResponseSchema = z.object({
|
|||
export const CreateActivityRequestSchema = z.object({
|
||||
name: z.string().min(1).max(200),
|
||||
description: z.string().max(5000).default(""),
|
||||
sportType: SportTypeSchema.optional(),
|
||||
gpx: z.string().optional(),
|
||||
routeId: z.uuid().optional(),
|
||||
startedAt: z.iso.datetime().optional(),
|
||||
|
|
|
|||
|
|
@ -47,9 +47,11 @@ export {
|
|||
ActivitySummarySchema, ActivityDetailSchema,
|
||||
ActivityListResponseSchema,
|
||||
CreateActivityRequestSchema, CreateActivityResponseSchema,
|
||||
SPORT_TYPES, SportTypeSchema,
|
||||
type ActivitySummary, type ActivityDetail,
|
||||
type ActivityListResponse,
|
||||
type CreateActivityRequest, type CreateActivityResponse,
|
||||
type SportType,
|
||||
} from "./activities.ts";
|
||||
|
||||
// Uploads
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue