el.xwx.moe/types/global.ts

99 lines
2.0 KiB
TypeScript
Raw Normal View History

2023-05-22 07:20:48 -05:00
import { Collection, Link, Tag, User } from "@prisma/client";
2023-05-26 23:11:29 -05:00
2023-05-27 11:53:02 -05:00
type OptionalExcluding<T, TRequired extends keyof T> = Partial<T> &
2023-05-26 23:11:29 -05:00
Pick<T, TRequired>;
2023-03-05 15:03:20 -06:00
export interface LinkIncludingShortenedCollectionAndTags
2023-05-27 11:29:39 -05:00
extends Omit<Link, "id" | "createdAt" | "collectionId"> {
id?: number;
createdAt?: string;
collectionId?: number;
2023-03-28 02:31:50 -05:00
tags: Tag[];
2023-06-13 14:19:37 -05:00
pinnedBy?: {
id: number;
}[];
2023-06-24 16:54:35 -05:00
collection: OptionalExcluding<Collection, "name" | "ownerId">;
}
2023-05-26 23:11:29 -05:00
export interface Member {
collectionId?: number;
userId?: number;
canCreate: boolean;
canUpdate: boolean;
canDelete: boolean;
2023-07-08 05:35:43 -05:00
user: OptionalExcluding<User, "username" | "name">;
2023-05-26 23:11:29 -05:00
}
2023-06-16 07:55:21 -05:00
export interface CollectionIncludingMembersAndLinkCount
2023-06-18 00:27:57 -05:00
extends Omit<Collection, "id" | "createdAt" | "ownerId"> {
2023-05-26 23:11:29 -05:00
id?: number;
2023-06-18 00:27:57 -05:00
ownerId?: number;
2023-05-26 23:29:45 -05:00
createdAt?: string;
2023-06-18 00:27:57 -05:00
_count?: { links: number };
2023-05-26 23:11:29 -05:00
members: Member[];
2023-04-24 16:30:40 -05:00
}
2023-05-08 09:35:39 -05:00
2023-05-27 11:53:02 -05:00
export interface AccountSettings extends User {
2023-06-07 14:34:50 -05:00
profilePic: string;
2023-05-27 11:53:02 -05:00
newPassword?: string;
whitelistedUsers: string[];
2023-05-27 11:53:02 -05:00
}
interface LinksIncludingTags extends Link {
tags: Tag[];
}
export interface PublicCollectionIncludingLinks extends Collection {
links: LinksIncludingTags[];
2023-05-29 14:40:23 -05:00
}
2023-06-13 21:44:50 -05:00
export enum Sort {
DateNewestFirst,
DateOldestFirst,
2023-06-13 21:44:50 -05:00
NameAZ,
NameZA,
2023-06-13 23:40:23 -05:00
DescriptionAZ,
DescriptionZA,
2023-06-13 21:44:50 -05:00
}
export type LinkRequestQuery = {
2023-10-23 09:45:48 -05:00
sort: Sort;
2023-06-15 07:39:30 -05:00
cursor?: number;
collectionId?: number;
tagId?: number;
pinnedOnly?: boolean;
2023-10-23 09:45:48 -05:00
searchQueryString?: string;
searchByName?: boolean;
searchByUrl?: boolean;
searchByDescription?: boolean;
searchByTags?: boolean;
};
export type PublicLinkRequestQuery = {
2023-06-15 07:39:30 -05:00
cursor?: number;
collectionId: number;
};
interface CollectionIncludingLinks extends Collection {
links: LinksIncludingTags[];
}
export interface Backup extends Omit<User, "password" | "id" | "image"> {
collections: CollectionIncludingLinks[];
}
2023-09-10 23:20:31 -05:00
2023-10-16 17:27:04 -05:00
export type MigrationRequest = {
format: MigrationFormat;
data: string;
};
export enum MigrationFormat {
linkwarden,
htmlFile,
}
2023-09-10 23:20:31 -05:00
export enum Plan {
monthly,
yearly,
}