1
+ import { Request , Response } from "express" ;
2
+ import { REQUEST_STATE } from "../constants/requests" ;
3
+ import { Boom } from "express-boom" ;
4
+ import { RequestQuery } from "./requests" ;
5
+ import { userData } from "./global" ;
6
+ import { Timestamp } from "firebase-admin/firestore" ;
7
+
8
+ export type ImpersonationRequest = {
9
+ id : string ;
10
+ status : REQUEST_STATE ;
11
+ isImpersonationFinished : boolean ;
12
+ createdBy : string ;
13
+ createdFor : string ;
14
+ userId : string ;
15
+ reason : string ;
16
+ message ?: string ;
17
+ impersonatedUserId : string ;
18
+ createdAt : Timestamp ;
19
+ updatedAt : Timestamp ;
20
+ startedAt ?: Timestamp ;
21
+ endedAt ?: Timestamp ;
22
+ }
23
+
24
+ export type CreateImpersonationRequestBody = {
25
+ impersonatedUserId : string ;
26
+ reason : string ;
27
+ } ;
28
+
29
+ export type CreateImpersonationRequestModelBody = {
30
+ status : REQUEST_STATE ;
31
+ isImpersonationFinished : boolean ;
32
+ createdBy : string ;
33
+ createdFor : string ;
34
+ userId : string ;
35
+ reason : string ;
36
+ impersonatedUserId : string ;
37
+ }
38
+
39
+ export type UpdateImpersonationRequestDataBody = {
40
+ startedAt ?: Timestamp ;
41
+ endedAt : Timestamp ;
42
+ isImpersonationFinished ?: boolean ;
43
+ }
44
+
45
+ export type UpdateImpersonationRequestStatusBody = {
46
+ status : REQUEST_STATE . APPROVED | REQUEST_STATE . REJECTED ;
47
+ message ?: string ;
48
+ }
49
+
50
+ export type ImpersonationRequestQuery = RequestQuery & {
51
+ dev ?: string ;
52
+ } ;
53
+
54
+ export type ImpersonationRequestResponse = Response & {
55
+ boom : Boom ;
56
+ } ;
57
+
58
+ export type RequestParams = {
59
+ id : string ;
60
+ }
61
+
62
+ export type CreateImpersonationRequest = Request & {
63
+ userData : userData ;
64
+ body : CreateImpersonationRequestBody ;
65
+ query : ImpersonationRequestQuery ;
66
+ } ;
67
+
68
+ export type UpdateImpersonationRequestStatus = Request & {
69
+ userData : userData ;
70
+ body : UpdateImpersonationRequestStatusBody ;
71
+ query : ImpersonationRequestQuery ;
72
+ params : RequestParams ;
73
+ }
74
+
75
+ export type PaginatedImpersonationRequests = {
76
+ allRequests : ImpersonationRequest [ ] ;
77
+ next : string ;
78
+ prev : string ;
79
+ page : number ;
80
+ count : number ;
81
+ }
0 commit comments