@getjones/test-infra 4.4.2 → 4.4.4

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.
Files changed (225) hide show
  1. package/package.json +30 -30
  2. package/src/common/commonFlows/auth/auth.js +40 -40
  3. package/src/common/commonFlows/index.js +4 -4
  4. package/src/common/commonFlows/records/records.js +195 -195
  5. package/src/common/consts/accountSettings.js +10 -10
  6. package/src/common/consts/activationStatuses.js +6 -6
  7. package/src/common/consts/autocomplete.js +9 -9
  8. package/src/common/consts/constantsForRecordsSortingAndFilters.js +40 -40
  9. package/src/common/consts/dashboardCharts.js +18 -18
  10. package/src/common/consts/ocrStatuses.js +6 -6
  11. package/src/common/consts/projectSettings.js +21 -21
  12. package/src/common/consts/recordTypes.js +5 -5
  13. package/src/common/consts/s3FileTypes.js +13 -13
  14. package/src/common/consts/userTypes.js +8 -8
  15. package/src/common/errorCodes.js +3 -3
  16. package/src/common/httpResponseStatusCodes.json +11 -11
  17. package/src/common/httpResponseTypes.json +2 -2
  18. package/src/common/requests/apiKeyAuth/requests.js +44 -44
  19. package/src/common/requests/cookieAuth/requests.js +40 -40
  20. package/src/common/requests/internalAuth/requests.js +48 -48
  21. package/src/common/requests/requestHandlers.js +80 -80
  22. package/src/common/utils/complianceUtil.js +114 -114
  23. package/src/common/utils/configsUtil.js +22 -22
  24. package/src/common/utils/dataTypeUtils.js +41 -41
  25. package/src/common/utils/numberUtils.js +22 -22
  26. package/src/common/utils/objectUtils.js +7 -7
  27. package/src/common/utils/timeUtils.js +177 -177
  28. package/src/common/validations/errorValidation.js +16 -16
  29. package/src/common/validations/typeValidations.js +36 -36
  30. package/src/defaults/configs/auditConfigs.js +124 -124
  31. package/src/defaults/configs/coverage.js +227 -227
  32. package/src/defaults/configs/polices.js +75 -75
  33. package/src/defaults/configs/requirement.js +32 -32
  34. package/src/defaults/index.js +6 -6
  35. package/src/env.js +57 -57
  36. package/src/factory/globalRecord/globalRecord.js +43 -43
  37. package/src/factory/index.js +8 -8
  38. package/src/factory/records/records.js +231 -231
  39. package/src/factory/users/users.js +77 -77
  40. package/src/index.js +95 -95
  41. package/src/saas/internal-api/accountDirectory/api/accountDirectory.api.js +50 -44
  42. package/src/saas/internal-api/accountDirectory/api/accountDirectory.service.js +182 -158
  43. package/src/saas/internal-api/accountDirectory/index.js +4 -4
  44. package/src/saas/internal-api/accountDirectory/models/accountDirectory.model.js +40 -40
  45. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +35 -35
  46. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +93 -93
  47. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.api.js +29 -29
  48. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.service.js +61 -61
  49. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  50. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  51. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  52. package/src/saas/internal-api/accounts/api/settings/settings.service.js +41 -41
  53. package/src/saas/internal-api/accounts/consts/consts.js +8 -8
  54. package/src/saas/internal-api/accounts/index.js +22 -22
  55. package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
  56. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +42 -40
  57. package/src/saas/internal-api/accounts/utils/utils.js +58 -58
  58. package/src/saas/internal-api/agreement/api/agreement.api.js +39 -39
  59. package/src/saas/internal-api/agreement/api/agreement.service.js +121 -121
  60. package/src/saas/internal-api/agreement/consts/consts.js +10 -10
  61. package/src/saas/internal-api/agreement/index.js +12 -12
  62. package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
  63. package/src/saas/internal-api/agreement/models/createAgreementByAuditorModel.js +11 -11
  64. package/src/saas/internal-api/agreement/models/createAgreementByPMModel.js +13 -13
  65. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +43 -43
  66. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +105 -105
  67. package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +11 -11
  68. package/src/saas/internal-api/auditCustomerRules/index.js +6 -6
  69. package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +46 -46
  70. package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +19 -19
  71. package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
  72. package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
  73. package/src/saas/internal-api/auditNotes/index.js +4 -4
  74. package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
  75. package/src/saas/internal-api/auth/api/auth.api.js +27 -27
  76. package/src/saas/internal-api/auth/api/auth.service.js +90 -90
  77. package/src/saas/internal-api/auth/index.js +3 -3
  78. package/src/saas/internal-api/coi/api/coi.api.js +45 -45
  79. package/src/saas/internal-api/coi/api/coi.service.js +39 -39
  80. package/src/saas/internal-api/coi/consts/hashes.js +4 -4
  81. package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -5
  82. package/src/saas/internal-api/coi/index.js +14 -14
  83. package/src/saas/internal-api/coi/models/Combine.last.two.cois.model.js +25 -25
  84. package/src/saas/internal-api/coi/models/submit.coi.model.js +19 -19
  85. package/src/saas/internal-api/coi/utils/utils.js +117 -117
  86. package/src/saas/internal-api/compliance/api/audit/audit.api.js +115 -115
  87. package/src/saas/internal-api/compliance/api/audit/audit.service.js +300 -300
  88. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  89. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  90. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  91. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +48 -48
  92. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +38 -38
  93. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +182 -182
  94. package/src/saas/internal-api/compliance/consts/audit.js +110 -110
  95. package/src/saas/internal-api/compliance/index.js +33 -33
  96. package/src/saas/internal-api/compliance/models/audit/audit.model.js +96 -96
  97. package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
  98. package/src/saas/internal-api/compliance/utils/auditUtil.js +254 -254
  99. package/src/saas/internal-api/compliance/utils/coverageUtil.js +40 -40
  100. package/src/saas/internal-api/contractors/api/contractors.api.js +203 -203
  101. package/src/saas/internal-api/contractors/api/contractors.service.js +342 -342
  102. package/src/saas/internal-api/contractors/consts/consts.js +6 -6
  103. package/src/saas/internal-api/contractors/index.js +8 -8
  104. package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
  105. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +62 -62
  106. package/src/saas/internal-api/contractors/models/link.request.model.js +10 -10
  107. package/src/saas/internal-api/contractors/models/subscription.contractor.model.js +13 -13
  108. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  109. package/src/saas/internal-api/contractors/utils.js +25 -25
  110. package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
  111. package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
  112. package/src/saas/internal-api/dashboard/index.js +5 -5
  113. package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
  114. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  115. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +156 -156
  116. package/src/saas/internal-api/dbEmails/consts/consts.js +55 -55
  117. package/src/saas/internal-api/dbEmails/index.js +6 -6
  118. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
  119. package/src/saas/internal-api/dbEmails/utils/util.js +87 -87
  120. package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
  121. package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
  122. package/src/saas/internal-api/emailCustomization/index.js +3 -3
  123. package/src/saas/internal-api/globalRecord/api/global.record.api.js +101 -101
  124. package/src/saas/internal-api/globalRecord/api/global.record.service.js +117 -117
  125. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  126. package/src/saas/internal-api/globalRecord/index.js +6 -6
  127. package/src/saas/internal-api/globalRecord/models/global.record.model.js +60 -60
  128. package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
  129. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  130. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  131. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  132. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  133. package/src/saas/internal-api/projects/api/core/projects.service.js +70 -70
  134. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  135. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
  136. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  137. package/src/saas/internal-api/projects/index.js +24 -24
  138. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  139. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  140. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +40 -40
  141. package/src/saas/internal-api/projects/utils/utils.js +155 -155
  142. package/src/saas/internal-api/recordHub/api/record.hub.api.js +14 -14
  143. package/src/saas/internal-api/recordHub/api/record.hub.service.js +21 -21
  144. package/src/saas/internal-api/recordHub/index.js +3 -3
  145. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  146. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +47 -47
  147. package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -12
  148. package/src/saas/internal-api/recordNotes/index.js +3 -3
  149. package/src/saas/internal-api/reports/api/reports.api.js +62 -62
  150. package/src/saas/internal-api/reports/api/reports.service.js +79 -79
  151. package/src/saas/internal-api/reports/consts/consts.js +74 -74
  152. package/src/saas/internal-api/reports/index.js +15 -15
  153. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  154. package/src/saas/internal-api/requests/api/requests.api.js +120 -120
  155. package/src/saas/internal-api/requests/api/requests.service.js +272 -272
  156. package/src/saas/internal-api/requests/index.js +20 -20
  157. package/src/saas/internal-api/requests/models/create.request.model.js +33 -33
  158. package/src/saas/internal-api/requests/models/draft.request.criteria.model.js +18 -18
  159. package/src/saas/internal-api/requests/models/draft.request.report.model.js +14 -14
  160. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  161. package/src/saas/internal-api/requests/models/requestListCriteriaModel.js +17 -17
  162. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  163. package/src/saas/internal-api/requests/utils.js +8 -8
  164. package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
  165. package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
  166. package/src/saas/internal-api/requestsTable/index.js +3 -3
  167. package/src/saas/internal-api/requirements/api/requirements.api.js +57 -57
  168. package/src/saas/internal-api/requirements/api/requirements.service.js +177 -177
  169. package/src/saas/internal-api/requirements/consts/attributeTypes.json +8 -8
  170. package/src/saas/internal-api/requirements/consts/consts.js +6 -6
  171. package/src/saas/internal-api/requirements/index.js +10 -10
  172. package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
  173. package/src/saas/internal-api/requirements/models/policy.model.js +35 -35
  174. package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
  175. package/src/saas/internal-api/requirements/utils/utils.js +129 -129
  176. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  177. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  178. package/src/saas/internal-api/serviceArea/index.js +4 -4
  179. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  180. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  181. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  182. package/src/saas/internal-api/tabs/index.js +3 -3
  183. package/src/saas/internal-api/tabs/models/tabs.model.js +19 -19
  184. package/src/saas/internal-api/thread-scheduler/runner.js +55 -55
  185. package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +37 -37
  186. package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +64 -64
  187. package/src/saas/internal-api/uploadFiles/consts.js +12 -12
  188. package/src/saas/internal-api/uploadFiles/index.js +3 -3
  189. package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +38 -38
  190. package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +108 -108
  191. package/src/saas/internal-api/users/api/users.api.js +121 -121
  192. package/src/saas/internal-api/users/api/users.service.js +214 -214
  193. package/src/saas/internal-api/users/index.js +16 -16
  194. package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
  195. package/src/saas/internal-api/users/models/notification.settings.model.js +12 -12
  196. package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
  197. package/src/saas/internal-api/users/models/users.model.js +41 -41
  198. package/src/saas/internal-api/users/utils/util.js +39 -39
  199. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  200. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  201. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  202. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  203. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  204. package/src/saas/openapi/coi/coi.api.js +30 -30
  205. package/src/saas/openapi/coi/coi.service.js +43 -43
  206. package/src/saas/openapi/projects/projects.api.js +83 -83
  207. package/src/saas/openapi/projects/projects.service.js +64 -64
  208. package/src/saas/openapi/requests/index.js +7 -7
  209. package/src/saas/openapi/requests/models/invite.request.model.js +40 -40
  210. package/src/saas/openapi/requests/models/update.request.model.js +35 -35
  211. package/src/saas/openapi/requests/requests.api.js +87 -87
  212. package/src/saas/openapi/requests/requests.service.js +81 -81
  213. package/src/saas/openapi/requirements/index.js +6 -6
  214. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  215. package/src/saas/openapi/requirements/requirements.api.js +41 -41
  216. package/src/saas/openapi/requirements/requirements.service.js +49 -49
  217. package/src/saas/openapi/tabs/index.js +6 -6
  218. package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
  219. package/src/saas/openapi/tabs/tabs.api.js +27 -27
  220. package/src/saas/openapi/tabs/tabs.service.js +19 -19
  221. package/src/saas/openapi/users/user.model.js +10 -10
  222. package/src/saas/openapi/users/users.api.js +33 -33
  223. package/src/saas/openapi/users/users.service.js +41 -41
  224. package/tests/env.test.js +40 -40
  225. package/tests/validation.test.js +83 -83
@@ -1,129 +1,129 @@
1
- const attributeTypes = require('../consts/attributeTypes.json');
2
- const dataTypeUtils = require('../../../../common/utils/dataTypeUtils');
3
- const { UpdateRequirementModel } = require('../models/update.requirement.model');
4
- const { AttributeModel, PolicyModel, AttributeTypes } = require('../models/policy.model');
5
- const { CreateRequirementModel } = require('../models/create.requirement.model');
6
-
7
- const customAttributes = {
8
- Including: 'multiple' //because attributeTypes.multiple => 'Multiple' with capital M
9
- };
10
- const numericAttributes = ['Indemnity Period', 'Notice of Cancellation', 'Notice of Cancellation Endorsement'];
11
- const amBestAttributes = {
12
- amBestRating: 'AM Best Rating',
13
- amBestFinancialSizeCategory: 'AM Best Financial Size Category'
14
- };
15
-
16
- const convertNumericValuesToNumberType = function(value, attributeName) {
17
- if (dataTypeUtils.isString(value) && value.startsWith('$')) {
18
- return Number(value.replace(/[$,]/g, ''));
19
- }
20
-
21
- if (numericAttributes.includes(attributeName)) {
22
- return Number(value);
23
- }
24
-
25
- return value;
26
- };
27
-
28
- const preparePolicyAttributesTypes = function(value, attributeName) {
29
- const attributesValue = convertNumericValuesToNumberType(value, attributeName);
30
-
31
- if (dataTypeUtils.isNumber(attributesValue)) {
32
- return numericAttributes.includes(attributeName) ?
33
- AttributeTypes.get(attributeTypes.numeric) :
34
- AttributeTypes.get(attributeTypes.limit);
35
- }
36
-
37
- if (dataTypeUtils.isBoolean(attributesValue)) {
38
- return AttributeTypes.get(attributeTypes.boolean);
39
- }
40
-
41
- if (dataTypeUtils.isString(attributesValue)) {
42
- if (attributeName === amBestAttributes.amBestRating) {
43
- return AttributeTypes.get(attributeTypes.amBestRating);
44
- }
45
-
46
- if (attributeName === amBestAttributes.amBestFinancialSizeCategory) {
47
- return AttributeTypes.get(attributeTypes.amBestFinancialSizeCategory);
48
- }
49
- }
50
-
51
- return AttributeTypes.get(attributeTypes.multiple);
52
- };
53
-
54
- const prepareEndorsementAttributesTypes = function(value) {
55
- if (dataTypeUtils.isBoolean(value)) {
56
- return AttributeTypes.get(attributeTypes.boolean);
57
- }
58
-
59
- return AttributeTypes.get(attributeTypes.endorsement);
60
- };
61
-
62
- const parseRequirementConfig = function(config) {
63
- if (dataTypeUtils.isArray(config)) {
64
- // If config is an array type it means the config is already parsed.
65
- return config;
66
- }
67
-
68
- const policies = [];
69
- for (const policy in config) {
70
- const attributes = [];
71
-
72
- if (dataTypeUtils.isObject(config[policy])) {
73
- for (const attribute in config[policy]) {
74
- const attributeName = customAttributes[attribute] || attribute;
75
-
76
- attributes.push({
77
- name: attributeName,
78
- type: preparePolicyAttributesTypes(config[policy][attribute], attributeName),
79
- values: attributeName === customAttributes.Including ? //Including attributes in Automobile Liability
80
- config[policy][attribute].split(', ') :
81
- [convertNumericValuesToNumberType(config[policy][attribute], attributeName)]
82
- });
83
- };
84
- } else {
85
- attributes.push({
86
- name: policy,
87
- type: prepareEndorsementAttributesTypes(config[policy]),
88
- values: [config[policy]]
89
- });
90
- }
91
-
92
- policies.push({
93
- name: policy,
94
- attributes
95
- });
96
- }
97
- return policies;
98
- };
99
-
100
- const getPolicyModel = function(policyData) {
101
- const attributes = policyData.attributes;
102
- const attributeModels = attributes.map(attribute =>
103
- new AttributeModel(attribute.name, attribute.type, attribute.values));
104
-
105
- return new PolicyModel(policyData.name, attributeModels);
106
- };
107
-
108
- const getCreateRequirementModel = function(requirement) {
109
- const { policies, name, sharingLevel } = requirement;
110
-
111
- const parsedPolicies = parseRequirementConfig(policies);
112
- const policyModels = parsedPolicies.map(policy => getPolicyModel(policy));
113
-
114
- return new CreateRequirementModel(name, policyModels, sharingLevel);
115
- };
116
-
117
- const getUpdateRequirementModel = function(updatedRequirement) {
118
- const { id, policies, name, recordType, sharingLevel, dateModified } = updatedRequirement;
119
-
120
- const parsedPolicies = parseRequirementConfig(policies);
121
- const policyModels = parsedPolicies.map(policy => getPolicyModel(policy));
122
-
123
- return new UpdateRequirementModel({ id, name, policies: policyModels, dateModified, sharingLevel, recordType });
124
- };
125
-
126
- module.exports = {
127
- getCreateRequirementModel,
128
- getUpdateRequirementModel
129
- };
1
+ const attributeTypes = require('../consts/attributeTypes.json');
2
+ const dataTypeUtils = require('../../../../common/utils/dataTypeUtils');
3
+ const { UpdateRequirementModel } = require('../models/update.requirement.model');
4
+ const { AttributeModel, PolicyModel, AttributeTypes } = require('../models/policy.model');
5
+ const { CreateRequirementModel } = require('../models/create.requirement.model');
6
+
7
+ const customAttributes = {
8
+ Including: 'multiple' //because attributeTypes.multiple => 'Multiple' with capital M
9
+ };
10
+ const numericAttributes = ['Indemnity Period', 'Notice of Cancellation', 'Notice of Cancellation Endorsement'];
11
+ const amBestAttributes = {
12
+ amBestRating: 'AM Best Rating',
13
+ amBestFinancialSizeCategory: 'AM Best Financial Size Category'
14
+ };
15
+
16
+ const convertNumericValuesToNumberType = function(value, attributeName) {
17
+ if (dataTypeUtils.isString(value) && value.startsWith('$')) {
18
+ return Number(value.replace(/[$,]/g, ''));
19
+ }
20
+
21
+ if (numericAttributes.includes(attributeName)) {
22
+ return Number(value);
23
+ }
24
+
25
+ return value;
26
+ };
27
+
28
+ const preparePolicyAttributesTypes = function(value, attributeName) {
29
+ const attributesValue = convertNumericValuesToNumberType(value, attributeName);
30
+
31
+ if (dataTypeUtils.isNumber(attributesValue)) {
32
+ return numericAttributes.includes(attributeName) ?
33
+ AttributeTypes.get(attributeTypes.numeric) :
34
+ AttributeTypes.get(attributeTypes.limit);
35
+ }
36
+
37
+ if (dataTypeUtils.isBoolean(attributesValue)) {
38
+ return AttributeTypes.get(attributeTypes.boolean);
39
+ }
40
+
41
+ if (dataTypeUtils.isString(attributesValue)) {
42
+ if (attributeName === amBestAttributes.amBestRating) {
43
+ return AttributeTypes.get(attributeTypes.amBestRating);
44
+ }
45
+
46
+ if (attributeName === amBestAttributes.amBestFinancialSizeCategory) {
47
+ return AttributeTypes.get(attributeTypes.amBestFinancialSizeCategory);
48
+ }
49
+ }
50
+
51
+ return AttributeTypes.get(attributeTypes.multiple);
52
+ };
53
+
54
+ const prepareEndorsementAttributesTypes = function(value) {
55
+ if (dataTypeUtils.isBoolean(value)) {
56
+ return AttributeTypes.get(attributeTypes.boolean);
57
+ }
58
+
59
+ return AttributeTypes.get(attributeTypes.endorsement);
60
+ };
61
+
62
+ const parseRequirementConfig = function(config) {
63
+ if (dataTypeUtils.isArray(config)) {
64
+ // If config is an array type it means the config is already parsed.
65
+ return config;
66
+ }
67
+
68
+ const policies = [];
69
+ for (const policy in config) {
70
+ const attributes = [];
71
+
72
+ if (dataTypeUtils.isObject(config[policy])) {
73
+ for (const attribute in config[policy]) {
74
+ const attributeName = customAttributes[attribute] || attribute;
75
+
76
+ attributes.push({
77
+ name: attributeName,
78
+ type: preparePolicyAttributesTypes(config[policy][attribute], attributeName),
79
+ values: attributeName === customAttributes.Including ? //Including attributes in Automobile Liability
80
+ config[policy][attribute].split(', ') :
81
+ [convertNumericValuesToNumberType(config[policy][attribute], attributeName)]
82
+ });
83
+ };
84
+ } else {
85
+ attributes.push({
86
+ name: policy,
87
+ type: prepareEndorsementAttributesTypes(config[policy]),
88
+ values: [config[policy]]
89
+ });
90
+ }
91
+
92
+ policies.push({
93
+ name: policy,
94
+ attributes
95
+ });
96
+ }
97
+ return policies;
98
+ };
99
+
100
+ const getPolicyModel = function(policyData) {
101
+ const attributes = policyData.attributes;
102
+ const attributeModels = attributes.map(attribute =>
103
+ new AttributeModel(attribute.name, attribute.type, attribute.values));
104
+
105
+ return new PolicyModel(policyData.name, attributeModels);
106
+ };
107
+
108
+ const getCreateRequirementModel = function(requirement) {
109
+ const { policies, name, sharingLevel } = requirement;
110
+
111
+ const parsedPolicies = parseRequirementConfig(policies);
112
+ const policyModels = parsedPolicies.map(policy => getPolicyModel(policy));
113
+
114
+ return new CreateRequirementModel(name, policyModels, sharingLevel);
115
+ };
116
+
117
+ const getUpdateRequirementModel = function(updatedRequirement) {
118
+ const { id, policies, name, recordType, sharingLevel, dateModified } = updatedRequirement;
119
+
120
+ const parsedPolicies = parseRequirementConfig(policies);
121
+ const policyModels = parsedPolicies.map(policy => getPolicyModel(policy));
122
+
123
+ return new UpdateRequirementModel({ id, name, policies: policyModels, dateModified, sharingLevel, recordType });
124
+ };
125
+
126
+ module.exports = {
127
+ getCreateRequirementModel,
128
+ getUpdateRequirementModel
129
+ };
@@ -1,12 +1,12 @@
1
- const requests = require('../../../../common/requests/cookieAuth/requests');
2
- const { backendUrl } = require('../../../../env').getEnv();
3
-
4
- const Endpoints = {
5
- coordinates: (city, state) => `${backendUrl}/saas/coordinates?city=${city}&state=${state}`
6
- };
7
-
8
- const getCoordinatesByAddress = (city, state, context) => {
9
- return requests.getRequestHandler(Endpoints.coordinates(city, state), {}, context);
10
- };
11
-
12
- module.exports = { getCoordinatesByAddress };
1
+ const requests = require('../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ coordinates: (city, state) => `${backendUrl}/saas/coordinates?city=${city}&state=${state}`
6
+ };
7
+
8
+ const getCoordinatesByAddress = (city, state, context) => {
9
+ return requests.getRequestHandler(Endpoints.coordinates(city, state), {}, context);
10
+ };
11
+
12
+ module.exports = { getCoordinatesByAddress };
@@ -1,7 +1,7 @@
1
- const coordinates = require('./coordinates.api');
2
-
3
- const getCoordinatesByAddress = (city, state, context) => {
4
- return coordinates.getCoordinatesByAddress(city, state, context);
5
- };
6
-
7
- module.exports = { getCoordinatesByAddress };
1
+ const coordinates = require('./coordinates.api');
2
+
3
+ const getCoordinatesByAddress = (city, state, context) => {
4
+ return coordinates.getCoordinatesByAddress(city, state, context);
5
+ };
6
+
7
+ module.exports = { getCoordinatesByAddress };
@@ -1,4 +1,4 @@
1
- const services = require('./api/coordinates.service');
2
- const utils = require('./utils/utils');
3
-
4
- module.exports = { services, utils };
1
+ const services = require('./api/coordinates.service');
2
+ const utils = require('./utils/utils');
3
+
4
+ module.exports = { services, utils };
@@ -1,8 +1,8 @@
1
- const service = require('../api/coordinates.service');
2
-
3
- const getCoordinatesByAddress = async (city, state, context) => {
4
- const response = await service.getCoordinatesByAddress(city, state, context);
5
- return response.data;
6
- };
7
-
8
- module.exports = { getCoordinatesByAddress };
1
+ const service = require('../api/coordinates.service');
2
+
3
+ const getCoordinatesByAddress = async (city, state, context) => {
4
+ const response = await service.getCoordinatesByAddress(city, state, context);
5
+ return response.data;
6
+ };
7
+
8
+ module.exports = { getCoordinatesByAddress };
@@ -1,32 +1,32 @@
1
- const requests = require('../../../../common/requests/cookieAuth/requests');
2
- const { backendUrl } = require('../../../../env').getEnv();
3
-
4
- const Endpoints = {
5
- getTabsByProjectId: `${backendUrl}/saas/vendortab`,
6
- getTabsByTabId: `${backendUrl}/saas/vendortab`,
7
- create: `${backendUrl}/saas/vendortab`,
8
- update: `${backendUrl}/saas/vendortab`,
9
- delete: `${backendUrl}/saas/vendortab`
10
- };
11
-
12
- const getTabByTabId = (tabId, context) => {
13
- return requests.getRequestHandler(Endpoints.getTabsByTabId, { tabId }, context);
14
- };
15
-
16
- const getTabsByProjectId = (projectId, context) => {
17
- return requests.getRequestHandler(Endpoints.getTabsByProjectId, { projectId }, context);
18
- };
19
-
20
- const createTab = (tabModel, context) => {
21
- return requests.postRequestHandler(Endpoints.create, tabModel, context);
22
- };
23
-
24
- const updateTab = (tabModel, context) => {
25
- return requests.putRequestHandler(Endpoints.update, tabModel, context);
26
- };
27
-
28
- const deleteTab = (tabId, context) => {
29
- return requests.deleteRequestHandler(Endpoints.delete, context, {}, { tabId });
30
- };
31
-
32
- module.exports = { getTabByTabId, getTabsByProjectId, createTab, updateTab, deleteTab };
1
+ const requests = require('../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ getTabsByProjectId: `${backendUrl}/saas/vendortab`,
6
+ getTabsByTabId: `${backendUrl}/saas/vendortab`,
7
+ create: `${backendUrl}/saas/vendortab`,
8
+ update: `${backendUrl}/saas/vendortab`,
9
+ delete: `${backendUrl}/saas/vendortab`
10
+ };
11
+
12
+ const getTabByTabId = (tabId, context) => {
13
+ return requests.getRequestHandler(Endpoints.getTabsByTabId, { tabId }, context);
14
+ };
15
+
16
+ const getTabsByProjectId = (projectId, context) => {
17
+ return requests.getRequestHandler(Endpoints.getTabsByProjectId, { projectId }, context);
18
+ };
19
+
20
+ const createTab = (tabModel, context) => {
21
+ return requests.postRequestHandler(Endpoints.create, tabModel, context);
22
+ };
23
+
24
+ const updateTab = (tabModel, context) => {
25
+ return requests.putRequestHandler(Endpoints.update, tabModel, context);
26
+ };
27
+
28
+ const deleteTab = (tabId, context) => {
29
+ return requests.deleteRequestHandler(Endpoints.delete, context, {}, { tabId });
30
+ };
31
+
32
+ module.exports = { getTabByTabId, getTabsByProjectId, createTab, updateTab, deleteTab };
@@ -1,54 +1,54 @@
1
- const tabsAPI = require('./tabs.api');
2
- const { CreateTabModel, UpdateTabModel } = require('../models/tabs.model');
3
-
4
- const createTab = async (projectId, tabName, tabType, context) => {
5
- const tabModel = new CreateTabModel(projectId, tabName, tabType);
6
- return tabsAPI.createTab(tabModel, context);
7
- };
8
-
9
- const getTabById = async (tabId, context) => {
10
- return tabsAPI.getTabByTabId(tabId, context);
11
- };
12
-
13
- const getTabsByProjectId = async (projectId, context) => {
14
- return tabsAPI.getTabsByProjectId(projectId, context);
15
- };
16
-
17
- const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
18
- const { data: tabs } = await getTabsByProjectId(projectId, context);
19
- const requestedTab = tabType ?
20
- tabs.find(tab => tab.tabName === tabName && tab.type === tabType) :
21
- tabs.find(tab => tab.tabName === tabName);
22
- return requestedTab;
23
- };
24
-
25
- const getOrCreateTab = async (projectId, tabName, tabType, context) => {
26
- const { data: tabs } = await getTabsByProjectId(projectId, context);
27
- const existingTab = tabs.find(tab => tab.tabName === tabName && tab.type === tabType);
28
-
29
- if (existingTab) {
30
- return existingTab;
31
- }
32
-
33
- const createResponse = await createTab(projectId, tabName, tabType, context);
34
- return createResponse.data;
35
- };
36
-
37
- const updateTab = async ({ id, projectId, name, type, context, dateModified }) => {
38
- const tabModel = new UpdateTabModel({ id, projectId, name, type, dateModified });
39
- return tabsAPI.updateTab(tabModel, context);
40
- };
41
-
42
- const deleteTabById = async (tabId, context) => {
43
- return tabsAPI.deleteTab(tabId, context);
44
- };
45
-
46
- module.exports = {
47
- createTab,
48
- getTabById,
49
- getTabsByProjectId,
50
- getTabsByName,
51
- getOrCreateTab,
52
- updateTab,
53
- deleteTabById
54
- };
1
+ const tabsAPI = require('./tabs.api');
2
+ const { CreateTabModel, UpdateTabModel } = require('../models/tabs.model');
3
+
4
+ const createTab = async (projectId, tabName, tabType, context) => {
5
+ const tabModel = new CreateTabModel(projectId, tabName, tabType);
6
+ return tabsAPI.createTab(tabModel, context);
7
+ };
8
+
9
+ const getTabById = async (tabId, context) => {
10
+ return tabsAPI.getTabByTabId(tabId, context);
11
+ };
12
+
13
+ const getTabsByProjectId = async (projectId, context) => {
14
+ return tabsAPI.getTabsByProjectId(projectId, context);
15
+ };
16
+
17
+ const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
18
+ const { data: tabs } = await getTabsByProjectId(projectId, context);
19
+ const requestedTab = tabType ?
20
+ tabs.find(tab => tab.tabName === tabName && tab.type === tabType) :
21
+ tabs.find(tab => tab.tabName === tabName);
22
+ return requestedTab;
23
+ };
24
+
25
+ const getOrCreateTab = async (projectId, tabName, tabType, context) => {
26
+ const { data: tabs } = await getTabsByProjectId(projectId, context);
27
+ const existingTab = tabs.find(tab => tab.tabName === tabName && tab.type === tabType);
28
+
29
+ if (existingTab) {
30
+ return existingTab;
31
+ }
32
+
33
+ const createResponse = await createTab(projectId, tabName, tabType, context);
34
+ return createResponse.data;
35
+ };
36
+
37
+ const updateTab = async ({ id, projectId, name, type, context, dateModified }) => {
38
+ const tabModel = new UpdateTabModel({ id, projectId, name, type, dateModified });
39
+ return tabsAPI.updateTab(tabModel, context);
40
+ };
41
+
42
+ const deleteTabById = async (tabId, context) => {
43
+ return tabsAPI.deleteTab(tabId, context);
44
+ };
45
+
46
+ module.exports = {
47
+ createTab,
48
+ getTabById,
49
+ getTabsByProjectId,
50
+ getTabsByName,
51
+ getOrCreateTab,
52
+ updateTab,
53
+ deleteTabById
54
+ };
@@ -1,3 +1,3 @@
1
- const services = require('./api/tabs.service');
2
-
3
- module.exports = { services };
1
+ const services = require('./api/tabs.service');
2
+
3
+ module.exports = { services };
@@ -1,19 +1,19 @@
1
- class CreateTabModel {
2
- constructor(projectId, tabName, tabType) {
3
- this.projectId = projectId;
4
- this.tabName = tabName;
5
- this.type = tabType;
6
- }
7
- }
8
-
9
- class UpdateTabModel {
10
- constructor({ projectId, name: tabName, type: tabType, id: tabId, dateModified } = {}) {
11
- this.tabId = tabId;
12
- this.projectId = projectId;
13
- this.tabName = tabName;
14
- this.type = tabType;
15
- this.dateModified = dateModified;
16
- }
17
- }
18
-
19
- module.exports = { CreateTabModel, UpdateTabModel };
1
+ class CreateTabModel {
2
+ constructor(projectId, tabName, tabType) {
3
+ this.projectId = projectId;
4
+ this.tabName = tabName;
5
+ this.type = tabType;
6
+ }
7
+ }
8
+
9
+ class UpdateTabModel {
10
+ constructor({ projectId, name: tabName, type: tabType, id: tabId, dateModified } = {}) {
11
+ this.tabId = tabId;
12
+ this.projectId = projectId;
13
+ this.tabName = tabName;
14
+ this.type = tabType;
15
+ this.dateModified = dateModified;
16
+ }
17
+ }
18
+
19
+ module.exports = { CreateTabModel, UpdateTabModel };
@@ -1,55 +1,55 @@
1
- const requests = require('../../internal-api/../../common/requests/cookieAuth/requests');
2
- const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
3
- const timeUtils = require('../../../common/utils/timeUtils');
4
-
5
- const { backendUrl, threadSchedulerSecret } = require('../../../env').getEnv();
6
-
7
- const Endpoints = {
8
- threadSchedular: `${backendUrl}/threadSchedular/${threadSchedulerSecret}`,
9
- internalFacingThreadScheduler: `${backendUrl}/threadScheduler/internal-facing/${threadSchedulerSecret}`
10
- };
11
- const defaultRetriesNumber = 10;
12
-
13
- const runThreadSchedulerWithRetries = async (endpoint, params, retries) => {
14
- let response;
15
-
16
- while (!response || isOverloadError(response.status) && retries--) {
17
- response = await requests.getRequestHandler(endpoint, params);
18
- await timeUtils.waitFor(1.5).seconds;
19
- }
20
-
21
- if (response.status !== httpResponseStatusCodes.OK) {
22
- throw new Error(`Thread scheduler has failed to run\n${response}`);
23
- }
24
-
25
- return response;
26
- };
27
-
28
- const runThreadScheduler = async ({ contractorIds = [], scheduledReportsIds = [], retries = defaultRetriesNumber } = {}) => {
29
- const params = { contractorIdsList: contractorIds.toString(), scheduledReportsIds: scheduledReportsIds.toString() };
30
-
31
- return runThreadSchedulerWithRetries(Endpoints.threadSchedular, params, retries);
32
- };
33
-
34
- const runInternalFacingThreadScheduler = async ({ accountIds = [], retries = defaultRetriesNumber } = {}) => {
35
- const params = { dailyReportsAccountIds: accountIds.toString() };
36
-
37
- return runThreadSchedulerWithRetries(Endpoints.internalFacingThreadScheduler, params, retries);
38
- };
39
-
40
- module.exports = {
41
- runForRecords: function(contractorIds) {
42
- return runThreadScheduler({ contractorIds });
43
- },
44
- runForReports: function(scheduledReportsIds) {
45
- return runThreadScheduler({ scheduledReportsIds });
46
- },
47
- runInternalFacing: function(accountIds) {
48
- return runInternalFacingThreadScheduler({ accountIds });
49
- }
50
- };
51
-
52
- function isOverloadError(errorCode) {
53
- const overloadResponseErrors = [httpResponseStatusCodes.TOO_MANY_REQUESTS, httpResponseStatusCodes.CONFLICT];
54
- return overloadResponseErrors.includes(errorCode);
55
- }
1
+ const requests = require('../../internal-api/../../common/requests/cookieAuth/requests');
2
+ const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
3
+ const timeUtils = require('../../../common/utils/timeUtils');
4
+
5
+ const { backendUrl, threadSchedulerSecret } = require('../../../env').getEnv();
6
+
7
+ const Endpoints = {
8
+ threadSchedular: `${backendUrl}/threadSchedular/${threadSchedulerSecret}`,
9
+ internalFacingThreadScheduler: `${backendUrl}/threadScheduler/internal-facing/${threadSchedulerSecret}`
10
+ };
11
+ const defaultRetriesNumber = 10;
12
+
13
+ const runThreadSchedulerWithRetries = async (endpoint, params, retries) => {
14
+ let response;
15
+
16
+ while (!response || isOverloadError(response.status) && retries--) {
17
+ response = await requests.getRequestHandler(endpoint, params);
18
+ await timeUtils.waitFor(1.5).seconds;
19
+ }
20
+
21
+ if (response.status !== httpResponseStatusCodes.OK) {
22
+ throw new Error(`Thread scheduler has failed to run\n${response}`);
23
+ }
24
+
25
+ return response;
26
+ };
27
+
28
+ const runThreadScheduler = async ({ contractorIds = [], scheduledReportsIds = [], retries = defaultRetriesNumber } = {}) => {
29
+ const params = { contractorIdsList: contractorIds.toString(), scheduledReportsIds: scheduledReportsIds.toString() };
30
+
31
+ return runThreadSchedulerWithRetries(Endpoints.threadSchedular, params, retries);
32
+ };
33
+
34
+ const runInternalFacingThreadScheduler = async ({ accountIds = [], retries = defaultRetriesNumber } = {}) => {
35
+ const params = { dailyReportsAccountIds: accountIds.toString() };
36
+
37
+ return runThreadSchedulerWithRetries(Endpoints.internalFacingThreadScheduler, params, retries);
38
+ };
39
+
40
+ module.exports = {
41
+ runForRecords: function(contractorIds) {
42
+ return runThreadScheduler({ contractorIds });
43
+ },
44
+ runForReports: function(scheduledReportsIds) {
45
+ return runThreadScheduler({ scheduledReportsIds });
46
+ },
47
+ runInternalFacing: function(accountIds) {
48
+ return runInternalFacingThreadScheduler({ accountIds });
49
+ }
50
+ };
51
+
52
+ function isOverloadError(errorCode) {
53
+ const overloadResponseErrors = [httpResponseStatusCodes.TOO_MANY_REQUESTS, httpResponseStatusCodes.CONFLICT];
54
+ return overloadResponseErrors.includes(errorCode);
55
+ }