@tagsamurai/gsts-api-services 2.0.1-alpha.3 → 2.0.1-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/dto/iam.dto.d.ts +85 -0
- package/src/services/iam.service.d.ts +45 -0
- package/src/types/iam.type.d.ts +143 -0
package/package.json
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { QueryParams } from '../types/fetchResponse.type';
|
|
2
|
+
import { ModuleAccess } from '../types/iam.type';
|
|
3
|
+
export interface LoginPayload {
|
|
4
|
+
email: string;
|
|
5
|
+
password: string | null;
|
|
6
|
+
overrideSession: boolean;
|
|
7
|
+
isMobile: boolean;
|
|
8
|
+
otp: string | null;
|
|
9
|
+
captcha: string;
|
|
10
|
+
agreePolicy: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SetPasswordPayload {
|
|
13
|
+
type: 'confirm' | 'reset';
|
|
14
|
+
token: string;
|
|
15
|
+
password: string;
|
|
16
|
+
}
|
|
17
|
+
export interface BaseParams extends QueryParams {
|
|
18
|
+
page?: number;
|
|
19
|
+
limit?: number;
|
|
20
|
+
search?: string;
|
|
21
|
+
sortBy?: string;
|
|
22
|
+
sortOrder?: number;
|
|
23
|
+
column?: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface GetPositionListParams extends BaseParams {
|
|
26
|
+
}
|
|
27
|
+
export interface CreateEditPositionPayload {
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
export interface GetDivisionListParams extends BaseParams {
|
|
31
|
+
}
|
|
32
|
+
export interface CreateEditDivisionPayload {
|
|
33
|
+
name: string;
|
|
34
|
+
}
|
|
35
|
+
export interface CreateUserPayload {
|
|
36
|
+
profilePicture?: File | string;
|
|
37
|
+
firstName: string;
|
|
38
|
+
lastName: string;
|
|
39
|
+
positionId?: string;
|
|
40
|
+
divisionId: string;
|
|
41
|
+
employeeId?: string;
|
|
42
|
+
email: string;
|
|
43
|
+
access: string;
|
|
44
|
+
expiryDate?: string;
|
|
45
|
+
tag?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface GetGlobalUserListParams extends BaseParams {
|
|
48
|
+
isActive?: boolean[];
|
|
49
|
+
position?: string[];
|
|
50
|
+
division?: string[];
|
|
51
|
+
modifiedBy?: string[];
|
|
52
|
+
updatedAt?: string[];
|
|
53
|
+
}
|
|
54
|
+
export type GetGlobalUserOptionsParams = {
|
|
55
|
+
isActiveOptions?: boolean;
|
|
56
|
+
positionOptions?: boolean;
|
|
57
|
+
divisionOptions?: boolean;
|
|
58
|
+
modifiedByOptions?: boolean;
|
|
59
|
+
};
|
|
60
|
+
export interface SetActiveGlobalUserPayload {
|
|
61
|
+
isActive: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface EditUserPayload extends CreateUserPayload {
|
|
64
|
+
}
|
|
65
|
+
export interface EditUserFcmTokenPayload {
|
|
66
|
+
data: {
|
|
67
|
+
userId: string;
|
|
68
|
+
token: string;
|
|
69
|
+
}[];
|
|
70
|
+
}
|
|
71
|
+
export interface ResendActivationEmailPayload {
|
|
72
|
+
ids: string[];
|
|
73
|
+
}
|
|
74
|
+
export interface ChangePasswordPayload {
|
|
75
|
+
oldPassword: string;
|
|
76
|
+
newPassword: string;
|
|
77
|
+
}
|
|
78
|
+
export interface ModuleAuthPayload {
|
|
79
|
+
module: ModuleAccess;
|
|
80
|
+
}
|
|
81
|
+
export interface GetConcurrentUsersParams extends BaseParams {
|
|
82
|
+
}
|
|
83
|
+
export interface LogoutSessionPayload {
|
|
84
|
+
sessionId: string;
|
|
85
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { DropdownOption } from '../types/options.type';
|
|
3
|
+
import { FetchDetailResponse, FetchListResponse } from '../types/fetchResponse.type';
|
|
4
|
+
import { CreateEditDivisionPayload, CreateEditPositionPayload, GetDivisionListParams, GetPositionListParams, LoginPayload, SetPasswordPayload, CreateUserPayload, GetGlobalUserListParams, GetGlobalUserOptionsParams, SetActiveGlobalUserPayload, EditUserPayload, EditUserFcmTokenPayload, ResendActivationEmailPayload, ChangePasswordPayload, ModuleAuthPayload, GetConcurrentUsersParams, LogoutSessionPayload } from '../dto/iam.dto';
|
|
5
|
+
import { PositionList, LoginResponse, RequestOtpResponse, RequestResetLinkResponse, DivisionList, DivisionListDetail, GlobalUserList, GlobalUserOptions, GlobalUserDetail, LoginModuleResponse, ConcurrentUserList, VerifyTokenResponse, PositionDetail, ChangePasswordResponse } from '../types/iam.type';
|
|
6
|
+
declare const IamServices: {
|
|
7
|
+
login: (payload: LoginPayload) => Promise<AxiosResponse<FetchDetailResponse<LoginResponse>>>;
|
|
8
|
+
logout: () => Promise<AxiosResponse>;
|
|
9
|
+
verifyToken: (token: string) => Promise<AxiosResponse<FetchDetailResponse<VerifyTokenResponse>>>;
|
|
10
|
+
requestOtp: (email: string) => Promise<AxiosResponse<RequestOtpResponse>>;
|
|
11
|
+
requestResetLink: (email: string) => Promise<AxiosResponse<RequestResetLinkResponse>>;
|
|
12
|
+
setPassword: (payload: SetPasswordPayload) => Promise<AxiosResponse>;
|
|
13
|
+
confirmEmailChange: (token: string) => Promise<AxiosResponse>;
|
|
14
|
+
cancelEmailChange: (token: string) => Promise<AxiosResponse>;
|
|
15
|
+
getPositionList: (params: GetPositionListParams) => Promise<AxiosResponse<FetchListResponse<PositionList>>>;
|
|
16
|
+
getPositionDetail: (id: string) => Promise<AxiosResponse<FetchDetailResponse<PositionDetail>>>;
|
|
17
|
+
createPosition: (payload: CreateEditPositionPayload) => Promise<AxiosResponse>;
|
|
18
|
+
editPosition: (id: string, payload: CreateEditPositionPayload) => Promise<AxiosResponse>;
|
|
19
|
+
deletePosition: (ids: string[]) => Promise<AxiosResponse>;
|
|
20
|
+
getDivisionList: (params: GetDivisionListParams) => Promise<AxiosResponse<FetchListResponse<DivisionList>>>;
|
|
21
|
+
getDivisionDetail: (id: string) => Promise<AxiosResponse<FetchDetailResponse<DivisionListDetail>>>;
|
|
22
|
+
createDivision: (payload: CreateEditDivisionPayload) => Promise<AxiosResponse>;
|
|
23
|
+
editDivision: (id: string, payload: CreateEditDivisionPayload) => Promise<AxiosResponse>;
|
|
24
|
+
deleteDivision: (ids: string[]) => Promise<AxiosResponse>;
|
|
25
|
+
createUsers: (payload: CreateUserPayload) => Promise<AxiosResponse>;
|
|
26
|
+
getGlobalUserList: (params: GetGlobalUserListParams) => Promise<AxiosResponse<FetchListResponse<GlobalUserList>>>;
|
|
27
|
+
getGlobalUserOptions: (params: GetGlobalUserOptionsParams) => Promise<AxiosResponse<FetchDetailResponse<GlobalUserOptions>>>;
|
|
28
|
+
getGlobalUserDetail: (id: string) => Promise<AxiosResponse<FetchDetailResponse<GlobalUserDetail>>>;
|
|
29
|
+
setActiveGlobalUser: (ids: string[], payload: SetActiveGlobalUserPayload) => Promise<AxiosResponse>;
|
|
30
|
+
editUsers: (id: string, payload: EditUserPayload) => Promise<AxiosResponse>;
|
|
31
|
+
editUsersFcmToken: (payload: EditUserFcmTokenPayload) => Promise<AxiosResponse>;
|
|
32
|
+
resendActivationEmail: (payload: ResendActivationEmailPayload) => Promise<AxiosResponse>;
|
|
33
|
+
changePassword: (id: string, payload: ChangePasswordPayload) => Promise<AxiosResponse<ChangePasswordResponse>>;
|
|
34
|
+
deleteUsers: (ids: string[]) => Promise<AxiosResponse>;
|
|
35
|
+
logoutModule: (payload: ModuleAuthPayload) => Promise<AxiosResponse>;
|
|
36
|
+
loginModule: (payload: ModuleAuthPayload) => Promise<AxiosResponse<FetchDetailResponse<LoginModuleResponse>>>;
|
|
37
|
+
getConcurrentUsers: (params: GetConcurrentUsersParams, moduleId?: string) => Promise<AxiosResponse<FetchDetailResponse<ConcurrentUserList>>>;
|
|
38
|
+
logoutSession: (payload: LogoutSessionPayload, moduleId?: string) => Promise<AxiosResponse>;
|
|
39
|
+
getPositionDropdown: () => Promise<AxiosResponse<FetchDetailResponse<DropdownOption[]>>>;
|
|
40
|
+
getDivisionDropdown: () => Promise<AxiosResponse<FetchDetailResponse<DropdownOption[]>>>;
|
|
41
|
+
exportPositionTable: () => Promise<AxiosResponse<Blob>>;
|
|
42
|
+
exportDivisionTable: () => Promise<AxiosResponse<Blob>>;
|
|
43
|
+
exportUserTable: () => Promise<AxiosResponse<Blob>>;
|
|
44
|
+
};
|
|
45
|
+
export default IamServices;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { MultiSelectOption } from './options.type';
|
|
2
|
+
export interface LoginResponse {
|
|
3
|
+
_id: string;
|
|
4
|
+
companyName: string;
|
|
5
|
+
companyCode: string;
|
|
6
|
+
fullName: string;
|
|
7
|
+
profilePicture: string;
|
|
8
|
+
email: string;
|
|
9
|
+
isDefault: boolean;
|
|
10
|
+
access: string[];
|
|
11
|
+
generalSetting: {
|
|
12
|
+
dateFormat: string;
|
|
13
|
+
timeFormat: string;
|
|
14
|
+
timezone: string;
|
|
15
|
+
currency: {
|
|
16
|
+
currency: string;
|
|
17
|
+
symbol: string;
|
|
18
|
+
locale: string;
|
|
19
|
+
label: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
type BaseMessage = string & {};
|
|
24
|
+
export interface VerifyTokenResponse {
|
|
25
|
+
message: 'Token Verified!' | 'Token not found' | 'Internal server error' | BaseMessage;
|
|
26
|
+
data: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface BaseResponse<TMessage> {
|
|
29
|
+
status: number;
|
|
30
|
+
message: TMessage;
|
|
31
|
+
data?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export type RequestResetLinkMessage = 'EMAIL_NOT_REGISTERED' | BaseMessage;
|
|
34
|
+
export type RequestOtpMessage = 'Successfully requested otp' | 'EMAIL_NOT_REGISTERED' | 'INACTIVE_USER' | BaseMessage;
|
|
35
|
+
export interface RequestResetLinkResponse extends BaseResponse<RequestResetLinkMessage> {
|
|
36
|
+
}
|
|
37
|
+
export interface RequestOtpResponse extends BaseResponse<RequestOtpMessage> {
|
|
38
|
+
}
|
|
39
|
+
interface BasePosition {
|
|
40
|
+
_id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
}
|
|
43
|
+
export interface PositionList extends BasePosition {
|
|
44
|
+
inUse: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface PositionDetail extends BasePosition {
|
|
47
|
+
}
|
|
48
|
+
interface BaseDivision {
|
|
49
|
+
_id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
}
|
|
52
|
+
export interface DivisionList extends BaseDivision {
|
|
53
|
+
inUse: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface DivisionListDetail extends BaseDivision {
|
|
56
|
+
}
|
|
57
|
+
export interface ChangePasswordResponse {
|
|
58
|
+
status?: number;
|
|
59
|
+
message?: 'INCORRECT_PASSWORD' | BaseMessage;
|
|
60
|
+
}
|
|
61
|
+
export interface GlobalUserList {
|
|
62
|
+
_id: string;
|
|
63
|
+
isActive: boolean;
|
|
64
|
+
isDefault: boolean;
|
|
65
|
+
profilePicture: string | null;
|
|
66
|
+
fullName: string;
|
|
67
|
+
email: string;
|
|
68
|
+
position: string | null;
|
|
69
|
+
division: string;
|
|
70
|
+
employeeId: string | null;
|
|
71
|
+
modifiedBy: string;
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
pendingApproval: number;
|
|
74
|
+
assignedAssets: number;
|
|
75
|
+
borrowedAssets: number;
|
|
76
|
+
isEmailConfirmed: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface GlobalUserOptions {
|
|
79
|
+
isActiveOptions: {
|
|
80
|
+
label: string;
|
|
81
|
+
value: boolean;
|
|
82
|
+
}[];
|
|
83
|
+
positionOptions: MultiSelectOption[];
|
|
84
|
+
divisionOptions: MultiSelectOption[];
|
|
85
|
+
modifiedByOptions: MultiSelectOption[];
|
|
86
|
+
}
|
|
87
|
+
export type ModuleAccess = 'Global Settings' | 'Fixed Asset' | 'Supply Asset' | 'Admin Console';
|
|
88
|
+
export interface GlobalUserDetail {
|
|
89
|
+
_id: string;
|
|
90
|
+
isActive: boolean;
|
|
91
|
+
isDefault: boolean;
|
|
92
|
+
isEmailConfirmed: boolean;
|
|
93
|
+
profilePicture: string | null;
|
|
94
|
+
userTag: string | null;
|
|
95
|
+
userType: string;
|
|
96
|
+
firstName: string;
|
|
97
|
+
lastName: string;
|
|
98
|
+
fullName: string;
|
|
99
|
+
email: string;
|
|
100
|
+
pendingEmailChange: string | null;
|
|
101
|
+
position: string | null;
|
|
102
|
+
division: string;
|
|
103
|
+
employeeId: string | null;
|
|
104
|
+
expiryDate: string | null;
|
|
105
|
+
access: (ModuleAccess | BaseMessage)[];
|
|
106
|
+
}
|
|
107
|
+
export interface LoginModuleResponse extends LoginResponse {
|
|
108
|
+
isTotalControl: boolean;
|
|
109
|
+
isReadOnly: boolean;
|
|
110
|
+
plan: string;
|
|
111
|
+
addOn: Record<string, boolean>;
|
|
112
|
+
systemRoles: Record<string, {
|
|
113
|
+
create: boolean;
|
|
114
|
+
view: boolean;
|
|
115
|
+
update: boolean;
|
|
116
|
+
delete: boolean;
|
|
117
|
+
}>;
|
|
118
|
+
transactionRoles: Record<string, {
|
|
119
|
+
manager: boolean;
|
|
120
|
+
monitoringReport: boolean;
|
|
121
|
+
approver: boolean;
|
|
122
|
+
staff: boolean;
|
|
123
|
+
}>;
|
|
124
|
+
generalSetting: LoginResponse['generalSetting'] & {
|
|
125
|
+
geolocation: boolean;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export interface ConcurrentUser {
|
|
129
|
+
_id: string;
|
|
130
|
+
profilePicture: string;
|
|
131
|
+
name: string;
|
|
132
|
+
email: string;
|
|
133
|
+
userType: string;
|
|
134
|
+
position: string;
|
|
135
|
+
division: string;
|
|
136
|
+
lastLogin: string;
|
|
137
|
+
}
|
|
138
|
+
export interface ConcurrentUserList {
|
|
139
|
+
moduleId: string;
|
|
140
|
+
activeSessions: ConcurrentUser[];
|
|
141
|
+
count: number;
|
|
142
|
+
}
|
|
143
|
+
export {};
|