From 9d127cbb6cf4abe6de319a4f839089e1311c806b Mon Sep 17 00:00:00 2001 From: TheSparta Date: Wed, 15 May 2024 23:40:32 +0100 Subject: [PATCH 1/3] Add missing types for handled match routes --- project/src/callbacks/MatchCallbacks.ts | 52 +++++++------- project/src/controllers/MatchController.ts | 16 ++--- .../eft/match/IAcceptGroupInviteRequest.ts | 4 -- .../eft/match/IAcceptGroupInviteResponse.ts | 19 ----- .../eft/match/ICancelGroupInviteRequest.ts | 4 -- .../eft/match/ICreateGroupRequestData.ts | 8 --- .../eft/match/IDeclineGroupInviteRequest.ts | 4 -- .../eft/match/IGetGroupStatusResponse.ts | 25 ------- .../eft/match/IGetProfileRequestData.ts | 4 -- .../match/IGetRaidConfigurationRequestData.ts | 69 +------------------ .../src/models/eft/match/IGroupCharacter.ts | 41 +++++++++++ .../models/eft/match/IGroupCurrentResponse.ts | 13 ---- .../models/eft/match/IJoinMatchRequestData.ts | 12 ---- .../src/models/eft/match/IJoinMatchResult.ts | 21 ------ .../eft/match/IMatchGroupCurrentResponse.ts | 6 ++ .../eft/match/IMatchGroupInviteSendRequest.ts | 5 ++ .../match/IMatchGroupPlayerRemoveRequest.ts | 4 ++ .../eft/match/IMatchGroupStartGameRequest.ts | 7 ++ ...estData.ts => IMatchGroupStatusRequest.ts} | 2 +- .../eft/match/IMatchGroupStatusResponse.ts | 7 ++ .../eft/match/IMatchGroupTransferRequest.ts | 4 ++ .../models/eft/match/IProfileStatusRequest.ts | 4 ++ .../eft/match/IProfileStatusResponse.ts | 7 ++ project/src/models/eft/match/IRaidSettings.ts | 50 ++++++++++++++ .../match/IRemovePlayerFromGroupRequest.ts | 4 -- .../src/models/eft/match/IRequestIdRequest.ts | 4 ++ .../eft/match/ISendGroupInviteRequest.ts | 5 -- project/src/models/eft/match/IServer.ts | 6 ++ .../src/models/eft/match/ISessionStatus.ts | 16 +++++ .../models/eft/match/ITransferGroupRequest.ts | 4 -- project/src/models/eft/notifier/INotifier.ts | 2 +- .../src/routers/static/MatchStaticRouter.ts | 18 ++--- project/src/services/MatchLocationService.ts | 1 - 33 files changed, 210 insertions(+), 238 deletions(-) delete mode 100644 project/src/models/eft/match/IAcceptGroupInviteRequest.ts delete mode 100644 project/src/models/eft/match/IAcceptGroupInviteResponse.ts delete mode 100644 project/src/models/eft/match/ICancelGroupInviteRequest.ts delete mode 100644 project/src/models/eft/match/ICreateGroupRequestData.ts delete mode 100644 project/src/models/eft/match/IDeclineGroupInviteRequest.ts delete mode 100644 project/src/models/eft/match/IGetGroupStatusResponse.ts delete mode 100644 project/src/models/eft/match/IGetProfileRequestData.ts create mode 100644 project/src/models/eft/match/IGroupCharacter.ts delete mode 100644 project/src/models/eft/match/IGroupCurrentResponse.ts delete mode 100644 project/src/models/eft/match/IJoinMatchRequestData.ts delete mode 100644 project/src/models/eft/match/IJoinMatchResult.ts create mode 100644 project/src/models/eft/match/IMatchGroupCurrentResponse.ts create mode 100644 project/src/models/eft/match/IMatchGroupInviteSendRequest.ts create mode 100644 project/src/models/eft/match/IMatchGroupPlayerRemoveRequest.ts create mode 100644 project/src/models/eft/match/IMatchGroupStartGameRequest.ts rename project/src/models/eft/match/{IGetGroupStatusRequestData.ts => IMatchGroupStatusRequest.ts} (80%) create mode 100644 project/src/models/eft/match/IMatchGroupStatusResponse.ts create mode 100644 project/src/models/eft/match/IMatchGroupTransferRequest.ts create mode 100644 project/src/models/eft/match/IProfileStatusRequest.ts create mode 100644 project/src/models/eft/match/IProfileStatusResponse.ts create mode 100644 project/src/models/eft/match/IRaidSettings.ts delete mode 100644 project/src/models/eft/match/IRemovePlayerFromGroupRequest.ts create mode 100644 project/src/models/eft/match/IRequestIdRequest.ts delete mode 100644 project/src/models/eft/match/ISendGroupInviteRequest.ts create mode 100644 project/src/models/eft/match/IServer.ts create mode 100644 project/src/models/eft/match/ISessionStatus.ts delete mode 100644 project/src/models/eft/match/ITransferGroupRequest.ts diff --git a/project/src/callbacks/MatchCallbacks.ts b/project/src/callbacks/MatchCallbacks.ts index 5bedd35f..81537a76 100644 --- a/project/src/callbacks/MatchCallbacks.ts +++ b/project/src/callbacks/MatchCallbacks.ts @@ -3,21 +3,19 @@ import { MatchController } from "@spt-aki/controllers/MatchController"; import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData"; import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData"; import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData"; -import { IAcceptGroupInviteRequest } from "@spt-aki/models/eft/match/IAcceptGroupInviteRequest"; -import { IAcceptGroupInviteResponse } from "@spt-aki/models/eft/match/IAcceptGroupInviteResponse"; -import { ICancelGroupInviteRequest } from "@spt-aki/models/eft/match/ICancelGroupInviteRequest"; -import { IDeclineGroupInviteRequest } from "@spt-aki/models/eft/match/IDeclineGroupInviteRequest"; import { IEndOfflineRaidRequestData } from "@spt-aki/models/eft/match/IEndOfflineRaidRequestData"; -import { IGetGroupStatusRequestData } from "@spt-aki/models/eft/match/IGetGroupStatusRequestData"; -import { IGetGroupStatusResponse } from "@spt-aki/models/eft/match/IGetGroupStatusResponse"; import { IGetRaidConfigurationRequestData } from "@spt-aki/models/eft/match/IGetRaidConfigurationRequestData"; -import { IGroupCurrentResponse } from "@spt-aki/models/eft/match/IGroupCurrentResponse"; -import { IJoinMatchRequestData } from "@spt-aki/models/eft/match/IJoinMatchRequestData"; -import { IJoinMatchResult } from "@spt-aki/models/eft/match/IJoinMatchResult"; +import { IGroupCharacter } from "@spt-aki/models/eft/match/IGroupCharacter"; +import { IMatchGroupCurrentResponse } from "@spt-aki/models/eft/match/IMatchGroupCurrentResponse"; +import { IMatchGroupInviteSendRequest } from "@spt-aki/models/eft/match/IMatchGroupInviteSendRequest"; +import { IMatchGroupPlayerRemoveRequest } from "@spt-aki/models/eft/match/IMatchGroupPlayerRemoveRequest"; +import { IMatchGroupStartGameRequest } from "@spt-aki/models/eft/match/IMatchGroupStartGameRequest"; +import { IMatchGroupStatusRequest } from "@spt-aki/models/eft/match/IMatchGroupStatusRequest"; +import { IMatchGroupStatusResponse } from "@spt-aki/models/eft/match/IMatchGroupStatusResponse"; +import { IMatchGroupTransferRequest } from "@spt-aki/models/eft/match/IMatchGroupTransferRequest"; +import { IProfileStatusResponse } from "@spt-aki/models/eft/match/IProfileStatusResponse"; import { IPutMetricsRequestData } from "@spt-aki/models/eft/match/IPutMetricsRequestData"; -import { IRemovePlayerFromGroupRequest } from "@spt-aki/models/eft/match/IRemovePlayerFromGroupRequest"; -import { ISendGroupInviteRequest } from "@spt-aki/models/eft/match/ISendGroupInviteRequest"; -import { ITransferGroupRequest } from "@spt-aki/models/eft/match/ITransferGroupRequest"; +import { IRequestIdRequest } from "@spt-aki/models/eft/match/IRequestIdRequest"; import { IUpdatePingRequestData } from "@spt-aki/models/eft/match/IUpdatePingRequestData"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; @@ -59,7 +57,7 @@ export class MatchCallbacks url: string, info: IEmptyRequestData, sessionID: string, - ): IGetBodyResponseData + ): IGetBodyResponseData { throw new Error("Method not implemented."); } @@ -78,7 +76,11 @@ export class MatchCallbacks /** Handle client/match/group/invite/send */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - public sendGroupInvite(url: string, info: ISendGroupInviteRequest, sessionID: string): IGetBodyResponseData + public sendGroupInvite( + url: string, + info: IMatchGroupInviteSendRequest, + sessionID: string, + ): IGetBodyResponseData { return this.httpResponse.getBody("2427943f23698ay9f2863735"); } @@ -87,9 +89,9 @@ export class MatchCallbacks // eslint-disable-next-line @typescript-eslint/no-unused-vars public acceptGroupInvite( url: string, - info: IAcceptGroupInviteRequest, + info: IRequestIdRequest, sessionId: string, - ): IGetBodyResponseData + ): IGetBodyResponseData { const result = []; result.push({}); @@ -101,7 +103,7 @@ export class MatchCallbacks // eslint-disable-next-line @typescript-eslint/no-unused-vars public declineGroupInvite( url: string, - info: IDeclineGroupInviteRequest, + info: IRequestIdRequest, sessionId: string, ): IGetBodyResponseData { @@ -112,7 +114,7 @@ export class MatchCallbacks // eslint-disable-next-line @typescript-eslint/no-unused-vars public cancelGroupInvite( url: string, - info: ICancelGroupInviteRequest, + info: IRequestIdRequest, sessionID: string, ): IGetBodyResponseData { @@ -123,7 +125,7 @@ export class MatchCallbacks // eslint-disable-next-line @typescript-eslint/no-unused-vars public transferGroup( url: string, - info: ITransferGroupRequest, + info: IMatchGroupTransferRequest, sessionId: string, ): IGetBodyResponseData { @@ -160,9 +162,9 @@ export class MatchCallbacks /** Handle match/group/start_game */ public joinMatch( url: string, - info: IJoinMatchRequestData, + info: IMatchGroupStartGameRequest, sessionID: string, - ): IGetBodyResponseData + ): IGetBodyResponseData { return this.httpResponse.getBody(this.matchController.joinMatch(info, sessionID)); } @@ -182,16 +184,16 @@ export class MatchCallbacks // eslint-disable-next-line @typescript-eslint/no-unused-vars public getGroupStatus( url: string, - info: IGetGroupStatusRequestData, + info: IMatchGroupStatusRequest, sessionID: string, - ): IGetBodyResponseData + ): IGetBodyResponseData { return this.httpResponse.getBody(this.matchController.getGroupStatus(info)); } /** Handle client/match/group/delete */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - public deleteGroup(url: string, info: any, sessionID: string): IGetBodyResponseData + public deleteGroup(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData { this.matchController.deleteGroup(info); return this.httpResponse.getBody(true); @@ -208,7 +210,7 @@ export class MatchCallbacks // eslint-disable-next-line @typescript-eslint/no-unused-vars public removePlayerFromGroup( url: string, - info: IRemovePlayerFromGroupRequest, + info: IMatchGroupPlayerRemoveRequest, sessionID: string, ): IGetBodyResponseData { diff --git a/project/src/controllers/MatchController.ts b/project/src/controllers/MatchController.ts index de2b8caa..23dd7b78 100644 --- a/project/src/controllers/MatchController.ts +++ b/project/src/controllers/MatchController.ts @@ -7,11 +7,11 @@ import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { IEndOfflineRaidRequestData } from "@spt-aki/models/eft/match/IEndOfflineRaidRequestData"; -import { IGetGroupStatusRequestData } from "@spt-aki/models/eft/match/IGetGroupStatusRequestData"; -import { IGetGroupStatusResponse } from "@spt-aki/models/eft/match/IGetGroupStatusResponse"; import { IGetRaidConfigurationRequestData } from "@spt-aki/models/eft/match/IGetRaidConfigurationRequestData"; -import { IJoinMatchRequestData } from "@spt-aki/models/eft/match/IJoinMatchRequestData"; -import { IJoinMatchResult } from "@spt-aki/models/eft/match/IJoinMatchResult"; +import { IMatchGroupStartGameRequest } from "@spt-aki/models/eft/match/IMatchGroupStartGameRequest"; +import { IMatchGroupStatusRequest } from "@spt-aki/models/eft/match/IMatchGroupStatusRequest"; +import { IMatchGroupStatusResponse } from "@spt-aki/models/eft/match/IMatchGroupStatusResponse"; +import { IProfileStatusResponse } from "@spt-aki/models/eft/match/IProfileStatusResponse"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; import { MessageType } from "@spt-aki/models/enums/MessageType"; import { Traders } from "@spt-aki/models/enums/Traders"; @@ -76,9 +76,9 @@ export class MatchController /** Handle match/group/start_game */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - public joinMatch(info: IJoinMatchRequestData, sessionId: string): IJoinMatchResult + public joinMatch(info: IMatchGroupStartGameRequest, sessionId: string): IProfileStatusResponse { - const output: IJoinMatchResult = { maxPveCountExceeded: false, profiles: [] }; + const output: IProfileStatusResponse = { maxPveCountExceeded: false, profiles: [] }; // get list of players joining into the match output.profiles.push({ @@ -92,7 +92,7 @@ export class MatchController location: "TODO get location", raidMode: "Online", mode: "deathmatch", - shortid: null, + shortId: null, // eslint-disable-next-line @typescript-eslint/naming-convention additional_info: null, }); @@ -102,7 +102,7 @@ export class MatchController /** Handle client/match/group/status */ // eslint-disable-next-line @typescript-eslint/no-unused-vars - public getGroupStatus(info: IGetGroupStatusRequestData): IGetGroupStatusResponse + public getGroupStatus(info: IMatchGroupStatusRequest): IMatchGroupStatusResponse { return { players: [], maxPveCountExceeded: false }; } diff --git a/project/src/models/eft/match/IAcceptGroupInviteRequest.ts b/project/src/models/eft/match/IAcceptGroupInviteRequest.ts deleted file mode 100644 index 63f2aadb..00000000 --- a/project/src/models/eft/match/IAcceptGroupInviteRequest.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface IAcceptGroupInviteRequest -{ - requestId: string -} diff --git a/project/src/models/eft/match/IAcceptGroupInviteResponse.ts b/project/src/models/eft/match/IAcceptGroupInviteResponse.ts deleted file mode 100644 index cf650480..00000000 --- a/project/src/models/eft/match/IAcceptGroupInviteResponse.ts +++ /dev/null @@ -1,19 +0,0 @@ -export interface IAcceptGroupInviteResponse -{ - _id: string - aid: number - Info: PlayerInviteInfo - isLeader: boolean - isReady: boolean -} - -export interface PlayerInviteInfo -{ - Nickname: string - Side: string - Level: number - MemberCategory: number - GameVersion: string - SavageLockTime: number - SavageNickname: string -} diff --git a/project/src/models/eft/match/ICancelGroupInviteRequest.ts b/project/src/models/eft/match/ICancelGroupInviteRequest.ts deleted file mode 100644 index 253d4a94..00000000 --- a/project/src/models/eft/match/ICancelGroupInviteRequest.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ICancelGroupInviteRequest -{ - requestId: string -} diff --git a/project/src/models/eft/match/ICreateGroupRequestData.ts b/project/src/models/eft/match/ICreateGroupRequestData.ts deleted file mode 100644 index e742335f..00000000 --- a/project/src/models/eft/match/ICreateGroupRequestData.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { RaidMode } from "@spt-aki/models/enums/RaidMode"; - -export interface ICreateGroupRequestData -{ - location: string - raidMode: RaidMode - startInGroup: boolean -} diff --git a/project/src/models/eft/match/IDeclineGroupInviteRequest.ts b/project/src/models/eft/match/IDeclineGroupInviteRequest.ts deleted file mode 100644 index 718641e0..00000000 --- a/project/src/models/eft/match/IDeclineGroupInviteRequest.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface IDeclineGroupInviteRequest -{ - requestId: string; -} diff --git a/project/src/models/eft/match/IGetGroupStatusResponse.ts b/project/src/models/eft/match/IGetGroupStatusResponse.ts deleted file mode 100644 index fed1ccdc..00000000 --- a/project/src/models/eft/match/IGetGroupStatusResponse.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { MemberCategory } from "@spt-aki/models/enums/MemberCategory"; - -export interface IGetGroupStatusResponse -{ - players: IPlayer[] - maxPveCountExceeded: boolean -} - -export interface IPlayer -{ - aid: string - _id: string - lookingGroup: boolean - IsLeader: boolean - IsReady: boolean - Info: ICurrentGroupMemberInfo -} - -export interface ICurrentGroupMemberInfo -{ - Nickname: string - Side: string - Level: string - MemberCategory: MemberCategory -} diff --git a/project/src/models/eft/match/IGetProfileRequestData.ts b/project/src/models/eft/match/IGetProfileRequestData.ts deleted file mode 100644 index 6be9dc34..00000000 --- a/project/src/models/eft/match/IGetProfileRequestData.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface IGetProfileRequestData -{ - profileId: string -} diff --git a/project/src/models/eft/match/IGetRaidConfigurationRequestData.ts b/project/src/models/eft/match/IGetRaidConfigurationRequestData.ts index 2548f84e..947762dd 100644 --- a/project/src/models/eft/match/IGetRaidConfigurationRequestData.ts +++ b/project/src/models/eft/match/IGetRaidConfigurationRequestData.ts @@ -1,71 +1,8 @@ -export interface IGetRaidConfigurationRequestData +import { IRaidSettings } from "@spt-aki/models/eft/match/IRaidSettings"; + +export interface IGetRaidConfigurationRequestData extends IRaidSettings { keyId: string - side: string - location: string - timeVariant: string - raidMode: string - metabolismDisabled: boolean - playersSpawnPlace: string - timeAndWeatherSettings: TimeAndWeatherSettings - botSettings: BotSettings - wavesSettings: WavesSettings CanShowGroupPreview: boolean MaxGroupCount: number } - -// { -// keyId: "", -// side: "Pmc", -// location: "factory4_day", -// timeVariant: "CURR", or "PAST" -// raidMode: "Local", -// metabolismDisabled: false, -// playersSpawnPlace: "SamePlace", -// timeAndWeatherSettings: { -// isRandomTime: false, -// isRandomWeather: false, -// cloudinessType: "Clear", -// rainType: "NoRain", -// windType: "Light", -// fogType: "NoFog", -// timeFlowType: "x1", -// hourOfDay: -1 -// }, -// botSettings: { -// isScavWars: false, -// botAmount: "AsOnline" -// }, -// wavesSettings: { -// botAmount: "AsOnline", -// botDifficulty: "AsOnline", -// isBosses: true, -// isTaggedAndCursed: false -// } -// } - -export interface TimeAndWeatherSettings -{ - isRandomTime: boolean - isRandomWeather: boolean - cloudinessType: string - rainType: string - windType: string - fogType: string - timeFlowType: string - hourOfDay: number -} - -export interface BotSettings -{ - isScavWars: boolean - botAmount: string -} - -export interface WavesSettings -{ - botAmount: string - botDifficulty: string - isBosses: boolean - isTaggedAndCursed: boolean -} diff --git a/project/src/models/eft/match/IGroupCharacter.ts b/project/src/models/eft/match/IGroupCharacter.ts new file mode 100644 index 00000000..98c61d1e --- /dev/null +++ b/project/src/models/eft/match/IGroupCharacter.ts @@ -0,0 +1,41 @@ +import { Item } from "@spt-aki/models/eft/common/tables/IItem"; +import { MemberCategory } from "@spt-aki/models/enums/MemberCategory"; + +export interface IGroupCharacter +{ + _id: string + aid: number + Info: { + Nickname: string + Side: string + Level: number + MemberCategory: MemberCategory + GameVersion?: string + SavageLockTime?: number + SavageNickname?: string + hasCoopExtension?: boolean + } + PlayerVisualRepresentation?: { + Info: { + Side: string + Level: number + Nickname: string + MemberCategory: MemberCategory + GameVersion: string + } + Customization: { + Head: string + Body: string + Feet: string + Hands: string + } + Equipment: { + Id: string + Items: Item[] + } + } + isLeader: boolean + isReady?: boolean + region?: string + lookingGroup?: boolean +} diff --git a/project/src/models/eft/match/IGroupCurrentResponse.ts b/project/src/models/eft/match/IGroupCurrentResponse.ts deleted file mode 100644 index 266ac492..00000000 --- a/project/src/models/eft/match/IGroupCurrentResponse.ts +++ /dev/null @@ -1,13 +0,0 @@ -export interface IGroupCurrentResponse -{ - squad: ISquadMember[] -} - -export interface ISquadMember -{ - _id: string - aid: number - Info: any - isLeader: boolean - isReady: boolean -} diff --git a/project/src/models/eft/match/IJoinMatchRequestData.ts b/project/src/models/eft/match/IJoinMatchRequestData.ts deleted file mode 100644 index d06fb6ce..00000000 --- a/project/src/models/eft/match/IJoinMatchRequestData.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface IJoinMatchRequestData -{ - groupId: string - servers: Server[] -} - -export interface Server -{ - ping: number - ip: string - port: string -} diff --git a/project/src/models/eft/match/IJoinMatchResult.ts b/project/src/models/eft/match/IJoinMatchResult.ts deleted file mode 100644 index da9f4025..00000000 --- a/project/src/models/eft/match/IJoinMatchResult.ts +++ /dev/null @@ -1,21 +0,0 @@ -export interface IJoinMatchResult -{ - maxPveCountExceeded: boolean - profiles: IJoinMatchPlayerProfile[] -} - -export interface IJoinMatchPlayerProfile -{ - profileid: string - profileToken: string - status: string - sid: string - ip: string - port: number - version: string - location: string - raidMode: string - mode: string - shortid: string - additional_info: any[] -} diff --git a/project/src/models/eft/match/IMatchGroupCurrentResponse.ts b/project/src/models/eft/match/IMatchGroupCurrentResponse.ts new file mode 100644 index 00000000..7f504cbc --- /dev/null +++ b/project/src/models/eft/match/IMatchGroupCurrentResponse.ts @@ -0,0 +1,6 @@ +import { IGroupCharacter } from "@spt-aki/models/eft/match/IGroupCharacter"; + +export interface IMatchGroupCurrentResponse +{ + squad: IGroupCharacter[] +} diff --git a/project/src/models/eft/match/IMatchGroupInviteSendRequest.ts b/project/src/models/eft/match/IMatchGroupInviteSendRequest.ts new file mode 100644 index 00000000..b1dddb36 --- /dev/null +++ b/project/src/models/eft/match/IMatchGroupInviteSendRequest.ts @@ -0,0 +1,5 @@ +export interface IMatchGroupInviteSendRequest +{ + to: string + inLobby: boolean +} diff --git a/project/src/models/eft/match/IMatchGroupPlayerRemoveRequest.ts b/project/src/models/eft/match/IMatchGroupPlayerRemoveRequest.ts new file mode 100644 index 00000000..6cdef152 --- /dev/null +++ b/project/src/models/eft/match/IMatchGroupPlayerRemoveRequest.ts @@ -0,0 +1,4 @@ +export interface IMatchGroupPlayerRemoveRequest +{ + aidToKick: string +} diff --git a/project/src/models/eft/match/IMatchGroupStartGameRequest.ts b/project/src/models/eft/match/IMatchGroupStartGameRequest.ts new file mode 100644 index 00000000..9396124f --- /dev/null +++ b/project/src/models/eft/match/IMatchGroupStartGameRequest.ts @@ -0,0 +1,7 @@ +import { IServer } from "@spt-aki/models/eft/match/IServer"; + +export interface IMatchGroupStartGameRequest +{ + groupId: string + servers: IServer[] +} diff --git a/project/src/models/eft/match/IGetGroupStatusRequestData.ts b/project/src/models/eft/match/IMatchGroupStatusRequest.ts similarity index 80% rename from project/src/models/eft/match/IGetGroupStatusRequestData.ts rename to project/src/models/eft/match/IMatchGroupStatusRequest.ts index d1488a40..e5587e67 100644 --- a/project/src/models/eft/match/IGetGroupStatusRequestData.ts +++ b/project/src/models/eft/match/IMatchGroupStatusRequest.ts @@ -1,6 +1,6 @@ import { RaidMode } from "@spt-aki/models/enums/RaidMode"; -export interface IGetGroupStatusRequestData +export interface IMatchGroupStatusRequest { location: string savage: boolean diff --git a/project/src/models/eft/match/IMatchGroupStatusResponse.ts b/project/src/models/eft/match/IMatchGroupStatusResponse.ts new file mode 100644 index 00000000..4890b101 --- /dev/null +++ b/project/src/models/eft/match/IMatchGroupStatusResponse.ts @@ -0,0 +1,7 @@ +import { IGroupCharacter } from "@spt-aki/models/eft/match/IGroupCharacter"; + +export interface IMatchGroupStatusResponse +{ + players: IGroupCharacter[] + maxPveCountExceeded: boolean +} diff --git a/project/src/models/eft/match/IMatchGroupTransferRequest.ts b/project/src/models/eft/match/IMatchGroupTransferRequest.ts new file mode 100644 index 00000000..692e9cd4 --- /dev/null +++ b/project/src/models/eft/match/IMatchGroupTransferRequest.ts @@ -0,0 +1,4 @@ +export interface IMatchGroupTransferRequest +{ + aidToChange: string +} diff --git a/project/src/models/eft/match/IProfileStatusRequest.ts b/project/src/models/eft/match/IProfileStatusRequest.ts new file mode 100644 index 00000000..b5039edb --- /dev/null +++ b/project/src/models/eft/match/IProfileStatusRequest.ts @@ -0,0 +1,4 @@ +export interface IProfileStatusRequest +{ + groupId: number +} diff --git a/project/src/models/eft/match/IProfileStatusResponse.ts b/project/src/models/eft/match/IProfileStatusResponse.ts new file mode 100644 index 00000000..48e85816 --- /dev/null +++ b/project/src/models/eft/match/IProfileStatusResponse.ts @@ -0,0 +1,7 @@ +import { ISessionStatus } from "@spt-aki/models/eft/match/ISessionStatus"; + +export interface IProfileStatusResponse +{ + maxPveCountExceeded: boolean + profiles: ISessionStatus[] +} diff --git a/project/src/models/eft/match/IRaidSettings.ts b/project/src/models/eft/match/IRaidSettings.ts new file mode 100644 index 00000000..2a14a009 --- /dev/null +++ b/project/src/models/eft/match/IRaidSettings.ts @@ -0,0 +1,50 @@ +import { DateTime } from "@spt-aki/models/enums/DateTime"; +import { PlayersSpawnPlace } from "@spt-aki/models/enums/PlayersSpawnPlace"; +import { RaidMode } from "@spt-aki/models/enums/RaidMode"; +import { BotAmount } from "@spt-aki/models/enums/RaidSettings/BotAmount"; +import { BotDifficulty } from "@spt-aki/models/enums/RaidSettings/BotDifficulty"; +import { CloudinessType } from "@spt-aki/models/enums/RaidSettings/TimeAndWeather/CloudinessType"; +import { FogType } from "@spt-aki/models/enums/RaidSettings/TimeAndWeather/FogType"; +import { RainType } from "@spt-aki/models/enums/RaidSettings/TimeAndWeather/RainType"; +import { TimeFlowType } from "@spt-aki/models/enums/RaidSettings/TimeAndWeather/TimeFlowType"; +import { WindSpeed } from "@spt-aki/models/enums/RaidSettings/TimeAndWeather/WindSpeed"; +import { SideType } from "@spt-aki/models/enums/SideType"; + +export interface IRaidSettings +{ + location: string + timeVariant: DateTime + raidMode: RaidMode + metabolismDisabled: boolean + playersSpawnPlace: PlayersSpawnPlace + timeAndWeatherSettings: TimeAndWeatherSettings + botSettings: BotSettings + wavesSettings: WavesSettings + side: SideType +} + +export interface TimeAndWeatherSettings +{ + isRandomTime: boolean + isRandomWeather: boolean + cloudinessType: CloudinessType + rainType: RainType + fogType: FogType + windType: WindSpeed + timeFlowType: TimeFlowType + hourOfDay: number +} + +export interface BotSettings +{ + isScavWars: boolean + botAmount: BotAmount +} + +export interface WavesSettings +{ + botAmount: BotAmount + botDifficulty: BotDifficulty + isBosses: boolean + isTaggedAndCursed: boolean +} diff --git a/project/src/models/eft/match/IRemovePlayerFromGroupRequest.ts b/project/src/models/eft/match/IRemovePlayerFromGroupRequest.ts deleted file mode 100644 index 60219e63..00000000 --- a/project/src/models/eft/match/IRemovePlayerFromGroupRequest.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface IRemovePlayerFromGroupRequest -{ - aidToKick: string -} diff --git a/project/src/models/eft/match/IRequestIdRequest.ts b/project/src/models/eft/match/IRequestIdRequest.ts new file mode 100644 index 00000000..a742c2ce --- /dev/null +++ b/project/src/models/eft/match/IRequestIdRequest.ts @@ -0,0 +1,4 @@ +export interface IRequestIdRequest +{ + requestId: string +} diff --git a/project/src/models/eft/match/ISendGroupInviteRequest.ts b/project/src/models/eft/match/ISendGroupInviteRequest.ts deleted file mode 100644 index 40d1a551..00000000 --- a/project/src/models/eft/match/ISendGroupInviteRequest.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface ISendGroupInviteRequest -{ - to: string - inLobby: boolean -} diff --git a/project/src/models/eft/match/IServer.ts b/project/src/models/eft/match/IServer.ts new file mode 100644 index 00000000..d5510fdd --- /dev/null +++ b/project/src/models/eft/match/IServer.ts @@ -0,0 +1,6 @@ +export interface IServer +{ + ping: number + ip: string + port: number +} diff --git a/project/src/models/eft/match/ISessionStatus.ts b/project/src/models/eft/match/ISessionStatus.ts new file mode 100644 index 00000000..0b76b4a9 --- /dev/null +++ b/project/src/models/eft/match/ISessionStatus.ts @@ -0,0 +1,16 @@ +export interface ISessionStatus +{ + profileid: string + profileToken: string + status: string + ip: string + port: number + sid: string + version?: string + location?: string + raidMode?: string + mode?: string + shortId?: string + // eslint-disable-next-line @typescript-eslint/naming-convention + additional_info?: any[] +} diff --git a/project/src/models/eft/match/ITransferGroupRequest.ts b/project/src/models/eft/match/ITransferGroupRequest.ts deleted file mode 100644 index ddce126a..00000000 --- a/project/src/models/eft/match/ITransferGroupRequest.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ITransferGroupRequest -{ - aidToChange: string -} diff --git a/project/src/models/eft/notifier/INotifier.ts b/project/src/models/eft/notifier/INotifier.ts index 99b5121d..f21d5a81 100644 --- a/project/src/models/eft/notifier/INotifier.ts +++ b/project/src/models/eft/notifier/INotifier.ts @@ -45,5 +45,5 @@ export enum NotificationType FRIEND_LIST_NEW_REQUEST = "friendListNewRequest", FRIEND_LIST_REMOVED_FROM_FRIEND_LIST = "youAreRemovedFromFriendList", YOU_ARE_ADDED_TO_IGNORE_LIST = "YouWereAddedToIgnoreList", - YOU_ARE_REMOVED_FROM_IGNORE_LIST = "youAreRemoveFromIgnoreList" + YOU_ARE_REMOVED_FROM_IGNORE_LIST = "youAreRemoveFromIgnoreList", } diff --git a/project/src/routers/static/MatchStaticRouter.ts b/project/src/routers/static/MatchStaticRouter.ts index 5e2612a7..49fbd65c 100644 --- a/project/src/routers/static/MatchStaticRouter.ts +++ b/project/src/routers/static/MatchStaticRouter.ts @@ -4,10 +4,10 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData"; import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData"; import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData"; -import { IAcceptGroupInviteResponse } from "@spt-aki/models/eft/match/IAcceptGroupInviteResponse"; -import { IGetGroupStatusResponse } from "@spt-aki/models/eft/match/IGetGroupStatusResponse"; -import { IGroupCurrentResponse } from "@spt-aki/models/eft/match/IGroupCurrentResponse"; -import { IJoinMatchResult } from "@spt-aki/models/eft/match/IJoinMatchResult"; +import { IGroupCharacter } from "@spt-aki/models/eft/match/IGroupCharacter"; +import { IMatchGroupCurrentResponse } from "@spt-aki/models/eft/match/IMatchGroupCurrentResponse"; +import { IMatchGroupStatusResponse } from "@spt-aki/models/eft/match/IMatchGroupStatusResponse"; +import { IProfileStatusResponse } from "@spt-aki/models/eft/match/IProfileStatusResponse"; @injectable() export class MatchStaticRouter extends StaticRouter @@ -41,7 +41,7 @@ export class MatchStaticRouter extends StaticRouter info: any, sessionID: string, output: string, - ): Promise> => + ): Promise> => { return this.matchCallbacks.joinMatch(url, info, sessionID); }, @@ -84,7 +84,7 @@ export class MatchStaticRouter extends StaticRouter info: any, sessionID: string, output: string, - ): Promise> => + ): Promise> => { return this.matchCallbacks.getGroupStatus(url, info, sessionID); }, @@ -96,7 +96,7 @@ export class MatchStaticRouter extends StaticRouter info: any, sessionID: string, output: string, - ): Promise> => + ): Promise> => { return this.matchCallbacks.joinMatch(url, info, sessionID); }, @@ -115,7 +115,7 @@ export class MatchStaticRouter extends StaticRouter info: IEmptyRequestData, sessionID: string, output: string, - ): Promise> => + ): Promise> => { return this.matchCallbacks.groupCurrent(url, info, sessionID); }, @@ -153,7 +153,7 @@ export class MatchStaticRouter extends StaticRouter info: any, sessionID: string, output: string, - ): Promise> => + ): Promise> => { return this.matchCallbacks.acceptGroupInvite(url, info, sessionID); }, diff --git a/project/src/services/MatchLocationService.ts b/project/src/services/MatchLocationService.ts index 758c4fc0..ad93afc7 100644 --- a/project/src/services/MatchLocationService.ts +++ b/project/src/services/MatchLocationService.ts @@ -1,5 +1,4 @@ import { inject, injectable } from "tsyringe"; -import { ICreateGroupRequestData } from "@spt-aki/models/eft/match/ICreateGroupRequestData"; import { SaveServer } from "@spt-aki/servers/SaveServer"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; From f147bb64eb210b533df4e7032985c1cbd19f753a Mon Sep 17 00:00:00 2001 From: TheSparta Date: Wed, 15 May 2024 23:47:37 +0100 Subject: [PATCH 2/3] restructured Notification interfaces... - Restructured notification interfaces - Added some missing enums --- project/src/helpers/NotificationSendHelper.ts | 10 +++-- project/src/helpers/NotifierHelper.ts | 18 ++++---- project/src/models/eft/notifier/INotifier.ts | 42 +------------------ project/src/models/eft/ws/IWsAid.ts | 6 +++ project/src/models/eft/ws/IWsAidNickname.ts | 7 ++++ .../models/eft/ws/IWsChatMessageReceived.ts | 10 +++++ project/src/models/eft/ws/IWsGroupId.ts | 6 +++ .../eft/ws/IWsGroupMatchInviteAccept.ts | 7 ++++ .../eft/ws/IWsGroupMatchInviteDecline.ts | 7 ++++ .../models/eft/ws/IWsGroupMatchInviteSend.ts | 9 ++++ .../eft/ws/IWsGroupMatchLeaderChanged.ts | 6 +++ .../models/eft/ws/IWsGroupMatchRaidReady.ts | 7 ++++ .../eft/ws/IWsGroupMatchRaidSettings.ts | 7 ++++ .../src/models/eft/ws/IWsNotificationEvent.ts | 5 +++ project/src/models/eft/ws/IWsPing.ts | 6 +++ .../src/models/eft/ws/IWsRagfairOfferSold.ts | 8 ++++ project/src/models/eft/ws/IWsUserConfirmed.ts | 20 +++++++++ project/src/models/enums/DateTime.ts | 5 +++ .../src/models/enums/NotificationEventType.ts | 29 +++++++++++++ project/src/models/enums/PlayersSpawnPlace.ts | 6 +++ project/src/models/enums/ProfileStatus.ts | 8 ++++ .../enums/{ => RaidSettings}/BotAmount.ts | 1 + .../enums/{ => RaidSettings}/BotDifficulty.ts | 0 .../TimeAndWeather/CloudinessType.ts | 9 ++++ .../RaidSettings/TimeAndWeather/FogType.ts | 8 ++++ .../RaidSettings/TimeAndWeather/RainType.ts | 8 ++++ .../TimeAndWeather/TimeFlowType.ts | 11 +++++ .../RaidSettings/TimeAndWeather/WindSpeed.ts | 8 ++++ project/src/models/enums/SideType.ts | 6 +++ project/src/servers/WebSocketServer.ts | 7 ++-- project/src/services/NotificationService.ts | 4 +- 31 files changed, 233 insertions(+), 58 deletions(-) create mode 100644 project/src/models/eft/ws/IWsAid.ts create mode 100644 project/src/models/eft/ws/IWsAidNickname.ts create mode 100644 project/src/models/eft/ws/IWsChatMessageReceived.ts create mode 100644 project/src/models/eft/ws/IWsGroupId.ts create mode 100644 project/src/models/eft/ws/IWsGroupMatchInviteAccept.ts create mode 100644 project/src/models/eft/ws/IWsGroupMatchInviteDecline.ts create mode 100644 project/src/models/eft/ws/IWsGroupMatchInviteSend.ts create mode 100644 project/src/models/eft/ws/IWsGroupMatchLeaderChanged.ts create mode 100644 project/src/models/eft/ws/IWsGroupMatchRaidReady.ts create mode 100644 project/src/models/eft/ws/IWsGroupMatchRaidSettings.ts create mode 100644 project/src/models/eft/ws/IWsNotificationEvent.ts create mode 100644 project/src/models/eft/ws/IWsPing.ts create mode 100644 project/src/models/eft/ws/IWsRagfairOfferSold.ts create mode 100644 project/src/models/eft/ws/IWsUserConfirmed.ts create mode 100644 project/src/models/enums/DateTime.ts create mode 100644 project/src/models/enums/NotificationEventType.ts create mode 100644 project/src/models/enums/PlayersSpawnPlace.ts create mode 100644 project/src/models/enums/ProfileStatus.ts rename project/src/models/enums/{ => RaidSettings}/BotAmount.ts (84%) rename project/src/models/enums/{ => RaidSettings}/BotDifficulty.ts (100%) create mode 100644 project/src/models/enums/RaidSettings/TimeAndWeather/CloudinessType.ts create mode 100644 project/src/models/enums/RaidSettings/TimeAndWeather/FogType.ts create mode 100644 project/src/models/enums/RaidSettings/TimeAndWeather/RainType.ts create mode 100644 project/src/models/enums/RaidSettings/TimeAndWeather/TimeFlowType.ts create mode 100644 project/src/models/enums/RaidSettings/TimeAndWeather/WindSpeed.ts create mode 100644 project/src/models/enums/SideType.ts diff --git a/project/src/helpers/NotificationSendHelper.ts b/project/src/helpers/NotificationSendHelper.ts index 0600d8ad..a7347a25 100644 --- a/project/src/helpers/NotificationSendHelper.ts +++ b/project/src/helpers/NotificationSendHelper.ts @@ -1,8 +1,10 @@ import { inject, injectable } from "tsyringe"; -import { INotification, NotificationType } from "@spt-aki/models/eft/notifier/INotifier"; import { Dialogue, IUserDialogInfo, Message } from "@spt-aki/models/eft/profile/IAkiProfile"; +import { IWsChatMessageReceived } from "@spt-aki/models/eft/ws/IWsChatMessageReceived"; +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; import { MemberCategory } from "@spt-aki/models/enums/MemberCategory"; import { MessageType } from "@spt-aki/models/enums/MessageType"; +import { NotificationEventType } from "@spt-aki/models/enums/NotificationEventType"; import { SaveServer } from "@spt-aki/servers/SaveServer"; import { WebSocketServer } from "@spt-aki/servers/WebSocketServer"; import { NotificationService } from "@spt-aki/services/NotificationService"; @@ -24,7 +26,7 @@ export class NotificationSendHelper * @param sessionID * @param notificationMessage */ - public sendMessage(sessionID: string, notificationMessage: INotification): void + public sendMessage(sessionID: string, notificationMessage: IWsNotificationEvent): void { if (this.webSocketServer.isConnectionWebSocket(sessionID)) { @@ -65,8 +67,8 @@ export class NotificationSendHelper }; dialog.messages.push(message); - const notification: INotification = { - type: NotificationType.NEW_MESSAGE, + const notification: IWsChatMessageReceived = { + type: NotificationEventType.CHAT_MESSAGE_RECEIVED, eventId: message._id, dialogId: message.uid, message: message, diff --git a/project/src/helpers/NotifierHelper.ts b/project/src/helpers/NotifierHelper.ts index 287a3982..7775879d 100644 --- a/project/src/helpers/NotifierHelper.ts +++ b/project/src/helpers/NotifierHelper.ts @@ -1,7 +1,10 @@ import { inject, injectable } from "tsyringe"; import { HttpServerHelper } from "@spt-aki/helpers/HttpServerHelper"; -import { INotification, NotificationType } from "@spt-aki/models/eft/notifier/INotifier"; import { Message, MessageContentRagfair } from "@spt-aki/models/eft/profile/IAkiProfile"; +import { IWsChatMessageReceived } from "@spt-aki/models/eft/ws/IWsChatMessageReceived"; +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; +import { IWsRagfairOfferSold } from "@spt-aki/models/eft/ws/IWsRagfairOfferSold"; +import { NotificationEventType } from "@spt-aki/models/enums/NotificationEventType"; @injectable() export class NotifierHelper @@ -9,12 +12,12 @@ export class NotifierHelper /** * The default notification sent when waiting times out. */ - protected defaultNotification: INotification = { type: NotificationType.PING, eventId: "ping" }; + protected defaultNotification: IWsNotificationEvent = { type: NotificationEventType.PING, eventId: "ping" }; constructor(@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper) {} - public getDefaultNotification(): INotification + public getDefaultNotification(): IWsNotificationEvent { return this.defaultNotification; } @@ -28,12 +31,11 @@ export class NotifierHelper public createRagfairOfferSoldNotification( dialogueMessage: Message, ragfairData: MessageContentRagfair, - ): INotification + ): IWsRagfairOfferSold { return { - type: NotificationType.RAGFAIR_OFFER_SOLD, + type: NotificationEventType.RAGFAIR_OFFER_SOLD, eventId: dialogueMessage._id, - dialogId: dialogueMessage.uid, ...ragfairData, }; } @@ -43,10 +45,10 @@ export class NotifierHelper * @param dialogueMessage * @returns */ - public createNewMessageNotification(dialogueMessage: Message): INotification + public createNewMessageNotification(dialogueMessage: Message): IWsChatMessageReceived { return { - type: NotificationType.NEW_MESSAGE, + type: NotificationEventType.CHAT_MESSAGE_RECEIVED, eventId: dialogueMessage._id, dialogId: dialogueMessage.uid, message: dialogueMessage, diff --git a/project/src/models/eft/notifier/INotifier.ts b/project/src/models/eft/notifier/INotifier.ts index f21d5a81..86c67229 100644 --- a/project/src/models/eft/notifier/INotifier.ts +++ b/project/src/models/eft/notifier/INotifier.ts @@ -1,49 +1,9 @@ -import { Message } from "@spt-aki/models/eft/profile/IAkiProfile"; - export interface INotifierChannel { server: string + // eslint-disable-next-line @typescript-eslint/naming-convention channel_id: string url: string notifierServer: string ws: string } - -export interface INotification -{ - type: NotificationType - eventId: string - dialogId?: string - message?: Message -} - -export enum NotificationType -{ - RAGFAIR_OFFER_SOLD = "RagfairOfferSold", - RAGFAIR_RATING_CHANGE = "RagfairRatingChange", - /** ChatMessageReceived */ - NEW_MESSAGE = "new_message", - PING = "ping", - TRADER_SUPPLY = "TraderSupply", - TRADER_STANDING = "TraderStanding", - UNLOCK_TRADER = "UnlockTrader", - GROUP_MATCH_RAID_SETTINGS = "groupMatchRaidSettings", - GROUP_MATCH_RAID_NOT_READY = "groupMatchRaidNotReady", - GROUP_MATCH_RAID_READY = "groupMatchRaidReady", - GROUP_MATCH_INVITE_ACCEPT = "groupMatchInviteAccept", - GROUP_MATCH_INVITE_DECLINE = "groupMatchInviteDecline", - GROUP_MATCH_INVITE_SEND = "groupMatchInviteSend", - GROUP_MATCH_LEADER_CHANGED = "groupMatchLeaderChanged", - GROUP_MATCH_START_GAME = "groupMatchStartGame", - GROUP_MATCH_USER_LEAVE = "groupMatchUserLeave", - GROUP_MATCH_WAS_REMOVED = "groupMatchWasRemoved", - GROUP_MATCH_USER_BAD_VERSION = "groupMatchUserHasBadVersion", - USER_CONFIRMED = "userConfirmed", - CHANNEL_DELETED = "channel_deleted", - FRIEND_LIST_REQUEST_ACCEPTED = "friendListRequestAccept", - FRIEND_LIST_REQUEST_DECLINED = "friendListRequestDecline", - FRIEND_LIST_NEW_REQUEST = "friendListNewRequest", - FRIEND_LIST_REMOVED_FROM_FRIEND_LIST = "youAreRemovedFromFriendList", - YOU_ARE_ADDED_TO_IGNORE_LIST = "YouWereAddedToIgnoreList", - YOU_ARE_REMOVED_FROM_IGNORE_LIST = "youAreRemoveFromIgnoreList", -} diff --git a/project/src/models/eft/ws/IWsAid.ts b/project/src/models/eft/ws/IWsAid.ts new file mode 100644 index 00000000..b602b7fc --- /dev/null +++ b/project/src/models/eft/ws/IWsAid.ts @@ -0,0 +1,6 @@ +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; + +export interface IWsAid extends IWsNotificationEvent +{ + aid: number +} diff --git a/project/src/models/eft/ws/IWsAidNickname.ts b/project/src/models/eft/ws/IWsAidNickname.ts new file mode 100644 index 00000000..660cd576 --- /dev/null +++ b/project/src/models/eft/ws/IWsAidNickname.ts @@ -0,0 +1,7 @@ +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; + +export interface IWsAidNickname extends IWsNotificationEvent +{ + aid: number + Nickname: string +} diff --git a/project/src/models/eft/ws/IWsChatMessageReceived.ts b/project/src/models/eft/ws/IWsChatMessageReceived.ts new file mode 100644 index 00000000..1f4cdb5b --- /dev/null +++ b/project/src/models/eft/ws/IWsChatMessageReceived.ts @@ -0,0 +1,10 @@ +import { Message } from "@spt-aki/models/eft/profile/IAkiProfile"; +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; +import { IGroupCharacter } from "../match/IGroupCharacter"; + +export interface IWsChatMessageReceived extends IWsNotificationEvent +{ + dialogId: string + message: Message + profiles?: IGroupCharacter[] +} diff --git a/project/src/models/eft/ws/IWsGroupId.ts b/project/src/models/eft/ws/IWsGroupId.ts new file mode 100644 index 00000000..7905454f --- /dev/null +++ b/project/src/models/eft/ws/IWsGroupId.ts @@ -0,0 +1,6 @@ +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; + +export interface IWsGroupId extends IWsNotificationEvent +{ + groupId: string +} diff --git a/project/src/models/eft/ws/IWsGroupMatchInviteAccept.ts b/project/src/models/eft/ws/IWsGroupMatchInviteAccept.ts new file mode 100644 index 00000000..9d17c085 --- /dev/null +++ b/project/src/models/eft/ws/IWsGroupMatchInviteAccept.ts @@ -0,0 +1,7 @@ +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; +import { IGroupCharacter } from "../match/IGroupCharacter"; + +export interface IWsGroupMatchInviteAccept extends IWsNotificationEvent, IGroupCharacter +{ + +} diff --git a/project/src/models/eft/ws/IWsGroupMatchInviteDecline.ts b/project/src/models/eft/ws/IWsGroupMatchInviteDecline.ts new file mode 100644 index 00000000..ac27e1be --- /dev/null +++ b/project/src/models/eft/ws/IWsGroupMatchInviteDecline.ts @@ -0,0 +1,7 @@ +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; + +export interface IWsGroupMatchInviteDecline extends IWsNotificationEvent +{ + aid: number + Nickname: string +} diff --git a/project/src/models/eft/ws/IWsGroupMatchInviteSend.ts b/project/src/models/eft/ws/IWsGroupMatchInviteSend.ts new file mode 100644 index 00000000..5c623441 --- /dev/null +++ b/project/src/models/eft/ws/IWsGroupMatchInviteSend.ts @@ -0,0 +1,9 @@ +import { IGroupCharacter } from "@spt-aki/models/eft/match/IGroupCharacter"; +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; + +export interface IWsGroupMatchInviteSend extends IWsNotificationEvent +{ + requestId: string + from: number + members: IGroupCharacter[] +} diff --git a/project/src/models/eft/ws/IWsGroupMatchLeaderChanged.ts b/project/src/models/eft/ws/IWsGroupMatchLeaderChanged.ts new file mode 100644 index 00000000..b6461547 --- /dev/null +++ b/project/src/models/eft/ws/IWsGroupMatchLeaderChanged.ts @@ -0,0 +1,6 @@ +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; + +export interface IWsGroupMatchLeaderChanged extends IWsNotificationEvent +{ + owner: number +} diff --git a/project/src/models/eft/ws/IWsGroupMatchRaidReady.ts b/project/src/models/eft/ws/IWsGroupMatchRaidReady.ts new file mode 100644 index 00000000..ec58350c --- /dev/null +++ b/project/src/models/eft/ws/IWsGroupMatchRaidReady.ts @@ -0,0 +1,7 @@ +import { IGroupCharacter } from "@spt-aki/models/eft/match/IGroupCharacter"; +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; + +export interface IWsGroupMatchRaidReady extends IWsNotificationEvent +{ + extendedProfile: IGroupCharacter +} diff --git a/project/src/models/eft/ws/IWsGroupMatchRaidSettings.ts b/project/src/models/eft/ws/IWsGroupMatchRaidSettings.ts new file mode 100644 index 00000000..ac1f2dae --- /dev/null +++ b/project/src/models/eft/ws/IWsGroupMatchRaidSettings.ts @@ -0,0 +1,7 @@ +import { IRaidSettings } from "@spt-aki/models/eft/match/IRaidSettings"; +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; + +export interface IWsGroupMatchRaidSettings extends IWsNotificationEvent +{ + raidSettings: IRaidSettings +} diff --git a/project/src/models/eft/ws/IWsNotificationEvent.ts b/project/src/models/eft/ws/IWsNotificationEvent.ts new file mode 100644 index 00000000..5346f44e --- /dev/null +++ b/project/src/models/eft/ws/IWsNotificationEvent.ts @@ -0,0 +1,5 @@ +export interface IWsNotificationEvent +{ + type: string + eventId: string +} diff --git a/project/src/models/eft/ws/IWsPing.ts b/project/src/models/eft/ws/IWsPing.ts new file mode 100644 index 00000000..5e32118d --- /dev/null +++ b/project/src/models/eft/ws/IWsPing.ts @@ -0,0 +1,6 @@ +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; + +export interface IWsPing extends IWsNotificationEvent +{ + +} diff --git a/project/src/models/eft/ws/IWsRagfairOfferSold.ts b/project/src/models/eft/ws/IWsRagfairOfferSold.ts new file mode 100644 index 00000000..dce4e350 --- /dev/null +++ b/project/src/models/eft/ws/IWsRagfairOfferSold.ts @@ -0,0 +1,8 @@ +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; + +export interface IWsRagfairOfferSold extends IWsNotificationEvent +{ + offerId: string + count: number + handbookId: string +} diff --git a/project/src/models/eft/ws/IWsUserConfirmed.ts b/project/src/models/eft/ws/IWsUserConfirmed.ts new file mode 100644 index 00000000..a202e3a6 --- /dev/null +++ b/project/src/models/eft/ws/IWsUserConfirmed.ts @@ -0,0 +1,20 @@ +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; +import { ProfileStatus } from "@spt-aki/models/enums/ProfileStatus"; +import { RaidMode } from "@spt-aki/models/enums/RaidMode"; + +export interface IWsUserConfirmed extends IWsNotificationEvent +{ + profileid: string + profileToken: string + status: ProfileStatus + ip: string + port: number + sid: string + version: string + location: string + raidMode: RaidMode + mode: string + shortId: string + // eslint-disable-next-line @typescript-eslint/naming-convention + additional_info: any[] +} diff --git a/project/src/models/enums/DateTime.ts b/project/src/models/enums/DateTime.ts new file mode 100644 index 00000000..5c00969a --- /dev/null +++ b/project/src/models/enums/DateTime.ts @@ -0,0 +1,5 @@ +export enum DateTime +{ + CURR = "CURR", + PAST = "PAST", +} diff --git a/project/src/models/enums/NotificationEventType.ts b/project/src/models/enums/NotificationEventType.ts new file mode 100644 index 00000000..2381f90f --- /dev/null +++ b/project/src/models/enums/NotificationEventType.ts @@ -0,0 +1,29 @@ +export enum NotificationEventType +{ + RAGFAIR_OFFER_SOLD = "RagfairOfferSold", + RAGFAIR_RATING_CHANGE = "RagfairRatingChange", + CHAT_MESSAGE_RECEIVED = "new_message", + PING = "ping", + TRADER_SUPPLY = "TraderSupply", + TRADER_STANDING = "TraderStanding", + UNLOCK_TRADER = "UnlockTrader", + GROUP_MATCH_RAID_SETTINGS = "groupMatchRaidSettings", + GROUP_MATCH_RAID_NOT_READY = "groupMatchRaidNotReady", + GROUP_MATCH_RAID_READY = "groupMatchRaidReady", + GROUP_MATCH_INVITE_ACCEPT = "groupMatchInviteAccept", + GROUP_MATCH_INVITE_DECLINE = "groupMatchInviteDecline", + GROUP_MATCH_INVITE_SEND = "groupMatchInviteSend", + GROUP_MATCH_LEADER_CHANGED = "groupMatchLeaderChanged", + GROUP_MATCH_START_GAME = "groupMatchStartGame", + GROUP_MATCH_USER_LEAVE = "groupMatchUserLeave", + GROUP_MATCH_WAS_REMOVED = "groupMatchWasRemoved", + GROUP_MATCH_USER_BAD_VERSION = "groupMatchUserHasBadVersion", + USER_CONFIRMED = "userConfirmed", + CHANNEL_DELETED = "channel_deleted", + FRIEND_LIST_REQUEST_ACCEPTED = "friendListRequestAccept", + FRIEND_LIST_REQUEST_DECLINED = "friendListRequestDecline", + FRIEND_LIST_NEW_REQUEST = "friendListNewRequest", + FRIEND_LIST_REMOVED_FROM_FRIEND_LIST = "youAreRemovedFromFriendList", + YOU_ARE_ADDED_TO_IGNORE_LIST = "YouWereAddedToIgnoreList", + YOU_ARE_REMOVED_FROM_IGNORE_LIST = "youAreRemoveFromIgnoreList", +} diff --git a/project/src/models/enums/PlayersSpawnPlace.ts b/project/src/models/enums/PlayersSpawnPlace.ts new file mode 100644 index 00000000..f0263d3c --- /dev/null +++ b/project/src/models/enums/PlayersSpawnPlace.ts @@ -0,0 +1,6 @@ +export enum PlayersSpawnPlace +{ + SAME_PLACE = "SamePlace", + DIFFERENT_PLACES = "DifferentPlaces", + AT_THE_ENDS_OF_THE_MAP = "AtTheEndsOfTheMap", +} diff --git a/project/src/models/enums/ProfileStatus.ts b/project/src/models/enums/ProfileStatus.ts new file mode 100644 index 00000000..4d61d105 --- /dev/null +++ b/project/src/models/enums/ProfileStatus.ts @@ -0,0 +1,8 @@ +export enum ProfileStatus +{ + FREE = "Free", + MATCH_WAIT = "MatchWait", + BUSY = "Busy", + LEAVING = "Leaving", + TRANSFER = "Transfer", +} diff --git a/project/src/models/enums/BotAmount.ts b/project/src/models/enums/RaidSettings/BotAmount.ts similarity index 84% rename from project/src/models/enums/BotAmount.ts rename to project/src/models/enums/RaidSettings/BotAmount.ts index 80ad9233..dd13559f 100644 --- a/project/src/models/enums/BotAmount.ts +++ b/project/src/models/enums/RaidSettings/BotAmount.ts @@ -1,6 +1,7 @@ export enum BotAmount { AS_ONLINE = "AsOnline", + NO_BOTS = "NoBots", LOW = "Low", MEDIUM = "Medium", HIGH = "High", diff --git a/project/src/models/enums/BotDifficulty.ts b/project/src/models/enums/RaidSettings/BotDifficulty.ts similarity index 100% rename from project/src/models/enums/BotDifficulty.ts rename to project/src/models/enums/RaidSettings/BotDifficulty.ts diff --git a/project/src/models/enums/RaidSettings/TimeAndWeather/CloudinessType.ts b/project/src/models/enums/RaidSettings/TimeAndWeather/CloudinessType.ts new file mode 100644 index 00000000..eda0403b --- /dev/null +++ b/project/src/models/enums/RaidSettings/TimeAndWeather/CloudinessType.ts @@ -0,0 +1,9 @@ +export enum CloudinessType +{ + CLEAR = "Clear", + PARTLY_CLOUDY = "PartlyCloudy", + CLOUDY = "Cloudy", + CLOUDY_WITH_GAPS = "CloudyWithGaps", + HEAVY_CLOUD_COVER = "HeavyCloudCover", + THUNDER_CLOUD = "Thundercloud", +} diff --git a/project/src/models/enums/RaidSettings/TimeAndWeather/FogType.ts b/project/src/models/enums/RaidSettings/TimeAndWeather/FogType.ts new file mode 100644 index 00000000..c6ed34c1 --- /dev/null +++ b/project/src/models/enums/RaidSettings/TimeAndWeather/FogType.ts @@ -0,0 +1,8 @@ +export enum FogType +{ + NO_FOG = "NoFog", + FAINT = "Faint", + FOG = "Fog", + HEAVY = "Heavy", + CONTINUOUS = "Continuous", +} diff --git a/project/src/models/enums/RaidSettings/TimeAndWeather/RainType.ts b/project/src/models/enums/RaidSettings/TimeAndWeather/RainType.ts new file mode 100644 index 00000000..c17f4b64 --- /dev/null +++ b/project/src/models/enums/RaidSettings/TimeAndWeather/RainType.ts @@ -0,0 +1,8 @@ +export enum RainType +{ + NO_RAIN = "NoRain", + DRIZZLING = "Drizzling", + RAIN = "Rain", + HEAVY = "Heavy", + SHOWER = "Shower", +} diff --git a/project/src/models/enums/RaidSettings/TimeAndWeather/TimeFlowType.ts b/project/src/models/enums/RaidSettings/TimeAndWeather/TimeFlowType.ts new file mode 100644 index 00000000..21540363 --- /dev/null +++ b/project/src/models/enums/RaidSettings/TimeAndWeather/TimeFlowType.ts @@ -0,0 +1,11 @@ +export enum TimeFlowType +{ + X0 = "x0", + X0_14 = "x0_14", + X0_25 = "x0_25", + X0_5 = "x0_5", + X1 = "x1", + X2 = "x2", + X4 = "x4", + X8 = "x8", +} diff --git a/project/src/models/enums/RaidSettings/TimeAndWeather/WindSpeed.ts b/project/src/models/enums/RaidSettings/TimeAndWeather/WindSpeed.ts new file mode 100644 index 00000000..d4cb5912 --- /dev/null +++ b/project/src/models/enums/RaidSettings/TimeAndWeather/WindSpeed.ts @@ -0,0 +1,8 @@ +export enum WindSpeed +{ + LIGHT = "Light", + MODERATE = "Moderate", + STRONG = "Strong", + VERY_STRONG = "VeryStrong", + HURRICANE = "Hurricane", +} diff --git a/project/src/models/enums/SideType.ts b/project/src/models/enums/SideType.ts new file mode 100644 index 00000000..60686e0f --- /dev/null +++ b/project/src/models/enums/SideType.ts @@ -0,0 +1,6 @@ +export enum SideType +{ + PMC = "Pmc", + SAVAGE = "Savage", + RANDOM = "Random", +} diff --git a/project/src/servers/WebSocketServer.ts b/project/src/servers/WebSocketServer.ts index 8a96922d..73dc55a1 100644 --- a/project/src/servers/WebSocketServer.ts +++ b/project/src/servers/WebSocketServer.ts @@ -3,8 +3,9 @@ import { inject, injectable } from "tsyringe"; import WebSocket from "ws"; import { HttpServerHelper } from "@spt-aki/helpers/HttpServerHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; -import { INotification, NotificationType } from "@spt-aki/models/eft/notifier/INotifier"; +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; +import { NotificationEventType } from "@spt-aki/models/enums/NotificationEventType"; import { IHttpConfig } from "@spt-aki/models/spt/config/IHttpConfig"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ConfigServer } from "@spt-aki/servers/ConfigServer"; @@ -29,7 +30,7 @@ export class WebSocketServer } protected httpConfig: IHttpConfig; - protected defaultNotification: INotification = { type: NotificationType.PING, eventId: "ping" }; + protected defaultNotification: IWsNotificationEvent = { type: NotificationEventType.PING, eventId: "ping" }; protected webSocketServer: WebSocket.Server; protected webSockets: Record = {}; @@ -62,7 +63,7 @@ export class WebSocketServer this.webSocketServer.addListener("connection", this.wsOnConnection.bind(this)); } - public sendMessage(sessionID: string, output: INotification): void + public sendMessage(sessionID: string, output: IWsNotificationEvent): void { try { diff --git a/project/src/services/NotificationService.ts b/project/src/services/NotificationService.ts index f26ad928..57d89aa4 100644 --- a/project/src/services/NotificationService.ts +++ b/project/src/services/NotificationService.ts @@ -1,5 +1,5 @@ import { injectable } from "tsyringe"; -import { INotification } from "@spt-aki/models/eft/notifier/INotifier"; +import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent"; @injectable() export class NotificationService @@ -37,7 +37,7 @@ export class NotificationService /** * Add message to queue */ - public add(sessionID: string, message: INotification): void + public add(sessionID: string, message: IWsNotificationEvent): void { this.get(sessionID).push(message); } From 79781ab8bbe573344197e3eb35f49f5a0ab5a60c Mon Sep 17 00:00:00 2001 From: Refringe Date: Thu, 16 May 2024 08:41:05 +0000 Subject: [PATCH 3/3] Linting Updates (!336) This update now runs Prettier before ESLint (with the Stylistic plugin) for code formatting. This takes care of a lot of the edge cases that ESLint doesn't touch by itself. Also adds the `eslint-plugin-unused-imports` ESLint plugin to remove unused imports and the `eslint-plugin-switch-allman` ESLint plugin to enforce Allman braces on case declarations. The VSCode format-on-save function now requires two additional extentions to be installed: Prettier and Format Code Action. Links can be found in the README and in the recommended extentions section of VSCode when the workspace is open. Co-authored-by: chomp Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/336 Co-authored-by: Refringe Co-committed-by: Refringe --- .gitignore | 1 + README.md | 84 ++++++------ project/.eslintrc.json | 151 ++++++++++----------- project/.prettierignore | 10 ++ project/.prettierrc | 3 + project/.vscode/extensions.json | 8 -- project/.vscode/launch.json | 35 ----- project/Server.code-workspace | 55 ++++++-- project/package.json | 9 ++ project/src/services/ModCompilerService.ts | 7 +- 10 files changed, 190 insertions(+), 173 deletions(-) create mode 100644 project/.prettierignore create mode 100644 project/.prettierrc delete mode 100644 project/.vscode/extensions.json delete mode 100644 project/.vscode/launch.json diff --git a/.gitignore b/.gitignore index 19e2cdb0..a2b82631 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ project/src/__coverage__/ ## visual studio .vs .idea +.vscode slnx.sqlite slnx-journal.sqlite diff --git a/README.md b/README.md index b1cebba3..35ac59f3 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,16 @@ This is the Server project for the Single Player Tarkov mod for Escape From Tark - [Features](#features) - [Installation](#installation) - - [Requirements](#requirements) - - [Initial Setup](#initial-setup) + - [Requirements](#requirements) + - [Initial Setup](#initial-setup) - [Development](#development) - - [Commands](#commands) - - [Debugging](#debugging) - - [Mod Debugging](#mod-debugging) + - [Commands](#commands) + - [Debugging](#debugging) + - [Mod Debugging](#mod-debugging) - [Contributing](#contributing) - - [Branches](#branchs) - - [Pull Request Guidelines](#pull-request-guidelines) - - [Tests](#tests) + - [Branches](#branchs) + - [Pull Request Guidelines](#pull-request-guidelines) + - [Tests](#tests) - [License](#license) ## Features @@ -31,10 +31,11 @@ This project has been built in [Visual Studio Code](https://code.visualstudio.co There are a number of VSC extensions that we recommended for this project. VSC will prompt you to install these when you open the workspace file. If you do not see the prompt, you can install them manually: - [EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) - Editor Settings Synchronization -- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - Linting for Coding Issues & Naming Conventions - [Vitest](https://marketplace.visualstudio.com/items?itemName=vitest.explorer) - Debugging Tests - [SPT ID Highlighter](https://marketplace.visualstudio.com/items?itemName=refringe.spt-id-highlighter) - Converts IDs to Names - +- [Format Code Action](https://marketplace.visualstudio.com/items?itemName=rohit-gohri.format-code-action) - Custom Format-on-save Actions +- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - Code Formatting +- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - Linting for Coding Issues & Naming Conventions ### Initial Setup @@ -42,9 +43,9 @@ To prepare the project for development you will need to: 1. Run `git clone https://dev.sp-tarkov.com/SPT-AKI/Server.git server` to clone the repository. 2. Run `git lfs pull` to download LFS files locally. -2. Open the `project/mod.code-workspace` file in Visual Studio Code (VSC). -3. Run `nvm use 20.11.1` in the VSC terminal. -4. Run `npm install` in the VSC terminal. +3. Open the `project/mod.code-workspace` file in Visual Studio Code (VSC). +4. Run `nvm use 20.11.1` in the VSC terminal. +5. Run `npm install` in the VSC terminal. ## Development @@ -52,24 +53,27 @@ To prepare the project for development you will need to: The following commands are available after the initial setup. Run them with `npm run `. -| Command | Description | -|--------------------------|-----------------------------------------------------------------------| -| `check:circular` | Check for circular dependencies in the project. | -| `lint` | Check the project for coding standards and style/formatting issues. | -| `lint:fix` | Automatically fix coding standard issues and style/formatting issues. | -| `test` | Run all tests. | -| `test:watch` | Run tests in watch mode. Tests will re-run when files are changed. | -| `test:coverage` | Run tests and generate a coverage report. | -| `test:ui` | Run tests in UI mode. This will open a browser window to view tests. | -| `build:release` | Build the project for release. | -| `build:debug` | Build the project for debugging. | -| `build:bleeding` | Build the project on the bleeding edge. | -| `build:bleedingmods` | Build the project on the bleeding edge with mods. | -| `run:build` | Run the project in build mode. | -| `run:debug` | Run the project in debug mode. | -| `run:profiler` | Run the project in profiler mode. | -| `gen:types` | Generate types for the project. | -| `gen:docs` | Generate documentation for the project. | +| Command | Description | +| -------------------- | ----------------------------------------------------------------------------- | +| `check:circular` | Check for circular dependencies in the project. | +| `lint` | Check the project for coding standards and post-Prettier formatting issues. | +| `lint:fix` | Automatically fix coding standard issues and post-Prettier formatting issues. | +| `style` | Check the project for coding standards and post-Prettier formatting issues. | +| `style:fix` | Automatically fix coding standard issues and post-Prettier formatting issues. | +| `format` | Run Prettier and then ESLint Stylistic to fix code formatting. | +| `test` | Run all tests. | +| `test:watch` | Run tests in watch mode. Tests will re-run when files are changed. | +| `test:coverage` | Run tests and generate a coverage report. | +| `test:ui` | Run tests in UI mode. This will open a browser window to view tests. | +| `build:release` | Build the project for release. | +| `build:debug` | Build the project for debugging. | +| `build:bleeding` | Build the project on the bleeding edge. | +| `build:bleedingmods` | Build the project on the bleeding edge with mods. | +| `run:build` | Run the project in build mode. | +| `run:debug` | Run the project in debug mode. | +| `run:profiler` | Run the project in profiler mode. | +| `gen:types` | Generate types for the project. | +| `gen:docs` | Generate documentation for the project. | ### Debugging @@ -85,29 +89,29 @@ We're really excited that you're interested in contributing! Before submitting y ### Branchs -- __master__ +- **master** The default branch used for the latest stable release. This branch is protected and typically is only merges with release branches. -- __3.9.0-DEV__ +- **3.9.0-DEV** Development for the next minor release of SPT. Minor releases target the latest version of EFT. Late in the minor release cycle the EFT version is frozen for stability to prepare for release. Larger changes to the project structure may be included in minor releases. -- __3.8.1-DEV__ +- **3.8.4-DEV** Development for the next hotfix release of SPT. Hotfix releases include bug fixes and minor features that do not effect the coding structure of the project. Special care is taken to not break server mod stability. These always target the same version of EFT as the last minor release. ### Pull Request Guidelines -- __Keep Them Small__ +- **Keep Them Small** If you're fixing a bug, try to keep the changes to the bug fix only. If you're adding a feature, try to keep the changes to the feature only. This will make it easier to review and merge your changes. -- __Perform a Self-Review__ +- **Perform a Self-Review** Before submitting your changes, review your own code. This will help you catch any mistakes you may have made. -- __Remove Noise__ +- **Remove Noise** Remove any unnecessary changes to white space, code style formatting, or some text change that has no impact related to the intention of the PR. -- __Create a Meaningful Title__ +- **Create a Meaningful Title** When creating a PR, make sure the title is meaningful and describes the changes you've made. -- __Write Detailed Commit Messages__ +- **Write Detailed Commit Messages** Bring out your table manners, speak the Queen's English and be on your best behaviour. ### Style Guide -We use ESLint Stylistic to enforce a consistent code style. Please run `npm run lint` and/or `npm run lint:fix` before submitting your changes. This is made easier by using the recommended VSC extensions to automatically format your code whenever you save a file. +We use a combination of Prettier and ESLint Stylistic to enforce a consistent code style. Please run `npm run format` before submitting your changes. This is made easier by using the recommended VSC extensions to automatically format your code whenever you save a file. ### Tests diff --git a/project/.eslintrc.json b/project/.eslintrc.json index 49d679c8..f69b3c19 100644 --- a/project/.eslintrc.json +++ b/project/.eslintrc.json @@ -3,13 +3,10 @@ "plugin:@typescript-eslint/recommended", "plugin:@stylistic/recommended-extends", "plugin:import/recommended", - "plugin:import/typescript" - ], - "plugins": [ - "@typescript-eslint", - "@stylistic", - "import" + "plugin:import/typescript", + "prettier" ], + "plugins": ["@typescript-eslint", "@stylistic", "import", "unused-imports", "switch-allman"], "settings": { "import/resolver": { "typescript": { @@ -26,81 +23,83 @@ "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-var-requires": "error", - "@typescript-eslint/explicit-module-boundary-types": ["error", { - "allowArgumentsExplicitlyTypedAsAny": true - }], - "@typescript-eslint/naming-convention": ["error", { - "selector": "default", - "format": ["camelCase"], - "leadingUnderscore": "allow" - }, { - "selector": "typeLike", - "format": ["PascalCase"] - }, { - "selector": "objectLiteralProperty", - "format": ["PascalCase", "camelCase", "snake_case"], - "leadingUnderscore": "allow" - }, { - "selector": "typeProperty", - "format": ["PascalCase", "camelCase"], - "leadingUnderscore": "allow" - }, { - "selector": "enumMember", - "format": ["UPPER_CASE"] - }, { - "selector": "property", - "modifiers": ["readonly", "static"], - "format": ["UPPER_CASE"] - }], + "@typescript-eslint/explicit-module-boundary-types": [ + "error", + { + "allowArgumentsExplicitlyTypedAsAny": true + } + ], + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "default", + "format": ["camelCase"], + "leadingUnderscore": "allow" + }, + { + "selector": "typeLike", + "format": ["PascalCase"] + }, + { + "selector": "objectLiteralProperty", + "format": ["PascalCase", "camelCase", "snake_case"], + "leadingUnderscore": "allow" + }, + { + "selector": "typeProperty", + "format": ["PascalCase", "camelCase"], + "leadingUnderscore": "allow" + }, + { + "selector": "enumMember", + "format": ["UPPER_CASE"] + }, + { + "selector": "property", + "modifiers": ["readonly", "static"], + "format": ["UPPER_CASE"] + } + ], "@stylistic/indent": ["error", 4, { "MemberExpression": 1, "SwitchCase": 1 }], "@stylistic/brace-style": ["error", "allman", { "allowSingleLine": false }], "@stylistic/semi": ["error", "always"], "@stylistic/quotes": ["error", "double", { "avoidEscape": true }], - "@stylistic/linebreak-style": ["error", "unix"], - "@stylistic/max-len": ["error", { - "code": 120, - "tabWidth": 4, - "ignoreComments": true, - "ignoreTrailingComments": true, - "ignoreUrls": true, - "ignoreStrings": true, - "ignoreTemplateLiterals": true, - "ignoreRegExpLiterals": true - }], - "@stylistic/multiline-ternary": ["error", "always-multiline"], - "@stylistic/no-confusing-arrow": ["error", {"allowParens": true}], - "@stylistic/no-extra-parens": ["error", "all", { - "returnAssign": false, - "nestedBinaryExpressions": false, - "ternaryOperandBinaryExpressions": false, - "enforceForArrowConditionals": false - }], - "@stylistic/new-parens": "error", - "@stylistic/newline-per-chained-call": ["error", { "ignoreChainWithDepth": 3 }], - "@stylistic/no-extra-semi": "error", - "@stylistic/no-floating-decimal": "error", - "@stylistic/no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1 }], - "@stylistic/switch-colon-spacing": "error", - "@stylistic/type-annotation-spacing": "error", - "@stylistic/type-generic-spacing": ["error"], - "@stylistic/type-named-tuple-spacing": ["error"], - "@stylistic/wrap-regex": "error", - "@stylistic/yield-star-spacing": ["error", "both"], - "import/order": ["error", { - "groups": ["builtin", "external", "internal", "parent", "sibling", "index"], - "pathGroups": [ - { - "pattern": "tsyringe", - "group": "builtin", - "position": "before" - } - ], - "newlines-between": "never", - "alphabetize": { - "order": "asc", - "caseInsensitive": true + "@stylistic/operator-linebreak": ["error", "before"], + "@stylistic/arrow-parens": ["error", "always"], + "@stylistic/max-len": [ + "warn", + { + "code": 121, // +1 to prevent conflicts with Prettier rule. + "tabWidth": 4, + "ignoreComments": true, + "ignoreTrailingComments": true, + "ignoreUrls": true, + "ignoreStrings": true, + "ignoreTemplateLiterals": true, + "ignoreRegExpLiterals": true } - }] + ], + "@stylistic/multiline-ternary": ["error", "always-multiline"], + "import/order": [ + "error", + { + "groups": ["builtin", "external", "internal", "parent", "sibling", "index"], + "pathGroups": [ + { + "pattern": "tsyringe", + "group": "builtin", + "position": "before" + } + ], + "newlines-between": "never", + "alphabetize": { + "order": "asc", + "caseInsensitive": true + } + } + ], + "unused-imports/no-unused-imports-ts": "error", + "switch-allman/case-allman": "error" }, "overrides": [ { diff --git a/project/.prettierignore b/project/.prettierignore new file mode 100644 index 00000000..7b79a188 --- /dev/null +++ b/project/.prettierignore @@ -0,0 +1,10 @@ +**/.git +**/.pkg-cache +**/.vscode +**/build +**/node_modules +**/types +**/tests/__cache__ +**/tests/__coverage__ +.editorconfig +src/services/ModCompilerService.ts diff --git a/project/.prettierrc b/project/.prettierrc new file mode 100644 index 00000000..04ff7639 --- /dev/null +++ b/project/.prettierrc @@ -0,0 +1,3 @@ +{ + "quoteProps": "consistent" +} diff --git a/project/.vscode/extensions.json b/project/.vscode/extensions.json deleted file mode 100644 index 547ba280..00000000 --- a/project/.vscode/extensions.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "recommendations": [ - "EditorConfig.EditorConfig", - "vitest.explorer", - "refringe.spt-id-highlighter", - "dbaeumer.vscode-eslint" - ] -} diff --git a/project/.vscode/launch.json b/project/.vscode/launch.json deleted file mode 100644 index 5bb44a65..00000000 --- a/project/.vscode/launch.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Debug", - "type": "node", - "runtimeVersion": "20.11.1", - "runtimeExecutable": "npm", - "request": "launch", - "sourceMaps": true, - "runtimeArgs": [ - "run", - "run:debug" - ], - "outFiles": [ - "!**/node_modules/**" - ], - "cwd": "${workspaceFolder}", - "outputCapture": "std" - }, - { - "name": "Run Vitest Tests", - "type": "node", - "runtimeVersion": "20.11.1", - "runtimeExecutable": "npm", - "request": "launch", - "runtimeArgs": [ - "run", - "test" - ], - "console": "integratedTerminal", - "internalConsoleOptions": "neverOpen" - } - ] -} diff --git a/project/Server.code-workspace b/project/Server.code-workspace index a47cd254..ad4e8f48 100644 --- a/project/Server.code-workspace +++ b/project/Server.code-workspace @@ -1,17 +1,52 @@ { "folders": [ { - "path": "." - } + "path": ".", + }, ], "settings": { "window.title": "SPT-AKI Server", - "editor.formatOnSave": true, - "editor.defaultFormatter": "dbaeumer.vscode-eslint", - "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit" - }, - "eslint.debug": true, - "eslint.experimental.useFlatConfig": false - } + "editor.formatOnSave": false, // We use an extension to format on save. + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.codeActionsOnSave": ["source.formatDocument", "source.fixAll.eslint"], + "eslint.debug": false, + "eslint.experimental.useFlatConfig": false, + }, + "extensions": { + "recommendations": [ + "EditorConfig.EditorConfig", // EditorConfig file format support. + "vitest.explorer", // ViTest test runner. + "refringe.spt-id-highlighter", // Highly SPT IDs. + "rohit-gohri.format-code-action", // Custom format on save actions. + "esbenp.prettier-vscode", // Prettier code formatter. + "dbaeumer.vscode-eslint", // ESLint code linter and formatter. + ], + }, + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "Debug", + "type": "node", + "runtimeVersion": "20.11.1", + "runtimeExecutable": "npm", + "request": "launch", + "sourceMaps": true, + "runtimeArgs": ["run", "run:debug"], + "outFiles": ["!**/node_modules/**"], + "cwd": "${workspaceFolder}", + "outputCapture": "std", + }, + { + "name": "Run Vitest Tests", + "type": "node", + "runtimeVersion": "20.11.1", + "runtimeExecutable": "npm", + "request": "launch", + "runtimeArgs": ["run", "test"], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + }, + ], + }, } diff --git a/project/package.json b/project/package.json index 9c7493c5..5f834739 100644 --- a/project/package.json +++ b/project/package.json @@ -14,6 +14,9 @@ "check:circular": "madge --circular --ts-config tsconfig.json --extensions ts ./src/", "lint": "eslint src", "lint:fix": "eslint src --fix", + "style": "prettier src --check", + "style:fix": "prettier src --write", + "format": "npm run style:fix && npm run lint:fix", "test": "vitest run", "test:watch": "vitest", "test:coverage": "vitest run --coverage", @@ -67,8 +70,12 @@ "@yao-pkg/pkg-fetch": "3.5.9", "cross-env": "~7.0", "eslint": "~8.57", + "eslint-config-prettier": "^9.1.0", "eslint-import-resolver-typescript": "~3.6", "eslint-plugin-import": "~2.29", + "eslint-plugin-prettier": "^5.1.3", + "eslint-plugin-switch-allman": "^1.0.2", + "eslint-plugin-unused-imports": "^3.2.0", "fs-extra": "~11.2", "gulp": "~4.0", "gulp-decompress": "~3.0", @@ -77,9 +84,11 @@ "gulp-rename": "~2.0", "madge": "~6.1", "minimist": "~1.2", + "prettier": "^3.2.5", "resedit": "~2.0", "ts-node-dev": "~2.0", "tsconfig-paths": "~4.2", + "tslint-config-prettier": "^1.18.0", "typedoc": "~0.25", "typemoq": "~2.1", "typescript-eslint": "~7.8", diff --git a/project/src/services/ModCompilerService.ts b/project/src/services/ModCompilerService.ts index 99cf9a53..f56ea4e8 100644 --- a/project/src/services/ModCompilerService.ts +++ b/project/src/services/ModCompilerService.ts @@ -85,8 +85,7 @@ export class ModCompilerService protected async compile(fileNames: string[], options: ts.CompilerOptions): Promise { // C:/snapshot/project || /snapshot/project - const baseDir: string = __dirname.replace(/\\/g, "/").split("/").slice(0, 3) - .join("/"); + const baseDir: string = __dirname.replace(/\\/g, "/").split("/").slice(0, 3).join("/"); for (const filePath of fileNames) { @@ -140,7 +139,7 @@ export class ModCompilerService */ protected areFilesReady(fileNames: string[]): boolean { - return fileNames.filter(x => !this.vfs.exists(x.replace(".ts", ".js"))).length === 0; + return fileNames.filter((x) => !this.vfs.exists(x.replace(".ts", ".js"))).length === 0; } /** @@ -150,6 +149,6 @@ export class ModCompilerService */ protected delay(ms: number): Promise { - return new Promise(resolve => setTimeout(resolve, ms)); + return new Promise((resolve) => setTimeout(resolve, ms)); } }