mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-26 15:54:35 +08:00
refactor(types): update namespace naming
This commit is contained in:
parent
4f5f28a92d
commit
15af21cbf3
9 changed files with 24 additions and 18 deletions
|
@ -5,14 +5,14 @@ export default class ApeKeys {
|
|||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
async get(): Ape.EndpointResponse<ApeKeysApe.GetApeKeys> {
|
||||
async get(): Ape.EndpointResponse<Ape.ApeKeys.GetApeKeys> {
|
||||
return await this.httpClient.get(BASE_PATH);
|
||||
}
|
||||
|
||||
async generate(
|
||||
name: string,
|
||||
enabled: boolean
|
||||
): Ape.EndpointResponse<ApeKeysApe.GenerateApeKey> {
|
||||
): Ape.EndpointResponse<Ape.ApeKeys.GenerateApeKey> {
|
||||
const payload = { name, enabled };
|
||||
return await this.httpClient.post(BASE_PATH, { payload });
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ export default class Configs {
|
|||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
async get(): Ape.EndpointResponse<ConfigsApe.GetConfig> {
|
||||
async get(): Ape.EndpointResponse<Ape.Configs.GetConfig> {
|
||||
return await this.httpClient.get(BASE_PATH);
|
||||
}
|
||||
|
||||
async save(
|
||||
config: MonkeyTypes.Config
|
||||
): Ape.EndpointResponse<ConfigsApe.PostConfig> {
|
||||
): Ape.EndpointResponse<Ape.Configs.PostConfig> {
|
||||
return await this.httpClient.patch(BASE_PATH, { payload: { config } });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ export default class Quotes {
|
|||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
async get(): Ape.EndpointResponse<QuotesApe.GetQuotes> {
|
||||
async get(): Ape.EndpointResponse<Ape.Quotes.GetQuotes> {
|
||||
return await this.httpClient.get(BASE_PATH);
|
||||
}
|
||||
|
||||
async isSubmissionEnabled(): Ape.EndpointResponse<QuotesApe.GetIsSubmissionEnabled> {
|
||||
async isSubmissionEnabled(): Ape.EndpointResponse<Ape.Quotes.GetIsSubmissionEnabled> {
|
||||
return await this.httpClient.get(`${BASE_PATH}/isSubmissionEnabled`);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ export default class Quotes {
|
|||
source: string,
|
||||
language: string,
|
||||
captcha: string
|
||||
): Ape.EndpointResponse<QuotesApe.PostQuotes> {
|
||||
): Ape.EndpointResponse<Ape.Quotes.PostQuotes> {
|
||||
const payload = {
|
||||
text,
|
||||
source,
|
||||
|
@ -33,7 +33,7 @@ export default class Quotes {
|
|||
quoteSubmissionId: string,
|
||||
editText?: string,
|
||||
editSource?: string
|
||||
): Ape.EndpointResponse<QuotesApe.PostApprove> {
|
||||
): Ape.EndpointResponse<Ape.Quotes.PostApprove> {
|
||||
const payload = {
|
||||
quoteId: quoteSubmissionId,
|
||||
editText,
|
||||
|
@ -45,7 +45,7 @@ export default class Quotes {
|
|||
|
||||
async rejectSubmission(
|
||||
quoteSubmissionId: string
|
||||
): Ape.EndpointResponse<QuotesApe.PostReject> {
|
||||
): Ape.EndpointResponse<Ape.Quotes.PostReject> {
|
||||
return await this.httpClient.post(`${BASE_PATH}/reject`, {
|
||||
payload: { quoteId: quoteSubmissionId },
|
||||
});
|
||||
|
@ -53,7 +53,7 @@ export default class Quotes {
|
|||
|
||||
async getRating(
|
||||
quote: MonkeyTypes.Quote
|
||||
): Ape.EndpointResponse<QuotesApe.GetRating> {
|
||||
): Ape.EndpointResponse<Ape.Quotes.GetRating> {
|
||||
const searchQuery = {
|
||||
quoteId: quote.id,
|
||||
language: quote.language,
|
||||
|
@ -65,7 +65,7 @@ export default class Quotes {
|
|||
async addRating(
|
||||
quote: MonkeyTypes.Quote,
|
||||
rating: number
|
||||
): Ape.EndpointResponse<QuotesApe.PostRating> {
|
||||
): Ape.EndpointResponse<Ape.Quotes.PostRating> {
|
||||
const payload = {
|
||||
quoteId: quote.id,
|
||||
rating,
|
||||
|
@ -81,7 +81,7 @@ export default class Quotes {
|
|||
reason: string,
|
||||
comment: string,
|
||||
captcha: string
|
||||
): Ape.EndpointResponse<QuotesApe.PostReport> {
|
||||
): Ape.EndpointResponse<Ape.Quotes.PostReport> {
|
||||
const payload = {
|
||||
quoteId,
|
||||
quoteLanguage,
|
||||
|
|
4
frontend/src/ts/ape/types/ape-keys.d.ts
vendored
4
frontend/src/ts/ape/types/ape-keys.d.ts
vendored
|
@ -1,4 +1,6 @@
|
|||
declare namespace ApeKeysApe {
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
// for some reason when using the dot notaion, the types are not being recognized as used
|
||||
declare namespace Ape.ApeKeys {
|
||||
type GetApeKeys = Record<string, SharedTypes.ApeKey>;
|
||||
|
||||
type GenerateApeKey = {
|
||||
|
|
4
frontend/src/ts/ape/types/configs.d.ts
vendored
4
frontend/src/ts/ape/types/configs.d.ts
vendored
|
@ -1,4 +1,6 @@
|
|||
declare namespace ConfigsApe {
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
// for some reason when using the dot notaion, the types are not being recognized as used
|
||||
declare namespace Ape.Configs {
|
||||
type GetConfig = {
|
||||
_id: string;
|
||||
uid: string;
|
||||
|
|
4
frontend/src/ts/ape/types/quotes.d.ts
vendored
4
frontend/src/ts/ape/types/quotes.d.ts
vendored
|
@ -1,4 +1,6 @@
|
|||
declare namespace QuotesApe {
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
// for some reason when using the dot notaion, the types are not being recognized as used
|
||||
declare namespace Ape.Quotes {
|
||||
type Quote = {
|
||||
_id: string;
|
||||
text: string;
|
||||
|
|
|
@ -6,7 +6,7 @@ import * as ConnectionState from "../states/connection";
|
|||
import * as Skeleton from "./skeleton";
|
||||
import { isPopupVisible } from "../utils/misc";
|
||||
|
||||
let apeKeys: ApeKeysApe.GetApeKeys | null = {};
|
||||
let apeKeys: Ape.ApeKeys.GetApeKeys | null = {};
|
||||
|
||||
const wrapperId = "apeKeysPopupWrapper";
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import { isPopupVisible } from "../utils/misc";
|
|||
|
||||
const wrapperId = "quoteApprovePopupWrapper";
|
||||
|
||||
let quotes: QuotesApe.Quote[] = [];
|
||||
let quotes: Ape.Quotes.Quote[] = [];
|
||||
|
||||
function updateList(): void {
|
||||
$("#quoteApprovePopupWrapper .quotes").empty();
|
||||
|
|
|
@ -1317,7 +1317,7 @@ list["generateApeKey"] = new SimplePopup(
|
|||
}
|
||||
|
||||
//if response is 200 data is guaranteed to not be null
|
||||
const data = response.data as ApeKeysApe.GenerateApeKey;
|
||||
const data = response.data as Ape.ApeKeys.GenerateApeKey;
|
||||
|
||||
return {
|
||||
status: 1,
|
||||
|
|
Loading…
Reference in a new issue