From b60fec02fe041a112fdc392079a1fd07970cf5fa Mon Sep 17 00:00:00 2001 From: Niek Candaele Date: Sat, 4 Jan 2025 12:27:26 +0100 Subject: [PATCH] fix: issue with stale server connection info When someone updates a server on nodeA, that change is not propagated to nodeB. This results in Takaro trying to connect to gameservers with outdated connectionInfo -> errors! --- packages/app-api/src/lib/socketServer.ts | 23 +- .../app-api/src/service/GameServerService.ts | 37 +- .../src/generated/.openapi-generator/VERSION | 2 +- packages/lib-apiclient/src/generated/api.ts | 343 +++++++++++------- packages/lib-apiclient/src/generated/base.ts | 4 +- .../lib-apiclient/src/generated/common.ts | 4 +- .../src/generated/configuration.ts | 4 +- packages/lib-apiclient/src/generated/index.ts | 4 +- packages/lib-modules/src/dto/takaroEvents.ts | 21 ++ .../components/events/EventFeed/EventItem.tsx | 9 + .../EventNameSelectField/eventNames.tsx | 3 + 11 files changed, 313 insertions(+), 141 deletions(-) diff --git a/packages/app-api/src/lib/socketServer.ts b/packages/app-api/src/lib/socketServer.ts index a87ad0a441..0247a4bb58 100644 --- a/packages/app-api/src/lib/socketServer.ts +++ b/packages/app-api/src/lib/socketServer.ts @@ -2,13 +2,14 @@ import { Server, Socket } from 'socket.io'; import { IncomingMessage, Server as HttpServer, ServerResponse } from 'http'; import { config } from '../config.js'; import { ctx, errors, logger } from '@takaro/util'; -import { EventPayload, EventTypes } from '@takaro/modules'; +import { EventPayload, EventTypes, HookEvents } from '@takaro/modules'; import { instrument } from '@socket.io/admin-ui'; import { AuthenticatedRequest, AuthService } from '../service/AuthService.js'; import { NextFunction, Response } from 'express'; import { createAdapter } from '@socket.io/redis-adapter'; import { Redis } from '@takaro/db'; import { EventOutputDTO } from '../service/EventService.js'; +import { GameServerService } from '../service/GameServerService.js'; interface ServerToClientEvents { gameEvent: (gameserverId: string, type: EventTypes, data: EventPayload) => void; @@ -22,6 +23,7 @@ interface ClientToServerEvents { interface InterServerEvents { ping: () => void; + event: (event: EventOutputDTO) => void; } interface SocketData { @@ -76,6 +78,22 @@ class SocketServer { }); }); + this.io.on('event', (event: EventOutputDTO) => { + const eventsToRefreshServerCache: EventTypes[] = [ + HookEvents.GAMESERVER_CREATED, + HookEvents.GAMESERVER_DELETED, + HookEvents.GAMESERVER_UPDATED, + ]; + + if (eventsToRefreshServerCache.includes(event.eventName)) { + this.log.info( + `Received event from other node that indicates we need to refresh cache for gameserver ${event.gameserverId}`, + ); + const gameserverService = new GameServerService(event.domain); + gameserverService.refreshGameInstance(event.gameserverId); + } + }); + this.log.info('Socket server started'); } @@ -92,6 +110,9 @@ class SocketServer { data: Parameters = [], ) { this.io.to(domainId).emit(event, ...data); + if (event === 'event') { + this.io.serverSideEmit(event, data as unknown as EventOutputDTO); + } } private async routerMiddleware( diff --git a/packages/app-api/src/service/GameServerService.ts b/packages/app-api/src/service/GameServerService.ts index ec87977e8a..1181368a4c 100644 --- a/packages/app-api/src/service/GameServerService.ts +++ b/packages/app-api/src/service/GameServerService.ts @@ -33,6 +33,9 @@ import { EventChatMessage, TakaroEventModuleInstalled, TakaroEventModuleUninstalled, + TakaroEventGameserverCreated, + TakaroEventGameserverUpdated, + TakaroEventGameserverDeleted, ChatChannel, } from '@takaro/modules'; import { ITakaroQuery } from '@takaro/db'; @@ -156,6 +159,10 @@ export class GameServerService extends TakaroService< return new GameServerRepo(this.domainId); } + public refreshGameInstance(id: string) { + gameClassCache.delete(id); + } + find(filters: ITakaroQuery): Promise> { return this.repo.find(filters); } @@ -168,6 +175,14 @@ export class GameServerService extends TakaroService< const isReachable = await this.testReachability(undefined, JSON.parse(item.connectionInfo), item.type); const createdServer = await this.repo.create(item); + const eventsService = new EventService(this.domainId); + await eventsService.create( + new EventCreateDTO({ + eventName: EVENT_TYPES.GAMESERVER_CREATED, + gameserverId: createdServer.id, + meta: new TakaroEventGameserverCreated(), + }), + ); await queueService.queues.connector.queue.add({ domainId: this.domainId, gameServerId: createdServer.id, @@ -192,7 +207,7 @@ export class GameServerService extends TakaroService< }); await Promise.all(installedModules.map((mod) => this.uninstallModule(id, mod.moduleId))); - gameClassCache.delete(id); + this.refreshGameInstance(id); const gateway = new Pushgateway(config.get('metrics.pushgatewayUrl'), {}); gateway.delete({ jobName: 'worker', groupings: { gameserver: id } }); @@ -204,6 +219,14 @@ export class GameServerService extends TakaroService< time: new Date().toISOString(), }); await this.repo.delete(id); + const eventsService = new EventService(this.domainId); + await eventsService.create( + new EventCreateDTO({ + eventName: EVENT_TYPES.GAMESERVER_DELETED, + gameserverId: id, + meta: new TakaroEventGameserverDeleted(), + }), + ); await queueService.queues.system.queue.add( { domainId: this.domainId, @@ -216,7 +239,15 @@ export class GameServerService extends TakaroService< async update(id: string, item: GameServerUpdateDTO): Promise { const updatedServer = await this.repo.update(id, item); - gameClassCache.delete(id); + this.refreshGameInstance(id); + const eventsService = new EventService(this.domainId); + await eventsService.create( + new EventCreateDTO({ + eventName: EVENT_TYPES.GAMESERVER_UPDATED, + gameserverId: id, + meta: new TakaroEventGameserverUpdated(), + }), + ); await queueService.queues.connector.queue.add({ domainId: this.domainId, gameServerId: id, @@ -252,7 +283,7 @@ export class GameServerService extends TakaroService< // When a user is trying to fix their connection info, it's important we don't cache stale/wrong connection info if (!reachability.connectable) { - gameClassCache.delete(id); + this.refreshGameInstance(id); } return reachability; diff --git a/packages/lib-apiclient/src/generated/.openapi-generator/VERSION b/packages/lib-apiclient/src/generated/.openapi-generator/VERSION index 758bb9c821..09a6d30847 100644 --- a/packages/lib-apiclient/src/generated/.openapi-generator/VERSION +++ b/packages/lib-apiclient/src/generated/.openapi-generator/VERSION @@ -1 +1 @@ -7.10.0 +7.8.0 diff --git a/packages/lib-apiclient/src/generated/api.ts b/packages/lib-apiclient/src/generated/api.ts index ce6be7de34..66af8c91af 100644 --- a/packages/lib-apiclient/src/generated/api.ts +++ b/packages/lib-apiclient/src/generated/api.ts @@ -1,10 +1,10 @@ /* tslint:disable */ /* eslint-disable */ /** - * Takaro app-api + * Takaro API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: development - c5f9cff194f87c14e431b69759a49bebf5cb396f + * The version of the OpenAPI document: unset - unset * Contact: support@takaro.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). @@ -72,16 +72,16 @@ export interface ActivityInputDTO { dataType: ActivityInputDTODataTypeEnum; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof ActivityInputDTO */ - startDate?: string; + startDate?: StatsControllerGetPingStatsStartDateParameter; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof ActivityInputDTO */ - endDate?: string; + endDate?: StatsControllerGetPingStatsStartDateParameter; } export const ActivityInputDTOTimeTypeEnum = { @@ -552,16 +552,16 @@ export interface BaseGameEvent { export interface BaseStatsInputDTO { /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof BaseStatsInputDTO */ - startDate?: string; + startDate?: StatsControllerGetPingStatsStartDateParameter; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof BaseStatsInputDTO */ - endDate?: string; + endDate?: StatsControllerGetPingStatsStartDateParameter; } /** * @@ -1949,6 +1949,9 @@ export const EventCreateDTOEventNameEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', PlayerConnected: 'player-connected', PlayerDisconnected: 'player-disconnected', ChatMessage: 'chat-message', @@ -2214,6 +2217,9 @@ export const EventOutputDTOEventNameEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', PlayerConnected: 'player-connected', PlayerDisconnected: 'player-disconnected', ChatMessage: 'chat-message', @@ -2240,6 +2246,9 @@ export type EventOutputDTOMeta = | TakaroEventCronjobExecuted | TakaroEventCurrencyAdded | TakaroEventCurrencyDeducted + | TakaroEventGameserverCreated + | TakaroEventGameserverDeleted + | TakaroEventGameserverUpdated | TakaroEventHookExecuted | TakaroEventModuleCreated | TakaroEventModuleDeleted @@ -2425,6 +2434,9 @@ export const EventSearchInputAllowedFiltersEventNameEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', PlayerConnected: 'player-connected', PlayerDisconnected: 'player-disconnected', ChatMessage: 'chat-message', @@ -2555,16 +2567,16 @@ export interface EventsCountInputDTO { bucketStep: EventsCountInputDTOBucketStepEnum; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof EventsCountInputDTO */ - startDate?: string; + startDate?: StatsControllerGetPingStatsStartDateParameter; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof EventsCountInputDTO */ - endDate?: string; + endDate?: StatsControllerGetPingStatsStartDateParameter; } export const EventsCountInputDTOEventNameEnum = { @@ -2593,6 +2605,9 @@ export const EventsCountInputDTOEventNameEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', PlayerConnected: 'player-connected', PlayerDisconnected: 'player-disconnected', ChatMessage: 'chat-message', @@ -3651,6 +3666,9 @@ export const HookCreateDTOEventTypeEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', } as const; export type HookCreateDTOEventTypeEnum = (typeof HookCreateDTOEventTypeEnum)[keyof typeof HookCreateDTOEventTypeEnum]; @@ -3794,6 +3812,9 @@ export const HookOutputDTOEventTypeEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', } as const; export type HookOutputDTOEventTypeEnum = (typeof HookOutputDTOEventTypeEnum)[keyof typeof HookOutputDTOEventTypeEnum]; @@ -3882,6 +3903,9 @@ export const HookSearchInputAllowedFiltersEventTypeEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', } as const; export type HookSearchInputAllowedFiltersEventTypeEnum = @@ -4028,6 +4052,9 @@ export const HookTriggerDTOEventTypeEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', } as const; export type HookTriggerDTOEventTypeEnum = @@ -4104,6 +4131,9 @@ export const HookUpdateDTOEventTypeEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', } as const; export type HookUpdateDTOEventTypeEnum = (typeof HookUpdateDTOEventTypeEnum)[keyof typeof HookUpdateDTOEventTypeEnum]; @@ -4340,6 +4370,9 @@ export const IHookEventTypeEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', } as const; export type IHookEventTypeEnum = (typeof IHookEventTypeEnum)[keyof typeof IHookEventTypeEnum]; @@ -5014,16 +5047,16 @@ export interface LatencyInputDTO { gameServerId: string; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof LatencyInputDTO */ - startDate?: string; + startDate?: StatsControllerGetPingStatsStartDateParameter; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof LatencyInputDTO */ - endDate?: string; + endDate?: StatsControllerGetPingStatsStartDateParameter; } /** * @@ -5252,10 +5285,10 @@ export interface MessageSendInputDTO { export interface MetadataOutput { /** * - * @type {string} + * @type {MetadataOutputServerTime} * @memberof MetadataOutput */ - serverTime: string; + serverTime: MetadataOutputServerTime; /** * * @type {ErrorOutput} @@ -5281,6 +5314,12 @@ export interface MetadataOutput { */ total?: number; } +/** + * @type MetadataOutputServerTime + * @export + */ +export type MetadataOutputServerTime = string; + /** * * @export @@ -5817,16 +5856,16 @@ export interface OptionalPogStatsInputDTO { playerId?: string; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof OptionalPogStatsInputDTO */ - startDate?: string; + startDate?: StatsControllerGetPingStatsStartDateParameter; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof OptionalPogStatsInputDTO */ - endDate?: string; + endDate?: StatsControllerGetPingStatsStartDateParameter; } /** * @@ -7312,16 +7351,16 @@ export interface PlayersOnlineInputDTO { gameServerId?: string; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof PlayersOnlineInputDTO */ - startDate?: string; + startDate?: StatsControllerGetPingStatsStartDateParameter; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof PlayersOnlineInputDTO */ - endDate?: string; + endDate?: StatsControllerGetPingStatsStartDateParameter; } /** * @@ -7362,16 +7401,16 @@ export interface PogStatsInputDTO { playerId: string; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof PogStatsInputDTO */ - startDate?: string; + startDate?: StatsControllerGetPingStatsStartDateParameter; /** * - * @type {string} + * @type {StatsControllerGetPingStatsStartDateParameter} * @memberof PogStatsInputDTO */ - endDate?: string; + endDate?: StatsControllerGetPingStatsStartDateParameter; } /** * @@ -8712,6 +8751,12 @@ export interface ShopSearchInputAllowedRangeFilter { */ updatedAt?: NOTDOMAINSCOPEDTakaroModelDTOCreatedAt; } +/** + * @type StatsControllerGetPingStatsStartDateParameter + * @export + */ +export type StatsControllerGetPingStatsStartDateParameter = string; + /** * * @export @@ -8926,6 +8971,45 @@ export interface TakaroEventFunctionResult { */ tryAgainIn?: number; } +/** + * + * @export + * @interface TakaroEventGameserverCreated + */ +export interface TakaroEventGameserverCreated { + /** + * + * @type {NOTDOMAINSCOPEDTakaroModelDTOCreatedAt} + * @memberof TakaroEventGameserverCreated + */ + timestamp: NOTDOMAINSCOPEDTakaroModelDTOCreatedAt; +} +/** + * + * @export + * @interface TakaroEventGameserverDeleted + */ +export interface TakaroEventGameserverDeleted { + /** + * + * @type {NOTDOMAINSCOPEDTakaroModelDTOCreatedAt} + * @memberof TakaroEventGameserverDeleted + */ + timestamp: NOTDOMAINSCOPEDTakaroModelDTOCreatedAt; +} +/** + * + * @export + * @interface TakaroEventGameserverUpdated + */ +export interface TakaroEventGameserverUpdated { + /** + * + * @type {NOTDOMAINSCOPEDTakaroModelDTOCreatedAt} + * @memberof TakaroEventGameserverUpdated + */ + timestamp: NOTDOMAINSCOPEDTakaroModelDTOCreatedAt; +} /** * * @export @@ -22203,8 +22287,8 @@ export const StatsApiAxiosParamCreator = function (configuration?: Configuration * @param {StatsControllerGetActivityStatsTimeTypeEnum} timeType * @param {StatsControllerGetActivityStatsDataTypeEnum} dataType * @param {string} [gameServerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -22212,8 +22296,8 @@ export const StatsApiAxiosParamCreator = function (configuration?: Configuration timeType: StatsControllerGetActivityStatsTimeTypeEnum, dataType: StatsControllerGetActivityStatsDataTypeEnum, gameServerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options: RawAxiosRequestConfig = {}, ): Promise => { // verify required parameter 'timeType' is not null or undefined @@ -22306,16 +22390,16 @@ export const StatsApiAxiosParamCreator = function (configuration?: Configuration * @summary Get currency stats * @param {string} gameServerId * @param {string} [playerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ statsControllerGetCurrencyStats: async ( gameServerId: string, playerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options: RawAxiosRequestConfig = {}, ): Promise => { // verify required parameter 'gameServerId' is not null or undefined @@ -22369,8 +22453,8 @@ export const StatsApiAxiosParamCreator = function (configuration?: Configuration * @param {string} [moduleId] * @param {string} [playerId] * @param {string} [userId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -22382,8 +22466,8 @@ export const StatsApiAxiosParamCreator = function (configuration?: Configuration moduleId?: string, playerId?: string, userId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options: RawAxiosRequestConfig = {}, ): Promise => { // verify required parameter 'eventName' is not null or undefined @@ -22453,15 +22537,15 @@ export const StatsApiAxiosParamCreator = function (configuration?: Configuration * The roundtrip time for reachability tests between Takaro and the game server * @summary Get latency stats * @param {string} gameServerId - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ statsControllerGetLatencyStats: async ( gameServerId: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options: RawAxiosRequestConfig = {}, ): Promise => { // verify required parameter 'gameServerId' is not null or undefined @@ -22506,16 +22590,16 @@ export const StatsApiAxiosParamCreator = function (configuration?: Configuration * @summary Get ping stats * @param {string} gameServerId * @param {string} playerId - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ statsControllerGetPingStats: async ( gameServerId: string, playerId: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options: RawAxiosRequestConfig = {}, ): Promise => { // verify required parameter 'gameServerId' is not null or undefined @@ -22565,15 +22649,15 @@ export const StatsApiAxiosParamCreator = function (configuration?: Configuration * Required permissions: `READ_PLAYERS` * @summary Get player online stats * @param {string} [gameServerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ statsControllerGetPlayerOnlineStats: async ( gameServerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options: RawAxiosRequestConfig = {}, ): Promise => { const localVarPath = `/stats/players-online`; @@ -22627,8 +22711,8 @@ export const StatsApiFp = function (configuration?: Configuration) { * @param {StatsControllerGetActivityStatsTimeTypeEnum} timeType * @param {StatsControllerGetActivityStatsDataTypeEnum} dataType * @param {string} [gameServerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -22636,8 +22720,8 @@ export const StatsApiFp = function (configuration?: Configuration) { timeType: StatsControllerGetActivityStatsTimeTypeEnum, dataType: StatsControllerGetActivityStatsDataTypeEnum, gameServerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.statsControllerGetActivityStats( @@ -22687,16 +22771,16 @@ export const StatsApiFp = function (configuration?: Configuration) { * @summary Get currency stats * @param {string} gameServerId * @param {string} [playerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ async statsControllerGetCurrencyStats( gameServerId: string, playerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.statsControllerGetCurrencyStats( @@ -22727,8 +22811,8 @@ export const StatsApiFp = function (configuration?: Configuration) { * @param {string} [moduleId] * @param {string} [playerId] * @param {string} [userId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -22740,8 +22824,8 @@ export const StatsApiFp = function (configuration?: Configuration) { moduleId?: string, playerId?: string, userId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.statsControllerGetEventsCount( @@ -22771,15 +22855,15 @@ export const StatsApiFp = function (configuration?: Configuration) { * The roundtrip time for reachability tests between Takaro and the game server * @summary Get latency stats * @param {string} gameServerId - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ async statsControllerGetLatencyStats( gameServerId: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.statsControllerGetLatencyStats( @@ -22804,16 +22888,16 @@ export const StatsApiFp = function (configuration?: Configuration) { * @summary Get ping stats * @param {string} gameServerId * @param {string} playerId - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ async statsControllerGetPingStats( gameServerId: string, playerId: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.statsControllerGetPingStats( @@ -22838,15 +22922,15 @@ export const StatsApiFp = function (configuration?: Configuration) { * Required permissions: `READ_PLAYERS` * @summary Get player online stats * @param {string} [gameServerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ async statsControllerGetPlayerOnlineStats( gameServerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { const localVarAxiosArgs = await localVarAxiosParamCreator.statsControllerGetPlayerOnlineStats( @@ -22882,8 +22966,8 @@ export const StatsApiFactory = function (configuration?: Configuration, basePath * @param {StatsControllerGetActivityStatsTimeTypeEnum} timeType * @param {StatsControllerGetActivityStatsDataTypeEnum} dataType * @param {string} [gameServerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -22891,8 +22975,8 @@ export const StatsApiFactory = function (configuration?: Configuration, basePath timeType: StatsControllerGetActivityStatsTimeTypeEnum, dataType: StatsControllerGetActivityStatsDataTypeEnum, gameServerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): AxiosPromise { return localVarFp @@ -22919,16 +23003,16 @@ export const StatsApiFactory = function (configuration?: Configuration, basePath * @summary Get currency stats * @param {string} gameServerId * @param {string} [playerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ statsControllerGetCurrencyStats( gameServerId: string, playerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): AxiosPromise { return localVarFp @@ -22945,8 +23029,8 @@ export const StatsApiFactory = function (configuration?: Configuration, basePath * @param {string} [moduleId] * @param {string} [playerId] * @param {string} [userId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ @@ -22958,8 +23042,8 @@ export const StatsApiFactory = function (configuration?: Configuration, basePath moduleId?: string, playerId?: string, userId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): AxiosPromise { return localVarFp @@ -22981,15 +23065,15 @@ export const StatsApiFactory = function (configuration?: Configuration, basePath * The roundtrip time for reachability tests between Takaro and the game server * @summary Get latency stats * @param {string} gameServerId - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ statsControllerGetLatencyStats( gameServerId: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): AxiosPromise { return localVarFp @@ -23001,16 +23085,16 @@ export const StatsApiFactory = function (configuration?: Configuration, basePath * @summary Get ping stats * @param {string} gameServerId * @param {string} playerId - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ statsControllerGetPingStats( gameServerId: string, playerId: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): AxiosPromise { return localVarFp @@ -23021,15 +23105,15 @@ export const StatsApiFactory = function (configuration?: Configuration, basePath * Required permissions: `READ_PLAYERS` * @summary Get player online stats * @param {string} [gameServerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} */ statsControllerGetPlayerOnlineStats( gameServerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ): AxiosPromise { return localVarFp @@ -23052,8 +23136,8 @@ export class StatsApi extends BaseAPI { * @param {StatsControllerGetActivityStatsTimeTypeEnum} timeType * @param {StatsControllerGetActivityStatsDataTypeEnum} dataType * @param {string} [gameServerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StatsApi @@ -23062,8 +23146,8 @@ export class StatsApi extends BaseAPI { timeType: StatsControllerGetActivityStatsTimeTypeEnum, dataType: StatsControllerGetActivityStatsDataTypeEnum, gameServerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ) { return StatsApiFp(this.configuration) @@ -23090,8 +23174,8 @@ export class StatsApi extends BaseAPI { * @summary Get currency stats * @param {string} gameServerId * @param {string} [playerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StatsApi @@ -23099,8 +23183,8 @@ export class StatsApi extends BaseAPI { public statsControllerGetCurrencyStats( gameServerId: string, playerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ) { return StatsApiFp(this.configuration) @@ -23118,8 +23202,8 @@ export class StatsApi extends BaseAPI { * @param {string} [moduleId] * @param {string} [playerId] * @param {string} [userId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StatsApi @@ -23132,8 +23216,8 @@ export class StatsApi extends BaseAPI { moduleId?: string, playerId?: string, userId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ) { return StatsApiFp(this.configuration) @@ -23156,16 +23240,16 @@ export class StatsApi extends BaseAPI { * The roundtrip time for reachability tests between Takaro and the game server * @summary Get latency stats * @param {string} gameServerId - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StatsApi */ public statsControllerGetLatencyStats( gameServerId: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ) { return StatsApiFp(this.configuration) @@ -23178,8 +23262,8 @@ export class StatsApi extends BaseAPI { * @summary Get ping stats * @param {string} gameServerId * @param {string} playerId - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StatsApi @@ -23187,8 +23271,8 @@ export class StatsApi extends BaseAPI { public statsControllerGetPingStats( gameServerId: string, playerId: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ) { return StatsApiFp(this.configuration) @@ -23200,16 +23284,16 @@ export class StatsApi extends BaseAPI { * Required permissions: `READ_PLAYERS` * @summary Get player online stats * @param {string} [gameServerId] - * @param {string} [startDate] - * @param {string} [endDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [startDate] + * @param {StatsControllerGetPingStatsStartDateParameter} [endDate] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof StatsApi */ public statsControllerGetPlayerOnlineStats( gameServerId?: string, - startDate?: string, - endDate?: string, + startDate?: StatsControllerGetPingStatsStartDateParameter, + endDate?: StatsControllerGetPingStatsStartDateParameter, options?: RawAxiosRequestConfig, ) { return StatsApiFp(this.configuration) @@ -23266,6 +23350,9 @@ export const StatsControllerGetEventsCountEventNameEnum = { ShopOrderCreated: 'shop-order-created', ShopOrderStatusChanged: 'shop-order-status-changed', PlayerLinked: 'player-linked', + GameserverCreated: 'gameserver-created', + GameserverUpdated: 'gameserver-updated', + GameserverDeleted: 'gameserver-deleted', PlayerConnected: 'player-connected', PlayerDisconnected: 'player-disconnected', ChatMessage: 'chat-message', diff --git a/packages/lib-apiclient/src/generated/base.ts b/packages/lib-apiclient/src/generated/base.ts index 93ae039241..b8bd4230cc 100644 --- a/packages/lib-apiclient/src/generated/base.ts +++ b/packages/lib-apiclient/src/generated/base.ts @@ -1,10 +1,10 @@ /* tslint:disable */ /* eslint-disable */ /** - * Takaro app-api + * Takaro API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: development - c5f9cff194f87c14e431b69759a49bebf5cb396f + * The version of the OpenAPI document: unset - unset * Contact: support@takaro.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/packages/lib-apiclient/src/generated/common.ts b/packages/lib-apiclient/src/generated/common.ts index d8c2f68d8f..f2f7f5a3a1 100644 --- a/packages/lib-apiclient/src/generated/common.ts +++ b/packages/lib-apiclient/src/generated/common.ts @@ -1,10 +1,10 @@ /* tslint:disable */ /* eslint-disable */ /** - * Takaro app-api + * Takaro API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: development - c5f9cff194f87c14e431b69759a49bebf5cb396f + * The version of the OpenAPI document: unset - unset * Contact: support@takaro.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/packages/lib-apiclient/src/generated/configuration.ts b/packages/lib-apiclient/src/generated/configuration.ts index 70f6d0b55b..2c85febd69 100644 --- a/packages/lib-apiclient/src/generated/configuration.ts +++ b/packages/lib-apiclient/src/generated/configuration.ts @@ -1,10 +1,10 @@ /* tslint:disable */ /* eslint-disable */ /** - * Takaro app-api + * Takaro API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: development - c5f9cff194f87c14e431b69759a49bebf5cb396f + * The version of the OpenAPI document: unset - unset * Contact: support@takaro.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/packages/lib-apiclient/src/generated/index.ts b/packages/lib-apiclient/src/generated/index.ts index c170cd8ebb..ff32b04e21 100644 --- a/packages/lib-apiclient/src/generated/index.ts +++ b/packages/lib-apiclient/src/generated/index.ts @@ -1,10 +1,10 @@ /* tslint:disable */ /* eslint-disable */ /** - * Takaro app-api + * Takaro API * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * - * The version of the OpenAPI document: development - c5f9cff194f87c14e431b69759a49bebf5cb396f + * The version of the OpenAPI document: unset - unset * Contact: support@takaro.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). diff --git a/packages/lib-modules/src/dto/takaroEvents.ts b/packages/lib-modules/src/dto/takaroEvents.ts index e8fab7e524..1f9e3b78c1 100644 --- a/packages/lib-modules/src/dto/takaroEvents.ts +++ b/packages/lib-modules/src/dto/takaroEvents.ts @@ -42,6 +42,9 @@ export const TakaroEvents = { SHOP_ORDER_CREATED: 'shop-order-created', SHOP_ORDER_STATUS_CHANGED: 'shop-order-status-changed', PLAYER_LINKED: 'player-linked', + GAMESERVER_CREATED: 'gameserver-created', + GAMESERVER_UPDATED: 'gameserver-updated', + GAMESERVER_DELETED: 'gameserver-deleted', } as const; export class BaseTakaroEvent extends BaseEvent { @@ -330,6 +333,21 @@ export class TakaroEventPlayerLinked extends BaseEvent type = TakaroEvents.PLAYER_LINKED; } +export class TakaroEventGameserverCreated extends BaseEvent { + @IsString() + type = TakaroEvents.GAMESERVER_CREATED; +} + +export class TakaroEventGameserverUpdated extends BaseEvent { + @IsString() + type = TakaroEvents.GAMESERVER_UPDATED; +} + +export class TakaroEventGameserverDeleted extends BaseEvent { + @IsString() + type = TakaroEvents.GAMESERVER_DELETED; +} + export const TakaroEventsMapping = { [TakaroEvents.ROLE_ASSIGNED]: TakaroEventRoleAssigned, [TakaroEvents.PLAYER_NEW_IP_DETECTED]: TakaroEventPlayerNewIpDetected, @@ -356,4 +374,7 @@ export const TakaroEventsMapping = { [TakaroEvents.SHOP_ORDER_CREATED]: TakaroEventShopOrderCreated, [TakaroEvents.SHOP_ORDER_STATUS_CHANGED]: TakaroEventShopOrderStatusChanged, [TakaroEvents.PLAYER_LINKED]: TakaroEventPlayerLinked, + [TakaroEvents.GAMESERVER_CREATED]: TakaroEventGameserverCreated, + [TakaroEvents.GAMESERVER_UPDATED]: TakaroEventGameserverUpdated, + [TakaroEvents.GAMESERVER_DELETED]: TakaroEventGameserverDeleted, } as const; diff --git a/packages/web-main/src/components/events/EventFeed/EventItem.tsx b/packages/web-main/src/components/events/EventFeed/EventItem.tsx index 59f4a51de1..ec63d8e7ae 100644 --- a/packages/web-main/src/components/events/EventFeed/EventItem.tsx +++ b/packages/web-main/src/components/events/EventFeed/EventItem.tsx @@ -254,6 +254,15 @@ export const EventItem: FC = ({ event }) => { ); break; + case EventOutputDTOEventNameEnum.GameserverCreated: + case EventOutputDTOEventNameEnum.GameserverUpdated: + case EventOutputDTOEventNameEnum.GameserverDeleted: + properties = ( + <> + + + ); + break; } return ( diff --git a/packages/web-main/src/components/selects/EventNameSelectField/eventNames.tsx b/packages/web-main/src/components/selects/EventNameSelectField/eventNames.tsx index 3c2be10078..59b2cea470 100644 --- a/packages/web-main/src/components/selects/EventNameSelectField/eventNames.tsx +++ b/packages/web-main/src/components/selects/EventNameSelectField/eventNames.tsx @@ -28,6 +28,9 @@ export const categorizedEventNames = [ { category: 'Game Server', events: [ + e.GameserverCreated, + e.GameserverUpdated, + e.GameserverDeleted, e.PlayerConnected, e.PlayerDisconnected, e.ChatMessage,