diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-28 22:24:26 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-12-28 22:25:01 +0100 |
| commit | 48ec0aae80a200d7eb50639ff4c4ca8ae564f29b (patch) | |
| tree | 8cf2a2a02a49d8295985d90679c33c5bc8375818 /src/frontend/app/api/schema.ts | |
| parent | b2ddc0ef449ccbe7f0d33e539ccdfc1baef04e2c (diff) | |
Implement displaying routes with dynamic data from OTP
Diffstat (limited to 'src/frontend/app/api/schema.ts')
| -rw-r--r-- | src/frontend/app/api/schema.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/frontend/app/api/schema.ts b/src/frontend/app/api/schema.ts index 63f4368..f7f0a39 100644 --- a/src/frontend/app/api/schema.ts +++ b/src/frontend/app/api/schema.ts @@ -70,6 +70,52 @@ export type Position = z.infer<typeof PositionSchema>; export type Arrival = z.infer<typeof ArrivalSchema>; export type StopArrivalsResponse = z.infer<typeof StopArrivalsResponseSchema>; +// Transit Routes +export const RouteSchema = z.object({ + id: z.string(), + shortName: z.string().nullable(), + longName: z.string().nullable(), + color: z.string().nullable(), + textColor: z.string().nullable(), + sortOrder: z.number().nullable(), + agencyName: z.string().nullable().optional(), + tripCount: z.number(), +}); + +export const PatternStopSchema = z.object({ + id: z.string(), + code: z.string().nullable(), + name: z.string(), + lat: z.number(), + lon: z.number(), + scheduledDepartures: z.array(z.number()), +}); + +export const PatternSchema = z.object({ + id: z.string(), + name: z.string().nullable(), + headsign: z.string().nullable(), + directionId: z.number(), + code: z.string().nullable(), + semanticHash: z.string().nullable(), + tripCount: z.number(), + geometry: z.array(z.array(z.number())).nullable(), + stops: z.array(PatternStopSchema), +}); + +export const RouteDetailsSchema = z.object({ + shortName: z.string().nullable(), + longName: z.string().nullable(), + color: z.string().nullable(), + textColor: z.string().nullable(), + patterns: z.array(PatternSchema), +}); + +export type Route = z.infer<typeof RouteSchema>; +export type PatternStop = z.infer<typeof PatternStopSchema>; +export type Pattern = z.infer<typeof PatternSchema>; +export type RouteDetails = z.infer<typeof RouteDetailsSchema>; + // Consolidated Circulation (Legacy/Alternative API) export const ConsolidatedCirculationSchema = z.object({ line: z.string(), |
