refactor: create types instead of using models

This commit is contained in:
Sonny
2024-05-26 23:43:48 +02:00
committed by Sonny
parent 55cd973b1a
commit e03952de1c
28 changed files with 582 additions and 176 deletions

View File

@@ -1,26 +1,55 @@
import type Collection from '#models/collection';
import { Visibility } from '@/app/enums/visibility';
type User = {
type CommonBase = {
id: number;
createdAt: string;
updatedAt: string;
};
type User = CommonBase & {
email: string;
name: string;
nickName: string;
fullname: string;
avatarUrl: string;
isAdmin: boolean;
};
type UserWithCollections = User & {
collections: Collection[];
};
type UserWithRelationCount = {
id: number;
type UserWithRelationCount = CommonBase & {
email: string;
fullname: string;
avatarUrl: string;
isAdmin: string;
createdAt: string;
updatedAt: string;
count: {
link: number;
collection: number;
};
};
type Link = CommonBase & {
name: string;
description: string | null;
url: string;
favorite: boolean;
collectionId: number;
};
type LinkWithCollection = Link & {
collection: Collection;
};
type Collection = CommonBase & {
name: string;
description: string | null;
visibility: Visibility;
nextId: number;
authorId: number;
};
type CollectionWithLinks = Collection & {
links: Link[];
};