From e842e4f257ca3b35213260a870a26c4dded12ce9 Mon Sep 17 00:00:00 2001 From: Placni Date: Sat, 30 Nov 2024 12:23:59 -0600 Subject: [PATCH] sync with latest api changes --- src/clients/ts/index.ts | 103 ++++++++++++++++++++++++++++++------ src/clients/ts/package.json | 2 +- swagger.json | 56 +++++++++++++------- 3 files changed, 126 insertions(+), 35 deletions(-) diff --git a/src/clients/ts/index.ts b/src/clients/ts/index.ts index 5512f1a..e71c5d5 100644 --- a/src/clients/ts/index.ts +++ b/src/clients/ts/index.ts @@ -33,7 +33,7 @@ export abstract class OtrApiWrapperBase { */ export type BeatmapsGetRequestParams = { /** - * (required) Search key (o!TR id or osu! id) + * (required) Search key (id or osu! id) */ key: number; } @@ -116,7 +116,7 @@ export class BeatmapsWrapper extends OtrApiWrapperBase { /** * Get a beatmap * - * Get a beatmap searching first by id, then by beatmap osu! id + * Get a beatmap searching first by id, then by osu! id * * Requires Authorization: * @@ -297,6 +297,74 @@ export class ClientsWrapper extends OtrApiWrapperBase { } } +export class DiagnosticsWrapper extends OtrApiWrapperBase { + protected instance: AxiosInstance; + protected baseUrl: string; + protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined; + + constructor(configuration: IOtrApiWrapperConfiguration) { + + super(configuration); + + this.instance = axios.create(this.configuration.clientConfiguration); + this.baseUrl = this.getBaseUrl(""); + + if (this.configuration.postConfigureClientMethod) { + this.configuration.postConfigureClientMethod(this.instance); + } + } + + /** + * Undocumented + * @return Success + */ + public ping( cancelToken?: CancelToken): Promise> { + + let url_ = this.baseUrl + "/api/v1/diagnostics/ping"; + url_ = url_.replace(/[?&]$/, ""); + + let options_: AxiosRequestConfig = { + method: "GET", + url: url_, + headers: { + }, + cancelToken + }; + (options_ as any).requiresAuth = false + + return this.instance.request(options_).catch((_error: any) => { + if (isAxiosError(_error) && _error.response) { + return _error.response; + } else { + throw _error; + } + }).then((_response: AxiosResponse) => { + return this.processPing(_response); + }); + } + + protected processPing(response: AxiosResponse): Promise> { + const status = response.status; + let _headers: any = {}; + if (response.headers && typeof response.headers === "object") { + for (const k in response.headers) { + if (response.headers.hasOwnProperty(k)) { + _headers[k] = response.headers[k]; + } + } + } + if (status === 200) { + const _responseText = response.data; + return Promise.resolve>(new OtrApiResponse(status, _headers, null as any)); + + } else if (status !== 200 && status !== 204) { + const _responseText = response.data; + return throwException("An unexpected server error occurred.", status, _responseText, _headers); + } + return Promise.resolve>(new OtrApiResponse(status, _headers, null as any)); + } +} + /** * Request parameters available for use when requesting {@link FilteringWrapper.prototype.filter | api/v1/filtering} */ @@ -1550,19 +1618,23 @@ export type LeaderboardsGetRequestParams = { */ chartType?: LeaderboardChartType | undefined; /** - * (optional) Rank floor + * (optional) Rank floor (The "better" inclusive rank bound. + * If given, only players with a rank greater than or equal to this value will be included) */ minRank?: number | undefined; /** - * (optional) Rank ceiling + * (optional) Rank ceiling (The "worse" inclusive rank bound. + * If given, only players with a rank less than or equal to this value will be included) */ maxRank?: number | undefined; /** - * (optional) Rating floor + * (optional) Rating floor (The "worse" inclusive rating bound. + * If given, only players with a rating greater than or equal to this value will be included) */ minRating?: number | undefined; /** - * (optional) Rating ceiling + * (optional) Rating ceiling (The "better" inclusive rating bound. + * If given, only players with a rating less than or equal to this value will be included) */ maxRating?: number | undefined; /** @@ -1870,15 +1942,15 @@ export type MatchesListRequestParams = { */ ruleset?: Ruleset | undefined; /** - * (optional) Filters results for only matches with a partially matching name + * (optional) Filters results for only matches with a partially matching name (case insensitive) */ name?: string | undefined; /** - * (optional) Filters results for only matches that occurred after a specified date + * (optional) Filters results for only matches that occurred on or after a specified date */ dateMin?: Date | undefined; /** - * (optional) Filters results for only matches that occurred before a specified date + * (optional) Filters results for only matches that occurred on or before a specified date */ dateMax?: Date | undefined; /** @@ -3348,7 +3420,7 @@ export type PlayersDeleteAdminNoteRequestParams = { */ export type PlayersGetRequestParams = { /** - * (required) Search key (o!TR id, osu! id, or osu! username) + * (required) Search key (id, osu! id, or osu! username) */ key: string; } @@ -3783,7 +3855,7 @@ export class PlayersWrapper extends OtrApiWrapperBase { * Get a player's stats * * Gets player by versatile search. - * If no ruleset is provided, the player's default is used. OsuApiClient.Net.Constants.Endpoints.Osu is used as a fallback. + * If no ruleset is provided, the player's default is used. Database.Enums.Ruleset.Osu is used as a fallback. * If a ruleset is provided but the player has no data for it, all optional fields of the response will be null. * API.DTOs.PlayerStatsDTO.PlayerInfo will always be populated as long as a player is found. * If no date range is provided, gets all stats without considering date @@ -4866,7 +4938,7 @@ export class TournamentsWrapper extends OtrApiWrapperBase { /** * Get all tournaments which fit an optional request query * - * Will not include match data + * Results will not include match data * @param params Request parameters (see {@link TournamentsListRequestParams}) * @return Returns all tournaments which fit the request query */ @@ -5878,7 +5950,7 @@ export class UsersWrapper extends OtrApiWrapperBase { let result404: any = null; let resultData404 = _responseText; result404 = JSON.parse(resultData404); - return throwException("A user matching the given id does not exist\r\nor an oauth client matching the given id is not owned by the user", status, _responseText, _headers, result404); + return throwException("A user matching the given id does not exist\r\nor an OAuth client matching the given id is not owned by the user", status, _responseText, _headers, result404); } else if (status === 400) { const _responseText = response.data; @@ -5958,7 +6030,7 @@ export class UsersWrapper extends OtrApiWrapperBase { let result404: any = null; let resultData404 = _responseText; result404 = JSON.parse(resultData404); - return throwException("A user matching the given id does not exist\r\nor an oauth client matching the given id is not owned by the user", status, _responseText, _headers, result404); + return throwException("A user matching the given id does not exist\r\nor an OAuth client matching the given id is not owned by the user", status, _responseText, _headers, result404); } else if (status === 200) { const _responseText = response.data; @@ -7432,8 +7504,7 @@ export interface TournamentSearchResultDTO { export interface TournamentSubmissionDTO { /** The name of the tournament */ name: string; - /** Acronym / shortened name of the tournament -For osu! World Cup 2023, this value would be "OWC23" */ + /** Acronym / shortened name of the tournament */ abbreviation: string; /** The osu! forum post advertising this tournament */ forumUrl: string; diff --git a/src/clients/ts/package.json b/src/clients/ts/package.json index 02aaddd..b176688 100644 --- a/src/clients/ts/package.json +++ b/src/clients/ts/package.json @@ -1,6 +1,6 @@ { "name": "@osu-tournament-rating/otr-api-client", - "version": "0.0.11", + "version": "0.0.12", "description": "Client code for interacting with the o!TR API", "files": [ "index.js", diff --git a/swagger.json b/swagger.json index 1f2adb6..57a7c7f 100644 --- a/swagger.json +++ b/swagger.json @@ -64,13 +64,13 @@ "Beatmaps" ], "summary": "Get a beatmap", - "description": "Get a beatmap searching first by id, then by beatmap osu! id\n\nRequires Authorization:\n\nClaim(s): admin", + "description": "Get a beatmap searching first by id, then by osu! id\n\nRequires Authorization:\n\nClaim(s): admin", "operationId": "Beatmaps_get", "parameters": [ { "name": "key", "in": "path", - "description": "Search key (o!TR id or osu! id)", + "description": "Search key (id or osu! id)", "required": true, "style": "simple", "schema": { @@ -240,6 +240,20 @@ "x-requiresAuthorization": true } }, + "/api/v1/diagnostics/ping": { + "get": { + "tags": [ + "Diagnostics" + ], + "operationId": "Diagnostics_ping", + "responses": { + "200": { + "description": "Success" + } + }, + "x-requiresAuthorization": false + } + }, "/api/v1/filtering": { "post": { "tags": [ @@ -1605,7 +1619,7 @@ { "name": "minRank", "in": "query", - "description": "Rank floor", + "description": "Rank floor (The \"better\" inclusive rank bound.\r\nIf given, only players with a rank greater than or equal to this value will be included)", "style": "form", "schema": { "maximum": 2147483647, @@ -1617,7 +1631,7 @@ { "name": "maxRank", "in": "query", - "description": "Rank ceiling", + "description": "Rank ceiling (The \"worse\" inclusive rank bound.\r\nIf given, only players with a rank less than or equal to this value will be included)", "style": "form", "schema": { "maximum": 2147483647, @@ -1629,7 +1643,7 @@ { "name": "minRating", "in": "query", - "description": "Rating floor", + "description": "Rating floor (The \"worse\" inclusive rating bound.\r\nIf given, only players with a rating greater than or equal to this value will be included)", "style": "form", "schema": { "maximum": 2147483647, @@ -1641,7 +1655,7 @@ { "name": "maxRating", "in": "query", - "description": "Rating ceiling", + "description": "Rating ceiling (The \"better\" inclusive rating bound.\r\nIf given, only players with a rating less than or equal to this value will be included)", "style": "form", "schema": { "maximum": 2147483647, @@ -2268,7 +2282,7 @@ { "name": "name", "in": "query", - "description": "Filters results for only matches with a partially matching name", + "description": "Filters results for only matches with a partially matching name (case insensitive)", "style": "form", "schema": { "type": "string" @@ -2277,7 +2291,7 @@ { "name": "dateMin", "in": "query", - "description": "Filters results for only matches that occurred after a specified date", + "description": "Filters results for only matches that occurred on or after a specified date", "style": "form", "schema": { "type": "string", @@ -2287,7 +2301,7 @@ { "name": "dateMax", "in": "query", - "description": "Filters results for only matches that occurred before a specified date", + "description": "Filters results for only matches that occurred on or before a specified date", "style": "form", "schema": { "type": "string", @@ -2363,7 +2377,8 @@ { "$ref": "#/components/schemas/MatchQuerySortType" } - ] + ], + "default": 2 } }, { @@ -3622,7 +3637,7 @@ { "name": "key", "in": "path", - "description": "Search key (o!TR id, osu! id, or osu! username)", + "description": "Search key (id, osu! id, or osu! username)", "required": true, "style": "simple", "schema": { @@ -3692,7 +3707,7 @@ "Players" ], "summary": "Get a player's stats", - "description": "Gets player by versatile search.\r\nIf no ruleset is provided, the player's default is used. OsuApiClient.Net.Constants.Endpoints.Osu is used as a fallback.\r\nIf a ruleset is provided but the player has no data for it, all optional fields of the response will be null.\r\nAPI.DTOs.PlayerStatsDTO.PlayerInfo will always be populated as long as a player is found.\r\nIf no date range is provided, gets all stats without considering date\n\nRequires Authorization:\n\nClaim(s): user, client", + "description": "Gets player by versatile search.\r\nIf no ruleset is provided, the player's default is used. Database.Enums.Ruleset.Osu is used as a fallback.\r\nIf a ruleset is provided but the player has no data for it, all optional fields of the response will be null.\r\nAPI.DTOs.PlayerStatsDTO.PlayerInfo will always be populated as long as a player is found.\r\nIf no date range is provided, gets all stats without considering date\n\nRequires Authorization:\n\nClaim(s): user, client", "operationId": "Players_getStats", "parameters": [ { @@ -4662,7 +4677,7 @@ "Tournaments" ], "summary": "Get all tournaments which fit an optional request query", - "description": "Will not include match data", + "description": "Results will not include match data", "operationId": "Tournaments_list", "parameters": [ { @@ -4695,7 +4710,8 @@ "description": "Filters results for only tournaments that are verified", "style": "form", "schema": { - "type": "boolean" + "type": "boolean", + "default": true } }, { @@ -4721,7 +4737,8 @@ { "$ref": "#/components/schemas/TournamentQuerySortType" } - ] + ], + "default": 1 } }, { @@ -5680,7 +5697,7 @@ ], "responses": { "404": { - "description": "A user matching the given id does not exist\r\nor an oauth client matching the given id is not owned by the user", + "description": "A user matching the given id does not exist\r\nor an OAuth client matching the given id is not owned by the user", "content": { "text/plain": { "schema": { @@ -5765,7 +5782,7 @@ ], "responses": { "404": { - "description": "A user matching the given id does not exist\r\nor an oauth client matching the given id is not owned by the user", + "description": "A user matching the given id does not exist\r\nor an OAuth client matching the given id is not owned by the user", "content": { "text/plain": { "schema": { @@ -8938,14 +8955,17 @@ "type": "object", "properties": { "name": { + "minLength": 1, "type": "string", "description": "The name of the tournament" }, "abbreviation": { + "minLength": 1, "type": "string", - "description": "Acronym / shortened name of the tournament\r\nFor osu! World Cup 2023, this value would be \"OWC23\"" + "description": "Acronym / shortened name of the tournament" }, "forumUrl": { + "minLength": 1, "type": "string", "description": "The osu! forum post advertising this tournament" },