diff --git a/components/blocks/cards/ForgotPasswordCard/ForgotPasswordCard.test.ts b/components/blocks/cards/ForgotPasswordCard/ForgotPasswordCard.test.ts index 8721d5f0..94cbdae6 100644 --- a/components/blocks/cards/ForgotPasswordCard/ForgotPasswordCard.test.ts +++ b/components/blocks/cards/ForgotPasswordCard/ForgotPasswordCard.test.ts @@ -46,7 +46,7 @@ describe('', () => { beforeEach(() => { vi.mock('lib/api/Account', () => ({ Account: function Account() { - this.recoverCreate = mockSuccessAccountRecoverCreate + this.sendRecoveryEmail = mockSuccessAccountRecoverCreate }, })) }) diff --git a/components/blocks/cards/LogInCard/LogInCard.test.ts b/components/blocks/cards/LogInCard/LogInCard.test.ts index e4fd859c..2cc41092 100644 --- a/components/blocks/cards/LogInCard/LogInCard.test.ts +++ b/components/blocks/cards/LogInCard/LogInCard.test.ts @@ -4,10 +4,10 @@ import LogInCard from './LogInCard.vue' import * as apiComposables from 'composables/api' const token = 'jwt-token' -const mockSuccessAccountLoginCreate = vi.fn(() => +const mockSuccessAccountLogin = vi.fn(() => Promise.resolve({ data: { token }, ok: true }), ) -const mockSuccessUsersMeList = vi.fn(() => +const mockSuccessMe = vi.fn(() => Promise.resolve({ data: { id: 1, username: 'admin' }, ok: true, @@ -22,12 +22,12 @@ describe('', () => { beforeEach(() => { vi.mock('lib/api/Account', () => ({ Account: function Account() { - this.loginCreate = mockSuccessAccountLoginCreate + this.login = mockSuccessAccountLogin }, })) vi.mock('lib/api/Users', () => ({ Users: function Users() { - this.usersMeList = mockSuccessUsersMeList + this.me = mockSuccessMe }, })) }) @@ -115,7 +115,7 @@ describe('', () => { await getByTestId(wrapper, 'login-button').trigger('click') expect(useLoginUserSpy).toBeCalledTimes(1) - expect(mockSuccessAccountLoginCreate).toBeCalledTimes(1) + expect(mockSuccessAccountLogin).toBeCalledTimes(1) }) }) diff --git a/composables/api/index.ts b/composables/api/index.ts index fff76ec6..008b1beb 100644 --- a/composables/api/index.ts +++ b/composables/api/index.ts @@ -1,7 +1,7 @@ export { default as useChangePassword } from './useChangePassword' export { default as useConfirmAccount } from './useConfirmAccount' -export { default as useGetLeaderboardDetail } from './useGetLeaderboardDetail' -export { default as useGetUserDetail } from './useGetUserDetail' +export { default as useGetLeaderboardBySlug } from './useGetLeaderboardBySlug' +export { default as useGetUser } from './useGetUser' export { default as useLoginUser } from './useLoginUser' export { default as useLogoutUser } from './useLogoutUser' export { default as useRecoverAccount } from './useRecoverAccount' diff --git a/composables/api/useChangePassword/index.ts b/composables/api/useChangePassword/index.ts index e39b4338..13357c8d 100644 --- a/composables/api/useChangePassword/index.ts +++ b/composables/api/useChangePassword/index.ts @@ -19,7 +19,7 @@ export async function useChangePassword( // eslint-disable-next-line @typescript-eslint/no-invalid-void-type return await useApi( - async () => await account.recoverCreate2(token, requestData), + async () => await account.changePassword(token, requestData), { onError, onOkay, diff --git a/composables/api/useChangePassword/useChangePassword.test.ts b/composables/api/useChangePassword/useChangePassword.test.ts index bd007757..2d29f176 100644 --- a/composables/api/useChangePassword/useChangePassword.test.ts +++ b/composables/api/useChangePassword/useChangePassword.test.ts @@ -1,6 +1,6 @@ import useChangePassword from '.' -const mockSuccessRecoverCreate2 = vi.fn(() => Promise.resolve({ ok: true })) +const mockSuccessChangePassword = vi.fn(() => Promise.resolve({ ok: true })) describe('useChangePassword', () => { describe('when everything is successful', () => { @@ -10,14 +10,14 @@ describe('useChangePassword', () => { it('changes the password for the user', async () => { vi.mock('lib/api/Account', () => ({ Account: function Account() { - this.recoverCreate2 = mockSuccessRecoverCreate2 + this.changePassword = mockSuccessChangePassword }, })) await useChangePassword(token, requestData) - expect(mockSuccessRecoverCreate2).toBeCalledTimes(1) - expect(mockSuccessRecoverCreate2).toBeCalledWith(token, requestData) + expect(mockSuccessChangePassword).toBeCalledTimes(1) + expect(mockSuccessChangePassword).toBeCalledWith(token, requestData) }) }) }) diff --git a/composables/api/useConfirmAccount/index.ts b/composables/api/useConfirmAccount/index.ts index c0eafa15..cf89046a 100644 --- a/composables/api/useConfirmAccount/index.ts +++ b/composables/api/useConfirmAccount/index.ts @@ -18,7 +18,7 @@ export async function useConfirmAccount( // eslint-disable-next-line @typescript-eslint/no-invalid-void-type return await useApi( - async () => await account.confirmUpdate(confirmationToken), + async () => await account.confirmAccount(confirmationToken), { onError, onOkay }, ) } diff --git a/composables/api/useConfirmAccount/useConfirmAccount.test.ts b/composables/api/useConfirmAccount/useConfirmAccount.test.ts index a91a8d55..ea498fcc 100644 --- a/composables/api/useConfirmAccount/useConfirmAccount.test.ts +++ b/composables/api/useConfirmAccount/useConfirmAccount.test.ts @@ -4,14 +4,14 @@ const mockSuccessAccountConfirmation = vi.fn(() => Promise.resolve({ ok: true }), ) -describe('useConfirmUser', () => { +describe('useConfirmAccount', () => { describe('when everything is successful', () => { const confirmationCode = '123' it('creates a PUT request to confirm the account', async () => { vi.mock('lib/api/Account', () => ({ Account: function Account() { - this.confirmUpdate = mockSuccessAccountConfirmation + this.confirmAccount = mockSuccessAccountConfirmation }, })) diff --git a/composables/api/useGetLeaderboardDetail/index.ts b/composables/api/useGetLeaderboardBySlug/index.ts similarity index 77% rename from composables/api/useGetLeaderboardDetail/index.ts rename to composables/api/useGetLeaderboardBySlug/index.ts index 52ad8d5a..c5f5bc8d 100644 --- a/composables/api/useGetLeaderboardDetail/index.ts +++ b/composables/api/useGetLeaderboardBySlug/index.ts @@ -8,7 +8,7 @@ import { Leaderboards } from 'lib/api/Leaderboards' import type { LeaderboardViewModel } from 'lib/api/data-contracts' import { useRuntimeConfig } from '#imports' -export async function useGetLeaderboardDetail( +export default async function useGetLeaderboardBySlug( leaderboardSlug: string, opts: optionalParameters = {}, ): Promise> { @@ -17,8 +17,11 @@ export async function useGetLeaderboardDetail( categories: [], id: -1, name: '', - rules: '', slug: '', + info: null, + createdAt: '', + updatedAt: null, + deletedAt: null, }) const leaderboardClient = new Leaderboards({ @@ -26,7 +29,8 @@ export async function useGetLeaderboardDetail( }) return await useApi( - async () => await leaderboardClient.leaderboardsDetail2(leaderboardSlug), + async () => + await leaderboardClient.getLeaderboardBySlug({ slug: leaderboardSlug }), { onError, onOkay, @@ -34,5 +38,3 @@ export async function useGetLeaderboardDetail( }, ) } - -export default useGetLeaderboardDetail diff --git a/composables/api/useGetLeaderboardBySlug/useGetLeaderboardBySlug.test.ts b/composables/api/useGetLeaderboardBySlug/useGetLeaderboardBySlug.test.ts new file mode 100644 index 00000000..6863b995 --- /dev/null +++ b/composables/api/useGetLeaderboardBySlug/useGetLeaderboardBySlug.test.ts @@ -0,0 +1,24 @@ +import useGetLeaderboardBySlug from '.' + +const mockSuccessGetLeaderboardBySlug = vi.fn(() => + Promise.resolve({ ok: true }), +) + +describe('useGetLeaderboardBySlug', () => { + describe('when everything is successful', () => { + const slug = 'pieces' + + it('creates a GET request to fetch the leaderboard details', async () => { + vi.mock('lib/api/Leaderboards', () => ({ + Leaderboards: function Leaderboards() { + this.getLeaderboardBySlug = mockSuccessGetLeaderboardBySlug + }, + })) + + await useGetLeaderboardBySlug(slug) + + expect(mockSuccessGetLeaderboardBySlug).toBeCalledTimes(1) + expect(mockSuccessGetLeaderboardBySlug).toBeCalledWith({ slug }) + }) + }) +}) diff --git a/composables/api/useGetLeaderboardDetail/useGetLeaderboardDetail.test.ts b/composables/api/useGetLeaderboardDetail/useGetLeaderboardDetail.test.ts deleted file mode 100644 index e3821c3e..00000000 --- a/composables/api/useGetLeaderboardDetail/useGetLeaderboardDetail.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import useGetLeaderboardDetail from '.' - -const mockSuccessLeaderboardsDetail = vi.fn(() => Promise.resolve({ ok: true })) - -describe('useGetLeaderboardDetail', () => { - describe('when everything is successful', () => { - const slug = 'pieces' - - it('creates a GET request to fetch the leaderboard details', async () => { - vi.mock('lib/api/Leaderboards', () => ({ - Leaderboards: function Leaderboards() { - this.leaderboardsDetail2 = mockSuccessLeaderboardsDetail - }, - })) - - await useGetLeaderboardDetail(slug) - - expect(mockSuccessLeaderboardsDetail).toBeCalledTimes(1) - expect(mockSuccessLeaderboardsDetail).toBeCalledWith(slug) - }) - }) -}) diff --git a/composables/api/useGetUserDetail/index.ts b/composables/api/useGetUser/index.ts similarity index 81% rename from composables/api/useGetUserDetail/index.ts rename to composables/api/useGetUser/index.ts index 71c09391..cbca0513 100644 --- a/composables/api/useGetUserDetail/index.ts +++ b/composables/api/useGetUser/index.ts @@ -7,7 +7,7 @@ import { import { Users } from 'lib/api/Users' import type { UserViewModel } from 'lib/api/data-contracts' -export async function useGetUserDetail( +export default async function useGetUser( userId: string, opts: optionalParameters = {}, ): Promise> { @@ -18,12 +18,10 @@ export async function useGetUserDetail( }) return await useApi( - async () => await userClient.usersDetail(userId), + async () => await userClient.getUser(userId), { onError, onOkay, }, ) } - -export default useGetUserDetail diff --git a/composables/api/useGetUser/useGetUser.test.ts b/composables/api/useGetUser/useGetUser.test.ts new file mode 100644 index 00000000..e4a7d776 --- /dev/null +++ b/composables/api/useGetUser/useGetUser.test.ts @@ -0,0 +1,22 @@ +import useGetUser from '.' + +const mockSuccessGetUser = vi.fn(() => Promise.resolve({ ok: true })) + +describe('useGetUser', () => { + describe('when everything is successful', () => { + const userId = 'cd79f511-a952-48d5-a1c9-262449bc2e34' + + it('creates a GET request to fetch the user details', async () => { + vi.mock('lib/api/Users', () => ({ + Users: function Users() { + this.getUser = mockSuccessGetUser + }, + })) + + await useGetUser(userId) + + expect(mockSuccessGetUser).toBeCalledTimes(1) + expect(mockSuccessGetUser).toBeCalledWith(userId) + }) + }) +}) diff --git a/composables/api/useGetUserDetail/useGetUserDetail.test.ts b/composables/api/useGetUserDetail/useGetUserDetail.test.ts deleted file mode 100644 index 6792ecd0..00000000 --- a/composables/api/useGetUserDetail/useGetUserDetail.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import useGetUserDetail from '.' - -const mockSuccessUsersDetail = vi.fn(() => Promise.resolve({ ok: true })) - -describe('useGetUserDetail', () => { - describe('when everything is successful', () => { - const userId = 'cd79f511-a952-48d5-a1c9-262449bc2e34' - - it('creates a GET request to fetch the user details', async () => { - vi.mock('lib/api/Users', () => ({ - Users: function Users() { - this.usersDetail = mockSuccessUsersDetail - }, - })) - - await useGetUserDetail(userId) - - expect(mockSuccessUsersDetail).toBeCalledTimes(1) - expect(mockSuccessUsersDetail).toBeCalledWith(userId) - }) - }) -}) diff --git a/composables/api/useLoginUser/index.ts b/composables/api/useLoginUser/index.ts index eb5afec3..4a6f5a69 100644 --- a/composables/api/useLoginUser/index.ts +++ b/composables/api/useLoginUser/index.ts @@ -19,7 +19,7 @@ export default async function useLoginUser( }) return await useApi( - async () => await account.loginCreate(requestData), + async () => await account.login(requestData), { onError, onOkay: async (d: LoginResponse) => { diff --git a/composables/api/useLoginUser/useLoginUser.test.ts b/composables/api/useLoginUser/useLoginUser.test.ts index 6ffa6da9..a890616c 100644 --- a/composables/api/useLoginUser/useLoginUser.test.ts +++ b/composables/api/useLoginUser/useLoginUser.test.ts @@ -2,15 +2,16 @@ import { useSessionToken } from '#imports' import useLoginUser from '.' // const mockFailureUsersLoginCreate = vi.fn(() => Promise.resolve({ ok: false })) -const mockSuccessAccountLoginCreate = vi.fn(() => +const mockSuccessAccountLogin = vi.fn(() => Promise.resolve({ data: { token: 'token' }, ok: true }), ) -const mockSuccessUsersMeList = vi.fn(() => +const mockSuccessMe = vi.fn(() => Promise.resolve({ data: { id: '05864eb1-540a-4b32-ad57-17871f2519f3', role: 'Confirmed', username: 'foo', + createdAt: '1984-01-01T00:00:00Z', }, ok: true, }), @@ -31,19 +32,19 @@ describe('useLoginUser', () => { it('creates a login session and returns the user information', async () => { vi.mock('lib/api/Users', () => ({ Users: function Users() { - this.usersMeList = mockSuccessUsersMeList + this.me = mockSuccessMe }, })) vi.mock('lib/api/Account', () => ({ Account: function Account() { - this.loginCreate = mockSuccessAccountLoginCreate + this.login = mockSuccessAccountLogin }, })) await useLoginUser({ email, password }, { onOkay: onOkaySpy }) - expect(mockSuccessAccountLoginCreate).toBeCalledTimes(1) - expect(mockSuccessAccountLoginCreate).toBeCalledWith({ email, password }) + expect(mockSuccessAccountLogin).toBeCalledTimes(1) + expect(mockSuccessAccountLogin).toBeCalledWith({ email, password }) expect(onOkaySpy).toBeCalledTimes(1) expect(useSessionToken().value).toBeTruthy() diff --git a/composables/api/useLogoutUser/useLogoutUser.test.ts b/composables/api/useLogoutUser/useLogoutUser.test.ts index 736779b1..1b2c95a7 100644 --- a/composables/api/useLogoutUser/useLogoutUser.test.ts +++ b/composables/api/useLogoutUser/useLogoutUser.test.ts @@ -7,6 +7,7 @@ const user: UserViewModel = { id: '575888bd-9702-41a9-9b75-fc87d785c22a', role: 'Confirmed', username: 'test', + createdAt: '1984-01-01T00:00:00Z', } afterEach(() => { @@ -17,7 +18,7 @@ afterEach(() => { describe('useLogoutUser', () => { beforeEach(() => { - fetchMock.mockIf(/.*\/api\/[Uu]sers\/me/, () => JSON.stringify(user)) + fetchMock.mockIf(/.*\/[Uu]ser\/me/, () => JSON.stringify(user)) useSessionToken().value = token }) diff --git a/composables/api/useRecoverAccount/index.ts b/composables/api/useRecoverAccount/index.ts index 6470e7c3..0a74b645 100644 --- a/composables/api/useRecoverAccount/index.ts +++ b/composables/api/useRecoverAccount/index.ts @@ -18,7 +18,7 @@ export async function useRecoverAccount( // eslint-disable-next-line @typescript-eslint/no-invalid-void-type return await useApi( - async () => await account.recoverCreate(requestData), + async () => await account.sendRecoveryEmail(requestData), { onError, onOkay, diff --git a/composables/api/useRecoverAccount/useRecoverAccount.test.ts b/composables/api/useRecoverAccount/useRecoverAccount.test.ts index b77cb164..51dff0e1 100644 --- a/composables/api/useRecoverAccount/useRecoverAccount.test.ts +++ b/composables/api/useRecoverAccount/useRecoverAccount.test.ts @@ -1,6 +1,6 @@ import useRecoverAccount from '.' -const mockSuccessRecoverCreate = vi.fn(() => Promise.resolve({ ok: true })) +const mockSuccessRecover = vi.fn(() => Promise.resolve({ ok: true })) describe('useRecoverAccount', () => { describe('when everything is successful', () => { @@ -9,14 +9,14 @@ describe('useRecoverAccount', () => { it('kicks off the account recovery process', async () => { vi.mock('lib/api/Account', () => ({ Account: function Account() { - this.recoverCreate = mockSuccessRecoverCreate + this.sendRecoveryEmail = mockSuccessRecover }, })) await useRecoverAccount(requestData) - expect(mockSuccessRecoverCreate).toBeCalledTimes(1) - expect(mockSuccessRecoverCreate).toBeCalledWith(requestData) + expect(mockSuccessRecover).toBeCalledTimes(1) + expect(mockSuccessRecover).toBeCalledWith(requestData) }) }) }) diff --git a/composables/api/useRegisterUser/index.ts b/composables/api/useRegisterUser/index.ts index 0cfdce14..491cdd8b 100644 --- a/composables/api/useRegisterUser/index.ts +++ b/composables/api/useRegisterUser/index.ts @@ -18,7 +18,7 @@ export async function useRegisterUser( }) return await useApi( - async () => await accountClient.registerCreate(requestData), + async () => await accountClient.register(requestData), { onError, onOkay, diff --git a/composables/api/useRegisterUser/useRegisterUser.test.ts b/composables/api/useRegisterUser/useRegisterUser.test.ts index 98959b8f..87ecf3dd 100644 --- a/composables/api/useRegisterUser/useRegisterUser.test.ts +++ b/composables/api/useRegisterUser/useRegisterUser.test.ts @@ -1,6 +1,6 @@ import useRegisterUser from '.' -const mockSuccessRegisterCreate = vi.fn(() => Promise.resolve({ ok: true })) +const mockSuccessRegister = vi.fn(() => Promise.resolve({ ok: true })) describe('useRegisterUser', () => { describe('when everything is successful', () => { @@ -11,7 +11,7 @@ describe('useRegisterUser', () => { it('registers a user, and returns the new user', async () => { vi.mock('lib/api/Account', () => ({ Account: function Account() { - this.registerCreate = mockSuccessRegisterCreate + this.register = mockSuccessRegister }, })) @@ -21,8 +21,8 @@ describe('useRegisterUser', () => { username, }) - expect(mockSuccessRegisterCreate).toBeCalledTimes(1) - expect(mockSuccessRegisterCreate).toBeCalledWith({ + expect(mockSuccessRegister).toBeCalledTimes(1) + expect(mockSuccessRegister).toBeCalledWith({ email, password, username, diff --git a/composables/api/useResendAccountConfirmation/index.ts b/composables/api/useResendAccountConfirmation/index.ts index 86432807..99907956 100644 --- a/composables/api/useResendAccountConfirmation/index.ts +++ b/composables/api/useResendAccountConfirmation/index.ts @@ -21,7 +21,7 @@ export default async function useResendAccountConfirmation( // eslint-disable-next-line @typescript-eslint/no-invalid-void-type return await useApi( async () => - await account.confirmCreate({ + await account.resendConfirmationEmail({ headers: { Authorization: `Bearer ${authToken.value}`, }, diff --git a/composables/api/useResendAccountConfirmation/useResendAccountConfirmation.test.ts b/composables/api/useResendAccountConfirmation/useResendAccountConfirmation.test.ts index d941131f..735fb1c8 100644 --- a/composables/api/useResendAccountConfirmation/useResendAccountConfirmation.test.ts +++ b/composables/api/useResendAccountConfirmation/useResendAccountConfirmation.test.ts @@ -4,7 +4,7 @@ import useLoginUser from '../useLoginUser' const mockSuccessLogin = vi.fn(() => Promise.resolve({ data: { token: 'token' }, ok: true }), ) -const mockSuccessResendAccount = vi.fn(() => Promise.resolve({ ok: true })) +const mockSuccessResendConfirmation = vi.fn(() => Promise.resolve({ ok: true })) const onOkaySpy = vi.fn() const email = 'test@lb.gg' const password = 'Password1' @@ -19,16 +19,16 @@ describe('useResendAccountConfirmation', () => { it('changes the password for the user', async () => { vi.mock('lib/api/Account', () => ({ Account: function Account() { - this.loginCreate = mockSuccessLogin - this.confirmCreate = mockSuccessResendAccount + this.login = mockSuccessLogin + this.resendConfirmationEmail = mockSuccessResendConfirmation }, })) await useLoginUser({ email, password }, { onOkay: onOkaySpy }) await useResendAccountConfirmation() - expect(mockSuccessResendAccount).toBeCalledTimes(1) - expect(mockSuccessResendAccount).toBeCalledWith({ + expect(mockSuccessResendConfirmation).toBeCalledTimes(1) + expect(mockSuccessResendConfirmation).toBeCalledWith({ headers: { Authorization: 'Bearer token' }, }) }) diff --git a/composables/api/useValidateRecoveryToken/index.ts b/composables/api/useValidateRecoveryToken/index.ts index be5c0a3d..cbfc8bef 100644 --- a/composables/api/useValidateRecoveryToken/index.ts +++ b/composables/api/useValidateRecoveryToken/index.ts @@ -18,7 +18,7 @@ export async function useValidateRecoveryToken( // eslint-disable-next-line @typescript-eslint/no-invalid-void-type return await useApi( - async () => await account.recoverDetail(recoveryToken), + async () => await account.testRecoveryToken(recoveryToken), { onError, onOkay }, ) } diff --git a/composables/api/useValidateRecoveryToken/useValidateRecoveryToken.test.ts b/composables/api/useValidateRecoveryToken/useValidateRecoveryToken.test.ts index 5f127c11..7509fe14 100644 --- a/composables/api/useValidateRecoveryToken/useValidateRecoveryToken.test.ts +++ b/composables/api/useValidateRecoveryToken/useValidateRecoveryToken.test.ts @@ -1,6 +1,6 @@ import useValidateRecoveryToken from '.' -const mockSuccessRecoverDetail = vi.fn(() => Promise.resolve({ ok: true })) +const mockSuccessTestRecoveryToken = vi.fn(() => Promise.resolve({ ok: true })) describe('useValidateRecoveryToken', () => { describe('when everything is successful', () => { @@ -9,14 +9,14 @@ describe('useValidateRecoveryToken', () => { it('validates the recovery token', async () => { vi.mock('lib/api/Account', () => ({ Account: function Account() { - this.recoverDetail = mockSuccessRecoverDetail + this.testRecoveryToken = mockSuccessTestRecoveryToken }, })) await useValidateRecoveryToken(token) - expect(mockSuccessRecoverDetail).toBeCalledTimes(1) - expect(mockSuccessRecoverDetail).toBeCalledWith(token) + expect(mockSuccessTestRecoveryToken).toBeCalledTimes(1) + expect(mockSuccessTestRecoveryToken).toBeCalledWith(token) }) }) }) diff --git a/composables/useCurrentUser.ts b/composables/useCurrentUser.ts index 284d2816..11e64026 100644 --- a/composables/useCurrentUser.ts +++ b/composables/useCurrentUser.ts @@ -18,7 +18,7 @@ export default function useCurrentUser() { const resp = await useApi( async () => - await users.usersMeList({ + await users.me({ headers: { Authorization: `Bearer ${token}` }, }), ) diff --git a/lib/api/Account.ts b/lib/api/Account.ts index 72fa2fb6..0a80f274 100644 --- a/lib/api/Account.ts +++ b/lib/api/Account.ts @@ -28,18 +28,21 @@ export class Account< * No description * * @tags Account - * @name RegisterCreate + * @name Register * @summary Registers a new User. * @request POST:/Account/register * @secure * @response `201` `UserViewModel` The `User` was registered and returned successfully. - * @response `400` `void` The request was malformed. - * @response `409` `ValidationProblemDetails` A `User` with the specified username or email already exists.

Validation error codes by property: - **Username**: - **UsernameTaken**: the username is already in use - **Email**: - **EmailAlreadyUsed**: the email is already in use - * @response `422` `void` The request contains errors.

Validation error codes by property: - **Username**: - **UsernameFormat**: Invalid username format - **Password**: - **PasswordFormat**: Invalid password format - **Email**: - **EmailValidator**: Invalid email format - * @response `500` `void` Server Error + * @response `400` `ProblemDetails` Bad Request + * @response `409` `ValidationProblemDetails` A `User` with the specified username or email already exists. Validation error codes by property: - **Username**: - **UsernameTaken**: the username is already in use - **Email**: - **EmailAlreadyUsed**: the email is already in use + * @response `422` `ValidationProblemDetails` The request contains errors. Validation error codes by property: - **Username**: - **UsernameFormat**: Invalid username format - **Password**: - **PasswordFormat**: Invalid password format - **Email**: - **EmailValidator**: Invalid email format + * @response `500` `void` Internal Server Error */ - registerCreate = (data: RegisterRequest, params: RequestParams = {}) => - this.request({ + register = (data: RegisterRequest, params: RequestParams = {}) => + this.request< + UserViewModel, + ProblemDetails | ValidationProblemDetails | void + >({ path: `/Account/register`, method: 'POST', body: data, @@ -52,19 +55,23 @@ export class Account< * No description * * @tags Account - * @name LoginCreate + * @name Login * @summary Logs a User in. * @request POST:/login * @secure * @response `200` `LoginResponse` The `User` was logged in successfully. A `LoginResponse` is returned, containing a token. - * @response `400` `void` The request was malformed. - * @response `401` `ProblemDetails` The password given was incorrect. - * @response `403` `ProblemDetails` The associated `User` is banned. - * @response `404` `ProblemDetails` No `User` with the requested details could be found. - * @response `422` `void` The request contains errors.

Validation error codes by property: - **Password**: - **NotEmptyValidator**: No password was passed - **PasswordFormat**: Invalid password format - **Email**: - **NotNullValidator**: No email was passed - **EmailValidator**: Invalid email format + * @response `400` `ProblemDetails` Bad Request + * @response `401` `void` The password given was incorrect. + * @response `403` `void` The associated `User` is banned. + * @response `404` `void` No `User` with the requested details could be found. + * @response `422` `ValidationProblemDetails` The request contains errors. Validation error codes by property: - **Password**: - **NotEmptyValidator**: No password was passed - **PasswordFormat**: Invalid password format - **Email**: - **NotNullValidator**: No email was passed - **EmailValidator**: Invalid email format + * @response `500` `void` Internal Server Error */ - loginCreate = (data: LoginRequest, params: RequestParams = {}) => - this.request({ + login = (data: LoginRequest, params: RequestParams = {}) => + this.request< + LoginResponse, + ProblemDetails | void | ValidationProblemDetails + >({ path: `/login`, method: 'POST', body: data, @@ -77,18 +84,17 @@ export class Account< * No description * * @tags Account - * @name ConfirmCreate + * @name ResendConfirmationEmail * @summary Resends the account confirmation link. * @request POST:/Account/confirm * @secure * @response `200` `void` A new confirmation link was generated. - * @response `400` `ProblemDetails` The request was malformed. - * @response `401` `ProblemDetails` The request doesn't contain a valid session token. - * @response `409` `ProblemDetails` The `User`'s account has already been confirmed. - * @response `429` `ProblemDetails` Too Many Requests + * @response `400` `ProblemDetails` Bad Request + * @response `401` `void` Unauthorized + * @response `409` `void` The `User`'s account has already been confirmed. * @response `500` `void` The account recovery email failed to be created. */ - confirmCreate = (params: RequestParams = {}) => + resendConfirmationEmail = (params: RequestParams = {}) => this.request({ path: `/Account/confirm`, method: 'POST', @@ -99,15 +105,19 @@ export class Account< * No description * * @tags Account - * @name RecoverCreate + * @name SendRecoveryEmail * @summary Sends an account recovery email. * @request POST:/Account/recover * @secure * @response `200` `void` This endpoint returns 200 OK regardless of whether the email was sent successfully or not. - * @response `400` `ProblemDetails` The request object was malformed. + * @response `400` `ProblemDetails` Bad Request + * @response `500` `void` Internal Server Error */ - recoverCreate = (data: RecoverAccountRequest, params: RequestParams = {}) => - this.request({ + sendRecoveryEmail = ( + data: RecoverAccountRequest, + params: RequestParams = {}, + ) => + this.request({ path: `/Account/recover`, method: 'POST', body: data, @@ -119,17 +129,18 @@ export class Account< * No description * * @tags Account - * @name ConfirmUpdate + * @name ConfirmAccount * @summary Confirms a user account. * @request PUT:/Account/confirm/{id} * @secure * @response `200` `void` The account was confirmed successfully. * @response `400` `ProblemDetails` Bad Request - * @response `404` `ProblemDetails` The token provided was invalid or expired. - * @response `409` `ProblemDetails` The user's account was either already confirmed or banned. + * @response `404` `void` The token provided was invalid or expired. + * @response `409` `void` the user's account was either already confirmed or banned. + * @response `500` `void` Internal Server Error */ - confirmUpdate = (id: string, params: RequestParams = {}) => - this.request({ + confirmAccount = (id: string, params: RequestParams = {}) => + this.request({ path: `/Account/confirm/${id}`, method: 'PUT', secure: true, @@ -139,16 +150,17 @@ export class Account< * No description * * @tags Account - * @name RecoverDetail + * @name TestRecoveryToken * @summary Tests an account recovery token for validity. * @request GET:/Account/recover/{id} * @secure * @response `200` `void` The token provided is valid. * @response `400` `ProblemDetails` Bad Request - * @response `404` `ProblemDetails` The token provided is invalid or expired, or the user is banned. + * @response `404` `void` The token provided is invalid or expired, or the user is banned. + * @response `500` `void` Internal Server Error */ - recoverDetail = (id: string, params: RequestParams = {}) => - this.request({ + testRecoveryToken = (id: string, params: RequestParams = {}) => + this.request({ path: `/Account/recover/${id}`, method: 'GET', secure: true, @@ -158,25 +170,24 @@ export class Account< * No description * * @tags Account - * @name RecoverCreate2 + * @name ChangePassword * @summary Recover the user's account by resetting their password to a new value. * @request POST:/Account/recover/{id} - * @originalName recoverCreate - * @duplicate * @secure * @response `200` `void` The user's password was reset successfully. * @response `400` `ProblemDetails` Bad Request - * @response `403` `ProblemDetails` The user is banned. - * @response `404` `ProblemDetails` The token provided is invalid or expired. - * @response `409` `ProblemDetails` The new password is the same as the user's existing password. - * @response `422` `ValidationProblemDetails` The request body contains errors.
A **PasswordFormat** Validation error on the Password field indicates that the password format is invalid. + * @response `403` `void` The user is banned. + * @response `404` `void` The token provided is invalid or expired. + * @response `409` `void` The new password is the same as the user's existing password. + * @response `422` `ValidationProblemDetails` The request body contains errors. A **PasswordFormat** Validation error on the Password field indicates that the password format is invalid. + * @response `500` `void` Internal Server Error */ - recoverCreate2 = ( + changePassword = ( id: string, data: ChangePasswordRequest, params: RequestParams = {}, ) => - this.request({ + this.request({ path: `/Account/recover/${id}`, method: 'POST', body: data, diff --git a/lib/api/AccountRoute.ts b/lib/api/AccountRoute.ts index 1f2f3c21..6443c87b 100644 --- a/lib/api/AccountRoute.ts +++ b/lib/api/AccountRoute.ts @@ -22,17 +22,17 @@ export namespace Account { /** * No description * @tags Account - * @name RegisterCreate + * @name Register * @summary Registers a new User. * @request POST:/Account/register * @secure * @response `201` `UserViewModel` The `User` was registered and returned successfully. - * @response `400` `void` The request was malformed. - * @response `409` `ValidationProblemDetails` A `User` with the specified username or email already exists.

Validation error codes by property: - **Username**: - **UsernameTaken**: the username is already in use - **Email**: - **EmailAlreadyUsed**: the email is already in use - * @response `422` `void` The request contains errors.

Validation error codes by property: - **Username**: - **UsernameFormat**: Invalid username format - **Password**: - **PasswordFormat**: Invalid password format - **Email**: - **EmailValidator**: Invalid email format - * @response `500` `void` Server Error + * @response `400` `ProblemDetails` Bad Request + * @response `409` `ValidationProblemDetails` A `User` with the specified username or email already exists. Validation error codes by property: - **Username**: - **UsernameTaken**: the username is already in use - **Email**: - **EmailAlreadyUsed**: the email is already in use + * @response `422` `ValidationProblemDetails` The request contains errors. Validation error codes by property: - **Username**: - **UsernameFormat**: Invalid username format - **Password**: - **PasswordFormat**: Invalid password format - **Email**: - **EmailValidator**: Invalid email format + * @response `500` `void` Internal Server Error */ - export namespace RegisterCreate { + export namespace Register { export type RequestParams = {} export type RequestQuery = {} export type RequestBody = RegisterRequest @@ -43,18 +43,19 @@ export namespace Account { /** * No description * @tags Account - * @name LoginCreate + * @name Login * @summary Logs a User in. * @request POST:/login * @secure * @response `200` `LoginResponse` The `User` was logged in successfully. A `LoginResponse` is returned, containing a token. - * @response `400` `void` The request was malformed. - * @response `401` `ProblemDetails` The password given was incorrect. - * @response `403` `ProblemDetails` The associated `User` is banned. - * @response `404` `ProblemDetails` No `User` with the requested details could be found. - * @response `422` `void` The request contains errors.

Validation error codes by property: - **Password**: - **NotEmptyValidator**: No password was passed - **PasswordFormat**: Invalid password format - **Email**: - **NotNullValidator**: No email was passed - **EmailValidator**: Invalid email format + * @response `400` `ProblemDetails` Bad Request + * @response `401` `void` The password given was incorrect. + * @response `403` `void` The associated `User` is banned. + * @response `404` `void` No `User` with the requested details could be found. + * @response `422` `ValidationProblemDetails` The request contains errors. Validation error codes by property: - **Password**: - **NotEmptyValidator**: No password was passed - **PasswordFormat**: Invalid password format - **Email**: - **NotNullValidator**: No email was passed - **EmailValidator**: Invalid email format + * @response `500` `void` Internal Server Error */ - export namespace LoginCreate { + export namespace Login { export type RequestParams = {} export type RequestQuery = {} export type RequestBody = LoginRequest @@ -65,18 +66,17 @@ export namespace Account { /** * No description * @tags Account - * @name ConfirmCreate + * @name ResendConfirmationEmail * @summary Resends the account confirmation link. * @request POST:/Account/confirm * @secure * @response `200` `void` A new confirmation link was generated. - * @response `400` `ProblemDetails` The request was malformed. - * @response `401` `ProblemDetails` The request doesn't contain a valid session token. - * @response `409` `ProblemDetails` The `User`'s account has already been confirmed. - * @response `429` `ProblemDetails` Too Many Requests + * @response `400` `ProblemDetails` Bad Request + * @response `401` `void` Unauthorized + * @response `409` `void` The `User`'s account has already been confirmed. * @response `500` `void` The account recovery email failed to be created. */ - export namespace ConfirmCreate { + export namespace ResendConfirmationEmail { export type RequestParams = {} export type RequestQuery = {} export type RequestBody = never @@ -87,14 +87,15 @@ export namespace Account { /** * No description * @tags Account - * @name RecoverCreate + * @name SendRecoveryEmail * @summary Sends an account recovery email. * @request POST:/Account/recover * @secure * @response `200` `void` This endpoint returns 200 OK regardless of whether the email was sent successfully or not. - * @response `400` `ProblemDetails` The request object was malformed. + * @response `400` `ProblemDetails` Bad Request + * @response `500` `void` Internal Server Error */ - export namespace RecoverCreate { + export namespace SendRecoveryEmail { export type RequestParams = {} export type RequestQuery = {} export type RequestBody = RecoverAccountRequest @@ -105,16 +106,17 @@ export namespace Account { /** * No description * @tags Account - * @name ConfirmUpdate + * @name ConfirmAccount * @summary Confirms a user account. * @request PUT:/Account/confirm/{id} * @secure * @response `200` `void` The account was confirmed successfully. * @response `400` `ProblemDetails` Bad Request - * @response `404` `ProblemDetails` The token provided was invalid or expired. - * @response `409` `ProblemDetails` The user's account was either already confirmed or banned. + * @response `404` `void` The token provided was invalid or expired. + * @response `409` `void` the user's account was either already confirmed or banned. + * @response `500` `void` Internal Server Error */ - export namespace ConfirmUpdate { + export namespace ConfirmAccount { export type RequestParams = { /** * The confirmation token. @@ -131,15 +133,16 @@ export namespace Account { /** * No description * @tags Account - * @name RecoverDetail + * @name TestRecoveryToken * @summary Tests an account recovery token for validity. * @request GET:/Account/recover/{id} * @secure * @response `200` `void` The token provided is valid. * @response `400` `ProblemDetails` Bad Request - * @response `404` `ProblemDetails` The token provided is invalid or expired, or the user is banned. + * @response `404` `void` The token provided is invalid or expired, or the user is banned. + * @response `500` `void` Internal Server Error */ - export namespace RecoverDetail { + export namespace TestRecoveryToken { export type RequestParams = { /** * The recovery token. @@ -156,20 +159,19 @@ export namespace Account { /** * No description * @tags Account - * @name RecoverCreate2 + * @name ChangePassword * @summary Recover the user's account by resetting their password to a new value. * @request POST:/Account/recover/{id} - * @originalName recoverCreate - * @duplicate * @secure * @response `200` `void` The user's password was reset successfully. * @response `400` `ProblemDetails` Bad Request - * @response `403` `ProblemDetails` The user is banned. - * @response `404` `ProblemDetails` The token provided is invalid or expired. - * @response `409` `ProblemDetails` The new password is the same as the user's existing password. - * @response `422` `ValidationProblemDetails` The request body contains errors.
A **PasswordFormat** Validation error on the Password field indicates that the password format is invalid. + * @response `403` `void` The user is banned. + * @response `404` `void` The token provided is invalid or expired. + * @response `409` `void` The new password is the same as the user's existing password. + * @response `422` `ValidationProblemDetails` The request body contains errors. A **PasswordFormat** Validation error on the Password field indicates that the password format is invalid. + * @response `500` `void` Internal Server Error */ - export namespace RecoverCreate2 { + export namespace ChangePassword { export type RequestParams = { /** * The recovery token. diff --git a/lib/api/Categories.ts b/lib/api/Categories.ts index 7448f358..e18fc08d 100644 --- a/lib/api/Categories.ts +++ b/lib/api/Categories.ts @@ -24,46 +24,43 @@ export class Categories< * No description * * @tags Categories - * @name CategoriesDetail + * @name GetCategory * @summary Gets a Category by its ID. - * @request GET:/api/Categories/{id} + * @request GET:/api/category/{id} * @secure - * @response `200` `CategoryViewModel` The `Category` was found and returned successfully. + * @response `200` `CategoryViewModel` OK * @response `400` `ProblemDetails` Bad Request - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` No `Category` with the requested ID could be found. + * @response `404` `void` Not Found + * @response `500` `void` Internal Server Error */ - categoriesDetail = (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/Categories/${id}`, + getCategory = (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/category/${id}`, method: 'GET', secure: true, format: 'json', ...params, }) /** - * No description - * - * @tags Categories - * @name CategoriesCreate - * @summary Creates a new Category. -This request is restricted to Moderators. - * @request POST:/api/Categories - * @secure - * @response `201` `CategoryViewModel` The `Category` was created and returned successfully. - * @response `400` `ProblemDetails` The request was malformed. - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` The requesting `User` is unauthorized to create a `Category`. - * @response `422` `ValidationProblemDetails` Client Error - */ - categoriesCreate = ( - data: CreateCategoryRequest, - params: RequestParams = {}, - ) => - this.request({ - path: `/api/Categories`, + * No description + * + * @tags Categories + * @name CreateCategory + * @summary Creates a new Category. This request is restricted to Moderators. + * @request POST:/categories/create + * @secure + * @response `201` `CategoryViewModel` Created + * @response `400` `ProblemDetails` Bad Request + * @response `403` `void` Forbidden + * @response `422` `ValidationProblemDetails` Unprocessable Content + * @response `500` `void` Internal Server Error + */ + createCategory = (data: CreateCategoryRequest, params: RequestParams = {}) => + this.request< + CategoryViewModel, + ProblemDetails | void | ValidationProblemDetails + >({ + path: `/categories/create`, method: 'POST', body: data, secure: true, diff --git a/lib/api/CategoriesRoute.ts b/lib/api/CategoriesRoute.ts index 0f49fd56..08145efc 100644 --- a/lib/api/CategoriesRoute.ts +++ b/lib/api/CategoriesRoute.ts @@ -15,22 +15,18 @@ export namespace Categories { /** * No description * @tags Categories - * @name CategoriesDetail + * @name GetCategory * @summary Gets a Category by its ID. - * @request GET:/api/Categories/{id} + * @request GET:/api/category/{id} * @secure - * @response `200` `CategoryViewModel` The `Category` was found and returned successfully. + * @response `200` `CategoryViewModel` OK * @response `400` `ProblemDetails` Bad Request - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` No `Category` with the requested ID could be found. + * @response `404` `void` Not Found + * @response `500` `void` Internal Server Error */ - export namespace CategoriesDetail { + export namespace GetCategory { export type RequestParams = { - /** - * The ID of the `Category` which should be retrieved. - * @format int64 - */ + /** @format int64 */ id: number } export type RequestQuery = {} @@ -40,21 +36,19 @@ export namespace Categories { } /** - * No description - * @tags Categories - * @name CategoriesCreate - * @summary Creates a new Category. -This request is restricted to Moderators. - * @request POST:/api/Categories - * @secure - * @response `201` `CategoryViewModel` The `Category` was created and returned successfully. - * @response `400` `ProblemDetails` The request was malformed. - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` The requesting `User` is unauthorized to create a `Category`. - * @response `422` `ValidationProblemDetails` Client Error -*/ - export namespace CategoriesCreate { + * No description + * @tags Categories + * @name CreateCategory + * @summary Creates a new Category. This request is restricted to Moderators. + * @request POST:/categories/create + * @secure + * @response `201` `CategoryViewModel` Created + * @response `400` `ProblemDetails` Bad Request + * @response `403` `void` Forbidden + * @response `422` `ValidationProblemDetails` Unprocessable Content + * @response `500` `void` Internal Server Error + */ + export namespace CreateCategory { export type RequestParams = {} export type RequestQuery = {} export type RequestBody = CreateCategoryRequest diff --git a/lib/api/Leaderboards.ts b/lib/api/Leaderboards.ts index ee1df96c..a6874cfc 100644 --- a/lib/api/Leaderboards.ts +++ b/lib/api/Leaderboards.ts @@ -11,7 +11,8 @@ import type { CreateLeaderboardRequest, - LeaderboardsListParams, + GetLeaderboardBySlugParams, + GetLeaderboardsParams, LeaderboardViewModel, ProblemDetails, ValidationProblemDetails, @@ -25,17 +26,18 @@ export class Leaderboards< * No description * * @tags Leaderboards - * @name LeaderboardsDetail - * @summary Gets a Leaderboard by its ID. - * @request GET:/api/Leaderboards/{id} + * @name GetLeaderboard + * @summary Gets a leaderboard by its ID. + * @request GET:/api/leaderboard/{id} * @secure - * @response `200` `LeaderboardViewModel` The `Leaderboard` was found and returned successfully. + * @response `200` `LeaderboardViewModel` OK * @response `400` `ProblemDetails` Bad Request - * @response `404` `ProblemDetails` No `Leaderboard` with the requested ID or slug could be found. + * @response `404` `void` Not Found + * @response `500` `void` Internal Server Error */ - leaderboardsDetail = (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/Leaderboards/${id}`, + getLeaderboard = (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/leaderboard/${id}`, method: 'GET', secure: true, format: 'json', @@ -45,20 +47,23 @@ export class Leaderboards< * No description * * @tags Leaderboards - * @name LeaderboardsDetail2 + * @name GetLeaderboardBySlug * @summary Gets a Leaderboard by its slug. - * @request GET:/api/Leaderboards/{slug} - * @originalName leaderboardsDetail - * @duplicate + * @request GET:/api/leaderboard * @secure - * @response `200` `LeaderboardViewModel` The `Leaderboard` was found and returned successfully. + * @response `200` `LeaderboardViewModel` OK * @response `400` `ProblemDetails` Bad Request - * @response `404` `ProblemDetails` No `Leaderboard` with the requested ID or slug could be found. + * @response `404` `void` Not Found + * @response `500` `void` Internal Server Error */ - leaderboardsDetail2 = (slug: string, params: RequestParams = {}) => - this.request({ - path: `/api/Leaderboards/${slug}`, + getLeaderboardBySlug = ( + query: GetLeaderboardBySlugParams, + params: RequestParams = {}, + ) => + this.request({ + path: `/api/leaderboard`, method: 'GET', + query: query, secure: true, format: 'json', ...params, @@ -67,18 +72,20 @@ export class Leaderboards< * No description * * @tags Leaderboards - * @name LeaderboardsList - * @summary Gets Leaderboards by their IDs. - * @request GET:/api/Leaderboards + * @name GetLeaderboards + * @summary Gets leaderboards by their IDs. + * @request GET:/api/leaderboards * @secure - * @response `200` `(LeaderboardViewModel)[]` The list of `Leaderboard`s was retrieved successfully. The result can be an empty collection. + * @response `200` `(LeaderboardViewModel)[]` OK + * @response `400` `ProblemDetails` Bad Request + * @response `500` `void` Internal Server Error */ - leaderboardsList = ( - query: LeaderboardsListParams, + getLeaderboards = ( + query: GetLeaderboardsParams, params: RequestParams = {}, ) => - this.request({ - path: `/api/Leaderboards`, + this.request({ + path: `/api/leaderboards`, method: 'GET', query: query, secure: true, @@ -86,30 +93,29 @@ export class Leaderboards< ...params, }) /** - * No description - * - * @tags Leaderboards - * @name LeaderboardsCreate - * @summary Creates a new Leaderboard. -This request is restricted to Administrators. - * @request POST:/api/Leaderboards - * @secure - * @response `201` `LeaderboardViewModel` The `Leaderboard` was created and returned successfully. - * @response `400` `ProblemDetails` The request was malformed. - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` The requesting `User` is unauthorized to create `Leaderboard`s. - * @response `422` `ValidationProblemDetails` Client Error - */ - leaderboardsCreate = ( + * No description + * + * @tags Leaderboards + * @name CreateLeaderboard + * @summary Creates a new leaderboard. This request is restricted to Administrators. + * @request POST:/leaderboards/create + * @secure + * @response `201` `LeaderboardViewModel` Created + * @response `400` `ProblemDetails` Bad Request + * @response `401` `void` Unauthorized + * @response `403` `void` The requesting `User` is unauthorized to create `Leaderboard`s. + * @response `422` `ValidationProblemDetails` Unprocessable Content + * @response `500` `void` Internal Server Error + */ + createLeaderboard = ( data: CreateLeaderboardRequest, params: RequestParams = {}, ) => this.request< LeaderboardViewModel, - ProblemDetails | ValidationProblemDetails + ProblemDetails | void | ValidationProblemDetails >({ - path: `/api/Leaderboards`, + path: `/leaderboards/create`, method: 'POST', body: data, secure: true, diff --git a/lib/api/LeaderboardsRoute.ts b/lib/api/LeaderboardsRoute.ts index 9b043987..fae24b97 100644 --- a/lib/api/LeaderboardsRoute.ts +++ b/lib/api/LeaderboardsRoute.ts @@ -18,20 +18,18 @@ export namespace Leaderboards { /** * No description * @tags Leaderboards - * @name LeaderboardsDetail - * @summary Gets a Leaderboard by its ID. - * @request GET:/api/Leaderboards/{id} + * @name GetLeaderboard + * @summary Gets a leaderboard by its ID. + * @request GET:/api/leaderboard/{id} * @secure - * @response `200` `LeaderboardViewModel` The `Leaderboard` was found and returned successfully. + * @response `200` `LeaderboardViewModel` OK * @response `400` `ProblemDetails` Bad Request - * @response `404` `ProblemDetails` No `Leaderboard` with the requested ID or slug could be found. + * @response `404` `void` Not Found + * @response `500` `void` Internal Server Error */ - export namespace LeaderboardsDetail { + export namespace GetLeaderboard { export type RequestParams = { - /** - * The ID of the `Leaderboard` which should be retrieved. - * @format int64 - */ + /** @format int64 */ id: number } export type RequestQuery = {} @@ -43,22 +41,20 @@ export namespace Leaderboards { /** * No description * @tags Leaderboards - * @name LeaderboardsDetail2 + * @name GetLeaderboardBySlug * @summary Gets a Leaderboard by its slug. - * @request GET:/api/Leaderboards/{slug} - * @originalName leaderboardsDetail - * @duplicate + * @request GET:/api/leaderboard * @secure - * @response `200` `LeaderboardViewModel` The `Leaderboard` was found and returned successfully. + * @response `200` `LeaderboardViewModel` OK * @response `400` `ProblemDetails` Bad Request - * @response `404` `ProblemDetails` No `Leaderboard` with the requested ID or slug could be found. + * @response `404` `void` Not Found + * @response `500` `void` Internal Server Error */ - export namespace LeaderboardsDetail2 { - export type RequestParams = { - /** The slug of the `Leaderboard` which should be retrieved. */ + export namespace GetLeaderboardBySlug { + export type RequestParams = {} + export type RequestQuery = { slug: string } - export type RequestQuery = {} export type RequestBody = never export type RequestHeaders = {} export type ResponseBody = LeaderboardViewModel @@ -67,16 +63,17 @@ export namespace Leaderboards { /** * No description * @tags Leaderboards - * @name LeaderboardsList - * @summary Gets Leaderboards by their IDs. - * @request GET:/api/Leaderboards + * @name GetLeaderboards + * @summary Gets leaderboards by their IDs. + * @request GET:/api/leaderboards * @secure - * @response `200` `(LeaderboardViewModel)[]` The list of `Leaderboard`s was retrieved successfully. The result can be an empty collection. + * @response `200` `(LeaderboardViewModel)[]` OK + * @response `400` `ProblemDetails` Bad Request + * @response `500` `void` Internal Server Error */ - export namespace LeaderboardsList { + export namespace GetLeaderboards { export type RequestParams = {} export type RequestQuery = { - /** The IDs of the `Leaderboard`s which should be retrieved. */ ids?: number[] } export type RequestBody = never @@ -85,21 +82,20 @@ export namespace Leaderboards { } /** - * No description - * @tags Leaderboards - * @name LeaderboardsCreate - * @summary Creates a new Leaderboard. -This request is restricted to Administrators. - * @request POST:/api/Leaderboards - * @secure - * @response `201` `LeaderboardViewModel` The `Leaderboard` was created and returned successfully. - * @response `400` `ProblemDetails` The request was malformed. - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` The requesting `User` is unauthorized to create `Leaderboard`s. - * @response `422` `ValidationProblemDetails` Client Error -*/ - export namespace LeaderboardsCreate { + * No description + * @tags Leaderboards + * @name CreateLeaderboard + * @summary Creates a new leaderboard. This request is restricted to Administrators. + * @request POST:/leaderboards/create + * @secure + * @response `201` `LeaderboardViewModel` Created + * @response `400` `ProblemDetails` Bad Request + * @response `401` `void` Unauthorized + * @response `403` `void` The requesting `User` is unauthorized to create `Leaderboard`s. + * @response `422` `ValidationProblemDetails` Unprocessable Content + * @response `500` `void` Internal Server Error + */ + export namespace CreateLeaderboard { export type RequestParams = {} export type RequestQuery = {} export type RequestBody = CreateLeaderboardRequest diff --git a/lib/api/Runs.ts b/lib/api/Runs.ts index bb965b8b..1a4495e3 100644 --- a/lib/api/Runs.ts +++ b/lib/api/Runs.ts @@ -14,6 +14,8 @@ import type { CreateRunRequest, ProblemDetails, RunViewModel, + ScoredRunViewModel, + TimedRunViewModel, ValidationProblemDetails, } from './data-contracts' import { ContentType, HttpClient, type RequestParams } from './http-client' @@ -25,19 +27,21 @@ export class Runs< * No description * * @tags Runs - * @name RunsDetail + * @name GetRun * @summary Gets a Run by its ID. - * @request GET:/api/Runs/{id} + * @request GET:/api/run/{id} * @secure - * @response `200` `RunViewModel` The `Run` was found and returned successfully. + * @response `200` `(RunViewModel | TimedRunViewModel | ScoredRunViewModel)` OK * @response `400` `ProblemDetails` Bad Request - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` No `Run` with the requested ID could be found. + * @response `404` `void` Not Found + * @response `500` `void` Internal Server Error */ - runsDetail = (id: string, params: RequestParams = {}) => - this.request({ - path: `/api/Runs/${id}`, + getRun = (id: string, params: RequestParams = {}) => + this.request< + RunViewModel | TimedRunViewModel | ScoredRunViewModel, + ProblemDetails | void + >({ + path: `/api/run/${id}`, method: 'GET', secure: true, format: 'json', @@ -47,20 +51,20 @@ export class Runs< * No description * * @tags Runs - * @name RunsCreate + * @name CreateRun * @summary Creates a new Run. - * @request POST:/api/Runs + * @request POST:/runs/create * @secure - * @response `201` `void` The `Run` was created and returned successfully. + * @response `201` `void` Created * @response `400` `ProblemDetails` Bad Request - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` Not Found - * @response `422` `ValidationProblemDetails` Client Error + * @response `401` `void` Unauthorized + * @response `403` `void` Forbidden + * @response `422` `ValidationProblemDetails` Unprocessable Content + * @response `500` `void` Internal Server Error */ - runsCreate = (data: CreateRunRequest, params: RequestParams = {}) => - this.request({ - path: `/api/Runs`, + createRun = (data: CreateRunRequest, params: RequestParams = {}) => + this.request({ + path: `/runs/create`, method: 'POST', body: data, secure: true, @@ -71,18 +75,18 @@ export class Runs< * No description * * @tags Runs - * @name RunsCategoryDetail - * @request GET:/api/Runs/{id}/category + * @name GetRunCategory + * @summary Gets the category a run belongs to. + * @request GET:/api/run/{id}/category * @secure - * @response `200` `CategoryViewModel` Success + * @response `200` `CategoryViewModel` OK * @response `400` `ProblemDetails` Bad Request - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` Not Found + * @response `404` `void` Not Found + * @response `500` `void` Internal Server Error */ - runsCategoryDetail = (id: string, params: RequestParams = {}) => - this.request({ - path: `/api/Runs/${id}/category`, + getRunCategory = (id: string, params: RequestParams = {}) => + this.request({ + path: `/api/run/${id}/category`, method: 'GET', secure: true, format: 'json', diff --git a/lib/api/RunsRoute.ts b/lib/api/RunsRoute.ts index de244e2b..37f47900 100644 --- a/lib/api/RunsRoute.ts +++ b/lib/api/RunsRoute.ts @@ -13,52 +13,52 @@ import type { CategoryViewModel, CreateRunRequest, RunViewModel, + ScoredRunViewModel, + TimedRunViewModel, } from './data-contracts' export namespace Runs { /** * No description * @tags Runs - * @name RunsDetail + * @name GetRun * @summary Gets a Run by its ID. - * @request GET:/api/Runs/{id} + * @request GET:/api/run/{id} * @secure - * @response `200` `RunViewModel` The `Run` was found and returned successfully. + * @response `200` `(RunViewModel | TimedRunViewModel | ScoredRunViewModel)` OK * @response `400` `ProblemDetails` Bad Request - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` No `Run` with the requested ID could be found. + * @response `404` `void` Not Found + * @response `500` `void` Internal Server Error */ - export namespace RunsDetail { + export namespace GetRun { export type RequestParams = { - /** - * The ID of the `Run` which should be retrieved.
- * It must be possible to parse this to `long` for this request to complete. - * @pattern ^[a-zA-Z0-9-_]{22}$ - */ + /** @pattern ^[a-zA-Z0-9-_]{22}$ */ id: string } export type RequestQuery = {} export type RequestBody = never export type RequestHeaders = {} - export type ResponseBody = RunViewModel + export type ResponseBody = + | RunViewModel + | TimedRunViewModel + | ScoredRunViewModel } /** * No description * @tags Runs - * @name RunsCreate + * @name CreateRun * @summary Creates a new Run. - * @request POST:/api/Runs + * @request POST:/runs/create * @secure - * @response `201` `void` The `Run` was created and returned successfully. + * @response `201` `void` Created * @response `400` `ProblemDetails` Bad Request - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` Not Found - * @response `422` `ValidationProblemDetails` Client Error + * @response `401` `void` Unauthorized + * @response `403` `void` Forbidden + * @response `422` `ValidationProblemDetails` Unprocessable Content + * @response `500` `void` Internal Server Error */ - export namespace RunsCreate { + export namespace CreateRun { export type RequestParams = {} export type RequestQuery = {} export type RequestBody = CreateRunRequest @@ -69,16 +69,16 @@ export namespace Runs { /** * No description * @tags Runs - * @name RunsCategoryDetail - * @request GET:/api/Runs/{id}/category + * @name GetRunCategory + * @summary Gets the category a run belongs to. + * @request GET:/api/run/{id}/category * @secure - * @response `200` `CategoryViewModel` Success + * @response `200` `CategoryViewModel` OK * @response `400` `ProblemDetails` Bad Request - * @response `401` `ProblemDetails` Unauthorized - * @response `403` `ProblemDetails` Forbidden - * @response `404` `ProblemDetails` Not Found + * @response `404` `void` Not Found + * @response `500` `void` Internal Server Error */ - export namespace RunsCategoryDetail { + export namespace GetRunCategory { export type RequestParams = { /** @pattern ^[a-zA-Z0-9-_]{22}$ */ id: string diff --git a/lib/api/Users.ts b/lib/api/Users.ts index e94b37db..5c32f6dd 100644 --- a/lib/api/Users.ts +++ b/lib/api/Users.ts @@ -19,37 +19,40 @@ export class Users< * No description * * @tags Users - * @name UsersDetail + * @name GetUser * @summary Gets a User by their ID. - * @request GET:/api/Users/{id} + * @request GET:/api/user/{id} * @secure * @response `200` `UserViewModel` The `User` was found and returned successfully. * @response `400` `ProblemDetails` Bad Request - * @response `404` `ProblemDetails` No `User` with the requested ID could be found. + * @response `404` `void` No `User` with the requested ID could be found. + * @response `500` `void` Internal Server Error */ - usersDetail = (id: string, params: RequestParams = {}) => - this.request({ - path: `/api/Users/${id}`, + getUser = (id: string, params: RequestParams = {}) => + this.request({ + path: `/api/user/${id}`, method: 'GET', secure: true, format: 'json', ...params, }) /** - * @description Call this method with the 'Authorization' header. A valid JWT bearer token must be passed.
Example: `{ 'Authorization': 'Bearer JWT' }`. + * @description Call this method with the 'Authorization' header. A valid JWT bearer token must be passed. Example: `{ 'Authorization': 'Bearer JWT' }`. * * @tags Users - * @name UsersMeList + * @name Me * @summary Gets the currently logged-in User. - * @request GET:/api/Users/me + * @request GET:/user/me * @secure - * @response `200` `UserViewModel` The `User` was found and returned successfully.. - * @response `401` `ProblemDetails` An invalid JWT was passed in. - * @response `404` `ProblemDetails` The user was not found in the database. + * @response `200` `UserViewModel` The `User` was found and returned successfully. + * @response `400` `ProblemDetails` Bad Request + * @response `401` `void` An invalid JWT was passed in. + * @response `404` `void` The user was not found in the database. + * @response `500` `void` Internal Server Error */ - usersMeList = (params: RequestParams = {}) => - this.request({ - path: `/api/Users/me`, + me = (params: RequestParams = {}) => + this.request({ + path: `/user/me`, method: 'GET', secure: true, format: 'json', diff --git a/lib/api/UsersRoute.ts b/lib/api/UsersRoute.ts index 67aaa5d0..0b180942 100644 --- a/lib/api/UsersRoute.ts +++ b/lib/api/UsersRoute.ts @@ -15,15 +15,16 @@ export namespace Users { /** * No description * @tags Users - * @name UsersDetail + * @name GetUser * @summary Gets a User by their ID. - * @request GET:/api/Users/{id} + * @request GET:/api/user/{id} * @secure * @response `200` `UserViewModel` The `User` was found and returned successfully. * @response `400` `ProblemDetails` Bad Request - * @response `404` `ProblemDetails` No `User` with the requested ID could be found. + * @response `404` `void` No `User` with the requested ID could be found. + * @response `500` `void` Internal Server Error */ - export namespace UsersDetail { + export namespace GetUser { export type RequestParams = { /** * The ID of the `User` which should be retrieved. @@ -38,17 +39,19 @@ export namespace Users { } /** - * @description Call this method with the 'Authorization' header. A valid JWT bearer token must be passed.
Example: `{ 'Authorization': 'Bearer JWT' }`. + * @description Call this method with the 'Authorization' header. A valid JWT bearer token must be passed. Example: `{ 'Authorization': 'Bearer JWT' }`. * @tags Users - * @name UsersMeList + * @name Me * @summary Gets the currently logged-in User. - * @request GET:/api/Users/me + * @request GET:/user/me * @secure - * @response `200` `UserViewModel` The `User` was found and returned successfully.. - * @response `401` `ProblemDetails` An invalid JWT was passed in. - * @response `404` `ProblemDetails` The user was not found in the database. + * @response `200` `UserViewModel` The `User` was found and returned successfully. + * @response `400` `ProblemDetails` Bad Request + * @response `401` `void` An invalid JWT was passed in. + * @response `404` `void` The user was not found in the database. + * @response `500` `void` Internal Server Error */ - export namespace UsersMeList { + export namespace Me { export type RequestParams = {} export type RequestQuery = {} export type RequestBody = never diff --git a/lib/api/data-contracts.ts b/lib/api/data-contracts.ts index 1dad3323..550ef98d 100644 --- a/lib/api/data-contracts.ts +++ b/lib/api/data-contracts.ts @@ -9,20 +9,10 @@ * --------------------------------------------------------------- */ -export interface CalendarSystem { - id: string - name: string - /** @format int32 */ - minYear: number - /** @format int32 */ - maxYear: number - eras: Era[] -} - /** Represents a `Category` tied to a `Leaderboard`. */ export interface CategoryViewModel { /** - * The unique identifier of the `Category`.
+ * The unique identifier of the `Category`. * @format int64 */ id: number @@ -32,15 +22,32 @@ export interface CategoryViewModel { */ name: string /** - * The URL-scoped unique identifier of the `Category`.
+ * The URL-scoped unique identifier of the `Category`. * @example "foo-bar-baz" */ slug: string /** - * The rules of the `Category`. + * Information pertaining to the `Category`. * @example "Video proof is required." */ - rules?: string | null + info: string | null + type: RunType + sortDirection: SortDirection + /** + * @format date-time + * @example "1984-01-01T00:00:00Z" + */ + createdAt: string + /** + * @format date-time + * @example "1984-01-01T00:00:00Z" + */ + updatedAt: string | null + /** + * @format date-time + * @example "1984-01-01T00:00:00Z" + */ + deletedAt: string | null } export interface ChangePasswordRequest { @@ -51,27 +58,28 @@ export interface ChangePasswordRequest { export interface CreateCategoryRequest { /** * The display name of the `Category`. - * @minLength 1 * @example "Foo Bar Baz%" */ name: string /** - * The URL-scoped unique identifier of the `Category`.
+ * The URL-scoped unique identifier of the `Category`. + * * Must be [2, 25] in length and consist only of alphanumeric characters and hyphens. - * @minLength 1 * @example "foo-bar-baz" */ slug: string /** - * The rules of the `Category`. + * Information pertaining to the `Category`. * @example "Video proof is required." */ - rules?: string | null + info: string | null /** * The ID of the `Leaderboard` the `Category` is a part of. * @format int64 */ leaderboardId: number + sortDirection: SortDirection + type: RunType } /** This request object is sent when creating a `Leaderboard`. */ @@ -82,44 +90,38 @@ export interface CreateLeaderboardRequest { */ name: string /** - * The URL-scoped unique identifier of the `Leaderboard`.
+ * The URL-scoped unique identifier of the `Leaderboard`. + * * Must be [2, 80] in length and consist only of alphanumeric characters and hyphens. * @example "foo-bar" */ slug: string + info: string | null } /** This request object is sent when creating a `Run`. */ export interface CreateRunRequest { - playedOn: LocalDate - submittedAt: Instant + info: string | null + /** + * The date the `Run` was played on. + * @format date + * @example "2000-01-01" + */ + playedOn: string /** * The ID of the `Category` for the `Run`. * @format int64 */ categoryId: number + /** @format int64 */ + timeOrScore: number } -export interface Era { - name: string -} - -export type Instant = object - -export type IsoDayOfWeek = - | 'None' - | 'Monday' - | 'Tuesday' - | 'Wednesday' - | 'Thursday' - | 'Friday' - | 'Saturday' - | 'Sunday' - /** Represents a collection of `Leaderboard` entities. */ export interface LeaderboardViewModel { /** - * The unique identifier of the `Leaderboard`.
+ * The unique identifier of the `Leaderboard`. + * * Generated on creation. * @format int64 */ @@ -130,36 +132,39 @@ export interface LeaderboardViewModel { */ name: string /** - * The URL-scoped unique identifier of the `Leaderboard`.
+ * The URL-scoped unique identifier of the `Leaderboard`. + * * Must be [2, 80] in length and consist only of alphanumeric characters and hyphens. * @example "foo-bar" */ slug: string /** - * The general rules for the Leaderboard. + * The general information for the Leaderboard. * @example "Timer starts on selecting New Game and ends when the final boss is beaten." */ - rules?: string | null + info: string | null + /** + * The time the Leaderboard was created. + * @format date-time + * @example "1984-01-01T00:00:00Z" + */ + createdAt: string + /** + * The last time the Leaderboard was updated or null. + * @format date-time + * @example "1984-01-01T00:00:00Z" + */ + updatedAt: string | null + /** + * The time at which the Leaderboard was deleted, or null if the Leaderboard has not been deleted. + * @format date-time + * @example "1984-01-01T00:00:00Z" + */ + deletedAt: string | null /** A collection of `Category` entities for the `Leaderboard`. */ categories: CategoryViewModel[] } -export interface LocalDate { - calendar: CalendarSystem - /** @format int32 */ - year: number - /** @format int32 */ - month: number - /** @format int32 */ - day: number - dayOfWeek: IsoDayOfWeek - /** @format int32 */ - yearOfEra: number - era: Era - /** @format int32 */ - dayOfYear: number -} - /** This request object is sent when a `User` is attempting to log in. */ export interface LoginRequest { /** @@ -235,26 +240,38 @@ export interface RegisterRequest { password: string } -export interface RunViewModel { +export type RunType = 'Time' | 'Score' + +export type RunViewModel = BaseRunViewModel & + ( + | BaseRunViewModelTypeMapping<'Time', TimedRunViewModel> + | BaseRunViewModelTypeMapping<'Score', ScoredRunViewModel> + ) + +export type ScoredRunViewModel = BaseRunViewModel & { /** - * The unique identifier of the `Run`.
- * Generated on creation. - * @pattern ^[a-zA-Z0-9-_]{22}$ + * The score achieved during the run. + * @format int64 */ - id: string - submittedAt: Instant + score: number +} + +export type SortDirection = 'Ascending' | 'Descending' + +export type TimedRunViewModel = BaseRunViewModel & { /** - * The ID of the `Category` for `Run`. - * @format int64 + * The duration of the run. + * @example "25:01:01.001" */ - categoryId: number + time: string } export type UserRole = 'Registered' | 'Confirmed' | 'Administrator' | 'Banned' export interface UserViewModel { /** - * The unique identifier of the `User`.
+ * The unique identifier of the `User`. + * * Generated on creation. * @pattern ^[a-zA-Z0-9-_]{22}$ */ @@ -269,6 +286,11 @@ export interface UserViewModel { */ username: string role: UserRole + /** + * @format date-time + * @example "1984-01-01T00:00:00Z" + */ + createdAt: string } export interface ValidationProblemDetails { @@ -278,11 +300,59 @@ export interface ValidationProblemDetails { status?: number | null detail?: string | null instance?: string | null - errors: Record + errors?: Record [key: string]: any } -export interface LeaderboardsListParams { - /** The IDs of the `Leaderboard`s which should be retrieved. */ +interface BaseRunViewModel { + $type: string + /** + * The unique identifier of the `Run`. + * + * Generated on creation. + * @pattern ^[a-zA-Z0-9-_]{22}$ + */ + id: string + /** User-provided details about the run. */ + info: string | null + /** + * The time the run was created. + * @format date-time + * @example "1984-01-01T00:00:00Z" + */ + createdAt: string + /** + * The last time the run was updated or null. + * @format date-time + * @example "1984-01-01T00:00:00Z" + */ + updatedAt: string | null + /** + * The time at which the run was deleted, or null if the run has not been deleted. + * @format date-time + * @example "1984-01-01T00:00:00Z" + */ + deletedAt: string | null + /** + * The ID of the `Category` for `Run`. + * @format int64 + */ + categoryId: number + /** + * The ID of the LeaderboardBackend.Models.Entities.User who submitted this run. + * @pattern ^[a-zA-Z0-9-_]{22}$ + */ + userId: string +} + +type BaseRunViewModelTypeMapping = { + $type: Key +} & Type + +export interface GetLeaderboardBySlugParams { + slug: string +} + +export interface GetLeaderboardsParams { ids?: number[] } diff --git a/pages/board/[slug].vue b/pages/board/[slug].vue index d1a0fdf1..38d7a678 100644 --- a/pages/board/[slug].vue +++ b/pages/board/[slug].vue @@ -1,10 +1,11 @@