diff --git a/packages/app-api/src/controllers/Shop/Listing.ts b/packages/app-api/src/controllers/Shop/Listing.ts index d2692e3fcc..8125a594a3 100644 --- a/packages/app-api/src/controllers/Shop/Listing.ts +++ b/packages/app-api/src/controllers/Shop/Listing.ts @@ -15,6 +15,8 @@ import { ShopListingUpdateDTO, ShopListingCreateDTO, ShopImportOptions, + ShopListingItemMetaOutputDTO, + ShopListingItemMetaInputDTO, } from '../../service/Shop/dto.js'; import multer from 'multer'; @@ -156,7 +158,20 @@ export class ShopListingController { const rawImportData = JSON.parse(req.body.import); const rawOptions = JSON.parse(req.body.options); - const importData: ShopListingCreateDTO[] = rawImportData.map((item: any) => new ShopListingCreateDTO(item)); + const importData: ShopListingCreateDTO[] = rawImportData.map( + (listing: any) => + new ShopListingCreateDTO({ + ...listing, + items: listing.items.map( + (item: ShopListingItemMetaOutputDTO) => + new ShopListingItemMetaInputDTO({ + amount: item.amount, + quality: item.quality, + code: item.item.code, + }), + ), + }), + ); const options = new ShopImportOptions(rawOptions); await Promise.all(importData.map((item) => item.validate())); diff --git a/packages/app-api/src/controllers/__tests__/ShopListing.integration.test.ts b/packages/app-api/src/controllers/__tests__/ShopListing.integration.test.ts index 377ff769fe..9621e49899 100644 --- a/packages/app-api/src/controllers/__tests__/ShopListing.integration.test.ts +++ b/packages/app-api/src/controllers/__tests__/ShopListing.integration.test.ts @@ -23,11 +23,16 @@ const shopSetup = async function (this: IntegrationTest): Promise { return this.client.shopListing.shopListingControllerCreate({ gameServerId: this.setupData.gameServer1.id, - items: [{ itemId: items[0].id, amount: 1 }], + items: [{ code: items[0].code, amount: 1 }], price: 100 + i, name: `Test item ${i}`, }); @@ -222,6 +227,8 @@ const tests = [ expect(shop2Listings).to.have.length(shop1Listings.length); // Check createdAt and compare to before to ensure these are new listings expect(shop2ListingsBefore.every((l) => shop2Listings.some((l2) => l2.createdAt < l.createdAt))).to.be.true; + // Ensure there are items in the listing + expect(shop2Listings.every((l) => l.items.length > 0)).to.be.true; }, }), new IntegrationTest({ @@ -237,7 +244,7 @@ const tests = [ Array.from({ length: listingsToMake }).map(async (_, i) => { return this.client.shopListing.shopListingControllerCreate({ gameServerId: this.setupData.gameServer1.id, - items: [{ itemId: items[0].id, amount: 1 }], + items: [{ code: items[0].code, amount: 1 }], price: 100 + i, name: `Test item ${i}`, }); @@ -277,6 +284,8 @@ const tests = [ }) ).data.data; expect(shop2Listings).to.have.length(shop1Listings.length + shop2ListingsBefore.length); + // Ensure there are items in the listing + expect(shop2Listings.every((l) => l.items.length > 0)).to.be.true; }, }), new IntegrationTest({ @@ -292,7 +301,7 @@ const tests = [ Array.from({ length: listingsToMake }).map(async (_, i) => { return this.client.shopListing.shopListingControllerCreate({ gameServerId: this.setupData.gameServer1.id, - items: [{ itemId: items[0].id, amount: 1 }], + items: [{ code: items[0].code, amount: 1 }], price: 100 + i, name: `Test item ${i}`, }); diff --git a/packages/app-api/src/controllers/__tests__/ShopOrder.integration.test.ts b/packages/app-api/src/controllers/__tests__/ShopOrder.integration.test.ts index de0ffffb24..d1d2cbed3c 100644 --- a/packages/app-api/src/controllers/__tests__/ShopOrder.integration.test.ts +++ b/packages/app-api/src/controllers/__tests__/ShopOrder.integration.test.ts @@ -92,14 +92,14 @@ const shopSetup = async function (this: IntegrationTest): Promise { + const { query } = await this.getModel(); + const data = await query.whereIn('code', codes).andWhere('gameserverId', gameserverId); + + if (!data) { + throw new errors.NotFoundError(); + } + + return Promise.all(data.map((item) => new ItemsOutputDTO(item))); + } + async find(filters: ITakaroQuery) { const { query } = await this.getModel(); diff --git a/packages/app-api/src/db/shopListing.ts b/packages/app-api/src/db/shopListing.ts index 286cb63f96..09a14c4e5f 100644 --- a/packages/app-api/src/db/shopListing.ts +++ b/packages/app-api/src/db/shopListing.ts @@ -2,7 +2,7 @@ import { ITakaroQuery, QueryBuilder, TakaroModel } from '@takaro/db'; import { Model } from 'objection'; import { errors, traceableClass } from '@takaro/util'; import { GameServerModel } from './gameserver.js'; -import { ItemsModel } from './items.js'; +import { ItemRepo, ItemsModel } from './items.js'; import { RoleModel } from './role.js'; import { ITakaroRepo } from './base.js'; import { ShopListingOutputDTO, ShopListingUpdateDTO, ShopListingCreateDTO } from '../service/Shop/dto.js'; @@ -158,12 +158,21 @@ export class ShopListingRepo extends ITakaroRepo< if (!item.items || !item.items.length) throw new errors.BadRequestError('At least one item is required'); - const itemMetas = item.items.map((i) => ({ - listingId: listing.id, - itemId: i.itemId, - amount: i.amount, - quality: i.quality, - })); + const itemRepo = new ItemRepo(this.domainId); + const items = await itemRepo.translateItemCodesToIds( + item.gameServerId, + item.items.map((i) => i.code).filter((code): code is string => code !== undefined), + ); + const itemMetas = item.items + .map((i) => ({ + listingId: listing.id, + itemId: items.find((item) => item.code === i.code)?.id || i.itemId, + amount: i.amount, + quality: i.quality, + })) + .filter((i) => i.itemId); + + if (!itemMetas.length) throw new errors.BadRequestError('No valid items found'); await Promise.all( itemMetas.map(async (i) => { @@ -205,12 +214,21 @@ export class ShopListingRepo extends ITakaroRepo< const res = await query.updateAndFetchById(id, data.toJSON()).returning('*'); if (data.items) { - const itemMetas = data.items.map((i) => ({ - listingId: id, - itemId: i.itemId, - amount: i.amount, - quality: i.quality, - })); + const itemRepo = new ItemRepo(this.domainId); + const items = await itemRepo.translateItemCodesToIds( + data.gameServerId, + data.items.map((i) => i.code).filter((code): code is string => code !== undefined), + ); + const itemMetas = data.items + .map((i) => { + return { + listingId: id, + itemId: items.find((item) => item.code === i.code)?.id || i.itemId, + amount: i.amount, + quality: i.quality, + }; + }) + .filter((i) => i.itemId); await ItemOnShopListingModel.bindKnex(knex).query().delete().where('listingId', id); diff --git a/packages/app-api/src/service/Shop/dto.ts b/packages/app-api/src/service/Shop/dto.ts index ac3d5bf533..3d21399760 100644 --- a/packages/app-api/src/service/Shop/dto.ts +++ b/packages/app-api/src/service/Shop/dto.ts @@ -13,7 +13,7 @@ import { TakaroModelDTO, TakaroDTO } from '@takaro/util'; import { Type } from 'class-transformer'; import { ItemsOutputDTO } from '../ItemsService.js'; -class ShopListingItemMetaOutputDTO extends TakaroModelDTO { +export class ShopListingItemMetaOutputDTO extends TakaroModelDTO { @IsNumber() amount: number; @IsString() @@ -30,8 +30,12 @@ export class ShopListingItemMetaInputDTO extends TakaroDTO { diff --git a/packages/app-api/src/service/Shop/index.ts b/packages/app-api/src/service/Shop/index.ts index bb175209ba..7d09f968a6 100644 --- a/packages/app-api/src/service/Shop/index.ts +++ b/packages/app-api/src/service/Shop/index.ts @@ -13,6 +13,7 @@ import { ShopOrderStatus, ShopOrderCreateInternalDTO, ShopImportOptions, + ShopListingItemMetaInputDTO, } from './dto.js'; import { UserService } from '../User/index.js'; import { checkPermissions } from '../AuthService.js'; @@ -29,6 +30,7 @@ import { TakaroEventShopOrderStatusChanged, } from '@takaro/modules'; import { IMessageOptsDTO, IPlayerReferenceDTO } from '@takaro/gameserver'; +import { ItemsService } from '../ItemsService.js'; @traceableClass('service:shopListing') export class ShopListingService extends TakaroService< @@ -93,8 +95,28 @@ export class ShopListingService extends TakaroService< return listing; } - async create(item: ShopListingCreateDTO): Promise { - const created = await this.repo.create(item); + async create(listing: ShopListingCreateDTO): Promise { + const itemCodes = listing.items.map((item) => item.code).filter(Boolean); + const itemsService = new ItemsService(this.domainId); + const items = await itemsService.find({ filters: { code: itemCodes } }); + listing.items = listing.items.map((item) => { + const code = items.results.find((i) => i.code === item.code); + if (!code) { + if (!item.itemId) + throw new errors.BadRequestError(`Item with code ${item.code} not found and no itemId provided`); + return new ShopListingItemMetaInputDTO({ + amount: item.amount, + quality: item.quality, + itemId: item.itemId, + }); + } + return new ShopListingItemMetaInputDTO({ + amount: item.amount, + quality: item.quality, + code: item.code, + }); + }); + const created = await this.repo.create(listing); await this.eventService.create( new EventCreateDTO({ @@ -344,10 +366,10 @@ export class ShopListingService extends TakaroService< } const promises = await Promise.allSettled( - data.map((item) => { - item.draft = options.draft; - item.gameServerId = options.gameServerId; - return this.create(item); + data.map((listing) => { + listing.draft = options.draft; + listing.gameServerId = options.gameServerId; + return this.create(listing); }), ); diff --git a/packages/app-api/src/workers/csmmImportWorker.ts b/packages/app-api/src/workers/csmmImportWorker.ts index 3aa11b9e2b..80279cc08b 100644 --- a/packages/app-api/src/workers/csmmImportWorker.ts +++ b/packages/app-api/src/workers/csmmImportWorker.ts @@ -14,7 +14,6 @@ import { PlayerService } from '../service/PlayerService.js'; import { PlayerOnGameServerService } from '../service/PlayerOnGameserverService.js'; import { IGamePlayer } from '@takaro/modules'; import { ShopListingService } from '../service/Shop/index.js'; -import { ItemsService } from '../service/ItemsService.js'; import { ShopListingCreateDTO, ShopListingItemMetaInputDTO } from '../service/Shop/dto.js'; const log = logger('worker:csmmImport'); @@ -80,7 +79,6 @@ async function process(job: Job) { const playerService = new PlayerService(job.data.domainId); const pogService = new PlayerOnGameServerService(job.data.domainId); const shopListingService = new ShopListingService(job.data.domainId); - const itemService = new ItemsService(job.data.domainId); let server: GameServerOutputDTO | null; @@ -233,7 +231,6 @@ async function process(job: Job) { // Import shop listings if (job.data.options.shop) { for (const listing of data.shopListings) { - const item = await itemService.find({ filters: { code: [listing.name] } }); // CSMM stores quality null as 0... const quality = listing.quality.toString() === '0' ? null : listing.quality; @@ -245,7 +242,7 @@ async function process(job: Job) { items: [ new ShopListingItemMetaInputDTO({ amount: listing.amount, - itemId: item.results[0].id, + code: listing.name, quality: quality, }), ], 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 22803c56fe..32d9cb2722 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 - 40d647fddb537c63b08136a307b99d7cb7513062 + * 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; } /** * @@ -2555,16 +2555,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 = { @@ -5014,16 +5014,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 +5252,10 @@ export interface MessageSendInputDTO { export interface MetadataOutput { /** * - * @type {string} + * @type {MetadataOutputServerTime} * @memberof MetadataOutput */ - serverTime: string; + serverTime: MetadataOutputServerTime; /** * * @type {ErrorOutput} @@ -5281,6 +5281,12 @@ export interface MetadataOutput { */ total?: number; } +/** + * @type MetadataOutputServerTime + * @export + */ +export type MetadataOutputServerTime = string; + /** * * @export @@ -5817,16 +5823,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 +7318,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 +7368,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; } /** * @@ -8055,7 +8061,13 @@ export interface ShopListingItemMetaInputDTO { * @type {string} * @memberof ShopListingItemMetaInputDTO */ - itemId: string; + code?: string; + /** + * + * @type {string} + * @memberof ShopListingItemMetaInputDTO + */ + itemId?: string; } /** * @@ -8706,6 +8718,12 @@ export interface ShopSearchInputAllowedRangeFilter { */ updatedAt?: NOTDOMAINSCOPEDTakaroModelDTOCreatedAt; } +/** + * @type StatsControllerGetPingStatsStartDateParameter + * @export + */ +export type StatsControllerGetPingStatsStartDateParameter = string; + /** * * @export @@ -22197,8 +22215,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} */ @@ -22206,8 +22224,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 @@ -22300,16 +22318,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 @@ -22363,8 +22381,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} */ @@ -22376,8 +22394,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 @@ -22447,15 +22465,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 @@ -22500,16 +22518,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 @@ -22559,15 +22577,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`; @@ -22621,8 +22639,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} */ @@ -22630,8 +22648,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( @@ -22681,16 +22699,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( @@ -22721,8 +22739,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} */ @@ -22734,8 +22752,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( @@ -22765,15 +22783,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( @@ -22798,16 +22816,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( @@ -22832,15 +22850,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( @@ -22876,8 +22894,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} */ @@ -22885,8 +22903,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 @@ -22913,16 +22931,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 @@ -22939,8 +22957,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} */ @@ -22952,8 +22970,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 @@ -22975,15 +22993,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 @@ -22995,16 +23013,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 @@ -23015,15 +23033,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 @@ -23046,8 +23064,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 @@ -23056,8 +23074,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) @@ -23084,8 +23102,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 @@ -23093,8 +23111,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) @@ -23112,8 +23130,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 @@ -23126,8 +23144,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) @@ -23150,16 +23168,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) @@ -23172,8 +23190,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 @@ -23181,8 +23199,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) @@ -23194,16 +23212,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) diff --git a/packages/lib-apiclient/src/generated/base.ts b/packages/lib-apiclient/src/generated/base.ts index afb3031a3a..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 - 40d647fddb537c63b08136a307b99d7cb7513062 + * 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 b1dd385d1b..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 - 40d647fddb537c63b08136a307b99d7cb7513062 + * 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 59ce4619bf..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 - 40d647fddb537c63b08136a307b99d7cb7513062 + * 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 8a7cddf4b9..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 - 40d647fddb537c63b08136a307b99d7cb7513062 + * 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/test/src/__snapshots__/ShopController/Update.json b/packages/test/src/__snapshots__/ShopController/Update.json index ff109350f9..525a2dfc4b 100644 --- a/packages/test/src/__snapshots__/ShopController/Update.json +++ b/packages/test/src/__snapshots__/ShopController/Update.json @@ -24,9 +24,9 @@ "createdAt": "2024-07-18T15:25:48.096Z", "updatedAt": "2024-07-18T15:25:48.096Z", "gameserverId": "becf27be-f2db-4a53-a2d4-56608001e5bb", - "name": "Stone", - "code": "stone", - "description": "Stone can get you stoned", + "name": "Wood", + "code": "wood", + "description": "Wood is good", "icon": null } } diff --git a/packages/web-main/src/components/cards/ShopListingCard/index.tsx b/packages/web-main/src/components/cards/ShopListingCard/index.tsx index 402e70327a..61f719df65 100644 --- a/packages/web-main/src/components/cards/ShopListingCard/index.tsx +++ b/packages/web-main/src/components/cards/ShopListingCard/index.tsx @@ -27,7 +27,8 @@ export const ShopListingCard: FC = ({ gameServerType, playerCurrencyAmount, }) => { - const shopListingName = shopListing.name || shopListing.items[0].item.name; + const firstItem = shopListing.items[0]?.item || { name: 'Unknown', code: 'unknown' }; + const shopListingName = shopListing.name || firstItem.name; const hasPermission = useHasPermission(['MANAGE_SHOP_LISTINGS']); return ( @@ -48,8 +49,8 @@ export const ShopListingCard: FC = ({ {getInitials(shopListingName)}