Files
tvone/lib/dtos.ts
T
peter 9d58259672
continuous-integration/drone/push Build is passing
add subcategory on creating news
2026-04-23 10:09:44 +01:00

215 lines
4.0 KiB
TypeScript

export type UserRole = "ADMIN" | "EDITOR" | "AUTHOR" | "READER";
export type ArticleStatus = "DRAFT" | "PUBLISHED" | "ARCHIVED";
export interface DeleteResponseDto {
deleted: true;
}
export interface UserOutputDto {
id: string;
keycloakId: string;
email: string;
displayName: string | null;
avatarKey: string | null;
role: UserRole;
createdAt: string;
updatedAt: string;
}
export interface CategoryOutputDto {
id: string;
name: string;
slug: string;
parentId: string | null;
createdAt: string;
updatedAt: string;
}
export interface CategoryTreeOutputDto extends CategoryOutputDto {
children: CategoryTreeOutputDto[];
}
export interface CreateCategoryInputDto {
name: string;
slug?: string;
parentId?: string | null;
}
export interface UpdateCategoryInputDto {
name?: string;
slug?: string;
parentId?: string | null;
}
export interface TagOutputDto {
id: string;
name: string;
slug: string;
createdAt: string;
updatedAt: string;
}
export interface CreateTagInputDto {
name: string;
slug?: string;
}
export interface UpdateTagInputDto {
name?: string;
slug?: string;
}
export interface ImageOutputDto {
id: string;
fileKey: string;
createdAt: string;
}
export interface UploadedImageOutputDto extends ImageOutputDto {
urls: string;
}
export interface ArticleAuthorOutputDto {
id: string;
displayName: string | null;
email?: string;
avatarKey: string | null;
}
export interface ArticleCategoryLinkOutputDto {
articleId: string;
categoryId: string;
category: CategoryOutputDto;
}
export interface ArticleTagLinkOutputDto {
articleId: string;
tagId: string;
tag: TagOutputDto;
}
export interface ArticleImageLinkOutputDto {
articleId: string;
imageId: string;
sortOrder: number;
image: ImageOutputDto;
}
export interface ArticleOutputDto {
id: string;
title: string;
slug: string;
content: string;
excerpt: string | null;
status: ArticleStatus;
publishedAt: string | null;
authorId: string;
author: ArticleAuthorOutputDto;
categories: ArticleCategoryLinkOutputDto[];
tags: ArticleTagLinkOutputDto[];
images: ArticleImageLinkOutputDto[];
createdAt: string;
updatedAt: string;
}
export interface ListArticlesInputDto {
page?: number;
limit?: number;
search?: string;
categoryId?: string;
tagId?: string;
}
export interface ManageArticlesInputDto extends ListArticlesInputDto {
status?: ArticleStatus;
}
export interface CreateArticleInputDto {
title: string;
slug?: string;
content: string;
excerpt?: string;
status?: ArticleStatus;
categoryIds?: string[];
tagIds?: string[];
imageIds?: string[];
}
export interface UpdateArticleInputDto {
title?: string;
slug?: string;
content?: string;
excerpt?: string;
status?: ArticleStatus;
categoryIds?: string[];
tagIds?: string[];
imageIds?: string[];
}
export interface AttachImageInputDto {
imageId: string;
sortOrder?: number;
}
export interface PaginatedArticlesOutputDto {
items: ArticleOutputDto[];
total: number;
page: number;
limit: number;
}
export interface CommentUserOutputDto {
id: string;
displayName: string | null;
avatarKey: string | null;
}
export interface CommentOutputDto {
id: string;
content: string;
articleId: string;
userId: string;
parentId: string | null;
user: CommentUserOutputDto;
createdAt: string;
updatedAt: string;
}
export interface CommentTreeOutputDto extends CommentOutputDto {
replies: CommentTreeOutputDto[];
}
export interface CreateCommentInputDto {
content: string;
parentId?: string;
}
export interface BookmarkOutputDto {
userId: string;
articleId: string;
createdAt: string;
article: ArticleOutputDto;
}
export interface PaginatedBookmarksOutputDto {
items: BookmarkOutputDto[];
total: number;
page: number;
limit: number;
}
export interface ProfileOutputDto {
keycloak: {
email?: string;
name?: string;
picture?: string;
email_verified?: boolean;
roles: string[];
};
user: UserOutputDto | null;
}
export interface UpdateMeInputDto {
displayName?: string;
avatarKey?: string;
}