@getjones/test-infra 2.6.1 → 2.6.3

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 (149) hide show
  1. package/package.json +29 -30
  2. package/src/common/commonFlows/index.js +3 -3
  3. package/src/common/commonFlows/records/records.js +71 -71
  4. package/src/common/consts/userTypes.js +5 -0
  5. package/src/common/httpResponseStatusCodes.json +11 -11
  6. package/src/common/requests/apiKeyAuth/requests.js +38 -38
  7. package/src/common/requests/cookieAuth/requests.js +40 -40
  8. package/src/common/requests/requestHandlers.js +60 -60
  9. package/src/common/utils/dataTypeUtils.js +41 -41
  10. package/src/common/utils/numberUtils.js +22 -22
  11. package/src/common/utils/objectUtils.js +7 -9
  12. package/src/common/utils/timeUtils.js +171 -171
  13. package/src/common/validations/errorValidation.js +16 -16
  14. package/src/common/validations/typeValidations.js +36 -36
  15. package/src/defaults/configs/auditConfigs.js +85 -85
  16. package/src/defaults/configs/polices.js +47 -47
  17. package/src/defaults/configs/requirement.js +29 -29
  18. package/src/defaults/index.js +5 -5
  19. package/src/env.js +57 -57
  20. package/src/factory/index.js +5 -0
  21. package/src/factory/records/records.js +105 -0
  22. package/src/index.js +74 -73
  23. package/src/resources/coi/coi.pdf +0 -0
  24. package/src/resources/coi/realCoi.pdf +5617 -20
  25. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
  26. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +77 -77
  27. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  28. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  29. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  30. package/src/saas/internal-api/accounts/api/settings/settings.service.js +24 -24
  31. package/src/saas/internal-api/accounts/consts/consts.js +6 -6
  32. package/src/saas/internal-api/accounts/index.js +21 -21
  33. package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
  34. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +23 -23
  35. package/src/saas/internal-api/accounts/utils/utils.js +32 -32
  36. package/src/saas/internal-api/auth/api/auth.api.js +18 -18
  37. package/src/saas/internal-api/auth/api/auth.service.js +67 -67
  38. package/src/saas/internal-api/auth/index.js +3 -3
  39. package/src/saas/internal-api/coi/api/coi.api.js +34 -34
  40. package/src/saas/internal-api/coi/api/coi.service.js +22 -22
  41. package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -7
  42. package/src/saas/internal-api/coi/index.js +13 -13
  43. package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
  44. package/src/saas/internal-api/coi/utils/utils.js +48 -48
  45. package/src/saas/internal-api/compliance/api/audit/audit.api.js +40 -40
  46. package/src/saas/internal-api/compliance/api/audit/audit.service.js +152 -151
  47. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  48. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  49. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  50. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +24 -24
  51. package/src/saas/internal-api/compliance/api/waive/waive.api.js +21 -21
  52. package/src/saas/internal-api/compliance/api/waive/waive.service.js +100 -15
  53. package/src/saas/internal-api/compliance/consts/audit.js +71 -81
  54. package/src/saas/internal-api/compliance/index.js +28 -28
  55. package/src/saas/internal-api/compliance/models/audit/audit.model.js +84 -84
  56. package/src/saas/internal-api/compliance/models/waive/waive.model.js +48 -45
  57. package/src/saas/internal-api/compliance/utils/util.js +207 -175
  58. package/src/saas/internal-api/contractors/api/contractors.api.js +141 -141
  59. package/src/saas/internal-api/contractors/api/contractors.service.js +147 -147
  60. package/src/saas/internal-api/contractors/index.js +8 -8
  61. package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
  62. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -60
  63. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  64. package/src/saas/internal-api/dashboardInnerPage/api/recordList.api.js +12 -12
  65. package/src/saas/internal-api/dashboardInnerPage/api/recordList.service.js +7 -7
  66. package/src/saas/internal-api/dashboardInnerPage/index.js +5 -5
  67. package/src/saas/internal-api/dashboardInnerPage/models/dashboard.filter.criteria.model.js +38 -38
  68. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  69. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +127 -127
  70. package/src/saas/internal-api/dbEmails/consts/consts.js +3 -3
  71. package/src/saas/internal-api/dbEmails/index.js +4 -4
  72. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
  73. package/src/saas/internal-api/dbEmails/utils/util.js +59 -59
  74. package/src/saas/internal-api/globalRecord/api/global.record.api.js +76 -76
  75. package/src/saas/internal-api/globalRecord/api/global.record.service.js +83 -83
  76. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  77. package/src/saas/internal-api/globalRecord/index.js +6 -6
  78. package/src/saas/internal-api/globalRecord/models/global.record.model.js +43 -43
  79. package/src/saas/internal-api/globalRecord/utils/util.js +148 -148
  80. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  81. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  82. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  83. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  84. package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
  85. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  86. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +17 -17
  87. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  88. package/src/saas/internal-api/projects/index.js +24 -24
  89. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  90. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  91. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +39 -39
  92. package/src/saas/internal-api/projects/utils/utils.js +82 -82
  93. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  94. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
  95. package/src/saas/internal-api/recordNotes/index.js +3 -3
  96. package/src/saas/internal-api/reports/api/reports.api.js +39 -39
  97. package/src/saas/internal-api/reports/api/reports.service.js +34 -34
  98. package/src/saas/internal-api/reports/consts/consts.js +63 -63
  99. package/src/saas/internal-api/reports/index.js +15 -15
  100. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  101. package/src/saas/internal-api/requests/api/requests.api.js +54 -54
  102. package/src/saas/internal-api/requests/api/requests.service.js +84 -51
  103. package/src/saas/internal-api/requests/index.js +14 -14
  104. package/src/saas/internal-api/requests/models/create.request.model.js +22 -22
  105. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  106. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  107. package/src/saas/internal-api/requests/utils.js +8 -8
  108. package/src/saas/internal-api/requirements/api/requirements.api.js +45 -45
  109. package/src/saas/internal-api/requirements/api/requirements.service.js +94 -94
  110. package/src/saas/internal-api/requirements/consts/attributeTypes.json +5 -5
  111. package/src/saas/internal-api/requirements/consts/consts.js +6 -6
  112. package/src/saas/internal-api/requirements/index.js +8 -8
  113. package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
  114. package/src/saas/internal-api/requirements/models/policy.model.js +32 -32
  115. package/src/saas/internal-api/requirements/models/update.requirement.model.js +21 -21
  116. package/src/saas/internal-api/requirements/utils/utils.js +101 -101
  117. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  118. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  119. package/src/saas/internal-api/serviceArea/index.js +4 -4
  120. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  121. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  122. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  123. package/src/saas/internal-api/tabs/index.js +3 -3
  124. package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
  125. package/src/saas/internal-api/thread-scheduler/runner.js +39 -39
  126. package/src/saas/internal-api/users/api/users.api.js +77 -77
  127. package/src/saas/internal-api/users/api/users.service.js +101 -101
  128. package/src/saas/internal-api/users/index.js +4 -4
  129. package/src/saas/internal-api/users/models/users.model.js +31 -31
  130. package/src/saas/internal-api/users/utils/util.js +14 -14
  131. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  132. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  133. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  134. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  135. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  136. package/src/saas/openapi/projects/projects.api.js +59 -59
  137. package/src/saas/openapi/projects/projects.service.js +44 -44
  138. package/src/saas/openapi/requests/index.js +6 -6
  139. package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
  140. package/src/saas/openapi/requests/requests.api.js +20 -20
  141. package/src/saas/openapi/requests/requests.service.js +18 -18
  142. package/src/saas/openapi/requirements/index.js +6 -6
  143. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  144. package/src/saas/openapi/requirements/requirements.api.js +12 -12
  145. package/src/saas/openapi/requirements/requirements.service.js +20 -20
  146. package/src/saas/openapi/tabs/tabs.api.js +13 -13
  147. package/src/saas/openapi/tabs/tabs.service.js +7 -7
  148. package/tests/env.test.js +40 -40
  149. package/tests/validation.test.js +83 -83
@@ -1,9 +1,7 @@
1
- const _ = require('lodash');
2
-
3
- const cloneObject = object => {
4
- return _.cloneDeep(object);
5
- };
6
-
7
- module.exports = {
8
- cloneObject
9
- };
1
+ const cloneObject = object => {
2
+ return JSON.parse(JSON.stringify(object));
3
+ };
4
+
5
+ module.exports = {
6
+ cloneObject
7
+ };
@@ -1,171 +1,171 @@
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
- };
17
-
18
- const peroids = {
19
- days: 'days',
20
- months: 'months',
21
- years: 'years'
22
- };
23
-
24
- const getOneYearAgoDate = format => moment().utc().subtract(1, peroids.years).format(format || formats.threadScheduler);
25
- const getSixMonthAgoDate = format => moment().utc().subtract(6, peroids.months).format(format || formats.threadScheduler);
26
- const getOneMonthAgoDate = format => moment().utc().subtract(1, peroids.months).format(format || formats.threadScheduler);
27
- const getFifteenDaysAgoDate = format => moment().utc().subtract(15, peroids.days).format(format || formats.threadScheduler);
28
- const getTenDaysAgoDate = format => moment().utc().subtract(10, peroids.days).format(format || formats.threadScheduler);
29
- const getEightDaysAgoDate = format => moment().utc().subtract(8, peroids.days).format(format || formats.threadScheduler);
30
- const getFiveDaysAgoDate = format => moment().utc().subtract(5, peroids.days).format(format || formats.threadScheduler);
31
- const getTwoDaysAgoDate = format => moment().utc().subtract(2, peroids.days).format(format || formats.threadScheduler);
32
- const getOneDayAgoDate = format => moment().utc().subtract(1, peroids.days).format(format || formats.threadScheduler);
33
- const getThirtyFiveDaysAgoDate = format => moment().utc().subtract(35, peroids.days).format(format || formats.threadScheduler);
34
- const getCurrentDate = format => moment().utc().format(format || formats.threadScheduler);
35
- const getDateInOneDay = format => moment().utc().add(1, peroids.days).format(format || formats.threadScheduler);
36
- const getDateinSixDays = format => moment().utc().add(6, peroids.days).format(format || formats.threadScheduler);
37
- const getDateinThirteenDays = format => moment().utc().add(13, peroids.days).format(format || formats.threadScheduler);
38
- const getDateinTwentyNineDays = format => moment().utc().add(29, peroids.days).format(format || formats.threadScheduler);
39
- const getOneWeekAgoDate = format => moment().utc().subtract(7, peroids.days).format(format || formats.threadScheduler);
40
- const getOneWeekAheadDate = format => moment().utc().add(7, peroids.days).format(format || formats.threadScheduler);
41
-
42
- const getLogTimestamp = () => {
43
- return moment().format(formats.logTimeStampFormat);
44
- };
45
-
46
- const getCurrentFormattedDate = () => {
47
- return new Date().toISOString();
48
- };
49
-
50
- const getDateWithOffset = (date, offsetInDays) => {
51
- date.setDate(date.getDate() + offsetInDays);
52
- return date;
53
- };
54
-
55
- const getAuditDateFormat = date => {
56
- const year = date.getUTCFullYear();
57
- const month = date.getUTCMonth() + 1; //getMonth is zero-based
58
- const day = date.getUTCDate();
59
-
60
- return `${month}/${day}/${year}`;
61
- };
62
-
63
- const getYearMonthDayFormat = date => {
64
- const year = date.getUTCFullYear();
65
- const month = String(date.getUTCMonth() + 1).length === 1 ? `0${(date.getUTCMonth() + 1)}` : (date.getUTCMonth() + 1);
66
- const day = String(date.getUTCDate()).length === 1 ? `0${date.getUTCDate()}` : date.getUTCDate();
67
-
68
- return `${year}-${month}-${day}`;
69
- };
70
-
71
- const dateToIsoFormat = date => {
72
- return new Date(date).toISOString();
73
- };
74
-
75
- const extractDateFromDateTime = date => {
76
- let extractedDate = date;
77
-
78
- if (date != null && date.length > 10) {
79
- extractedDate = date.substr(0, 10);
80
- }
81
-
82
- return extractedDate;
83
- };
84
-
85
- function waitFor(num) {
86
- return {
87
- mSeconds: new Promise(resolve => {
88
- setTimeout(resolve, num);
89
- }),
90
- seconds: new Promise(resolve => {
91
- setTimeout(resolve, num * 1000);
92
- })
93
- };
94
- }
95
-
96
- function getDayInMilliseconds() {
97
- return secondsInDay * millisecondsToSeconds;
98
- }
99
-
100
- function getPreviousDateByDays(days) {
101
- return new Date(new Date().getTime() - getDayInMilliseconds() * days);
102
- }
103
-
104
- const getInvitationDatesForNotResponsiveVendor = function() {
105
- const twoDaysAgoUtc = getTwoDaysAgoDate();
106
- const fiveDaysAgoUtc = getFiveDaysAgoDate();
107
- const eightDaysAgoUtc = getEightDaysAgoDate();
108
-
109
- return [twoDaysAgoUtc, fiveDaysAgoUtc, eightDaysAgoUtc];
110
- };
111
-
112
- const getInvitationDatesForNotResponsiveTenant = function() {
113
- const fiveDaysAgoUtc = getFiveDaysAgoDate();
114
- const tenDaysAgoUtc = getTenDaysAgoDate();
115
- const fifteenDaysAgoUtc = getFifteenDaysAgoDate();
116
-
117
- return [fiveDaysAgoUtc, tenDaysAgoUtc, fifteenDaysAgoUtc];
118
- };
119
-
120
- const isDateAfterOther = (date, other) => {
121
- return moment(date).isAfter(other);
122
- };
123
-
124
- const getAutomaticRenewalsExpirationDates = function() {
125
- const inTwentyNineDaysUtc = getDateinTwentyNineDays();
126
- const inThirteenDaysUtc = getDateinThirteenDays();
127
- const inSixDaysUtc = getDateinSixDays();
128
- const todayUtc = getCurrentDate();
129
-
130
- return [inTwentyNineDaysUtc, inThirteenDaysUtc, inSixDaysUtc, todayUtc];
131
- };
132
-
133
- const convertDateToNewFormat = (value, currentFormat, newFormat = formats.dayMonthYear) => {
134
- return moment(value, currentFormat).format(newFormat);
135
- };
136
-
137
- module.exports = {
138
- formats,
139
- getOneYearAgoDate,
140
- getSixMonthAgoDate,
141
- getOneMonthAgoDate,
142
- getFifteenDaysAgoDate,
143
- getTenDaysAgoDate,
144
- getEightDaysAgoDate,
145
- getFiveDaysAgoDate,
146
- getTwoDaysAgoDate,
147
- getOneDayAgoDate,
148
- getThirtyFiveDaysAgoDate,
149
- getCurrentDate,
150
- getDateInOneDay,
151
- getDateinSixDays,
152
- getDateinThirteenDays,
153
- getDateinTwentyNineDays,
154
- getInvitationDatesForNotResponsiveVendor,
155
- getInvitationDatesForNotResponsiveTenant,
156
- getAutomaticRenewalsExpirationDates,
157
- getLogTimestamp,
158
- getCurrentFormattedDate,
159
- getAuditDateFormat,
160
- getDateWithOffset,
161
- getYearMonthDayFormat,
162
- dateToIsoFormat,
163
- getDayInMilliseconds,
164
- extractDateFromDateTime,
165
- getPreviousDateByDays,
166
- waitFor,
167
- isDateAfterOther,
168
- convertDateToNewFormat,
169
- getOneWeekAgoDate,
170
- getOneWeekAheadDate
171
- };
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
+ };
17
+
18
+ const peroids = {
19
+ days: 'days',
20
+ months: 'months',
21
+ years: 'years'
22
+ };
23
+
24
+ const getOneYearAgoDate = format => moment().utc().subtract(1, peroids.years).format(format || formats.threadScheduler);
25
+ const getSixMonthAgoDate = format => moment().utc().subtract(6, peroids.months).format(format || formats.threadScheduler);
26
+ const getOneMonthAgoDate = format => moment().utc().subtract(1, peroids.months).format(format || formats.threadScheduler);
27
+ const getFifteenDaysAgoDate = format => moment().utc().subtract(15, peroids.days).format(format || formats.threadScheduler);
28
+ const getTenDaysAgoDate = format => moment().utc().subtract(10, peroids.days).format(format || formats.threadScheduler);
29
+ const getEightDaysAgoDate = format => moment().utc().subtract(8, peroids.days).format(format || formats.threadScheduler);
30
+ const getFiveDaysAgoDate = format => moment().utc().subtract(5, peroids.days).format(format || formats.threadScheduler);
31
+ const getTwoDaysAgoDate = format => moment().utc().subtract(2, peroids.days).format(format || formats.threadScheduler);
32
+ const getOneDayAgoDate = format => moment().utc().subtract(1, peroids.days).format(format || formats.threadScheduler);
33
+ const getThirtyFiveDaysAgoDate = format => moment().utc().subtract(35, peroids.days).format(format || formats.threadScheduler);
34
+ const getCurrentDate = format => moment().utc().format(format || formats.threadScheduler);
35
+ const getDateInOneDay = format => moment().utc().add(1, peroids.days).format(format || formats.threadScheduler);
36
+ const getDateinSixDays = format => moment().utc().add(6, peroids.days).format(format || formats.threadScheduler);
37
+ const getDateinThirteenDays = format => moment().utc().add(13, peroids.days).format(format || formats.threadScheduler);
38
+ const getDateinTwentyNineDays = format => moment().utc().add(29, peroids.days).format(format || formats.threadScheduler);
39
+ const getOneWeekAgoDate = () => moment().utc().subtract(7, peroids.days).format(formats.dayMonthYear);
40
+ const getOneWeekAheadDate = () => moment().utc().add(7, peroids.days).format(formats.dayMonthYear);
41
+
42
+ const getLogTimestamp = () => {
43
+ return moment().format(formats.logTimeStampFormat);
44
+ };
45
+
46
+ const getCurrentFormattedDate = () => {
47
+ return new Date().toISOString();
48
+ };
49
+
50
+ const getDateWithOffset = (date, offsetInDays) => {
51
+ date.setDate(date.getDate() + offsetInDays);
52
+ return date;
53
+ };
54
+
55
+ const getAuditDateFormat = date => {
56
+ const year = date.getUTCFullYear();
57
+ const month = date.getUTCMonth() + 1; //getMonth is zero-based
58
+ const day = date.getUTCDate();
59
+
60
+ return `${month}/${day}/${year}`;
61
+ };
62
+
63
+ const getYearMonthDayFormat = date => {
64
+ const year = date.getUTCFullYear();
65
+ const month = String(date.getUTCMonth() + 1).length === 1 ? `0${(date.getUTCMonth() + 1)}` : (date.getUTCMonth() + 1);
66
+ const day = String(date.getUTCDate()).length === 1 ? `0${date.getUTCDate()}` : date.getUTCDate();
67
+
68
+ return `${year}-${month}-${day}`;
69
+ };
70
+
71
+ const dateToIsoFormat = date => {
72
+ return new Date(date).toISOString();
73
+ };
74
+
75
+ const extractDateFromDateTime = date => {
76
+ let extractedDate = date;
77
+
78
+ if (date != null && date.length > 10) {
79
+ extractedDate = date.substr(0, 10);
80
+ }
81
+
82
+ return extractedDate;
83
+ };
84
+
85
+ function waitFor(num) {
86
+ return {
87
+ mSeconds: new Promise(resolve => {
88
+ setTimeout(resolve, num);
89
+ }),
90
+ seconds: new Promise(resolve => {
91
+ setTimeout(resolve, num * 1000);
92
+ })
93
+ };
94
+ }
95
+
96
+ function getDayInMilliseconds() {
97
+ return secondsInDay * millisecondsToSeconds;
98
+ }
99
+
100
+ function getPreviousDateByDays(days) {
101
+ return new Date(new Date().getTime() - getDayInMilliseconds() * days);
102
+ }
103
+
104
+ const getInvitationDatesForNotResponsiveVendor = function() {
105
+ const twoDaysAgoUtc = getTwoDaysAgoDate();
106
+ const fiveDaysAgoUtc = getFiveDaysAgoDate();
107
+ const eightDaysAgoUtc = getEightDaysAgoDate();
108
+
109
+ return [twoDaysAgoUtc, fiveDaysAgoUtc, eightDaysAgoUtc];
110
+ };
111
+
112
+ const getInvitationDatesForNotResponsiveTenant = function() {
113
+ const fiveDaysAgoUtc = getFiveDaysAgoDate();
114
+ const tenDaysAgoUtc = getTenDaysAgoDate();
115
+ const fifteenDaysAgoUtc = getFifteenDaysAgoDate();
116
+
117
+ return [fiveDaysAgoUtc, tenDaysAgoUtc, fifteenDaysAgoUtc];
118
+ };
119
+
120
+ const isDateAfterOther = (date, other) => {
121
+ return moment(date).isAfter(other);
122
+ };
123
+
124
+ const getAutomaticRenewalsExpirationDates = function() {
125
+ const inTwentyNineDaysUtc = getDateinTwentyNineDays();
126
+ const inThirteenDaysUtc = getDateinThirteenDays();
127
+ const inSixDaysUtc = getDateinSixDays();
128
+ const todayUtc = getCurrentDate();
129
+
130
+ return [inTwentyNineDaysUtc, inThirteenDaysUtc, inSixDaysUtc, todayUtc];
131
+ };
132
+
133
+ const convertDateToNewFormat = (value, currentFormat, newFormat = formats.dayMonthYear) => {
134
+ return moment(value, currentFormat).format(newFormat);
135
+ };
136
+
137
+ module.exports = {
138
+ formats,
139
+ getOneYearAgoDate,
140
+ getSixMonthAgoDate,
141
+ getOneMonthAgoDate,
142
+ getFifteenDaysAgoDate,
143
+ getTenDaysAgoDate,
144
+ getEightDaysAgoDate,
145
+ getFiveDaysAgoDate,
146
+ getTwoDaysAgoDate,
147
+ getOneDayAgoDate,
148
+ getThirtyFiveDaysAgoDate,
149
+ getCurrentDate,
150
+ getDateInOneDay,
151
+ getDateinSixDays,
152
+ getDateinThirteenDays,
153
+ getDateinTwentyNineDays,
154
+ getInvitationDatesForNotResponsiveVendor,
155
+ getInvitationDatesForNotResponsiveTenant,
156
+ getAutomaticRenewalsExpirationDates,
157
+ getLogTimestamp,
158
+ getCurrentFormattedDate,
159
+ getAuditDateFormat,
160
+ getDateWithOffset,
161
+ getYearMonthDayFormat,
162
+ dateToIsoFormat,
163
+ getDayInMilliseconds,
164
+ extractDateFromDateTime,
165
+ getPreviousDateByDays,
166
+ waitFor,
167
+ isDateAfterOther,
168
+ convertDateToNewFormat,
169
+ getOneWeekAgoDate,
170
+ getOneWeekAheadDate
171
+ };
@@ -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,85 +1,85 @@
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
- const DEFAULT_POLICY_NUMBER = '12345';
8
-
9
- const {
10
- certificateIssueDate,
11
- generalLiability
12
- } = policyNames;
13
-
14
- const {
15
- coverageExists,
16
- policyNumber,
17
- policyExpired,
18
- perOccurrence,
19
- perPolicy,
20
- perProject,
21
- perLocation,
22
- eachOccurrence,
23
- cancellationTerms,
24
- coiAuthentication,
25
- signature,
26
- amScore,
27
- insuredAddress,
28
- insuredName
29
- } = attributeNames;
30
-
31
- const policySelections = {
32
- YES: 'Yes',
33
- NO: 'No',
34
- OTHER: 'Other'
35
- };
36
-
37
- const getCompliantAuditConfig = ({ glPolicyNumber = DEFAULT_POLICY_NUMBER } = {}) => {
38
- return cloneObject({
39
- [certificateIssueDate]: DEFAULT_POLICY_DATE,
40
- [insuredAddress]: policySelections.YES,
41
- [insuredName]: policySelections.YES,
42
- [amScore]: DEFAULT_AM_SCORE,
43
- [generalLiability]: {
44
- [coverageExists]: policySelections.YES,
45
- [policyNumber]: glPolicyNumber,
46
- [policyExpired]: DEFAULT_POLICY_DATE,
47
- [perOccurrence]: policySelections.YES,
48
- [perPolicy]: policySelections.YES,
49
- [perProject]: policySelections.YES,
50
- [perLocation]: policySelections.YES,
51
- [eachOccurrence]: policySelections.YES
52
- },
53
- [cancellationTerms]: policySelections.YES,
54
- [coiAuthentication]: policySelections.YES,
55
- [signature]: policySelections.YES
56
- });
57
- };
58
-
59
- const getNotCompliantConfig = ({ glPolicyNumber } = {}) => {
60
- const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
61
- compliantConfig[signature] = policySelections.NO;
62
-
63
- return compliantConfig;
64
- };
65
-
66
- const getAboutExpiredConfig = ({ glPolicyNumber } = {}) => {
67
- const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
68
- compliantConfig[generalLiability][policyExpired] = getOneWeekAheadDate();
69
-
70
- return compliantConfig;
71
- };
72
-
73
- const getExpiredConfig = ({ glPolicyNumber } = {}) => {
74
- const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
75
- compliantConfig[generalLiability][policyExpired] = getOneWeekAgoDate();
76
-
77
- return compliantConfig;
78
- };
79
-
80
- module.exports = {
81
- getCompliantAuditConfig,
82
- getNotCompliantConfig,
83
- getAboutExpiredConfig,
84
- getExpiredConfig
85
- };
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
+ const DEFAULT_POLICY_NUMBER = '12345';
8
+
9
+ const {
10
+ certificateIssueDate,
11
+ generalLiability
12
+ } = policyNames;
13
+
14
+ const {
15
+ coverageExists,
16
+ policyNumber,
17
+ policyExpired,
18
+ perOccurrence,
19
+ perPolicy,
20
+ perProject,
21
+ perLocation,
22
+ eachOccurrence,
23
+ cancellationTerms,
24
+ coiAuthentication,
25
+ signature,
26
+ amScore,
27
+ insuredAddress,
28
+ insuredName
29
+ } = attributeNames;
30
+
31
+ const policySelections = {
32
+ YES: 'Yes',
33
+ NO: 'No',
34
+ OTHER: 'Other'
35
+ };
36
+
37
+ const getCompliantAuditConfig = ({ glPolicyNumber = DEFAULT_POLICY_NUMBER } = {}) => {
38
+ const config = cloneObject({
39
+ [certificateIssueDate]: `${DEFAULT_POLICY_DATE}`,
40
+ [insuredAddress]: policySelections.YES,
41
+ [insuredName]: policySelections.YES,
42
+ [amScore]: DEFAULT_AM_SCORE,
43
+ [generalLiability]: {
44
+ [coverageExists]: policySelections.YES,
45
+ [policyNumber]: glPolicyNumber,
46
+ [policyExpired]: `${DEFAULT_POLICY_DATE}`,
47
+ [perOccurrence]: policySelections.YES,
48
+ [perPolicy]: policySelections.YES,
49
+ [perProject]: policySelections.YES,
50
+ [perLocation]: policySelections.YES,
51
+ [eachOccurrence]: policySelections.YES
52
+ },
53
+ [cancellationTerms]: policySelections.YES,
54
+ [coiAuthentication]: policySelections.YES,
55
+ [signature]: policySelections.YES
56
+ });
57
+ return config;
58
+ };
59
+
60
+ const getNotCompliantConfig = ({ glPolicyNumber } = {}) => {
61
+ const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
62
+ compliantConfig[signature] = policySelections.NO;
63
+
64
+ return compliantConfig;
65
+ };
66
+
67
+ const getAboutExpiredConfig = ({ glPolicyNumber } = {}) => {
68
+ const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
69
+ compliantConfig[generalLiability][policyExpired] = `${getOneWeekAheadDate()}`;
70
+ return compliantConfig;
71
+ };
72
+
73
+ const getExpiredConfig = ({ glPolicyNumber } = {}) => {
74
+ const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
75
+ compliantConfig[generalLiability][policyExpired] = `${getOneWeekAgoDate()}`;
76
+
77
+ return compliantConfig;
78
+ };
79
+
80
+ module.exports = {
81
+ getCompliantAuditConfig,
82
+ getNotCompliantConfig,
83
+ getAboutExpiredConfig,
84
+ getExpiredConfig
85
+ };