From d2d57eb4f10890b71f2e95e83d2be6a913252a3b Mon Sep 17 00:00:00 2001 From: luigi-borriello00 <luigi.borriello2@studio.unibo.it> Date: Tue, 21 May 2024 13:58:14 +0200 Subject: [PATCH] fix(frontend): change getChannels response in order to match backend one --- .../src/main/vue/api/piperchat/channel.ts | 510 +++++++++--------- 1 file changed, 255 insertions(+), 255 deletions(-) diff --git a/frontend-service/src/main/vue/api/piperchat/channel.ts b/frontend-service/src/main/vue/api/piperchat/channel.ts index 093a6b9af..31e35c1ee 100644 --- a/frontend-service/src/main/vue/api/piperchat/channel.ts +++ b/frontend-service/src/main/vue/api/piperchat/channel.ts @@ -1,292 +1,292 @@ -import { type Empty, ErrorResponse, Response } from "../response"; -import type { RequestSchema } from "../schema"; +import {type Empty, ErrorResponse, Response} from "../response"; +import type {RequestSchema} from "../schema"; /* eslint-disable @typescript-eslint/no-namespace */ export module GetChannelsApi { - export module Request { - export type Type = Body & Params; - export type Params = { - serverId: string; - }; - export type Body = Empty; - export const Schema: RequestSchema = { - Params: { - serverId: "string", - }, - Body: {}, - }; - } - export module Responses { - interface Channel { - id: string; - name: string; - createdAt: Date; - channelType: string; - description?: string; + export module Request { + export type Type = Body & Params; + export type Params = { + serverId: string; + }; + export type Body = Empty; + export const Schema: RequestSchema = { + Params: { + serverId: "string", + }, + Body: {}, + }; } - export class Success extends Response { - statusCode = 200; - message = "Channels retrieved successfully"; + export module Responses { + interface Channel { + id: string; + name: string; + type: string; + description?: string; + } - constructor(public channels: Channel[]) { - super(); - } - } + export class Success extends Response { + statusCode = 200; + message = "Channels retrieved successfully"; - export type Type = Success; - } - export module Errors { - export class ServerNotFound extends ErrorResponse { - statusCode = 404; - error = "Server not found" as const; - } + constructor(public channels: Channel[]) { + super(); + } + } - export class UserNotAuthorized extends ErrorResponse { - statusCode = 403; - error = "User not authorized" as const; + export type Type = Success; } - - export type Type = ServerNotFound | UserNotAuthorized; - } - export type Response = Responses.Type | Errors.Type; + export module Errors { + export class ServerNotFound extends ErrorResponse { + statusCode = 404; + error = "Server not found" as const; + } + + export class UserNotAuthorized extends ErrorResponse { + statusCode = 403; + error = "User not authorized" as const; + } + + export type Type = ServerNotFound | UserNotAuthorized; + } + export type Response = Responses.Type | Errors.Type; } export module GetChannelByIdApi { - export module Request { - export type Type = Body & Params; - export type Params = { - serverId: string; - channelId: string; - }; - export const Schema: RequestSchema = { - Params: { - serverId: "string", - channelId: "string", - }, - Body: {}, - }; - } - export module Responses { - export interface Channel { - id: string; - name: string; - createdAt: Date; - channelType: string; - description?: string; + export module Request { + export type Type = Body & Params; + export type Params = { + serverId: string; + channelId: string; + }; + export const Schema: RequestSchema = { + Params: { + serverId: "string", + channelId: "string", + }, + Body: {}, + }; } - - export class Success extends Response { - statusCode = 200; - message = "Channels retrieved successfully"; - - constructor(public channel: Channel) { - super(); - } + export module Responses { + export interface Channel { + id: string; + name: string; + createdAt: Date; + channelType: string; + description?: string; + } + + export class Success extends Response { + statusCode = 200; + message = "Channels retrieved successfully"; + + constructor(public channel: Channel) { + super(); + } + } + + export type Type = Success; } - - export type Type = Success; - } - export module Errors { - export class ChannelNotFound extends ErrorResponse { - statusCode = 404; - error = "Channel not found" as const; + export module Errors { + export class ChannelNotFound extends ErrorResponse { + statusCode = 404; + error = "Channel not found" as const; + } + + export class UserNotAuthorized extends ErrorResponse { + statusCode = 403; + error = "User not authorized" as const; + } + + export class ServerNotFound extends ErrorResponse { + statusCode = 404; + error = "Server not found" as const; + } + + export type Type = ChannelNotFound | UserNotAuthorized | ServerNotFound; } - - export class UserNotAuthorized extends ErrorResponse { - statusCode = 403; - error = "User not authorized" as const; - } - - export class ServerNotFound extends ErrorResponse { - statusCode = 404; - error = "Server not found" as const; - } - - export type Type = ChannelNotFound | UserNotAuthorized | ServerNotFound; - } - export type Response = Responses.Type | Errors.Type; + export type Response = Responses.Type | Errors.Type; } export module CreateChannelApi { - export enum ChannelType { - Messages = "TEXT", - Multimedia = "MULTIMEDIA", - } - - export module Request { - export type Type = Body & Params; - export type Params = { - serverId: string; - }; - export type Body = { - name: string; - channelType: ChannelType; - description?: string; - }; - export const Schema: RequestSchema = { - Params: { - serverId: "string", - }, - Body: { - name: "string", - channelType: "string", - description: "string?", - }, - }; - } - export module Responses { - interface Channel { - id: string; - name: string; - createdAt: Date; - channelType: string; - description?: string; - } - - export class Success extends Response { - statusCode = 200; - message = "Channel created successfully"; - channel: Channel; - - constructor(channel: Channel) { - super(); - this.channel = channel; - } + export enum ChannelType { + Messages = "TEXT", + Multimedia = "MULTIMEDIA", } - export type Type = Success; - } - export module Errors { - export class ServerNotFound extends ErrorResponse { - statusCode = 404; - error = "Server not found" as const; + export module Request { + export type Type = Body & Params; + export type Params = { + serverId: string; + }; + export type Body = { + name: string; + channelType: ChannelType; + description?: string; + }; + export const Schema: RequestSchema = { + Params: { + serverId: "string", + }, + Body: { + name: "string", + channelType: "string", + description: "string?", + }, + }; } - - export class UserNotAuthorized extends ErrorResponse { - statusCode = 403; - error = "User not authorized" as const; - } - - export class ChannelAlreadyExists extends ErrorResponse { - statusCode = 409; - error = "Channel already exists" as const; + export module Responses { + interface Channel { + id: string; + name: string; + createdAt: Date; + channelType: string; + description?: string; + } + + export class Success extends Response { + statusCode = 200; + message = "Channel created successfully"; + channel: Channel; + + constructor(channel: Channel) { + super(); + this.channel = channel; + } + } + + export type Type = Success; } - - export class InvalidChannelType extends ErrorResponse { - statusCode = 400; - error = "Invalid channel type" as const; + export module Errors { + export class ServerNotFound extends ErrorResponse { + statusCode = 404; + error = "Server not found" as const; + } + + export class UserNotAuthorized extends ErrorResponse { + statusCode = 403; + error = "User not authorized" as const; + } + + export class ChannelAlreadyExists extends ErrorResponse { + statusCode = 409; + error = "Channel already exists" as const; + } + + export class InvalidChannelType extends ErrorResponse { + statusCode = 400; + error = "Invalid channel type" as const; + } + + export type Type = + | ServerNotFound + | UserNotAuthorized + | ChannelAlreadyExists + | InvalidChannelType; } - - export type Type = - | ServerNotFound - | UserNotAuthorized - | ChannelAlreadyExists - | InvalidChannelType; - } - export type Response = Responses.Type | Errors.Type; + export type Response = Responses.Type | Errors.Type; } export module UpdateChannelApi { - export module Request { - export type Type = Body & Params; - export type Params = { - serverId: string; - channelId: string; - }; - export type Body = { - name?: string; - description?: string; - }; - export const Schema: RequestSchema = { - Params: { - serverId: "string", - channelId: "string", - }, - Body: { - name: "string?", - description: "string?", - }, - }; - } - export module Responses { - export class Success extends Response { - statusCode = 200; - message = "Channel updated successfully"; - } - - export type Type = Success; - } - export module Errors { - export class ServerNotFound extends ErrorResponse { - statusCode = 404; - error = "Server not found" as const; + export module Request { + export type Type = Body & Params; + export type Params = { + serverId: string; + channelId: string; + }; + export type Body = { + name?: string; + description?: string; + }; + export const Schema: RequestSchema = { + Params: { + serverId: "string", + channelId: "string", + }, + Body: { + name: "string?", + description: "string?", + }, + }; } + export module Responses { + export class Success extends Response { + statusCode = 200; + message = "Channel updated successfully"; + } - export class ChannelNotFound extends ErrorResponse { - statusCode = 404; - error = "Channel not found" as const; + export type Type = Success; } - - export class UserNotAuthorized extends ErrorResponse { - statusCode = 403; - error = "User not authorized" as const; + export module Errors { + export class ServerNotFound extends ErrorResponse { + statusCode = 404; + error = "Server not found" as const; + } + + export class ChannelNotFound extends ErrorResponse { + statusCode = 404; + error = "Channel not found" as const; + } + + export class UserNotAuthorized extends ErrorResponse { + statusCode = 403; + error = "User not authorized" as const; + } + + export class ChannelAlreadyExists extends ErrorResponse { + statusCode = 409; + error = "Channel already exists" as const; + } + + export type Type = + | ServerNotFound + | ChannelNotFound + | UserNotAuthorized + | ChannelAlreadyExists; } - - export class ChannelAlreadyExists extends ErrorResponse { - statusCode = 409; - error = "Channel already exists" as const; - } - - export type Type = - | ServerNotFound - | ChannelNotFound - | UserNotAuthorized - | ChannelAlreadyExists; - } - export type Response = Responses.Type | Errors.Type; + export type Response = Responses.Type | Errors.Type; } export module DeleteChannelApi { - export module Request { - export type Type = Body & Params; - export type Params = { - serverId: string; - channelId: string; - }; - export type Body = Empty; - export const Schema: RequestSchema = { - Params: { - serverId: "string", - channelId: "string", - }, - Body: {}, - }; - } - export module Responses { - export class Success extends Response { - statusCode = 200; - message = "Channel deleted successfully"; + export module Request { + export type Type = Body & Params; + export type Params = { + serverId: string; + channelId: string; + }; + export type Body = Empty; + export const Schema: RequestSchema = { + Params: { + serverId: "string", + channelId: "string", + }, + Body: {}, + }; } + export module Responses { + export class Success extends Response { + statusCode = 200; + message = "Channel deleted successfully"; + } - export type Type = Success; - } - export module Errors { - export class ServerNotFound extends ErrorResponse { - statusCode = 404; - error = "Server not found" as const; + export type Type = Success; } - - export class ChannelNotFound extends ErrorResponse { - statusCode = 404; - error = "Channel not found" as const; + export module Errors { + export class ServerNotFound extends ErrorResponse { + statusCode = 404; + error = "Server not found" as const; + } + + export class ChannelNotFound extends ErrorResponse { + statusCode = 404; + error = "Channel not found" as const; + } + + export class UserNotAuthorized extends ErrorResponse { + statusCode = 403; + error = "User not authorized" as const; + } + + export type Type = ServerNotFound | ChannelNotFound | UserNotAuthorized; } - - export class UserNotAuthorized extends ErrorResponse { - statusCode = 403; - error = "User not authorized" as const; - } - - export type Type = ServerNotFound | ChannelNotFound | UserNotAuthorized; - } - export type Response = Responses.Type | Errors.Type; + export type Response = Responses.Type | Errors.Type; }