-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathindex.ts
130 lines (114 loc) · 2.61 KB
/
index.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
export enum PaginationTypeEnum {
LIMIT_AND_OFFSET = 'limit',
TAKE_AND_SKIP = 'take',
}
export enum CountQueryTypeEnum {
RAW = 'raw',
ENTITY = 'entity',
}
export interface IPaginationOptions<CustomMetaType = IPaginationMeta> {
/**
* @default 10
* the amount of items to be requested per page
*/
limit: number | string;
/**
* @default 1
* the page that is requested
*/
page: number | string;
/**
* a basic route for generating links (i.e., WITHOUT query params)
*/
route?: string;
/**
* For transforming the default meta data to a custom type
*/
metaTransformer?: (meta: IPaginationMeta) => CustomMetaType;
/**
* routingLabels for append in links (limit or/and page)
*/
routingLabels?: IPaginationOptionsRoutingLabels;
/**
* @default PaginationTypeEnum.LIMIT
* Used for changing query method to take/skip (defaults to limit/offset if no argument supplied)
*/
paginationType?: PaginationTypeEnum;
/**
* @default true
* Turn off pagination count total queries. itemCount, totalItems, itemsPerPage and totalPages will be undefined
*/
countQueries?: boolean;
/**
* @default CountQueryTypeEnum.RAW
* Used for count query with countQuery(builder, cacheOptions) which is RAW or builder.getCount() which is ENTITY
*/
countQueryType?: CountQueryTypeEnum;
/**
* @default false
* @link https://orkhan.gitbook.io/typeorm/docs/caching
*
* Enables or disables query result caching.
*/
cacheQueries?: TypeORMCacheType;
}
export type TypeORMCacheType =
| boolean
| number
| {
id: any;
milliseconds: number;
};
export interface ObjectLiteral {
[s: string]: any;
}
export interface IPaginationMeta extends ObjectLiteral {
/**
* the amount of items on this specific page
*/
itemCount: number;
/**
* the total amount of items
*/
totalItems?: number;
/**
* the amount of items that were requested per page
*/
itemsPerPage: number;
/**
* the total amount of pages in this paginator
*/
totalPages?: number;
/**
* the current page this paginator "points" to
*/
currentPage: number;
}
export interface IPaginationLinks {
/**
* a link to the "first" page
*/
first?: string;
/**
* a link to the "previous" page
*/
previous?: string;
/**
* a link to the "next" page
*/
next?: string;
/**
* a link to the "last" page
*/
last?: string;
}
export interface IPaginationOptionsRoutingLabels {
/**
* the limit text to append in router string
*/
limitLabel?: string;
/**
* the page text to append in router string
*/
pageLabel?: string;
}