From 346d20fc081bf15bd757f859b2b2352851887abb Mon Sep 17 00:00:00 2001 From: Spythere Date: Mon, 2 Dec 2024 17:03:33 +0100 Subject: [PATCH] restruct: types organization --- src/components/cards/RealStockCard.vue | 2 +- src/components/sections/InputsSection.vue | 2 +- src/components/tabs/StockGeneratorTab.vue | 2 +- src/components/tabs/WikiListTab.vue | 2 +- src/managers/apiStockManager.ts | 3 + src/mixins/stockMixin.ts | 2 +- src/mixins/stockPreviewMixin.ts | 2 +- src/store.ts | 2 +- src/types/api.types.ts | 87 +++++++++++++++++++++++ src/{types.ts => types/common.types.ts} | 0 src/utils/vehicleUtils.ts | 2 +- 11 files changed, 98 insertions(+), 8 deletions(-) create mode 100644 src/managers/apiStockManager.ts create mode 100644 src/types/api.types.ts rename src/{types.ts => types/common.types.ts} (100%) diff --git a/src/components/cards/RealStockCard.vue b/src/components/cards/RealStockCard.vue index d939637..f5ddad6 100644 --- a/src/components/cards/RealStockCard.vue +++ b/src/components/cards/RealStockCard.vue @@ -100,7 +100,7 @@ import { useStore } from '../../store'; import imageMixin from '../../mixins/imageMixin'; import stockMixin from '../../mixins/stockMixin'; -import { IRealComposition, VehicleGroupType } from '../../types'; +import { IRealComposition, VehicleGroupType } from '../../types/common.types'; function getVehicleType(stockType: string): VehicleGroupType { if (/^E/.test(stockType)) return 'loco-electric'; diff --git a/src/components/sections/InputsSection.vue b/src/components/sections/InputsSection.vue index 5d7d6b8..a66f89a 100644 --- a/src/components/sections/InputsSection.vue +++ b/src/components/sections/InputsSection.vue @@ -126,7 +126,7 @@ import imageMixin from '../../mixins/imageMixin'; import { useStore } from '../../store'; import stockPreviewMixin from '../../mixins/stockPreviewMixin'; import stockMixin from '../../mixins/stockMixin'; -import { LocoGroupType, WagonGroupType } from '../../types'; +import { LocoGroupType, WagonGroupType } from '../../types/common.types'; export default defineComponent({ mixins: [imageMixin, stockPreviewMixin, stockMixin], diff --git a/src/components/tabs/StockGeneratorTab.vue b/src/components/tabs/StockGeneratorTab.vue index c40323d..066433e 100644 --- a/src/components/tabs/StockGeneratorTab.vue +++ b/src/components/tabs/StockGeneratorTab.vue @@ -118,7 +118,7 @@ import { defineComponent } from 'vue'; import { useStore } from '../../store'; import stockMixin from '../../mixins/stockMixin'; -import { ICargo, ICarWagon, IStock } from '../../types'; +import { ICargo, ICarWagon, IStock } from '../../types/common.types'; import { isTractionUnit } from '../../utils/vehicleUtils'; import generatorDataJSON from '../../data/generatorData.json'; diff --git a/src/components/tabs/WikiListTab.vue b/src/components/tabs/WikiListTab.vue index 2ca7612..f4150c7 100644 --- a/src/components/tabs/WikiListTab.vue +++ b/src/components/tabs/WikiListTab.vue @@ -98,7 +98,7 @@ import { defineComponent } from 'vue'; import { useStore } from '../../store'; import stockPreviewMixin from '../../mixins/stockPreviewMixin'; -import { IVehicle } from '../../types'; +import { IVehicle } from '../../types/common.types'; import { isTractionUnit } from '../../utils/vehicleUtils'; import stockMixin from '../../mixins/stockMixin'; import imageMixin from '../../mixins/imageMixin'; diff --git a/src/managers/apiStockManager.ts b/src/managers/apiStockManager.ts new file mode 100644 index 0000000..91b0a3f --- /dev/null +++ b/src/managers/apiStockManager.ts @@ -0,0 +1,3 @@ +class ApiStockManager { + +} \ No newline at end of file diff --git a/src/mixins/stockMixin.ts b/src/mixins/stockMixin.ts index 21c1d51..31333fa 100644 --- a/src/mixins/stockMixin.ts +++ b/src/mixins/stockMixin.ts @@ -1,6 +1,6 @@ import { defineComponent } from 'vue'; import { useStore } from '../store'; -import { ICarWagon, ILocomotive, IStock, ICargo, IVehicle } from '../types'; +import { ICarWagon, ILocomotive, IStock, ICargo, IVehicle } from '../types/common.types'; import { isTractionUnit } from '../utils/vehicleUtils'; export default defineComponent({ diff --git a/src/mixins/stockPreviewMixin.ts b/src/mixins/stockPreviewMixin.ts index 0af938a..1d2ac6a 100644 --- a/src/mixins/stockPreviewMixin.ts +++ b/src/mixins/stockPreviewMixin.ts @@ -1,6 +1,6 @@ import { defineComponent } from 'vue'; import { useStore } from '../store'; -import { ICarWagon, ILocomotive, IStock, IVehicle, LocoGroupType, WagonGroupType } from '../types'; +import { ICarWagon, ILocomotive, IStock, IVehicle, LocoGroupType, WagonGroupType } from '../types/common.types'; import { isTractionUnit } from '../utils/vehicleUtils'; export default defineComponent({ diff --git a/src/store.ts b/src/store.ts index f844e26..140b129 100644 --- a/src/store.ts +++ b/src/store.ts @@ -9,7 +9,7 @@ import { LocoGroupType, WagonGroupType, IVehicleData, -} from './types'; +} from './types/common.types'; import { defineStore } from 'pinia'; import { acceptableWeight, diff --git a/src/types/api.types.ts b/src/types/api.types.ts new file mode 100644 index 0000000..8d474df --- /dev/null +++ b/src/types/api.types.ts @@ -0,0 +1,87 @@ +// API namespace +export namespace API { + export interface ActiveData { + trains: Train[]; + activeSceneries: ActiveScenery[]; + } +} + +export interface ActiveScenery { + dispatcherId: number; + dispatcherName: string; + dispatcherIsSupporter: boolean; + stationName: string; + stationHash: string; + region: string; + maxUsers: number; + currentUsers: number; + spawn: number; + lastSeen: number; + dispatcherExp: number; + nameFromHeader: string; + spawnString?: string; + networkConnectionString: string; + isOnline: number; + dispatcherRate: number; + dispatcherStatus: number; +} + +export interface Train { + id: string; + trainNo: number; + mass: number; + speed: number; + length: number; + distance: number; + stockString: string; + driverName: string; + driverId: number; + driverIsSupporter: boolean; + driverLevel: number; + currentStationHash: string; + currentStationName: string; + signal: string; + connectedTrack: string; + online: number; + lastSeen: number; + region: string; + isTimeout: boolean; + timetable?: Timetable; +} + +export interface Timetable { + SKR: boolean; + TWR: boolean; + hasDangerousCargo: boolean; + hasExtraDeliveries: boolean; + warningNotes: string; + category: string; + stopList: TimetableStop[]; + route: string; + timetableId: number; + sceneries: string[]; + path: string; +} + +export interface TimetableStop { + stopName: string; + stopNameRAW: string; + stopType: string; + stopDistance: number; + pointId: string; + comments?: (null | string)[]; + mainStop: boolean; + arrivalLine?: string; + arrivalTimestamp: number; + arrivalRealTimestamp: number; + arrivalDelay: number; + departureLine?: string; + departureTimestamp: number; + departureRealTimestamp: number; + departureDelay: number; + beginsHere: boolean; + terminatesHere: boolean; + confirmed: number; + stopped: number; + stopTime?: number; +} diff --git a/src/types.ts b/src/types/common.types.ts similarity index 100% rename from src/types.ts rename to src/types/common.types.ts diff --git a/src/utils/vehicleUtils.ts b/src/utils/vehicleUtils.ts index f4c62d4..51717ee 100644 --- a/src/utils/vehicleUtils.ts +++ b/src/utils/vehicleUtils.ts @@ -6,7 +6,7 @@ import { IVehiclesAPIResponse, LocoGroupType, WagonGroupType, -} from '../types'; +} from '../types/common.types'; import { MassLimitLocoType, SpeedLimitLocoType,