-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtypes.ts
57 lines (46 loc) · 1.23 KB
/
types.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
import {
FindOptionsOrder,
FindOptionsRelations,
FindOptionsSelect,
} from 'typeorm';
import { IPagination } from './custom.input';
import { IWhere } from './utils/types';
export const valueObj = {
ASC: 'ASC',
DESC: 'DESC',
asc: 'asc',
desc: 'desc',
1: 1,
'-1': -1,
} as const;
const direction = ['ASC', 'DESC', 'asc', 'desc'] as const;
type DirectionUnion = (typeof direction)[number];
const nulls = ['first', 'last', 'FIRST', 'LAST'] as const;
type NullsUnion = (typeof nulls)[number];
export const checkObject = {
direction,
nulls,
};
export const directionObj = {
direction: 'direction',
nulls: 'nulls',
} as const;
type IDirectionWitnNulls = {
[directionObj.direction]?: DirectionUnion;
[directionObj.nulls]?: NullsUnion;
};
export type IDriection = (typeof valueObj)[keyof typeof valueObj];
export type ISort = IDriection | IDirectionWitnNulls;
export interface IGetData<T> {
data?: T[];
count?: number;
}
export interface RepoQuery<T> {
pagination?: IPagination;
where?: IWhere<T>;
order?: FindOptionsOrder<T>;
relations?: FindOptionsRelations<T>;
select?: FindOptionsSelect<T>;
}
export type OneRepoQuery<T> = Required<Pick<RepoQuery<T>, 'where'>> &
Pick<RepoQuery<T>, 'relations' | 'select'>;