Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

4.4 KB
Raw Blame
import { Collection, EntityRepositoryType, type Opt, type Ref, defineEntity, p } from '@mikro-orm/core';
import { JourneysRepository } from '../repositories/Journeys.repository';
import { AssistantThreads } from './AssistantThreads.entity';
import { JourneyBookRevisions } from './JourneyBookRevisions.entity';
import { JourneyBooks } from './JourneyBooks.entity';
import { JourneyContributors } from './JourneyContributors.entity';
import { JourneyEntries } from './JourneyEntries.entity';
import { JourneyEntryStays } from './JourneyEntryStays.entity';
import { JourneyPhotos } from './JourneyPhotos.entity';
import { JourneyRecordedDays } from './JourneyRecordedDays.entity';
import { JourneyRecordingPrep } from './JourneyRecordingPrep.entity';
import { JourneyShareTokens } from './JourneyShareTokens.entity';
import { JourneyTrips } from './JourneyTrips.entity';
import { TripJournalLinks } from './TripJournalLinks.entity';
import { Users } from './Users.entity';

export class Journeys {
  [EntityRepositoryType]?: JourneysRepository;
  id!: number & Opt;
  user!: Ref<Users>;
  user_id!: number;
  title!: string;
  subtitle?: string | null;
  cover_gradient?: string | null;
  status?: string | null = 'draft';
  created_at!: number;
  updated_at!: number;
  cover_image?: string | null;
  show_trip_tracks: number & Opt = 0;
  show_verdict: number & Opt = 1;
  show_mood: number & Opt = 1;
  show_weather: number & Opt = 1;
  status_override?: string | null;
  photo_location: number & Opt = 0;
  auto_prepare_recordings: number & Opt = 0;
  assistant_threads_collection = new Collection<AssistantThreads>(this);
  journey_book_revisions_collection = new Collection<JourneyBookRevisions>(this);
  journey_books_collection = new Collection<JourneyBooks>(this);
  journey_contributors_collection = new Collection<JourneyContributors>(this);
  journey_entries_collection = new Collection<JourneyEntries>(this);
  journey_entry_stays_collection = new Collection<JourneyEntryStays>(this);
  journey_photos_collection = new Collection<JourneyPhotos>(this);
  journey_recorded_days_collection = new Collection<JourneyRecordedDays>(this);
  journey_recording_prep_collection = new Collection<JourneyRecordingPrep>(this);
  journey_share_tokens: Ref<JourneyShareTokens> | null = null;
  journey_trips_collection = new Collection<JourneyTrips>(this);
  trip_journal_links_collection = new Collection<TripJournalLinks>(this);
}

export const JourneysSchema = defineEntity({
  class: Journeys,
  repository: () => JourneysRepository,
  properties: {
    id: p.integer().primary(),
    user: () => p.manyToOne(Users).ref().hidden().index('idx_journeys_user'),
    user_id: p.integer().persist(false).index('idx_journeys_user'),
    title: p.text(),
    subtitle: p.text().nullable(),
    cover_gradient: p.text().nullable(),
    status: p.text().nullable(),
    created_at: p.integer(),
    updated_at: p.integer(),
    cover_image: p.text().nullable(),
    show_trip_tracks: p.integer().default(0),
    show_verdict: p.integer().default(1),
    show_mood: p.integer().default(1),
    show_weather: p.integer().default(1),
    status_override: p.text().nullable(),
    photo_location: p.integer().default(0),
    auto_prepare_recordings: p.integer().default(0),
    assistant_threads_collection: () => p.oneToMany(AssistantThreads).mappedBy('journey').hidden(),
    journey_book_revisions_collection: () => p.oneToMany(JourneyBookRevisions).mappedBy('journey').hidden(),
    journey_books_collection: () => p.oneToMany(JourneyBooks).mappedBy('journey').hidden(),
    journey_contributors_collection: () => p.oneToMany(JourneyContributors).mappedBy('journey').hidden(),
    journey_entries_collection: () => p.oneToMany(JourneyEntries).mappedBy('journey').hidden(),
    journey_entry_stays_collection: () => p.oneToMany(JourneyEntryStays).mappedBy('journey').hidden(),
    journey_photos_collection: () => p.oneToMany(JourneyPhotos).mappedBy('journey').hidden(),
    journey_recorded_days_collection: () => p.oneToMany(JourneyRecordedDays).mappedBy('journey').hidden(),
    journey_recording_prep_collection: () => p.oneToMany(JourneyRecordingPrep).mappedBy('journey').hidden(),
    journey_share_tokens: () => p.oneToOne(JourneyShareTokens).ref().mappedBy('journey').hidden(),
    journey_trips_collection: () => p.oneToMany(JourneyTrips).mappedBy('journey').hidden(),
    trip_journal_links_collection: () => p.oneToMany(TripJournalLinks).mappedBy('journey').hidden(),
  },
});