@getjones/test-infra 2.9.8 → 2.9.9
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/common/utils/configsUtil.js +22 -0
- package/src/common/utils/timeUtils.js +2 -0
- package/src/defaults/configs/polices.js +6 -2
- package/src/saas/internal-api/accounts/utils/utils.js +4 -12
- package/src/saas/internal-api/requirements/models/policy.model.js +1 -0
- package/src/saas/internal-api/users/api/users.api.js +6 -1
- package/src/saas/internal-api/users/api/users.service.js +31 -2
- package/src/saas/internal-api/users/models/users.model.js +11 -1
- package/src/saas/internal-api/users/utils/util.js +20 -1
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const isUIConfig = (config, attributesConvertor) => {
|
|
2
|
+
const converterKeys = Object.keys(attributesConvertor);
|
|
3
|
+
const configKeys = Object.keys(config);
|
|
4
|
+
|
|
5
|
+
return converterKeys.some(key => configKeys.includes(key));
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const objectConvertor = (config, attributesConvertor) => {
|
|
9
|
+
const covertConfig = {};
|
|
10
|
+
|
|
11
|
+
for (const field in config) {
|
|
12
|
+
const attributes = attributesConvertor[field];
|
|
13
|
+
covertConfig[attributes] = JSON.parse(config[field]);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return covertConfig;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
isUIConfig,
|
|
21
|
+
objectConvertor
|
|
22
|
+
};
|
|
@@ -21,7 +21,8 @@ const policyNames = {
|
|
|
21
21
|
agreement: 'Agreement',
|
|
22
22
|
certificateHolder: 'Certificate Holder',
|
|
23
23
|
additionalInformation: 'Additional Information',
|
|
24
|
-
additionalInsured: 'Additional Insured'
|
|
24
|
+
additionalInsured: 'Additional Insured',
|
|
25
|
+
businessInterruptionIncomeInsurance: 'Business Interruption / Income Insurance'
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
const attributeNames = {
|
|
@@ -40,7 +41,10 @@ const attributeNames = {
|
|
|
40
41
|
coiAuthentication: 'COI authentication',
|
|
41
42
|
signature: 'Signature',
|
|
42
43
|
occur: 'Occur',
|
|
43
|
-
text: 'text'
|
|
44
|
+
text: 'text',
|
|
45
|
+
indemnityPeriod: 'Indemnity Period',
|
|
46
|
+
actualLossSustained: 'Actual Loss Sustained',
|
|
47
|
+
extraExpense: 'Extra Expense'
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
module.exports = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const coreService = require('../api/core/accounts.core.service');
|
|
2
2
|
const CreateAccountModel = require('../models/core/create.account.model');
|
|
3
|
+
const configsUtil = require('../../../../common/utils/configsUtil');
|
|
3
4
|
|
|
4
5
|
const getOrCreateAccount = (context, accountName, email, { password, type } = {}) => {
|
|
5
6
|
const createAccountModel = new CreateAccountModel(
|
|
@@ -30,21 +31,12 @@ const deleteAccountByName = async (context, accountName) => {
|
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
const isUIConfig = config => {
|
|
33
|
-
|
|
34
|
-
const configKeys = Object.keys(config);
|
|
35
|
-
|
|
36
|
-
return convectorKeys.some(key => configKeys.includes(key));
|
|
34
|
+
return configsUtil.isUIConfig(config, attributesConvertor);
|
|
37
35
|
};
|
|
38
36
|
|
|
39
37
|
const parseAccountSettingsConfig = (accountId, settingsConfig) => {
|
|
40
|
-
const settings =
|
|
41
|
-
|
|
42
|
-
for (const field in settingsConfig) {
|
|
43
|
-
const attributes = attributesConvertor[field];
|
|
44
|
-
settings[attributes] = JSON.parse(settingsConfig[field]);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return settings;
|
|
38
|
+
const settings = configsUtil.objectConvertor(settingsConfig, attributesConvertor);
|
|
39
|
+
return { ... settings, accountId };
|
|
48
40
|
};
|
|
49
41
|
|
|
50
42
|
module.exports = {
|
|
@@ -5,6 +5,7 @@ const Endpoints = {
|
|
|
5
5
|
invite: `${backendUrl}/saas/project/team-member`,
|
|
6
6
|
editUserProjects: `${backendUrl}/saas/project/team-member`,
|
|
7
7
|
editUserRole: userId => `${backendUrl}/secured/users/${userId}/change-role`,
|
|
8
|
+
editUserProfile: `${backendUrl}/saas/user/update`,
|
|
8
9
|
getByProjectId: projectId =>
|
|
9
10
|
`${backendUrl}/saas/project/${projectId}/team-members`,
|
|
10
11
|
getByEmail: email => `${backendUrl}/saas/team-member/by-email/${email}`,
|
|
@@ -84,6 +85,9 @@ const sendForgetPasswordMail = userEmail => {
|
|
|
84
85
|
const body = { email: userEmail };
|
|
85
86
|
return requests.postRequestHandler(Endpoints.sendForgetPasswordMail, body);
|
|
86
87
|
};
|
|
88
|
+
const editUserProfile = (editUserProfileModel, context) => {
|
|
89
|
+
return requests.postRequestHandler(Endpoints.editUserProfile, editUserProfileModel, context);
|
|
90
|
+
};
|
|
87
91
|
|
|
88
92
|
module.exports = {
|
|
89
93
|
invite,
|
|
@@ -100,5 +104,6 @@ module.exports = {
|
|
|
100
104
|
editUserEmailNotificationsSettings,
|
|
101
105
|
sendForgetPasswordMail,
|
|
102
106
|
createInnerSystemUser,
|
|
103
|
-
getInnerSystemUsersPerRole
|
|
107
|
+
getInnerSystemUsersPerRole,
|
|
108
|
+
editUserProfile
|
|
104
109
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { InviteUserModel, SignupUserModel, EditUserModel } = require('../models/users.model');
|
|
1
|
+
const { InviteUserModel, SignupUserModel, EditUserModel, EditUserProfileModel } = require('../models/users.model');
|
|
2
2
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
3
3
|
const { getEnv } = require('../../../../env');
|
|
4
4
|
const { credentials } = getEnv();
|
|
@@ -147,6 +147,33 @@ const sendForgetPasswordMail = userEmail => {
|
|
|
147
147
|
return userAPI.sendForgetPasswordMail(userEmail);
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
+
const editUserProfile = async (email, fullName, context) => {
|
|
151
|
+
const { data: user } = await getUserByEmail(email, context);
|
|
152
|
+
|
|
153
|
+
const editUserProfileModel = new EditUserProfileModel(user.id, email, user.role, fullName);
|
|
154
|
+
|
|
155
|
+
const response = await userAPI.editUserProfile(editUserProfileModel, context);
|
|
156
|
+
|
|
157
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
158
|
+
throw Error(`Failed to edit user id: [${user.id}] profile\n${response}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return getUserByEmail(email, context);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const editUserSettings = async (email, config, context) => {
|
|
165
|
+
const { data: user } = await getUserByEmail(email, context);
|
|
166
|
+
const settingModel = util.getSettingsModel(config);
|
|
167
|
+
|
|
168
|
+
const response = await userAPI.editUserEmailNotificationsSettings(user.id, settingModel, context);
|
|
169
|
+
|
|
170
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
171
|
+
throw Error(`Failed to edit user id: [${user.id}] settings\n${response}`);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return getUserByEmail(email, context);
|
|
175
|
+
};
|
|
176
|
+
|
|
150
177
|
module.exports = {
|
|
151
178
|
inviteUser,
|
|
152
179
|
signupUser,
|
|
@@ -162,5 +189,7 @@ module.exports = {
|
|
|
162
189
|
reinviteUser,
|
|
163
190
|
editUserEmailNotificationsSettings,
|
|
164
191
|
sendForgetPasswordMail,
|
|
165
|
-
getOrCreateInnerSystemUser
|
|
192
|
+
getOrCreateInnerSystemUser,
|
|
193
|
+
editUserProfile,
|
|
194
|
+
editUserSettings
|
|
166
195
|
};
|
|
@@ -24,8 +24,18 @@ class EditUserModel {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
class EditUserProfileModel {
|
|
28
|
+
constructor(subUserId, email, role, fullName) {
|
|
29
|
+
this.subUserId = subUserId;
|
|
30
|
+
this.email = email;
|
|
31
|
+
this.role = role;
|
|
32
|
+
this.fullName = fullName;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
module.exports = {
|
|
28
37
|
InviteUserModel,
|
|
29
38
|
SignupUserModel,
|
|
30
|
-
EditUserModel
|
|
39
|
+
EditUserModel,
|
|
40
|
+
EditUserProfileModel
|
|
31
41
|
};
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
const { SignupUserModel } = require('../models/users.model');
|
|
2
|
+
const { NotificationSettingsModel } = require('../models/notification.settings.model');
|
|
2
3
|
const usersApi = require('../api/users.api');
|
|
3
4
|
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
5
|
+
const objectUtils = require('../../../../common/utils/configsUtil');
|
|
6
|
+
|
|
7
|
+
const attributesConvertor = {
|
|
8
|
+
'COI is not compliant.': 'auditNotCompliant',
|
|
9
|
+
'Policy is about to expire.': 'aboutToExpire',
|
|
10
|
+
'COI is compliant.': 'auditCompliant',
|
|
11
|
+
'Unresponsive contact.': 'missingCoi'
|
|
12
|
+
};
|
|
4
13
|
|
|
5
14
|
const getUserEncryptedData = async (email, role, context) => {
|
|
6
15
|
const response = await usersApi.getUserEncryptedData(email, role, context);
|
|
@@ -17,4 +26,14 @@ const getSignupUserModel = async (email, role, fullName, password, context) => {
|
|
|
17
26
|
return new SignupUserModel(fullName, role, password, userEncryptedData);
|
|
18
27
|
};
|
|
19
28
|
|
|
20
|
-
|
|
29
|
+
const getSettingsModel = settings => {
|
|
30
|
+
const isUIConfig = objectUtils.isUIConfig(settings, attributesConvertor);
|
|
31
|
+
|
|
32
|
+
const settingConfig = isUIConfig ?
|
|
33
|
+
objectUtils.objectConvertor(settings, attributesConvertor) :
|
|
34
|
+
settings;
|
|
35
|
+
|
|
36
|
+
return new NotificationSettingsModel(settingConfig);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
module.exports = { getSignupUserModel, getSettingsModel };
|