@getjones/test-infra 2.12.5 → 2.12.6
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/requests/internalAuth/requests.js +38 -0
- package/src/defaults/configs/polices.js +6 -5
- package/src/index.js +2 -0
- package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +43 -0
- package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +105 -0
- package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +11 -0
- package/src/saas/internal-api/auditCustomerRules/index.js +5 -0
- package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +46 -0
- package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +19 -0
- package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +1 -1
- package/src/saas/internal-api/contractors/api/contractors.api.js +10 -2
- package/src/saas/internal-api/contractors/api/contractors.service.js +12 -1
- package/src/saas/internal-api/dbEmails/consts/consts.js +2 -1
- package/src/saas/internal-api/recordNotes/api/record.notes.service.js +21 -3
- package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -0
- package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const requestHandler = require('../requestHandlers');
|
|
2
|
+
|
|
3
|
+
const getRequestHandler = (url, params = {}, headers = {}) => {
|
|
4
|
+
addInternalAuthHeader(headers);
|
|
5
|
+
return requestHandler.getRequestHandler(url, headers, params);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const postRequestHandler = (url, body, headers = {}, params = {}) => {
|
|
9
|
+
addInternalAuthHeader(headers);
|
|
10
|
+
return requestHandler.postRequestHandler(url, body, headers, params);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const putRequestHandler = (url, body, headers = {}, params = {}) => {
|
|
14
|
+
addInternalAuthHeader(headers);
|
|
15
|
+
return requestHandler.putRequestHandler(url, body, headers, params);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const patchRequestHandler = (url, body, headers = {}) => {
|
|
19
|
+
addInternalAuthHeader(headers);
|
|
20
|
+
return requestHandler.patchRequestHandler(url, body, headers);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const deleteRequestHandler = (url, headers = {}, params = {}, data = {}) => {
|
|
24
|
+
addInternalAuthHeader(headers);
|
|
25
|
+
return requestHandler.deleteRequestHandler(url, headers, params, data);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const addInternalAuthHeader = headers => {
|
|
29
|
+
headers['x-jcsc-auth'] = process.env.CROSS_SERVICES_COMMUNICATION_AUTH_KEY;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
getRequestHandler,
|
|
34
|
+
postRequestHandler,
|
|
35
|
+
putRequestHandler,
|
|
36
|
+
patchRequestHandler,
|
|
37
|
+
deleteRequestHandler
|
|
38
|
+
};
|
|
@@ -29,17 +29,18 @@ const attributeNames = {
|
|
|
29
29
|
insuredAddress: 'Insured Address',
|
|
30
30
|
insuredName: 'Insured Name',
|
|
31
31
|
amScore: 'AM Score',
|
|
32
|
+
cancellationTerms: 'Cancellation Terms',
|
|
33
|
+
coiAuthentication: 'COI authentication',
|
|
34
|
+
signature: 'Signature',
|
|
32
35
|
coverageExists: 'Coverage Exists',
|
|
33
|
-
eachOccurrence: 'Each Occurrence',
|
|
34
36
|
policyNumber: 'Policy Number',
|
|
35
37
|
policyExpired: 'Policy Expiry',
|
|
38
|
+
perOccurrence: 'Per Occur',
|
|
36
39
|
perPolicy: 'Per Policy',
|
|
37
40
|
perProject: 'Per Project',
|
|
38
41
|
perLocation: 'Per Location',
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
coiAuthentication: 'COI authentication',
|
|
42
|
-
signature: 'Signature',
|
|
42
|
+
eachOccurrence: 'Each Occurrence',
|
|
43
|
+
generalAggregate: 'General Aggregate',
|
|
43
44
|
occur: 'Occur',
|
|
44
45
|
text: 'text',
|
|
45
46
|
limit: 'limit',
|
package/src/index.js
CHANGED
|
@@ -23,6 +23,7 @@ const getInternalAPI = () => {
|
|
|
23
23
|
const coi = require('./saas/internal-api/coi');
|
|
24
24
|
const compliance = require('./saas/internal-api/compliance');
|
|
25
25
|
const auditNotes = require('./saas/internal-api/auditNotes');
|
|
26
|
+
const auditCustomerRules = require('./saas/internal-api/auditCustomerRules');
|
|
26
27
|
|
|
27
28
|
const users = require('./saas/internal-api/users');
|
|
28
29
|
|
|
@@ -55,6 +56,7 @@ const getInternalAPI = () => {
|
|
|
55
56
|
coi,
|
|
56
57
|
compliance,
|
|
57
58
|
auditNotes,
|
|
59
|
+
auditCustomerRules,
|
|
58
60
|
reports,
|
|
59
61
|
users,
|
|
60
62
|
charts,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const customerRuleBasePath = 'saas/customer-rule';
|
|
5
|
+
const customerRulesBasePath = 'saas/customer-rules';
|
|
6
|
+
|
|
7
|
+
const Endpoints = {
|
|
8
|
+
createCustomerRule: `${backendUrl}/${customerRuleBasePath}`,
|
|
9
|
+
getCustomerRulesForIcs: `${backendUrl}/${customerRulesBasePath}`,
|
|
10
|
+
getCustomerRulesForAuditor: `${backendUrl}/${customerRulesBasePath}/auditor`,
|
|
11
|
+
updateCustomerRule: ruleId => `${backendUrl}/${customerRuleBasePath}/${ruleId}`,
|
|
12
|
+
deleteCustomerRule: ruleId => `${backendUrl}/${customerRuleBasePath}/${ruleId}`
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const createCustomerRule = (customerRuleModel, context) => {
|
|
16
|
+
return requests.postRequestHandler(Endpoints.createCustomerRule, customerRuleModel, context);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getCustomerRulesForIcs = (projectId, context) => {
|
|
20
|
+
const params = { projectId };
|
|
21
|
+
return requests.getRequestHandler(Endpoints.getCustomerRulesForIcs, params, context);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const getCustomerRulesForAuditor = (recordId, context) => {
|
|
25
|
+
const params = { recordId };
|
|
26
|
+
return requests.getRequestHandler(Endpoints.getCustomerRulesForAuditor, params, context);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const updateCustomerRule = (customerRuleModel, customerRuleId, context) => {
|
|
30
|
+
return requests.putRequestHandler(Endpoints.updateCustomerRule(customerRuleId), customerRuleModel, context);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const deleteCustomerRuleById = (customerRuleModel, customerRuleId, context) => {
|
|
34
|
+
return requests.deleteRequestHandler(Endpoints.deleteCustomerRule(customerRuleId), context, {}, {}, customerRuleModel);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
createCustomerRule,
|
|
39
|
+
getCustomerRulesForIcs,
|
|
40
|
+
getCustomerRulesForAuditor,
|
|
41
|
+
updateCustomerRule,
|
|
42
|
+
deleteCustomerRuleById
|
|
43
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const auditApi = require('../api/customer.rules.api');
|
|
2
|
+
const { CustomerRuleModel } = require('../models/customer.rule.model');
|
|
3
|
+
const { convertGetRulesToModelConfig } = require('../utils/customer.rule.util');
|
|
4
|
+
const { customerRuleLevels } = require('../consts/customer.rule');
|
|
5
|
+
|
|
6
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
7
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
8
|
+
|
|
9
|
+
const createCustomerRule = async (customerRuleModel, context) => {
|
|
10
|
+
validateType(customerRuleModel, CustomerRuleModel);
|
|
11
|
+
const response = await auditApi.createCustomerRule(customerRuleModel, context);
|
|
12
|
+
|
|
13
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
14
|
+
throw Error(`Failed to create customer rule - Response: ${response.status}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return response;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const getCustomerRulesForIcs = async (projectId, context) => {
|
|
21
|
+
const response = await auditApi.getCustomerRulesForIcs(projectId, context);
|
|
22
|
+
|
|
23
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
24
|
+
throw Error(`Failed to get customer rules for ICS: projectId - ${projectId}. Response: ${response.status}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return response.data;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getCustomerRulesForAuditor = async (recordId, context) => {
|
|
31
|
+
const response = await auditApi.getCustomerRulesForAuditor(recordId, context);
|
|
32
|
+
|
|
33
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
34
|
+
throw Error(`Failed to get customer rules for auditor: recordId - ${recordId}. Response: ${response.status}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return response.data;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const updateCustomerRule = async (customerRuleModel, customerRuleId, context) => {
|
|
41
|
+
validateType(customerRuleModel, CustomerRuleModel);
|
|
42
|
+
const response = await auditApi.updateCustomerRule(customerRuleModel, customerRuleId, context);
|
|
43
|
+
|
|
44
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
45
|
+
throw Error(`Failed to update customer rule ${customerRuleId}. Response: ${response.status}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return response;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const deleteCustomerRuleById = async (customerRuleModel, customerRuleId, context) => {
|
|
52
|
+
validateType(customerRuleModel, CustomerRuleModel);
|
|
53
|
+
const response = await auditApi.deleteCustomerRuleById(customerRuleModel, customerRuleId, context);
|
|
54
|
+
|
|
55
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
56
|
+
throw Error(`Failed to delete customer rule - Response: ${response.status}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return response;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const deleteAllCustomerRulesInAccount = async (projectId, context) => {
|
|
63
|
+
const existingCustomerRules = await getCustomerRulesForIcs(projectId, context);
|
|
64
|
+
|
|
65
|
+
const levels = Object.values(customerRuleLevels);
|
|
66
|
+
|
|
67
|
+
for (const level of levels) {
|
|
68
|
+
const rulesByLevel = existingCustomerRules[level];
|
|
69
|
+
|
|
70
|
+
for (const customerRule of rulesByLevel) {
|
|
71
|
+
const convertedRuleConfig = convertGetRulesToModelConfig(customerRule);
|
|
72
|
+
const getRuleModel = getCustomerRuleModel(convertedRuleConfig);
|
|
73
|
+
await deleteCustomerRuleById(getRuleModel, customerRule.id, context);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const getCustomerRuleModel = ruleConfig => {
|
|
79
|
+
const { accountId, name, level, policyName, projectId, requirementId, attributeName, gapQuote, id, dateModified } = ruleConfig;
|
|
80
|
+
|
|
81
|
+
return new CustomerRuleModel(
|
|
82
|
+
accountId,
|
|
83
|
+
name,
|
|
84
|
+
level,
|
|
85
|
+
policyName,
|
|
86
|
+
{
|
|
87
|
+
projectId, //required also for tabRequirement
|
|
88
|
+
requirementId,
|
|
89
|
+
attributeName,
|
|
90
|
+
gapQuote,
|
|
91
|
+
id,
|
|
92
|
+
dateModified
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
module.exports = {
|
|
98
|
+
createCustomerRule,
|
|
99
|
+
getCustomerRulesForIcs,
|
|
100
|
+
getCustomerRulesForAuditor,
|
|
101
|
+
updateCustomerRule,
|
|
102
|
+
deleteCustomerRuleById,
|
|
103
|
+
deleteAllCustomerRulesInAccount,
|
|
104
|
+
getCustomerRuleModel
|
|
105
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const { customerRuleNames, customerRuleLevels } = require('../consts/customer.rule');
|
|
2
|
+
|
|
3
|
+
class CustomerRuleModel {
|
|
4
|
+
constructor(accountId, name, level, policyName, { attributeName, gapQuote, projectId, requirementId, id, dateModified } = {}) {
|
|
5
|
+
this.ruleAssociation = new RuleAssociation(level, accountId, { projectId, requirementId });
|
|
6
|
+
this.ruleConfig = new RuleConfig(name, policyName, { attributeName, gapQuote });
|
|
7
|
+
this.dateModified = dateModified;
|
|
8
|
+
this.id = id;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
CustomerRuleModel
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
class RuleAssociation {
|
|
17
|
+
constructor(level, accountId, { projectId, requirementId } = {}) {
|
|
18
|
+
validateCustomerRuleLevel(level);
|
|
19
|
+
|
|
20
|
+
this.level = level;
|
|
21
|
+
this.accountId = accountId;
|
|
22
|
+
this.projectId = projectId;
|
|
23
|
+
this.requirementId = requirementId;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class RuleConfig {
|
|
28
|
+
constructor(name, policyName, { attributeName, gapQuote } = {}) {
|
|
29
|
+
validateCustomerRuleName(name);
|
|
30
|
+
this.name = name;
|
|
31
|
+
this.applyRuleToPolicy = { policyName, attributeName };
|
|
32
|
+
this.gapQuote = gapQuote;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const validateCustomerRuleLevel = level => {
|
|
37
|
+
if (!Object.values(customerRuleLevels).includes(level)) {
|
|
38
|
+
throw new Error(`Invalid rule level: ${level}`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const validateCustomerRuleName = customerRuleName => {
|
|
43
|
+
if (!Object.values(customerRuleNames).includes(customerRuleName)) {
|
|
44
|
+
throw new Error(`Invalid customerRuleName: ${customerRuleName}`);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const convertGetRulesToModelConfig = rule => {
|
|
2
|
+
const { accountId, projectId, requirementId, level } = rule.ruleAssociation;
|
|
3
|
+
const { name, applyRuleToPolicy, gapQuote } = rule.ruleConfig;
|
|
4
|
+
const customerRuleConfig = {
|
|
5
|
+
id: rule.id,
|
|
6
|
+
accountId,
|
|
7
|
+
name,
|
|
8
|
+
level,
|
|
9
|
+
policyName: applyRuleToPolicy.policyName,
|
|
10
|
+
projectId,
|
|
11
|
+
requirementId,
|
|
12
|
+
attributeName: applyRuleToPolicy.attributeName,
|
|
13
|
+
gapQuote,
|
|
14
|
+
dateModified: rule.dateModified
|
|
15
|
+
};
|
|
16
|
+
return customerRuleConfig;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = { convertGetRulesToModelConfig };
|
|
@@ -110,6 +110,6 @@ async function deleteAuditNotesByIds(notes, context) {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
if (failed.length) {
|
|
113
|
-
throw Error(`Failed to delete ${failed.length} of ${
|
|
113
|
+
throw Error(`Failed to delete ${failed.length} of ${notes.length} notes in account. Failed with status: ${ failed[0].status }`);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
+
const internalRequests = require('../../../../common/requests/internalAuth/requests');
|
|
3
|
+
|
|
2
4
|
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
5
|
|
|
4
6
|
const Endpoints = {
|
|
@@ -24,7 +26,8 @@ const Endpoints = {
|
|
|
24
26
|
automationUpdateContractorUploadDate: contractorId => `${backendUrl}/saas/automation/contractor/${contractorId}/upload-date`,
|
|
25
27
|
assignRequirement: requestId => `${backendUrl}/saas/contractor/${requestId}/assign-requirement`,
|
|
26
28
|
linkedProjectsCount: recordId => `${backendUrl}/saas/record/count/${recordId}/linked-projects`,
|
|
27
|
-
verifyInviteLink: encryptedData => `${backendUrl}/vendor-app/verify-link?data=${encryptedData}
|
|
29
|
+
verifyInviteLink: encryptedData => `${backendUrl}/vendor-app/verify-link?data=${encryptedData}`,
|
|
30
|
+
getBasicDetailsById: recordId => `${backendUrl}/jcsc/record/${recordId}`
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
const getContractorsByAccountId = (params, context) => {
|
|
@@ -132,6 +135,10 @@ const getInviteLinkStatus = (encryptedData, context) => {
|
|
|
132
135
|
return requests.getRequestHandler(Endpoints.verifyInviteLink(encryptedData), {}, context, {});
|
|
133
136
|
};
|
|
134
137
|
|
|
138
|
+
const getBasicDetailsById = recordId => {
|
|
139
|
+
return internalRequests.getRequestHandler(Endpoints.getBasicDetailsById(recordId), {});
|
|
140
|
+
};
|
|
141
|
+
|
|
135
142
|
module.exports = {
|
|
136
143
|
changeRequirement,
|
|
137
144
|
assignRequirement,
|
|
@@ -155,5 +162,6 @@ module.exports = {
|
|
|
155
162
|
unmuteNotifications,
|
|
156
163
|
getLinkedProjectsCount,
|
|
157
164
|
updateLastInviteActionDate,
|
|
158
|
-
getInviteLinkStatus
|
|
165
|
+
getInviteLinkStatus,
|
|
166
|
+
getBasicDetailsById
|
|
159
167
|
};
|
|
@@ -179,6 +179,16 @@ const getContractorDetailsModel = recordConfig => {
|
|
|
179
179
|
return new ContractorDetailsModel(apiDetailsConfig);
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
+
const getBasicDetailsById = async recordId => {
|
|
183
|
+
const response = await contractorsAPI.getBasicDetailsById(recordId);
|
|
184
|
+
|
|
185
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
186
|
+
throw Error(`Failed to get basic record details by record id: ${recordId} - Response: ${response.status}`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return response.data;
|
|
190
|
+
};
|
|
191
|
+
|
|
182
192
|
module.exports = {
|
|
183
193
|
changeRequirement,
|
|
184
194
|
getContractorsByAccountId,
|
|
@@ -208,5 +218,6 @@ module.exports = {
|
|
|
208
218
|
restoreByRecordId,
|
|
209
219
|
updateLastInviteActionDate,
|
|
210
220
|
getInviteLinkStatus,
|
|
211
|
-
getContractorDetailsModel
|
|
221
|
+
getContractorDetailsModel,
|
|
222
|
+
getBasicDetailsById
|
|
212
223
|
};
|
|
@@ -47,7 +47,8 @@ const EMAIL_SUBJECT = {
|
|
|
47
47
|
fraudAuditorReview: ({ recordCompanyName, requesterName }) => `Authentication check for ${recordCompanyName} at ${requesterName}`,
|
|
48
48
|
requestNewCoi: ({ recordCompanyName, requesterName, isExpired }) => `${recordCompanyName}'s COI is ${isExpired ? 'expired' : 'about to expire'} - ${requesterName}`,
|
|
49
49
|
malwareCoiFound: 'COI upload failed to pass security scan',
|
|
50
|
-
thankYou: 'Thank you for submitting your COI'
|
|
50
|
+
thankYou: 'Thank you for submitting your COI',
|
|
51
|
+
teamNoteMention: ({ taggingUserFullName, recordCompanyName }) => `${taggingUserFullName} mentioned you in a team note for ${recordCompanyName}`
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT, tenantUserExtension };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const recordNotesAPI = require('./record.notes.api');
|
|
2
|
+
const utils = require('./record.notes.utils');
|
|
3
|
+
|
|
4
|
+
const createRecordNote = (recordId, data, context, { tagUsers, multipleParagraphs } = {}) => {
|
|
5
|
+
tagUsers && (data.content = utils.getMentionedNoteContent(tagUsers, data.content, { multipleParagraphs }));
|
|
2
6
|
|
|
3
|
-
const createRecordNote = (recordId, data, context) => {
|
|
4
7
|
return recordNotesAPI.createRecordNote(recordId, data, context);
|
|
5
8
|
};
|
|
6
9
|
|
|
@@ -8,6 +11,18 @@ const getNotesByRecordId = (recordId, context) => {
|
|
|
8
11
|
return recordNotesAPI.getNotesByRecordId(recordId, context);
|
|
9
12
|
};
|
|
10
13
|
|
|
14
|
+
const getRecordNoteById = async (noteId, recordId, context) => {
|
|
15
|
+
const response = await recordNotesAPI.getNotesByRecordId(recordId, context);
|
|
16
|
+
const notes = response.data;
|
|
17
|
+
const note = notes.find(note => note.id === noteId);
|
|
18
|
+
|
|
19
|
+
if (!note) {
|
|
20
|
+
throw new Error(`Note not found for note id: ${noteId} and record id: ${recordId}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return note;
|
|
24
|
+
};
|
|
25
|
+
|
|
11
26
|
const getNotesCountByRecordId = (recordId, context) => {
|
|
12
27
|
return recordNotesAPI.getNotesCountByRecordId(recordId, context);
|
|
13
28
|
};
|
|
@@ -16,7 +31,9 @@ const deleteByNoteId = (noteId, data, context) => {
|
|
|
16
31
|
return recordNotesAPI.deleteByNoteId(noteId, data, context);
|
|
17
32
|
};
|
|
18
33
|
|
|
19
|
-
const updateByNoteId = (noteId, data, context) => {
|
|
34
|
+
const updateByNoteId = (noteId, data, context, { tagUsers, multipleParagraphs } = {}) => {
|
|
35
|
+
tagUsers && (data.content = utils.getMentionedNoteContent(tagUsers, data.content, { multipleParagraphs }));
|
|
36
|
+
|
|
20
37
|
return recordNotesAPI.updateByNoteId(noteId, data, context);
|
|
21
38
|
};
|
|
22
39
|
|
|
@@ -25,5 +42,6 @@ module.exports = {
|
|
|
25
42
|
getNotesByRecordId,
|
|
26
43
|
getNotesCountByRecordId,
|
|
27
44
|
deleteByNoteId,
|
|
28
|
-
updateByNoteId
|
|
45
|
+
updateByNoteId,
|
|
46
|
+
getRecordNoteById
|
|
29
47
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const getMentionedNoteContent = (usersArray, noteContent = '', { multipleParagraphs } = {}) => {
|
|
2
|
+
for (const user of usersArray) {
|
|
3
|
+
const newContent = `<span class="mention" data-name="${user.fullName}" data-id="${user.id}" draggable="false"><span contenteditable="false">@${user.fullName}</span></span>`;
|
|
4
|
+
noteContent += multipleParagraphs ? `<p>${newContent}</p>` : newContent;
|
|
5
|
+
};
|
|
6
|
+
noteContent = multipleParagraphs ? noteContent : `<p>${noteContent}</p>`;
|
|
7
|
+
return noteContent;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
getMentionedNoteContent
|
|
12
|
+
};
|
|
@@ -4,7 +4,7 @@ const { backendUrl } = require('../../../../env').getEnv();
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
getRelatedDocPreSignedUrl: `${backendUrl}/pre-signed-url/upload/document`,
|
|
6
6
|
uploadRelatedDoc: recordId => `${backendUrl}/saas/contractor/${recordId}/document`,
|
|
7
|
-
fileUpload: `${backendUrl}/file/upload`
|
|
7
|
+
fileUpload: `${backendUrl}/file/finalize-upload`
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
const getRelatedDocPreSignedUrl = (formData, context) => {
|