el.xwx.moe/types/global.ts
2023-06-05 19:48:54 +03:30

42 lines
1.0 KiB
TypeScript

import { Collection, Link, Tag, User } from "@prisma/client";
type OptionalExcluding<T, TRequired extends keyof T> = Partial<T> &
Pick<T, TRequired>;
export interface LinkIncludingCollectionAndTags
extends Omit<Link, "id" | "createdAt" | "collectionId"> {
id?: number;
createdAt?: string;
collectionId?: number;
tags: Tag[];
collection: OptionalExcluding<Collection, "name" | "ownerId">;
}
export interface Member {
collectionId?: number;
userId?: number;
canCreate: boolean;
canUpdate: boolean;
canDelete: boolean;
user: OptionalExcluding<User, "email" | "name">;
}
export interface CollectionIncludingMembers
extends Omit<Collection, "id" | "createdAt"> {
id?: number;
createdAt?: string;
members: Member[];
}
export interface AccountSettings extends User {
profilePic: string | null;
oldPassword?: string;
newPassword?: string;
}
export interface PublicCollectionIncludingLinks
extends Omit<Collection, "ownerId"> {
ownerName?: string;
links: Omit<Link, "screenshotPath" | "pdfPath">[];
}