el.xwx.moe/types/global.ts

152 lines
2.7 KiB
TypeScript
Raw Normal View History

2023-05-22 07:20:48 -05:00
import { Collection, Link, Tag, User } from "@prisma/client";
import Stripe from "stripe";
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-11-02 13:59:31 -05:00
extends Omit<
Link,
2024-03-27 02:27:59 -05:00
| "id"
| "createdAt"
| "collectionId"
| "updatedAt"
| "lastPreserved"
| "importDate"
2023-11-02 13:59:31 -05:00
> {
2023-05-27 11:29:39 -05:00
id?: number;
createdAt?: string;
2024-03-27 02:27:59 -05:00
importDate?: string;
2023-05-27 11:29:39 -05:00
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;
2023-10-28 00:42:31 -05:00
userId: number;
2023-05-26 23:11:29 -05:00
canCreate: boolean;
canUpdate: boolean;
canDelete: boolean;
2023-10-28 00:42:31 -05:00
user: OptionalExcluding<User, "username" | "name" | "id">;
2023-05-26 23:11:29 -05:00
}
2023-06-16 07:55:21 -05:00
export interface CollectionIncludingMembersAndLinkCount
2023-11-07 07:03:35 -06:00
extends Omit<Collection, "id" | "createdAt" | "ownerId" | "updatedAt"> {
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;
2024-03-01 08:33:58 -06:00
updatedAt?: 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-11-15 12:12:06 -06:00
export interface TagIncludingLinkCount extends Tag {
_count?: { links: number };
}
2023-05-27 11:53:02 -05:00
export interface AccountSettings extends User {
newPassword?: string;
whitelistedUsers: string[];
subscription?: {
active?: boolean;
};
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
2023-12-15 21:25:39 -06:00
export enum ViewMode {
2023-12-21 09:55:07 -06:00
Card = "card",
2023-12-16 14:06:26 -06:00
Grid = "grid",
2023-12-15 22:57:50 -06:00
List = "list",
2023-12-15 21:25:39 -06: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;
2023-11-01 05:01:26 -05:00
searchByTextContent?: boolean;
2023-10-23 09:45:48 -05:00
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"> {
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,
}
export type DeleteUserBody = {
password: string;
cancellation_details?: {
comment?: string;
feedback?: Stripe.SubscriptionCancelParams.CancellationDetails.Feedback;
};
};
2023-11-19 15:22:27 -06:00
export enum ArchivedFormat {
2023-11-25 02:19:02 -06:00
png,
jpeg,
2023-11-19 15:22:27 -06:00
pdf,
readability,
}
2023-11-25 02:19:02 -06:00
export enum LinkType {
url,
pdf,
image,
}
2024-01-13 00:20:06 -06:00
export enum TokenExpiry {
2024-01-13 00:20:06 -06:00
sevenDays,
oneMonth,
twoMonths,
threeMonths,
never,
}