-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.model.ts
98 lines (95 loc) · 2.7 KB
/
search.model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* Enum to determine @see SearchTag.type
* @property {SearchTagType.Fuzzy} Fuzzy /default) - search fuzzily for a tag/keyword
* @property {SearchTagType.DoInclude} DoInclude - Must have described Tag Name
* @property {SearchTagType.DoNotInclude} DoNotInclude - Must not have described Tag Name
*/
export enum SearchTagType {
Include,
Exclude,
Fuzzy
}
export enum SearchSortTypes {
DateAdded = 'date_added',
Relevance = 'relevance',
Random = 'random',
Views = 'views',
Favorites = 'favorites',
Toplist = 'toplist'
}
interface SearchTag {
required?: boolean;
type: SearchTagType;
name: string;
}
interface SearchCategories {
showGeneral: boolean;
showAnime?: boolean;
showPeople?: boolean;
}
export interface SearchPurity {
sfw: boolean;
sketchy?: boolean;
nsfw?: boolean;
}
/**
* self explained
* @param {number} x - width
* @param {number} y - height
*/
interface SearchResolution {
x: number;
y: number;
}
export enum SortRange {
OneDay = '1d',
ThreeDays = '3d',
OneWeek = '1w',
OneMonth = '1M',
ThreeMonths = '3M',
SixMonths = '6M',
OneYear = '1y'
// '1d' | '3d' | '1w' | '1M' | '3M' | '6M' | '1y'
}
interface SearchSorting {
type: SearchSortTypes;
order: 'asc' | 'desc';
}
export enum SearchFileType {
PNG = 'png',
JPG = 'jpg'
}
/**
* self explained ex:. 16:9, x = 16, y = 9
* @param {number} x - y Ratio ex:. 9
* @param {number} y - x Ratio ex:. 16
*/
interface Ratio { x: number; y: number; }
/**
* SearchQuery Model for the Search Method
* @param {string} search - search by string (fuzzy search will be used for that)
* @param {SearchTag[]?} tags - Tag Filtering
* @param {SearchCategories?} categories - Set categories to filter for
* @param {SearchPurity?} purity - Set purtiy to filter for
* @param {SearchSorting?} sorting - Set sorting filter to get either the latest, popular, your favorites or randomly picked
* @param {SortRange?} topRange - filter by created_at on toplist sorting
* @param {SearchResolution?} atleast - Minimum resolution allowed
* @param {SearchResolution[]?} resolutions - List of exact wallpaper resolutions Single resolution allowed
* @param {Ratio[]?} ratio - List of aspect ratios, Single ratio allowed
* @param {string[]?} colors - Search by color
* @param {number} page - Pagination, defaults to 0
*/
export interface SearchQuery {
search: string;
tags?: SearchTag[];
categories?: SearchCategories;
purity?: SearchPurity;
sorting?: SearchSorting;
topRange?: SortRange;
atleast?: SearchResolution;
resolutions?: SearchResolution[];
ratios?: Ratio[];
colors?: string[];
page?: number;
fileType?: SearchFileType;
}