mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-20 22:16:26 +00:00
refactor(server): types.ts keeps only imported types and derives Trip from the schema
Thirteen interfaces nobody imported are gone. Trip is now the selectable row of the generated TripsTable, so currency, is_archived and reminder_days read as the nullable columns they are and feed_token and reminder_sent_for exist.
This commit is contained in:
+13
-190
@@ -1,4 +1,6 @@
|
||||
import { Request } from 'express';
|
||||
import type { Selectable } from 'kysely';
|
||||
|
||||
import type { TripsTable } from './db/kysely/Trips.table';
|
||||
|
||||
export interface User {
|
||||
id: number;
|
||||
@@ -28,20 +30,12 @@ export interface User {
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface Trip {
|
||||
id: number;
|
||||
user_id: number;
|
||||
title: string;
|
||||
description?: string | null;
|
||||
start_date?: string | null;
|
||||
end_date?: string | null;
|
||||
currency: string;
|
||||
cover_image?: string | null;
|
||||
is_archived: number;
|
||||
reminder_days: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
/**
|
||||
* A trips row as the database holds it, derived from the generated table type
|
||||
* so it cannot drift from the schema (currency, is_archived and reminder_days
|
||||
* are nullable columns, and feed_token and reminder_sent_for exist).
|
||||
*/
|
||||
export type Trip = Selectable<TripsTable>;
|
||||
|
||||
export interface Day {
|
||||
id: number;
|
||||
@@ -93,15 +87,6 @@ export interface Place {
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
id: number;
|
||||
name: string;
|
||||
color: string;
|
||||
icon: string;
|
||||
user_id?: number | null;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface Tag {
|
||||
id: number;
|
||||
user_id: number;
|
||||
@@ -110,36 +95,6 @@ export interface Tag {
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface DayAssignment {
|
||||
id: number;
|
||||
day_id: number;
|
||||
place_id: number;
|
||||
order_index: number;
|
||||
notes?: string | null;
|
||||
reservation_status?: string;
|
||||
reservation_notes?: string | null;
|
||||
reservation_datetime?: string | null;
|
||||
assignment_time?: string | null;
|
||||
assignment_end_time?: string | null;
|
||||
end_day?: number;
|
||||
leg_transport_mode?: string | null;
|
||||
route_excluded?: number;
|
||||
incoming_leg_transport_mode?: string | null;
|
||||
/** The lodging booking that put this stop on the day, when one did. */
|
||||
accommodation_id?: number | null;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface PackingItem {
|
||||
id: number;
|
||||
trip_id: number;
|
||||
name: string;
|
||||
checked: number;
|
||||
category?: string | null;
|
||||
sort_order: number;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface BudgetItemReceipt {
|
||||
id: number;
|
||||
filename: string;
|
||||
@@ -194,7 +149,7 @@ export interface BudgetItemPayer {
|
||||
budget_item_id?: number;
|
||||
}
|
||||
|
||||
export interface ReservationEndpoint {
|
||||
interface ReservationEndpoint {
|
||||
id: number;
|
||||
reservation_id: number;
|
||||
role: 'from' | 'to' | 'stop';
|
||||
@@ -226,9 +181,9 @@ export interface Reservation {
|
||||
/**
|
||||
* TEXT at the DB, not INTEGER (Plan 3d inventory §18.1 — no FK, some rows
|
||||
* read back as `"14.0"`): every reader normalises it, so this stays a
|
||||
* string here rather than the `DayAssignment.accommodation_id` field
|
||||
* above's genuine INTEGER shape. Do not "fix" this to `number` — that
|
||||
* field is a different column on a different table.
|
||||
* string here rather than the genuine INTEGER shape of
|
||||
* `day_assignments.accommodation_id`. Do not "fix" this to `number`: that
|
||||
* is a different column on a different table.
|
||||
*/
|
||||
accommodation_id?: string | null;
|
||||
metadata?: string | null;
|
||||
@@ -239,34 +194,6 @@ export interface Reservation {
|
||||
place_name?: string;
|
||||
}
|
||||
|
||||
export interface TripFile {
|
||||
id: number;
|
||||
trip_id: number;
|
||||
place_id?: number | null;
|
||||
reservation_id?: number | null;
|
||||
note_id?: number | null;
|
||||
uploaded_by?: number | null;
|
||||
uploaded_by_name?: string | null;
|
||||
filename: string;
|
||||
original_name: string;
|
||||
file_size?: number | null;
|
||||
mime_type?: string | null;
|
||||
description?: string | null;
|
||||
starred?: number;
|
||||
deleted_at?: string | null;
|
||||
created_at?: string;
|
||||
reservation_title?: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface TripMember {
|
||||
id: number;
|
||||
trip_id: number;
|
||||
user_id: number;
|
||||
invited_by?: number | null;
|
||||
added_at?: string;
|
||||
}
|
||||
|
||||
export interface DayNote {
|
||||
id: number;
|
||||
day_id: number;
|
||||
@@ -280,104 +207,6 @@ export interface DayNote {
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface CollabNote {
|
||||
id: number;
|
||||
trip_id: number;
|
||||
user_id: number;
|
||||
category: string;
|
||||
title: string;
|
||||
content?: string | null;
|
||||
color: string;
|
||||
pinned: number;
|
||||
website?: string | null;
|
||||
username?: string;
|
||||
avatar?: string | null;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface CollabPoll {
|
||||
id: number;
|
||||
trip_id: number;
|
||||
user_id: number;
|
||||
question: string;
|
||||
options: string;
|
||||
multiple: number;
|
||||
closed: number;
|
||||
deadline?: string | null;
|
||||
username?: string;
|
||||
avatar?: string | null;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface CollabMessage {
|
||||
id: number;
|
||||
trip_id: number;
|
||||
user_id: number;
|
||||
text: string;
|
||||
reply_to?: number | null;
|
||||
deleted?: number;
|
||||
username?: string;
|
||||
avatar?: string | null;
|
||||
reply_text?: string | null;
|
||||
reply_username?: string | null;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface Addon {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
type: string;
|
||||
icon: string;
|
||||
enabled: number;
|
||||
config: string;
|
||||
sort_order: number;
|
||||
}
|
||||
|
||||
export interface AppSetting {
|
||||
key: string;
|
||||
value?: string | null;
|
||||
}
|
||||
|
||||
export interface Setting {
|
||||
id: number;
|
||||
user_id: number;
|
||||
key: string;
|
||||
value?: string | null;
|
||||
}
|
||||
|
||||
export interface AssignmentRow extends DayAssignment {
|
||||
place_name: string;
|
||||
place_description: string | null;
|
||||
lat: number | null;
|
||||
lng: number | null;
|
||||
address: string | null;
|
||||
category_id: number | null;
|
||||
price: number | null;
|
||||
place_currency: string | null;
|
||||
place_time: string | null;
|
||||
end_time: string | null;
|
||||
duration_minutes: number;
|
||||
place_notes: string | null;
|
||||
image_url: string | null;
|
||||
transport_mode: string;
|
||||
google_place_id: string | null;
|
||||
google_ftid: string | null;
|
||||
osm_id: string | null;
|
||||
amap_poi_id: string | null;
|
||||
website: string | null;
|
||||
phone: string | null;
|
||||
stop_type: string | null;
|
||||
/** How full this stop fills the tank, 1-100; null follows the traveller's own setting. */
|
||||
fill_percent: number | null;
|
||||
tour_place_id?: number | null;
|
||||
tour_route_geometry?: string | null;
|
||||
category_name: string | null;
|
||||
category_color: string | null;
|
||||
category_icon: string | null;
|
||||
}
|
||||
|
||||
export interface Participant {
|
||||
user_id: number;
|
||||
username: string;
|
||||
@@ -507,12 +336,6 @@ export interface GalleryPhoto {
|
||||
height?: number | null;
|
||||
}
|
||||
|
||||
export interface JourneyTrip {
|
||||
journey_id: number;
|
||||
trip_id: number;
|
||||
added_at: number;
|
||||
}
|
||||
|
||||
export interface JourneyContributor {
|
||||
journey_id: number;
|
||||
user_id: number;
|
||||
|
||||
Reference in New Issue
Block a user