@getjones/test-infra 2.7.6 → 2.7.8
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/saas/internal-api/accounts/api/settings/settings.service.js +1 -1
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +3 -1
- package/src/saas/internal-api/contractors/api/contractors.service.js +2 -2
- package/src/saas/internal-api/projects/api/settings/project.settings.service.js +19 -1
- package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +30 -26
- package/src/saas/internal-api/projects/utils/utils.js +75 -1
- package/src/saas/internal-api/requests/api/requests.service.js +5 -5
- package/src/saas/internal-api/requests/models/create.request.model.js +21 -15
- package/src/saas/internal-api/requirements/api/requirements.service.js +12 -1
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ const setAccountSettings = async (accountId, settings, context) => {
|
|
|
27
27
|
const updateResponse = await updateAccountSettings(settingsModel, context);
|
|
28
28
|
|
|
29
29
|
if (updateResponse.status !== httpResponseStatusCodes.OK) {
|
|
30
|
-
throw new Error(`Failed to set account: ${accountId} settings\n${updateResponse}`);
|
|
30
|
+
throw new Error(`Failed to set account: ${accountId} settings\n${updateResponse.data}`);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
return updateResponse;
|
|
@@ -10,7 +10,8 @@ class UpdateAccountSettingsModel {
|
|
|
10
10
|
isCoverageAudit = false,
|
|
11
11
|
isAccountRequirementsEnabled = false,
|
|
12
12
|
isAccountRequirementsAutoRenewalsEnabled = false,
|
|
13
|
-
autoGaps = {}
|
|
13
|
+
autoGaps = {},
|
|
14
|
+
auditSlaHours = 24
|
|
14
15
|
} = {}
|
|
15
16
|
) {
|
|
16
17
|
this.accountId = accountId;
|
|
@@ -23,6 +24,7 @@ class UpdateAccountSettingsModel {
|
|
|
23
24
|
this.isAccountRequirementsEnabled = isAccountRequirementsEnabled;
|
|
24
25
|
this.isAccountRequirementsAutoRenewalsEnabled = isAccountRequirementsAutoRenewalsEnabled;
|
|
25
26
|
this.autoGaps = { ... DEFAULT_AUTO_GAPS, ... autoGaps };
|
|
27
|
+
this.auditSlaHours = auditSlaHours;
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -127,9 +127,9 @@ const deleteAllRecordsInAccount = async (accountId, context, { activationStatus
|
|
|
127
127
|
}
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
const getRecordVerificationModel = async (recordId, context) => {
|
|
130
|
+
const getRecordVerificationModel = async (recordId, context, { requirementId, requirementDateModified } = {}) => {
|
|
131
131
|
const { data: recordData } = await getContractorById(recordId, context);
|
|
132
|
-
return new RecordModifyDateVerificationModel(recordData.id, { contractorDateModified: recordData.dateModified });
|
|
132
|
+
return new RecordModifyDateVerificationModel(recordData.id, { contractorDateModified: recordData.dateModified, requirementId, requirementDateModified });
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
const getAssignRequirementModel = (requirementId, companyName, emailAddress) => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const { getProjectSettingsByProjectId, updateProjectSettingsByProjectId } = require('./project.settings.api');
|
|
2
2
|
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
3
3
|
const UpdateProjectSettingsModel = require('../../models/settings/update.project.settings.model');
|
|
4
|
+
const util = require('../../utils/utils');
|
|
5
|
+
const httpResponseStatusCodes = require('../../../../../common/httpResponseStatusCodes.json');
|
|
4
6
|
|
|
5
7
|
const updateProjectSettings = (updateProjectSettingsModel, context) => {
|
|
6
8
|
validateType(updateProjectSettingsModel, UpdateProjectSettingsModel);
|
|
@@ -11,7 +13,23 @@ const getProjectSettings = (projectId, context) => {
|
|
|
11
13
|
return getProjectSettingsByProjectId(projectId, context);
|
|
12
14
|
};
|
|
13
15
|
|
|
16
|
+
const setProjectSettings = async (projectId, settings, context) => {
|
|
17
|
+
const isUIConfig = util.isUIConfig(settings);
|
|
18
|
+
|
|
19
|
+
const settingsConfig = isUIConfig ? util.parseProjectSettingsConfig(projectId, settings) : settings;
|
|
20
|
+
const settingsModel = new UpdateProjectSettingsModel(settingsConfig);
|
|
21
|
+
|
|
22
|
+
const updateResponse = await updateProjectSettings(settingsModel, context);
|
|
23
|
+
|
|
24
|
+
if (updateResponse.status !== httpResponseStatusCodes.OK) {
|
|
25
|
+
throw new Error(`Failed to set project: ${projectId} settings\n${updateResponse.statusText}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return updateResponse;
|
|
29
|
+
};
|
|
30
|
+
|
|
14
31
|
module.exports = {
|
|
15
32
|
updateProjectSettings,
|
|
16
|
-
getProjectSettings
|
|
33
|
+
getProjectSettings,
|
|
34
|
+
setProjectSettings
|
|
17
35
|
};
|
|
@@ -1,39 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
class UpdateProjectSettingsModel {
|
|
2
|
+
constructor(
|
|
3
|
+
{
|
|
4
|
+
autoGaps = {},
|
|
5
|
+
autoRenewals = false,
|
|
6
|
+
marketplaceSettings = {},
|
|
7
|
+
ocrEnabled = false,
|
|
8
|
+
onboardingPhase = false,
|
|
9
|
+
projectId = null,
|
|
10
|
+
qrEnabled = false,
|
|
11
|
+
tenantSolution = false,
|
|
12
|
+
autocompleteSettings = {}
|
|
13
|
+
} = {}
|
|
14
|
+
) {
|
|
15
|
+
this.autoGaps = { ... DEFAULT_AUTOGAPS, ... autoGaps };
|
|
16
|
+
this.autoRenewals = autoRenewals;
|
|
17
|
+
this.marketplaceSettings = { ... DEFAULT_MARKETPLACE, ... marketplaceSettings };
|
|
18
|
+
this.ocrEnabled = ocrEnabled;
|
|
19
|
+
this.onboardingPhase = onboardingPhase;
|
|
20
|
+
this.projectId = projectId;
|
|
21
|
+
this.qrEnabled = qrEnabled;
|
|
22
|
+
this.tenantSolution = tenantSolution;
|
|
23
|
+
this.autocompleteSettings = { ... DEFAULT_AUTOCOMPLETE_ADD_VENDORS, ... autocompleteSettings };
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
module.exports = UpdateProjectSettingsModel;
|
|
24
28
|
|
|
25
|
-
const
|
|
29
|
+
const DEFAULT_MARKETPLACE = {
|
|
26
30
|
marketplaceEnabled: false,
|
|
27
31
|
marketplacePreApproved: false,
|
|
28
32
|
marketplaceOnboardedVendors: false,
|
|
29
33
|
marketplaceCompliantVendorQuotationEnabled: false
|
|
30
34
|
};
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
const DEFAULT_AUTOGAPS = {
|
|
36
|
+
isAutoGapsEnabledForGuests: false,
|
|
37
|
+
isAutoGapsEnabledForTenants: false,
|
|
38
|
+
isAutoGapsEnabledForVendors: false
|
|
35
39
|
};
|
|
36
|
-
const
|
|
40
|
+
const DEFAULT_AUTOCOMPLETE_ADD_VENDORS = {
|
|
37
41
|
autocompleteAddVendorsForPm: false,
|
|
38
42
|
autocompleteAddVendorsForTenants: false
|
|
39
43
|
};
|
|
@@ -72,11 +72,85 @@ const deleteProjectByName = (accounId, projectName, context) => {
|
|
|
72
72
|
return services.deleteProjectByName(accounId, projectName, context);
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
+
const isUIConfig = config => {
|
|
76
|
+
const allKeysSettings = { ... attributesConvertor, ... marketplaceAttributesConvertor, ... autoGapsConvertor, ... autocompleteAttributesConvertor };
|
|
77
|
+
const convectorKeys = Object.keys(allKeysSettings);
|
|
78
|
+
const configKeys = Object.keys(config);
|
|
79
|
+
|
|
80
|
+
return convectorKeys.some(key => configKeys.includes(key));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const assignNewSettingFormat = (target, soursKey, soursValue, dictionaryObject) => {
|
|
84
|
+
const attributeKey = dictionaryObject[soursKey];
|
|
85
|
+
const attributeValue = JSON.parse(soursValue);
|
|
86
|
+
Object.assign(target, { [attributeKey]: attributeValue });
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const marketplaceParser = (settings, soursKey, soursValue, dictionary) => {
|
|
90
|
+
settings.marketplaceSettings = settings.marketplaceSettings || {};
|
|
91
|
+
|
|
92
|
+
assignNewSettingFormat(settings.marketplaceSettings, soursKey, soursValue, dictionary);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const autoGapsParser = (settings, soursKey, soursValue, dictionary) => {
|
|
96
|
+
settings.autoGaps = settings.autoGaps || {};
|
|
97
|
+
|
|
98
|
+
assignNewSettingFormat(settings.autoGaps, soursKey, soursValue, dictionary);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const autocompleteParser = (settings, soursKey, soursValue, dictionary) => {
|
|
102
|
+
settings.autocompleteSettings = settings.autocompleteSettings || {};
|
|
103
|
+
|
|
104
|
+
assignNewSettingFormat(settings.autocompleteSettings, soursKey, soursValue, dictionary);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const parseProjectSettingsConfig = (projectId, settingsConfig) => {
|
|
108
|
+
const settings = { projectId };
|
|
109
|
+
|
|
110
|
+
for (const setting in settingsConfig) {
|
|
111
|
+
marketplaceAttributesConvertor[setting] && marketplaceParser(settings, setting, settingsConfig[setting], marketplaceAttributesConvertor);
|
|
112
|
+
|
|
113
|
+
autocompleteAttributesConvertor[setting] && autocompleteParser(settings, setting, settingsConfig[setting], autocompleteAttributesConvertor);
|
|
114
|
+
|
|
115
|
+
attributesConvertor[setting] && assignNewSettingFormat(settings, setting, settingsConfig[setting], attributesConvertor);
|
|
116
|
+
|
|
117
|
+
autoGapsConvertor[setting] && autoGapsParser(settings, setting, settingsConfig[setting], autoGapsConvertor);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return settings;
|
|
121
|
+
};
|
|
122
|
+
|
|
75
123
|
module.exports = {
|
|
76
124
|
getProjectConfig,
|
|
77
125
|
getOrCreateProject,
|
|
78
126
|
getDefaultProjectId,
|
|
79
127
|
getCreateProjectModel,
|
|
80
128
|
getUpdateProjectModel,
|
|
81
|
-
deleteProjectByName
|
|
129
|
+
deleteProjectByName,
|
|
130
|
+
parseProjectSettingsConfig,
|
|
131
|
+
isUIConfig
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const attributesConvertor = {
|
|
135
|
+
'Automatic Renewal': 'autoRenewals',
|
|
136
|
+
'Onboarding Phase Enabled': 'onboardingPhase',
|
|
137
|
+
'Tenant App': 'tenantSolution'
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const marketplaceAttributesConvertor = {
|
|
141
|
+
'Vendor Network Onboarding': 'marketplaceEnabled',
|
|
142
|
+
'Vendor Network - Show Onboarded Vendors': 'marketplaceOnboardedVendors',
|
|
143
|
+
'Pre-Approved Tab': 'marketplacePreApproved',
|
|
144
|
+
'Compliant Vendor Quotation': 'marketplaceCompliantVendorQuotationEnabled'
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const autocompleteAttributesConvertor = {
|
|
148
|
+
'For PM': 'autocompleteAddVendorsForPm',
|
|
149
|
+
'For Tenants': 'autocompleteAddVendorsForTenants'
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const autoGapsConvertor = {
|
|
153
|
+
'Guests': 'isAutoGapsEnabledForGuests',
|
|
154
|
+
'Tenants': 'isAutoGapsEnabledForTenants',
|
|
155
|
+
'Vendors': 'isAutoGapsEnabledForVendors'
|
|
82
156
|
};
|
|
@@ -52,7 +52,7 @@ const getRequestsByAccountId = (accountId, context, activationStatus) => {
|
|
|
52
52
|
return requestsAPI.getRequestsByAccountId(accountId, context, params);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
const getCreateRequestModel = (requirementId, contractor, { tabId, publicLink, sendMail } = {}) => {
|
|
55
|
+
const getCreateRequestModel = (requirementId, contractor, { tabId, publicLink, sendMail, requirementDateModified } = {}) => {
|
|
56
56
|
const { recordType, email, companyName, additionalEmails } = contractor;
|
|
57
57
|
const contractorInfoModel = new ContractorInfo(recordType, email, companyName, additionalEmails);
|
|
58
58
|
|
|
@@ -63,12 +63,13 @@ const getCreateRequestModel = (requirementId, contractor, { tabId, publicLink, s
|
|
|
63
63
|
{
|
|
64
64
|
tabId,
|
|
65
65
|
publicLink,
|
|
66
|
-
sendMail
|
|
66
|
+
sendMail,
|
|
67
|
+
requirementDateModified
|
|
67
68
|
}
|
|
68
69
|
);
|
|
69
70
|
};
|
|
70
71
|
|
|
71
|
-
const getOrCreateRequest = async (context, tabId, requirementId, contractor, activationStatus, { sendMail } = {}) => {
|
|
72
|
+
const getOrCreateRequest = async (context, tabId, requirementId, contractor, activationStatus, { sendMail, requirementDateModified } = {}) => {
|
|
72
73
|
const { data: existingRequests } = await getRequestsByTabId(tabId, context, activationStatus);
|
|
73
74
|
|
|
74
75
|
const filteredRequests = Array.isArray(existingRequests) ? existingRequests.filter(({ record }) =>
|
|
@@ -78,8 +79,7 @@ const getOrCreateRequest = async (context, tabId, requirementId, contractor, act
|
|
|
78
79
|
return filteredRequests[0];
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
const createContractorModel = getCreateRequestModel(requirementId, contractor, { tabId, sendMail });
|
|
82
|
-
//JON-8788: add optional parameter dateModified otherwise doesn't work for updated req
|
|
82
|
+
const createContractorModel = getCreateRequestModel(requirementId, contractor, { tabId, sendMail, requirementDateModified });
|
|
83
83
|
const createContractorResponse = await createRequest(createContractorModel, context);
|
|
84
84
|
return createContractorResponse.data;
|
|
85
85
|
};
|
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
const { getEnv } = require('../../../../env');
|
|
2
2
|
const { credentials } = getEnv();
|
|
3
3
|
|
|
4
|
-
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
4
|
+
const { validateType, validateDateString } = require('../../../../common/validations/typeValidations');
|
|
5
5
|
|
|
6
6
|
const superUserEmail = credentials.superUser;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
class CreateRequestModel {
|
|
9
|
+
constructor(requirementId, inviterEmail, vendorInfo, { tabId = null, sendMail = false, publicLink, requirementDateModified } = {}) {
|
|
10
|
+
this.reqId = requirementId;
|
|
11
|
+
this.inviterEmail = inviterEmail || superUserEmail;
|
|
12
|
+
this.vendorInfo = vendorInfo;
|
|
13
|
+
this.disableMail = !sendMail;
|
|
14
|
+
this.tabId = tabId;
|
|
15
|
+
this.publicLink = publicLink;
|
|
16
|
+
this.dateModified = requirementDateModified;
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
vendorInfo && validateType(vendorInfo, ContractorInfo);
|
|
19
|
+
requirementDateModified && validateDateString(requirementDateModified);
|
|
20
|
+
}
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
class ContractorInfo {
|
|
24
|
+
constructor(recordType, email, companyName, additionalEmails) {
|
|
25
|
+
this.recordType = recordType;
|
|
26
|
+
this.email = email;
|
|
27
|
+
this.companyName = companyName;
|
|
28
|
+
this.title = email;
|
|
29
|
+
this.additionalEmails = additionalEmails;
|
|
30
|
+
}
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
module.exports = { CreateRequestModel, ContractorInfo };
|
|
@@ -106,6 +106,16 @@ const getUpdatedRequirementModel = async (updatedRequirement, tabId, context, {
|
|
|
106
106
|
return requirementUtils.getUpdateRequirementModel(updatedRequirement);
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
+
const getRequirementDateModified = async (tabId, requirementName, context) => {
|
|
110
|
+
const requirementRes = await getRequirementByName(tabId, requirementName, context);
|
|
111
|
+
|
|
112
|
+
if (!requirementRes) {
|
|
113
|
+
throw new Error(`Failed to retrieve requirement - ${requirementName}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return requirementRes.dateModified;
|
|
117
|
+
};
|
|
118
|
+
|
|
109
119
|
module.exports = {
|
|
110
120
|
createRequirement,
|
|
111
121
|
getRequirementById,
|
|
@@ -119,5 +129,6 @@ module.exports = {
|
|
|
119
129
|
deleteRequirementByName,
|
|
120
130
|
deleteAllRequirementsInTabs,
|
|
121
131
|
getCreateRequirementModel,
|
|
122
|
-
getUpdatedRequirementModel
|
|
132
|
+
getUpdatedRequirementModel,
|
|
133
|
+
getRequirementDateModified
|
|
123
134
|
};
|