Skip to content

Commit

Permalink
refactor(types): update namespace naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed Feb 7, 2024
1 parent 4f5f28a commit 15af21c
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions frontend/src/ts/ape/endpoints/ape-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ts/ape/endpoints/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
}
16 changes: 8 additions & 8 deletions frontend/src/ts/ape/endpoints/quotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -45,15 +45,15 @@ 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 },
});
}

async getRating(
quote: MonkeyTypes.Quote
): Ape.EndpointResponse<QuotesApe.GetRating> {
): Ape.EndpointResponse<Ape.Quotes.GetRating> {
const searchQuery = {
quoteId: quote.id,
language: quote.language,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/ts/ape/types/ape-keys.d.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/ts/ape/types/configs.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/ts/ape/types/quotes.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/popups/ape-keys-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/popups/quote-approve-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/popups/simple-popups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 15af21c

Please sign in to comment.