added cursor based pagination for links

This commit is contained in:
Daniel
2023-06-15 02:04:54 +03:30
parent 6323badbaf
commit 1b6d902c75
29 changed files with 507 additions and 182 deletions
+36 -8
View File
@@ -3,7 +3,7 @@ import { Collection, Link, Tag, User } from "@prisma/client";
type OptionalExcluding<T, TRequired extends keyof T> = Partial<T> &
Pick<T, TRequired>;
export interface LinkIncludingCollectionAndTags
export interface LinkIncludingShortenedCollectionAndTags
extends Omit<Link, "id" | "createdAt" | "collectionId"> {
id?: number;
createdAt?: string;
@@ -12,7 +12,10 @@ export interface LinkIncludingCollectionAndTags
pinnedBy?: {
id: number;
}[];
collection: OptionalExcluding<Collection, "name" | "ownerId">;
collection: OptionalExcluding<
Pick<Collection, "id" | "ownerId" | "name" | "color">,
"name" | "ownerId"
>;
}
export interface Member {
@@ -37,17 +40,42 @@ export interface AccountSettings extends User {
newPassword?: string;
}
export interface PublicCollectionIncludingLinks
extends Omit<Collection, "ownerId"> {
ownerName?: string;
links: Link[];
interface LinksIncludingTags extends Link {
tags: Tag[];
}
export interface PublicCollectionIncludingLinks extends Collection {
links: LinksIncludingTags[];
}
export enum Sort {
DateNewestFirst,
DateOldestFirst,
NameAZ,
NameZA,
DescriptionAZ,
DescriptionZA,
DateNewestFirst,
DateOldestFirst,
}
export type LinkSearchFilter = {
name: boolean;
url: boolean;
description: boolean;
collection: boolean;
tags: boolean;
};
export type LinkRequestQuery = {
cursor?: string;
collectionId?: number;
tagId?: number;
sort?: Sort;
searchFilter?: LinkSearchFilter;
searchQuery?: string;
pinnedOnly?: boolean;
};
export type PublicLinkRequestQuery = {
cursor?: string;
collectionId?: number;
};