@getjones/test-infra 2.8.2 → 2.8.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 (171) hide show
  1. package/package.json +29 -29
  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 +72 -72
  5. package/src/common/consts/dashboardCharts.js +17 -17
  6. package/src/common/consts/recordTypes.js +5 -5
  7. package/src/common/consts/userTypes.js +5 -5
  8. package/src/common/httpResponseStatusCodes.json +11 -11
  9. package/src/common/requests/apiKeyAuth/requests.js +44 -44
  10. package/src/common/requests/cookieAuth/requests.js +40 -40
  11. package/src/common/requests/requestHandlers.js +78 -78
  12. package/src/common/utils/complianceUtil.js +56 -56
  13. package/src/common/utils/dataTypeUtils.js +41 -41
  14. package/src/common/utils/numberUtils.js +22 -22
  15. package/src/common/utils/objectUtils.js +7 -7
  16. package/src/common/utils/timeUtils.js +175 -175
  17. package/src/common/validations/errorValidation.js +16 -16
  18. package/src/common/validations/typeValidations.js +36 -36
  19. package/src/defaults/configs/auditConfigs.js +91 -91
  20. package/src/defaults/configs/coverage.js +227 -227
  21. package/src/defaults/configs/polices.js +49 -49
  22. package/src/defaults/configs/requirement.js +32 -32
  23. package/src/defaults/index.js +6 -6
  24. package/src/env.js +57 -57
  25. package/src/factory/index.js +7 -7
  26. package/src/factory/records/records.js +142 -141
  27. package/src/factory/users/users.js +79 -79
  28. package/src/index.js +81 -81
  29. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
  30. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +77 -77
  31. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  32. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  33. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  34. package/src/saas/internal-api/accounts/api/settings/settings.service.js +41 -41
  35. package/src/saas/internal-api/accounts/consts/consts.js +6 -6
  36. package/src/saas/internal-api/accounts/index.js +21 -21
  37. package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
  38. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +38 -36
  39. package/src/saas/internal-api/accounts/utils/utils.js +66 -66
  40. package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
  41. package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
  42. package/src/saas/internal-api/auditNotes/index.js +4 -4
  43. package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
  44. package/src/saas/internal-api/auth/api/auth.api.js +27 -27
  45. package/src/saas/internal-api/auth/api/auth.service.js +90 -90
  46. package/src/saas/internal-api/auth/index.js +3 -3
  47. package/src/saas/internal-api/coi/api/coi.api.js +34 -34
  48. package/src/saas/internal-api/coi/api/coi.service.js +22 -22
  49. package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -5
  50. package/src/saas/internal-api/coi/index.js +13 -13
  51. package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
  52. package/src/saas/internal-api/coi/utils/utils.js +48 -48
  53. package/src/saas/internal-api/compliance/api/audit/audit.api.js +46 -46
  54. package/src/saas/internal-api/compliance/api/audit/audit.service.js +143 -143
  55. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  56. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  57. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  58. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +48 -48
  59. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +33 -33
  60. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +127 -127
  61. package/src/saas/internal-api/compliance/consts/audit.js +71 -71
  62. package/src/saas/internal-api/compliance/index.js +33 -33
  63. package/src/saas/internal-api/compliance/models/audit/audit.model.js +84 -84
  64. package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
  65. package/src/saas/internal-api/compliance/utils/auditUtil.js +222 -222
  66. package/src/saas/internal-api/compliance/utils/coverageUtil.js +40 -40
  67. package/src/saas/internal-api/contractors/api/contractors.api.js +153 -153
  68. package/src/saas/internal-api/contractors/api/contractors.service.js +169 -169
  69. package/src/saas/internal-api/contractors/consts/consts.js +6 -6
  70. package/src/saas/internal-api/contractors/index.js +9 -9
  71. package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
  72. package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
  73. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -60
  74. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  75. package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
  76. package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
  77. package/src/saas/internal-api/dashboard/index.js +5 -5
  78. package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
  79. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  80. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +127 -127
  81. package/src/saas/internal-api/dbEmails/consts/consts.js +37 -37
  82. package/src/saas/internal-api/dbEmails/index.js +5 -5
  83. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
  84. package/src/saas/internal-api/dbEmails/utils/util.js +68 -68
  85. package/src/saas/internal-api/globalRecord/api/global.record.api.js +82 -82
  86. package/src/saas/internal-api/globalRecord/api/global.record.service.js +95 -95
  87. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  88. package/src/saas/internal-api/globalRecord/index.js +6 -6
  89. package/src/saas/internal-api/globalRecord/models/global.record.model.js +43 -43
  90. package/src/saas/internal-api/globalRecord/utils/util.js +148 -148
  91. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  92. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  93. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  94. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  95. package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
  96. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  97. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
  98. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  99. package/src/saas/internal-api/projects/index.js +24 -24
  100. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  101. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  102. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +41 -41
  103. package/src/saas/internal-api/projects/utils/utils.js +156 -156
  104. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  105. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
  106. package/src/saas/internal-api/recordNotes/index.js +3 -3
  107. package/src/saas/internal-api/reports/api/reports.api.js +39 -39
  108. package/src/saas/internal-api/reports/api/reports.service.js +34 -34
  109. package/src/saas/internal-api/reports/consts/consts.js +63 -63
  110. package/src/saas/internal-api/reports/index.js +15 -15
  111. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  112. package/src/saas/internal-api/requests/api/requests.api.js +72 -72
  113. package/src/saas/internal-api/requests/api/requests.service.js +122 -114
  114. package/src/saas/internal-api/requests/index.js +14 -14
  115. package/src/saas/internal-api/requests/models/create.request.model.js +33 -33
  116. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  117. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  118. package/src/saas/internal-api/requests/utils.js +8 -8
  119. package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
  120. package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
  121. package/src/saas/internal-api/requestsTable/index.js +3 -3
  122. package/src/saas/internal-api/requirements/api/requirements.api.js +45 -45
  123. package/src/saas/internal-api/requirements/api/requirements.service.js +134 -134
  124. package/src/saas/internal-api/requirements/consts/attributeTypes.json +5 -5
  125. package/src/saas/internal-api/requirements/consts/consts.js +6 -6
  126. package/src/saas/internal-api/requirements/index.js +9 -9
  127. package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
  128. package/src/saas/internal-api/requirements/models/policy.model.js +32 -32
  129. package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
  130. package/src/saas/internal-api/requirements/utils/utils.js +102 -102
  131. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  132. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  133. package/src/saas/internal-api/serviceArea/index.js +4 -4
  134. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  135. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  136. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  137. package/src/saas/internal-api/tabs/index.js +3 -3
  138. package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
  139. package/src/saas/internal-api/thread-scheduler/runner.js +39 -39
  140. package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +32 -32
  141. package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +78 -78
  142. package/src/saas/internal-api/users/api/users.api.js +77 -77
  143. package/src/saas/internal-api/users/api/users.service.js +101 -101
  144. package/src/saas/internal-api/users/index.js +11 -11
  145. package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
  146. package/src/saas/internal-api/users/models/users.model.js +31 -31
  147. package/src/saas/internal-api/users/utils/util.js +20 -20
  148. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  149. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  150. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  151. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  152. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  153. package/src/saas/openapi/coi/coi.api.js +20 -20
  154. package/src/saas/openapi/coi/coi.service.js +13 -13
  155. package/src/saas/openapi/projects/projects.api.js +59 -59
  156. package/src/saas/openapi/projects/projects.service.js +44 -44
  157. package/src/saas/openapi/requests/index.js +7 -7
  158. package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
  159. package/src/saas/openapi/requests/models/update.request.model.js +35 -35
  160. package/src/saas/openapi/requests/requests.api.js +76 -76
  161. package/src/saas/openapi/requests/requests.service.js +65 -65
  162. package/src/saas/openapi/requirements/index.js +6 -6
  163. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  164. package/src/saas/openapi/requirements/requirements.api.js +26 -26
  165. package/src/saas/openapi/requirements/requirements.service.js +32 -32
  166. package/src/saas/openapi/tabs/index.js +6 -0
  167. package/src/saas/openapi/tabs/models/create.tab.model.js +6 -0
  168. package/src/saas/openapi/tabs/tabs.api.js +18 -13
  169. package/src/saas/openapi/tabs/tabs.service.js +11 -7
  170. package/tests/env.test.js +40 -40
  171. package/tests/validation.test.js +83 -83
@@ -1,175 +1,175 @@
1
- const moment = require('moment');
2
-
3
- const secondsInDay = 86400;
4
- const millisecondsToSeconds = 1000;
5
- const formats = {
6
- logTimeStampFormat: 'YYYY-MM-DD hh:mm:ss',
7
- dayMonthYear: 'DD/MM/YYYY',
8
- numericMonthDayYear: 'MM/DD/YYYY',
9
- monthDayYear: 'MMM DD, YYYY',
10
- monthDayYear_noZeroPrefix: 'MMM D, YYYY',
11
- dateTime: 'YYYY/MM/DD-hh:mm:ss',
12
- fullMonthDayYear: 'MMMM DD, YYYY',
13
- threadScheduler: '', // Passing empty string resolves moment.js format to ISO8601 standard like 2020-04-12T09:49:59Z;
14
- monthDayYear12hTime: 'MMM D, YYYY h:mm A',
15
- amPmTime: 'h:mm A',
16
- yearMonthDay: 'YYYY-MM-DD',
17
- shortedMonthName: 'MMM'
18
- };
19
-
20
- const peroids = {
21
- days: 'days',
22
- months: 'months',
23
- years: 'years'
24
- };
25
-
26
- const getOneYearAgoDate = format => moment().utc().subtract(1, peroids.years).format(format || formats.threadScheduler);
27
- const getSixMonthAgoDate = format => moment().utc().subtract(6, peroids.months).format(format || formats.threadScheduler);
28
- const getOneMonthAgoDate = format => moment().utc().subtract(1, peroids.months).format(format || formats.threadScheduler);
29
- const getFifteenDaysAgoDate = format => moment().utc().subtract(15, peroids.days).format(format || formats.threadScheduler);
30
- const getTenDaysAgoDate = format => moment().utc().subtract(10, peroids.days).format(format || formats.threadScheduler);
31
- const getEightDaysAgoDate = format => moment().utc().subtract(8, peroids.days).format(format || formats.threadScheduler);
32
- const getFiveDaysAgoDate = format => moment().utc().subtract(5, peroids.days).format(format || formats.threadScheduler);
33
- const getTwoDaysAgoDate = format => moment().utc().subtract(2, peroids.days).format(format || formats.threadScheduler);
34
- const getOneDayAgoDate = format => moment().utc().subtract(1, peroids.days).format(format || formats.threadScheduler);
35
- const getThirtyFiveDaysAgoDate = format => moment().utc().subtract(35, peroids.days).format(format || formats.threadScheduler);
36
- const getCurrentDate = format => moment().utc().format(format || formats.threadScheduler);
37
- const getDateInOneDay = format => moment().utc().add(1, peroids.days).format(format || formats.threadScheduler);
38
- const getDateinSixDays = format => moment().utc().add(6, peroids.days).format(format || formats.threadScheduler);
39
- const getDateInTwoMonths = format => moment().utc().add(2, peroids.months).format(format || formats.dayMonthYear);
40
- const getDateinThirteenDays = format => moment().utc().add(13, peroids.days).format(format || formats.threadScheduler);
41
- const getDateinTwentyNineDays = format => moment().utc().add(29, peroids.days).format(format || formats.threadScheduler);
42
- const getOneWeekAgoDate = () => moment().utc().subtract(7, peroids.days).format(formats.dayMonthYear);
43
- const getOneWeekAheadDate = () => moment().utc().add(7, peroids.days).format(formats.dayMonthYear);
44
-
45
- const getLogTimestamp = () => {
46
- return moment().format(formats.logTimeStampFormat);
47
- };
48
-
49
- const getCurrentFormattedDate = () => {
50
- return new Date().toISOString();
51
- };
52
-
53
- const getDateWithOffset = (date, offsetInDays) => {
54
- date.setDate(date.getDate() + offsetInDays);
55
- return date;
56
- };
57
-
58
- const getAuditDateFormat = date => {
59
- const year = date.getUTCFullYear();
60
- const month = date.getUTCMonth() + 1; //getMonth is zero-based
61
- const day = date.getUTCDate();
62
-
63
- return `${month}/${day}/${year}`;
64
- };
65
-
66
- const getYearMonthDayFormat = date => {
67
- const year = date.getUTCFullYear();
68
- const month = String(date.getUTCMonth() + 1).length === 1 ? `0${(date.getUTCMonth() + 1)}` : (date.getUTCMonth() + 1);
69
- const day = String(date.getUTCDate()).length === 1 ? `0${date.getUTCDate()}` : date.getUTCDate();
70
-
71
- return `${year}-${month}-${day}`;
72
- };
73
-
74
- const extractDateFromDateTime = date => {
75
- let extractedDate = date;
76
-
77
- if (date != null && date.length > 10) {
78
- extractedDate = date.substr(0, 10);
79
- }
80
-
81
- return extractedDate;
82
- };
83
-
84
- function waitFor(num) {
85
- return {
86
- mSeconds: new Promise(resolve => {
87
- setTimeout(resolve, num);
88
- }),
89
- seconds: new Promise(resolve => {
90
- setTimeout(resolve, num * 1000);
91
- })
92
- };
93
- }
94
-
95
- function getDayInMilliseconds() {
96
- return secondsInDay * millisecondsToSeconds;
97
- }
98
-
99
- function getPreviousDateByDays(days) {
100
- return new Date(new Date().getTime() - getDayInMilliseconds() * days);
101
- }
102
-
103
- const getInvitationDatesForNotResponsiveVendor = function() {
104
- const twoDaysAgoUtc = getTwoDaysAgoDate();
105
- const fiveDaysAgoUtc = getFiveDaysAgoDate();
106
- const eightDaysAgoUtc = getEightDaysAgoDate();
107
-
108
- return [twoDaysAgoUtc, fiveDaysAgoUtc, eightDaysAgoUtc];
109
- };
110
-
111
- const getInvitationDatesForNotResponsiveTenant = function() {
112
- const fiveDaysAgoUtc = getFiveDaysAgoDate();
113
- const tenDaysAgoUtc = getTenDaysAgoDate();
114
- const fifteenDaysAgoUtc = getFifteenDaysAgoDate();
115
-
116
- return [fiveDaysAgoUtc, tenDaysAgoUtc, fifteenDaysAgoUtc];
117
- };
118
-
119
- const isDateAfterOther = (date, other) => {
120
- return moment(date).isAfter(other);
121
- };
122
-
123
- const getAutomaticRenewalsExpirationDates = function() {
124
- const inTwentyNineDaysUtc = getDateinTwentyNineDays();
125
- const inThirteenDaysUtc = getDateinThirteenDays();
126
- const inSixDaysUtc = getDateinSixDays();
127
- const todayUtc = getCurrentDate();
128
-
129
- return [inTwentyNineDaysUtc, inThirteenDaysUtc, inSixDaysUtc, todayUtc];
130
- };
131
-
132
- const convertDateToNewFormat = (value, currentFormat, newFormat = formats.dayMonthYear) => {
133
- return moment(value, currentFormat).format(newFormat);
134
- };
135
-
136
- const convertDateToLongInt = value => {
137
- return Date.parse(value);
138
- };
139
-
140
- module.exports = {
141
- formats,
142
- getOneYearAgoDate,
143
- getSixMonthAgoDate,
144
- getOneMonthAgoDate,
145
- getFifteenDaysAgoDate,
146
- getTenDaysAgoDate,
147
- getEightDaysAgoDate,
148
- getFiveDaysAgoDate,
149
- getTwoDaysAgoDate,
150
- getOneDayAgoDate,
151
- getThirtyFiveDaysAgoDate,
152
- getCurrentDate,
153
- getDateInOneDay,
154
- getDateinSixDays,
155
- getDateinThirteenDays,
156
- getDateinTwentyNineDays,
157
- getDateInTwoMonths,
158
- getInvitationDatesForNotResponsiveVendor,
159
- getInvitationDatesForNotResponsiveTenant,
160
- getAutomaticRenewalsExpirationDates,
161
- getLogTimestamp,
162
- getCurrentFormattedDate,
163
- getAuditDateFormat,
164
- getDateWithOffset,
165
- getYearMonthDayFormat,
166
- getDayInMilliseconds,
167
- extractDateFromDateTime,
168
- getPreviousDateByDays,
169
- waitFor,
170
- isDateAfterOther,
171
- convertDateToNewFormat,
172
- getOneWeekAgoDate,
173
- getOneWeekAheadDate,
174
- convertDateToLongInt
175
- };
1
+ const moment = require('moment');
2
+
3
+ const secondsInDay = 86400;
4
+ const millisecondsToSeconds = 1000;
5
+ const formats = {
6
+ logTimeStampFormat: 'YYYY-MM-DD hh:mm:ss',
7
+ dayMonthYear: 'DD/MM/YYYY',
8
+ numericMonthDayYear: 'MM/DD/YYYY',
9
+ monthDayYear: 'MMM DD, YYYY',
10
+ monthDayYear_noZeroPrefix: 'MMM D, YYYY',
11
+ dateTime: 'YYYY/MM/DD-hh:mm:ss',
12
+ fullMonthDayYear: 'MMMM DD, YYYY',
13
+ threadScheduler: '', // Passing empty string resolves moment.js format to ISO8601 standard like 2020-04-12T09:49:59Z;
14
+ monthDayYear12hTime: 'MMM D, YYYY h:mm A',
15
+ amPmTime: 'h:mm A',
16
+ yearMonthDay: 'YYYY-MM-DD',
17
+ shortedMonthName: 'MMM'
18
+ };
19
+
20
+ const peroids = {
21
+ days: 'days',
22
+ months: 'months',
23
+ years: 'years'
24
+ };
25
+
26
+ const getOneYearAgoDate = format => moment().utc().subtract(1, peroids.years).format(format || formats.threadScheduler);
27
+ const getSixMonthAgoDate = format => moment().utc().subtract(6, peroids.months).format(format || formats.threadScheduler);
28
+ const getOneMonthAgoDate = format => moment().utc().subtract(1, peroids.months).format(format || formats.threadScheduler);
29
+ const getFifteenDaysAgoDate = format => moment().utc().subtract(15, peroids.days).format(format || formats.threadScheduler);
30
+ const getTenDaysAgoDate = format => moment().utc().subtract(10, peroids.days).format(format || formats.threadScheduler);
31
+ const getEightDaysAgoDate = format => moment().utc().subtract(8, peroids.days).format(format || formats.threadScheduler);
32
+ const getFiveDaysAgoDate = format => moment().utc().subtract(5, peroids.days).format(format || formats.threadScheduler);
33
+ const getTwoDaysAgoDate = format => moment().utc().subtract(2, peroids.days).format(format || formats.threadScheduler);
34
+ const getOneDayAgoDate = format => moment().utc().subtract(1, peroids.days).format(format || formats.threadScheduler);
35
+ const getThirtyFiveDaysAgoDate = format => moment().utc().subtract(35, peroids.days).format(format || formats.threadScheduler);
36
+ const getCurrentDate = format => moment().utc().format(format || formats.threadScheduler);
37
+ const getDateInOneDay = format => moment().utc().add(1, peroids.days).format(format || formats.threadScheduler);
38
+ const getDateinSixDays = format => moment().utc().add(6, peroids.days).format(format || formats.threadScheduler);
39
+ const getDateInTwoMonths = format => moment().utc().add(2, peroids.months).format(format || formats.dayMonthYear);
40
+ const getDateinThirteenDays = format => moment().utc().add(13, peroids.days).format(format || formats.threadScheduler);
41
+ const getDateinTwentyNineDays = format => moment().utc().add(29, peroids.days).format(format || formats.threadScheduler);
42
+ const getOneWeekAgoDate = () => moment().utc().subtract(7, peroids.days).format(formats.dayMonthYear);
43
+ const getOneWeekAheadDate = () => moment().utc().add(7, peroids.days).format(formats.dayMonthYear);
44
+
45
+ const getLogTimestamp = () => {
46
+ return moment().format(formats.logTimeStampFormat);
47
+ };
48
+
49
+ const getCurrentFormattedDate = () => {
50
+ return new Date().toISOString();
51
+ };
52
+
53
+ const getDateWithOffset = (date, offsetInDays) => {
54
+ date.setDate(date.getDate() + offsetInDays);
55
+ return date;
56
+ };
57
+
58
+ const getAuditDateFormat = date => {
59
+ const year = date.getUTCFullYear();
60
+ const month = date.getUTCMonth() + 1; //getMonth is zero-based
61
+ const day = date.getUTCDate();
62
+
63
+ return `${month}/${day}/${year}`;
64
+ };
65
+
66
+ const getYearMonthDayFormat = date => {
67
+ const year = date.getUTCFullYear();
68
+ const month = String(date.getUTCMonth() + 1).length === 1 ? `0${(date.getUTCMonth() + 1)}` : (date.getUTCMonth() + 1);
69
+ const day = String(date.getUTCDate()).length === 1 ? `0${date.getUTCDate()}` : date.getUTCDate();
70
+
71
+ return `${year}-${month}-${day}`;
72
+ };
73
+
74
+ const extractDateFromDateTime = date => {
75
+ let extractedDate = date;
76
+
77
+ if (date != null && date.length > 10) {
78
+ extractedDate = date.substr(0, 10);
79
+ }
80
+
81
+ return extractedDate;
82
+ };
83
+
84
+ function waitFor(num) {
85
+ return {
86
+ mSeconds: new Promise(resolve => {
87
+ setTimeout(resolve, num);
88
+ }),
89
+ seconds: new Promise(resolve => {
90
+ setTimeout(resolve, num * 1000);
91
+ })
92
+ };
93
+ }
94
+
95
+ function getDayInMilliseconds() {
96
+ return secondsInDay * millisecondsToSeconds;
97
+ }
98
+
99
+ function getPreviousDateByDays(days) {
100
+ return new Date(new Date().getTime() - getDayInMilliseconds() * days);
101
+ }
102
+
103
+ const getInvitationDatesForNotResponsiveVendor = function() {
104
+ const twoDaysAgoUtc = getTwoDaysAgoDate();
105
+ const fiveDaysAgoUtc = getFiveDaysAgoDate();
106
+ const eightDaysAgoUtc = getEightDaysAgoDate();
107
+
108
+ return [twoDaysAgoUtc, fiveDaysAgoUtc, eightDaysAgoUtc];
109
+ };
110
+
111
+ const getInvitationDatesForNotResponsiveTenant = function() {
112
+ const fiveDaysAgoUtc = getFiveDaysAgoDate();
113
+ const tenDaysAgoUtc = getTenDaysAgoDate();
114
+ const fifteenDaysAgoUtc = getFifteenDaysAgoDate();
115
+
116
+ return [fiveDaysAgoUtc, tenDaysAgoUtc, fifteenDaysAgoUtc];
117
+ };
118
+
119
+ const isDateAfterOther = (date, other) => {
120
+ return moment(date).isAfter(other);
121
+ };
122
+
123
+ const getAutomaticRenewalsExpirationDates = function() {
124
+ const inTwentyNineDaysUtc = getDateinTwentyNineDays();
125
+ const inThirteenDaysUtc = getDateinThirteenDays();
126
+ const inSixDaysUtc = getDateinSixDays();
127
+ const todayUtc = getCurrentDate();
128
+
129
+ return [inTwentyNineDaysUtc, inThirteenDaysUtc, inSixDaysUtc, todayUtc];
130
+ };
131
+
132
+ const convertDateToNewFormat = (value, currentFormat, newFormat = formats.dayMonthYear) => {
133
+ return moment(value, currentFormat).format(newFormat);
134
+ };
135
+
136
+ const convertDateToLongInt = value => {
137
+ return Date.parse(value);
138
+ };
139
+
140
+ module.exports = {
141
+ formats,
142
+ getOneYearAgoDate,
143
+ getSixMonthAgoDate,
144
+ getOneMonthAgoDate,
145
+ getFifteenDaysAgoDate,
146
+ getTenDaysAgoDate,
147
+ getEightDaysAgoDate,
148
+ getFiveDaysAgoDate,
149
+ getTwoDaysAgoDate,
150
+ getOneDayAgoDate,
151
+ getThirtyFiveDaysAgoDate,
152
+ getCurrentDate,
153
+ getDateInOneDay,
154
+ getDateinSixDays,
155
+ getDateinThirteenDays,
156
+ getDateinTwentyNineDays,
157
+ getDateInTwoMonths,
158
+ getInvitationDatesForNotResponsiveVendor,
159
+ getInvitationDatesForNotResponsiveTenant,
160
+ getAutomaticRenewalsExpirationDates,
161
+ getLogTimestamp,
162
+ getCurrentFormattedDate,
163
+ getAuditDateFormat,
164
+ getDateWithOffset,
165
+ getYearMonthDayFormat,
166
+ getDayInMilliseconds,
167
+ extractDateFromDateTime,
168
+ getPreviousDateByDays,
169
+ waitFor,
170
+ isDateAfterOther,
171
+ convertDateToNewFormat,
172
+ getOneWeekAgoDate,
173
+ getOneWeekAheadDate,
174
+ convertDateToLongInt
175
+ };
@@ -1,16 +1,16 @@
1
- const httpResponseStatusCodes = require('../httpResponseStatusCodes.json');
2
-
3
- const validateClientErrorResponseStatus = error => {
4
- if (!error.response || !isResponseStatusClientErrorCode(error.response.status)) {
5
- throw error;
6
- }
7
- };
8
-
9
- const isResponseStatusClientErrorCode = httpResponseStatusCode => {
10
- const minClientErrorCode = httpResponseStatusCodes.BAD_REQUEST;
11
- const maxClientErrorCode = httpResponseStatusCodes.CLIENT_CLOSED_REQUEST;
12
-
13
- return httpResponseStatusCode >= minClientErrorCode && httpResponseStatusCode <= maxClientErrorCode;
14
- };
15
-
16
- module.exports = { validateClientErrorResponseStatus };
1
+ const httpResponseStatusCodes = require('../httpResponseStatusCodes.json');
2
+
3
+ const validateClientErrorResponseStatus = error => {
4
+ if (!error.response || !isResponseStatusClientErrorCode(error.response.status)) {
5
+ throw error;
6
+ }
7
+ };
8
+
9
+ const isResponseStatusClientErrorCode = httpResponseStatusCode => {
10
+ const minClientErrorCode = httpResponseStatusCodes.BAD_REQUEST;
11
+ const maxClientErrorCode = httpResponseStatusCodes.CLIENT_CLOSED_REQUEST;
12
+
13
+ return httpResponseStatusCode >= minClientErrorCode && httpResponseStatusCode <= maxClientErrorCode;
14
+ };
15
+
16
+ module.exports = { validateClientErrorResponseStatus };
@@ -1,36 +1,36 @@
1
- const validateType = (input, expectedType) => {
2
- if (!(input instanceof expectedType)) {
3
- throw TypeError(`Type should be: ${expectedType}`);
4
- }
5
- };
6
-
7
- const validateDateString = dateString => {
8
- if (isNaN(Date.parse(dateString))) {
9
- throw TypeError(`Invalid date string '${dateString}'`);
10
- }
11
- };
12
-
13
- const validateInteger = (number, { min, max } = {}) => {
14
- if (!Number.isInteger(number)) {
15
- throw TypeError(`Invalid number '${number}'`);
16
- }
17
-
18
- const exceedsMin = !isNaN(min) && number < min;
19
- const exceedsMax = !isNaN(max) && number > max;
20
-
21
- if (exceedsMin && exceedsMax) {
22
- throw RangeError('Number is not in range.');
23
- } else if (exceedsMin) {
24
- throw RangeError(`Number is less than ${min}.`);
25
- } else if (exceedsMax) {
26
- throw RangeError(`Number is greater than ${max}.`);
27
- }
28
- };
29
-
30
- const validateArray = obj => {
31
- if (!Array.isArray(obj)) {
32
- throw TypeError(`Invalid Array '${JSON.stringify(obj)}'`);
33
- }
34
- };
35
-
36
- module.exports = { validateType, validateDateString, validateInteger, validateArray };
1
+ const validateType = (input, expectedType) => {
2
+ if (!(input instanceof expectedType)) {
3
+ throw TypeError(`Type should be: ${expectedType}`);
4
+ }
5
+ };
6
+
7
+ const validateDateString = dateString => {
8
+ if (isNaN(Date.parse(dateString))) {
9
+ throw TypeError(`Invalid date string '${dateString}'`);
10
+ }
11
+ };
12
+
13
+ const validateInteger = (number, { min, max } = {}) => {
14
+ if (!Number.isInteger(number)) {
15
+ throw TypeError(`Invalid number '${number}'`);
16
+ }
17
+
18
+ const exceedsMin = !isNaN(min) && number < min;
19
+ const exceedsMax = !isNaN(max) && number > max;
20
+
21
+ if (exceedsMin && exceedsMax) {
22
+ throw RangeError('Number is not in range.');
23
+ } else if (exceedsMin) {
24
+ throw RangeError(`Number is less than ${min}.`);
25
+ } else if (exceedsMax) {
26
+ throw RangeError(`Number is greater than ${max}.`);
27
+ }
28
+ };
29
+
30
+ const validateArray = obj => {
31
+ if (!Array.isArray(obj)) {
32
+ throw TypeError(`Invalid Array '${JSON.stringify(obj)}'`);
33
+ }
34
+ };
35
+
36
+ module.exports = { validateType, validateDateString, validateInteger, validateArray };
@@ -1,91 +1,91 @@
1
- const { policyNames, attributeNames } = require('./polices');
2
- const { cloneObject } = require('../../common/utils/objectUtils');
3
- const { getOneWeekAgoDate, getOneWeekAheadDate } = require('../../common/utils/timeUtils');
4
-
5
- const DEFAULT_POLICY_DATE = '24/05/2030';
6
- const DEFAULT_AM_SCORE = 'A';
7
-
8
- //Excluded from creating global record: 'ABC-12345-XYZ', 'ABC-123-XYZ', 'ABC-123'. When GR is needed - use different GL number.
9
- const DEFAULT_POLICY_NUMBER = 'ABC-12345-XYZ';
10
-
11
- const {
12
- certificateIssueDate,
13
- generalLiability
14
- } = policyNames;
15
-
16
- const {
17
- coverageExists,
18
- policyNumber,
19
- policyExpired,
20
- perOccurrence,
21
- perPolicy,
22
- perProject,
23
- perLocation,
24
- eachOccurrence,
25
- cancellationTerms,
26
- coiAuthentication,
27
- signature,
28
- amScore,
29
- insuredAddress,
30
- insuredName
31
- } = attributeNames;
32
-
33
- const policySelections = {
34
- YES: 'Yes',
35
- NO: 'No',
36
- OTHER: 'Other'
37
- };
38
-
39
- const getCompliantAuditConfig = ({ glPolicyNumber = DEFAULT_POLICY_NUMBER } = {}) => {
40
- const config = cloneObject({
41
- [certificateIssueDate]: `${DEFAULT_POLICY_DATE}`,
42
- [insuredAddress]: policySelections.YES,
43
- [insuredName]: policySelections.YES,
44
- [amScore]: DEFAULT_AM_SCORE,
45
- [generalLiability]: {
46
- [coverageExists]: policySelections.YES,
47
- [policyNumber]: glPolicyNumber,
48
- [policyExpired]: `${DEFAULT_POLICY_DATE}`,
49
- [perOccurrence]: policySelections.YES,
50
- [perPolicy]: policySelections.YES,
51
- [perProject]: policySelections.YES,
52
- [perLocation]: policySelections.YES,
53
- [eachOccurrence]: policySelections.YES
54
- },
55
- [cancellationTerms]: policySelections.YES,
56
- [coiAuthentication]: policySelections.YES,
57
- [signature]: policySelections.YES
58
- });
59
- return config;
60
- };
61
-
62
- const getNotCompliantConfig = ({ glPolicyNumber } = {}) => {
63
- const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
64
- compliantConfig[signature] = policySelections.NO;
65
-
66
- return compliantConfig;
67
- };
68
-
69
- const getAboutExpiredConfig = ({ glPolicyNumber } = {}) => {
70
- const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
71
- compliantConfig[generalLiability][policyExpired] = `${getOneWeekAheadDate()}`;
72
- return compliantConfig;
73
- };
74
-
75
- const getExpiredConfig = ({ glPolicyNumber } = {}) => {
76
- const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
77
- compliantConfig[generalLiability][policyExpired] = `${getOneWeekAgoDate()}`;
78
-
79
- return compliantConfig;
80
- };
81
-
82
- module.exports = {
83
- getCompliantAuditConfig,
84
- getNotCompliantConfig,
85
- getAboutExpiredConfig,
86
- getExpiredConfig,
87
- policySelections,
88
- defaultPolicyDate: DEFAULT_POLICY_DATE,
89
- defaultAMScore: DEFAULT_AM_SCORE,
90
- defaultPolicyNumber: DEFAULT_POLICY_NUMBER
91
- };
1
+ const { policyNames, attributeNames } = require('./polices');
2
+ const { cloneObject } = require('../../common/utils/objectUtils');
3
+ const { getOneWeekAgoDate, getOneWeekAheadDate } = require('../../common/utils/timeUtils');
4
+
5
+ const DEFAULT_POLICY_DATE = '24/05/2030';
6
+ const DEFAULT_AM_SCORE = 'A';
7
+
8
+ //Excluded from creating global record: 'ABC-12345-XYZ', 'ABC-123-XYZ', 'ABC-123'. When GR is needed - use different GL number.
9
+ const DEFAULT_POLICY_NUMBER = 'ABC-12345-XYZ';
10
+
11
+ const {
12
+ certificateIssueDate,
13
+ generalLiability
14
+ } = policyNames;
15
+
16
+ const {
17
+ coverageExists,
18
+ policyNumber,
19
+ policyExpired,
20
+ perOccurrence,
21
+ perPolicy,
22
+ perProject,
23
+ perLocation,
24
+ eachOccurrence,
25
+ cancellationTerms,
26
+ coiAuthentication,
27
+ signature,
28
+ amScore,
29
+ insuredAddress,
30
+ insuredName
31
+ } = attributeNames;
32
+
33
+ const policySelections = {
34
+ YES: 'Yes',
35
+ NO: 'No',
36
+ OTHER: 'Other'
37
+ };
38
+
39
+ const getCompliantAuditConfig = ({ glPolicyNumber = DEFAULT_POLICY_NUMBER } = {}) => {
40
+ const config = cloneObject({
41
+ [certificateIssueDate]: `${DEFAULT_POLICY_DATE}`,
42
+ [insuredAddress]: policySelections.YES,
43
+ [insuredName]: policySelections.YES,
44
+ [amScore]: DEFAULT_AM_SCORE,
45
+ [generalLiability]: {
46
+ [coverageExists]: policySelections.YES,
47
+ [policyNumber]: glPolicyNumber,
48
+ [policyExpired]: `${DEFAULT_POLICY_DATE}`,
49
+ [perOccurrence]: policySelections.YES,
50
+ [perPolicy]: policySelections.YES,
51
+ [perProject]: policySelections.YES,
52
+ [perLocation]: policySelections.YES,
53
+ [eachOccurrence]: policySelections.YES
54
+ },
55
+ [cancellationTerms]: policySelections.YES,
56
+ [coiAuthentication]: policySelections.YES,
57
+ [signature]: policySelections.YES
58
+ });
59
+ return config;
60
+ };
61
+
62
+ const getNotCompliantConfig = ({ glPolicyNumber } = {}) => {
63
+ const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
64
+ compliantConfig[signature] = policySelections.NO;
65
+
66
+ return compliantConfig;
67
+ };
68
+
69
+ const getAboutExpiredConfig = ({ glPolicyNumber } = {}) => {
70
+ const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
71
+ compliantConfig[generalLiability][policyExpired] = `${getOneWeekAheadDate()}`;
72
+ return compliantConfig;
73
+ };
74
+
75
+ const getExpiredConfig = ({ glPolicyNumber } = {}) => {
76
+ const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
77
+ compliantConfig[generalLiability][policyExpired] = `${getOneWeekAgoDate()}`;
78
+
79
+ return compliantConfig;
80
+ };
81
+
82
+ module.exports = {
83
+ getCompliantAuditConfig,
84
+ getNotCompliantConfig,
85
+ getAboutExpiredConfig,
86
+ getExpiredConfig,
87
+ policySelections,
88
+ defaultPolicyDate: DEFAULT_POLICY_DATE,
89
+ defaultAMScore: DEFAULT_AM_SCORE,
90
+ defaultPolicyNumber: DEFAULT_POLICY_NUMBER
91
+ };