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
|
|
@ -142,6 +142,24 @@ export const routeVersions = journalSchema.table("route_versions", {
|
|||
*/
|
||||
export type Audience = "public" | "followers-only";
|
||||
|
||||
/**
|
||||
* Sport / activity type. Nullable on activities (NULL = unspecified, which
|
||||
* is always valid). Stored as a plain text() column with a `.$type<>` guard,
|
||||
* matching the visibility/audience convention (no pgEnum). `SPORT_TYPES` is
|
||||
* the runtime source of truth for validation and iteration.
|
||||
*/
|
||||
export const SPORT_TYPES = [
|
||||
"hike",
|
||||
"walk",
|
||||
"run",
|
||||
"ride",
|
||||
"gravel",
|
||||
"mtb",
|
||||
"ski",
|
||||
"other",
|
||||
] as const;
|
||||
export type SportType = (typeof SPORT_TYPES)[number];
|
||||
|
||||
export const activities = journalSchema.table("activities", {
|
||||
id: text("id").primaryKey(),
|
||||
// Local author. NULL for activities ingested from a remote trails
|
||||
|
|
@ -153,6 +171,8 @@ export const activities = journalSchema.table("activities", {
|
|||
routeId: text("route_id").references(() => routes.id),
|
||||
name: text("name").notNull(),
|
||||
description: text("description").default(""),
|
||||
// Sport / activity type (NULL = unspecified). See SPORT_TYPES above.
|
||||
sportType: text("sport_type").$type<SportType>(),
|
||||
gpx: text("gpx"),
|
||||
geom: lineString("geom"),
|
||||
startedAt: timestamp("started_at", { withTimezone: true }),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue