@getjones/test-infra 3.0.1 → 3.0.2

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 (213) 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 +123 -102
  5. package/src/common/consts/activationStatuses.js +6 -6
  6. package/src/common/consts/constantsForRecordsSortingAndFilters.js +40 -0
  7. package/src/common/consts/dashboardCharts.js +18 -18
  8. package/src/common/consts/projectSettings.js +6 -6
  9. package/src/common/consts/recordTypes.js +5 -5
  10. package/src/common/consts/s3FileTypes.js +12 -12
  11. package/src/common/consts/userTypes.js +8 -8
  12. package/src/common/errorCodes.js +3 -3
  13. package/src/common/httpResponseStatusCodes.json +11 -11
  14. package/src/common/requests/apiKeyAuth/requests.js +44 -44
  15. package/src/common/requests/cookieAuth/requests.js +40 -40
  16. package/src/common/requests/internalAuth/requests.js +48 -48
  17. package/src/common/requests/requestHandlers.js +78 -78
  18. package/src/common/utils/complianceUtil.js +83 -83
  19. package/src/common/utils/configsUtil.js +22 -22
  20. package/src/common/utils/dataTypeUtils.js +41 -41
  21. package/src/common/utils/numberUtils.js +22 -22
  22. package/src/common/utils/objectUtils.js +7 -7
  23. package/src/common/utils/timeUtils.js +177 -177
  24. package/src/common/validations/errorValidation.js +16 -16
  25. package/src/common/validations/typeValidations.js +36 -36
  26. package/src/defaults/configs/auditConfigs.js +91 -91
  27. package/src/defaults/configs/coverage.js +227 -227
  28. package/src/defaults/configs/polices.js +64 -64
  29. package/src/defaults/configs/requirement.js +32 -32
  30. package/src/defaults/index.js +6 -6
  31. package/src/env.js +57 -57
  32. package/src/factory/globalRecord/globalRecord.js +70 -70
  33. package/src/factory/index.js +8 -8
  34. package/src/factory/records/records.js +169 -183
  35. package/src/factory/users/users.js +77 -77
  36. package/src/index.js +91 -91
  37. package/src/resources/virusFile.pdf +0 -0
  38. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +35 -35
  39. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +93 -93
  40. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.api.js +29 -29
  41. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.service.js +61 -61
  42. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  43. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  44. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  45. package/src/saas/internal-api/accounts/api/settings/settings.service.js +41 -41
  46. package/src/saas/internal-api/accounts/consts/consts.js +6 -6
  47. package/src/saas/internal-api/accounts/index.js +22 -22
  48. package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
  49. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +38 -38
  50. package/src/saas/internal-api/accounts/utils/utils.js +58 -58
  51. package/src/saas/internal-api/agreement/api/agreement.api.js +35 -35
  52. package/src/saas/internal-api/agreement/api/agreement.service.js +81 -81
  53. package/src/saas/internal-api/agreement/consts/consts.js +8 -8
  54. package/src/saas/internal-api/agreement/index.js +11 -11
  55. package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
  56. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +43 -43
  57. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +105 -105
  58. package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +11 -11
  59. package/src/saas/internal-api/auditCustomerRules/index.js +6 -6
  60. package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +46 -46
  61. package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +19 -19
  62. package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
  63. package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
  64. package/src/saas/internal-api/auditNotes/index.js +4 -4
  65. package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
  66. package/src/saas/internal-api/auth/api/auth.api.js +27 -27
  67. package/src/saas/internal-api/auth/api/auth.service.js +90 -90
  68. package/src/saas/internal-api/auth/index.js +3 -3
  69. package/src/saas/internal-api/coi/api/coi.api.js +40 -40
  70. package/src/saas/internal-api/coi/api/coi.service.js +26 -26
  71. package/src/saas/internal-api/coi/consts/hashes.js +4 -0
  72. package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -5
  73. package/src/saas/internal-api/coi/index.js +14 -13
  74. package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
  75. package/src/saas/internal-api/coi/utils/utils.js +48 -48
  76. package/src/saas/internal-api/compliance/api/audit/audit.api.js +100 -100
  77. package/src/saas/internal-api/compliance/api/audit/audit.service.js +242 -230
  78. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  79. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  80. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  81. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +48 -48
  82. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +33 -33
  83. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +141 -141
  84. package/src/saas/internal-api/compliance/consts/audit.js +103 -103
  85. package/src/saas/internal-api/compliance/index.js +33 -33
  86. package/src/saas/internal-api/compliance/models/audit/audit.model.js +94 -94
  87. package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
  88. package/src/saas/internal-api/compliance/utils/auditUtil.js +222 -222
  89. package/src/saas/internal-api/compliance/utils/coverageUtil.js +40 -40
  90. package/src/saas/internal-api/contractors/api/contractors.api.js +185 -179
  91. package/src/saas/internal-api/contractors/api/contractors.service.js +259 -247
  92. package/src/saas/internal-api/contractors/consts/consts.js +6 -6
  93. package/src/saas/internal-api/contractors/index.js +8 -8
  94. package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
  95. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +62 -60
  96. package/src/saas/internal-api/contractors/models/link.request.model.js +10 -0
  97. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  98. package/src/saas/internal-api/contractors/utils.js +25 -25
  99. package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
  100. package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
  101. package/src/saas/internal-api/dashboard/index.js +5 -5
  102. package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
  103. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  104. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +147 -147
  105. package/src/saas/internal-api/dbEmails/consts/consts.js +54 -54
  106. package/src/saas/internal-api/dbEmails/index.js +6 -6
  107. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
  108. package/src/saas/internal-api/dbEmails/utils/util.js +82 -82
  109. package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
  110. package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
  111. package/src/saas/internal-api/emailCustomization/index.js +3 -3
  112. package/src/saas/internal-api/globalRecord/api/global.record.api.js +95 -95
  113. package/src/saas/internal-api/globalRecord/api/global.record.service.js +105 -105
  114. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  115. package/src/saas/internal-api/globalRecord/index.js +6 -6
  116. package/src/saas/internal-api/globalRecord/models/global.record.model.js +60 -60
  117. package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
  118. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  119. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  120. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  121. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  122. package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
  123. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  124. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
  125. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  126. package/src/saas/internal-api/projects/index.js +24 -24
  127. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  128. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  129. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +41 -41
  130. package/src/saas/internal-api/projects/utils/utils.js +156 -156
  131. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  132. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +47 -47
  133. package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -12
  134. package/src/saas/internal-api/recordNotes/index.js +3 -3
  135. package/src/saas/internal-api/reports/api/reports.api.js +39 -39
  136. package/src/saas/internal-api/reports/api/reports.service.js +34 -34
  137. package/src/saas/internal-api/reports/consts/consts.js +65 -64
  138. package/src/saas/internal-api/reports/index.js +15 -15
  139. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  140. package/src/saas/internal-api/requests/api/requests.api.js +120 -96
  141. package/src/saas/internal-api/requests/api/requests.service.js +272 -220
  142. package/src/saas/internal-api/requests/index.js +20 -18
  143. package/src/saas/internal-api/requests/models/create.request.model.js +33 -34
  144. package/src/saas/internal-api/requests/models/draft.request.criteria.model.js +18 -0
  145. package/src/saas/internal-api/requests/models/draft.request.report.model.js +14 -14
  146. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  147. package/src/saas/internal-api/requests/models/requestListCriteriaModel.js +17 -17
  148. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  149. package/src/saas/internal-api/requests/utils.js +8 -8
  150. package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
  151. package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
  152. package/src/saas/internal-api/requestsTable/index.js +3 -3
  153. package/src/saas/internal-api/requirements/api/requirements.api.js +51 -51
  154. package/src/saas/internal-api/requirements/api/requirements.service.js +153 -153
  155. package/src/saas/internal-api/requirements/consts/attributeTypes.json +6 -6
  156. package/src/saas/internal-api/requirements/consts/consts.js +6 -6
  157. package/src/saas/internal-api/requirements/index.js +10 -10
  158. package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
  159. package/src/saas/internal-api/requirements/models/policy.model.js +33 -33
  160. package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
  161. package/src/saas/internal-api/requirements/utils/utils.js +116 -116
  162. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  163. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  164. package/src/saas/internal-api/serviceArea/index.js +4 -4
  165. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  166. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  167. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  168. package/src/saas/internal-api/tabs/index.js +3 -3
  169. package/src/saas/internal-api/tabs/models/tabs.model.js +19 -19
  170. package/src/saas/internal-api/thread-scheduler/runner.js +39 -39
  171. package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +31 -31
  172. package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +42 -42
  173. package/src/saas/internal-api/uploadFiles/consts.js +12 -12
  174. package/src/saas/internal-api/uploadFiles/index.js +3 -3
  175. package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +32 -32
  176. package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +97 -97
  177. package/src/saas/internal-api/users/api/users.api.js +115 -115
  178. package/src/saas/internal-api/users/api/users.service.js +203 -203
  179. package/src/saas/internal-api/users/index.js +16 -16
  180. package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
  181. package/src/saas/internal-api/users/models/notification.settings.model.js +12 -12
  182. package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
  183. package/src/saas/internal-api/users/models/users.model.js +41 -41
  184. package/src/saas/internal-api/users/utils/util.js +39 -39
  185. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  186. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  187. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  188. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  189. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  190. package/src/saas/openapi/coi/coi.api.js +20 -20
  191. package/src/saas/openapi/coi/coi.service.js +13 -13
  192. package/src/saas/openapi/projects/projects.api.js +83 -83
  193. package/src/saas/openapi/projects/projects.service.js +64 -64
  194. package/src/saas/openapi/requests/index.js +7 -7
  195. package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
  196. package/src/saas/openapi/requests/models/update.request.model.js +35 -35
  197. package/src/saas/openapi/requests/requests.api.js +82 -82
  198. package/src/saas/openapi/requests/requests.service.js +70 -70
  199. package/src/saas/openapi/requirements/index.js +6 -6
  200. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  201. package/src/saas/openapi/requirements/requirements.api.js +32 -32
  202. package/src/saas/openapi/requirements/requirements.service.js +37 -37
  203. package/src/saas/openapi/tabs/index.js +6 -6
  204. package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
  205. package/src/saas/openapi/tabs/tabs.api.js +27 -27
  206. package/src/saas/openapi/tabs/tabs.service.js +19 -19
  207. package/src/saas/openapi/users/user.model.js +10 -10
  208. package/src/saas/openapi/users/users.api.js +33 -33
  209. package/src/saas/openapi/users/users.service.js +41 -41
  210. package/tests/env.test.js +40 -40
  211. package/tests/validation.test.js +83 -83
  212. package/.npmrc.bak +0 -2
  213. package/package.json.bak +0 -30
@@ -1,41 +1,41 @@
1
- const dataTypes = Object.freeze({
2
- object: 'object',
3
- boolean: 'boolean',
4
- string: 'string',
5
- number: 'number'
6
- });
7
-
8
- const validateValueDataType = (value, type) => {
9
- return value !== null
10
- && value !== undefined
11
- && typeof value === type;
12
- };
13
-
14
- const isObject = value => {
15
- return validateValueDataType(value, dataTypes.object)
16
- && !isArray(value);
17
- };
18
-
19
- const isArray = value => {
20
- return Array.isArray(value);
21
- };
22
-
23
- const isBoolean = value => {
24
- return validateValueDataType(value, dataTypes.boolean);
25
- };
26
-
27
- const isString = value => {
28
- return validateValueDataType(value, dataTypes.string) || value instanceof String;
29
- };
30
-
31
- const isNumber = value => {
32
- return validateValueDataType(value, dataTypes.number) && Number.isFinite(value);
33
- };
34
-
35
- module.exports = {
36
- isObject,
37
- isArray,
38
- isBoolean,
39
- isString,
40
- isNumber
41
- };
1
+ const dataTypes = Object.freeze({
2
+ object: 'object',
3
+ boolean: 'boolean',
4
+ string: 'string',
5
+ number: 'number'
6
+ });
7
+
8
+ const validateValueDataType = (value, type) => {
9
+ return value !== null
10
+ && value !== undefined
11
+ && typeof value === type;
12
+ };
13
+
14
+ const isObject = value => {
15
+ return validateValueDataType(value, dataTypes.object)
16
+ && !isArray(value);
17
+ };
18
+
19
+ const isArray = value => {
20
+ return Array.isArray(value);
21
+ };
22
+
23
+ const isBoolean = value => {
24
+ return validateValueDataType(value, dataTypes.boolean);
25
+ };
26
+
27
+ const isString = value => {
28
+ return validateValueDataType(value, dataTypes.string) || value instanceof String;
29
+ };
30
+
31
+ const isNumber = value => {
32
+ return validateValueDataType(value, dataTypes.number) && Number.isFinite(value);
33
+ };
34
+
35
+ module.exports = {
36
+ isObject,
37
+ isArray,
38
+ isBoolean,
39
+ isString,
40
+ isNumber
41
+ };
@@ -1,22 +1,22 @@
1
- const { v4: uuidv4 } = require('uuid');
2
-
3
- const getRandomNumberInRange = (min, max) => {
4
- min = Math.ceil(min);
5
- max = Math.floor(max);
6
- return Math.floor(Math.random() * (max - min + 1)) + min;
7
- };
8
-
9
- const getCapitalLetterUnicodeValueList = ({ listLength = 26 }) => {
10
- //This code number represent the letter A
11
- const firstLetterUnicodeValue = 65;
12
- //Return list of unicodes values for all alphabet letters.
13
- //The index value will be in the ranges between 1-26 (The English alphabet has 26 letters)
14
- //In case listLength will be bigger then 26, index will start the cycle again respectively to the ranges
15
- return Array.from(Array(listLength)).map((_, index) => (index % 26) + firstLetterUnicodeValue);
16
- };
17
-
18
- const getUniqueNumber = () => {
19
- return uuidv4();
20
- };
21
-
22
- module.exports = { getRandomNumberInRange, getCapitalLetterUnicodeValueList, getUniqueNumber };
1
+ const { v4: uuidv4 } = require('uuid');
2
+
3
+ const getRandomNumberInRange = (min, max) => {
4
+ min = Math.ceil(min);
5
+ max = Math.floor(max);
6
+ return Math.floor(Math.random() * (max - min + 1)) + min;
7
+ };
8
+
9
+ const getCapitalLetterUnicodeValueList = ({ listLength = 26 }) => {
10
+ //This code number represent the letter A
11
+ const firstLetterUnicodeValue = 65;
12
+ //Return list of unicodes values for all alphabet letters.
13
+ //The index value will be in the ranges between 1-26 (The English alphabet has 26 letters)
14
+ //In case listLength will be bigger then 26, index will start the cycle again respectively to the ranges
15
+ return Array.from(Array(listLength)).map((_, index) => (index % 26) + firstLetterUnicodeValue);
16
+ };
17
+
18
+ const getUniqueNumber = () => {
19
+ return uuidv4();
20
+ };
21
+
22
+ module.exports = { getRandomNumberInRange, getCapitalLetterUnicodeValueList, getUniqueNumber };
@@ -1,7 +1,7 @@
1
- const cloneObject = object => {
2
- return JSON.parse(JSON.stringify(object));
3
- };
4
-
5
- module.exports = {
6
- cloneObject
7
- };
1
+ const cloneObject = object => {
2
+ return JSON.parse(JSON.stringify(object));
3
+ };
4
+
5
+ module.exports = {
6
+ cloneObject
7
+ };
@@ -1,177 +1,177 @@
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
- monthDYear: 'MMM D, YYYY',
11
- monthDayYear_noZeroPrefix: 'MMM D, YYYY',
12
- dateTime: 'YYYY/MM/DD-hh:mm:ss',
13
- fullMonthDayYear: 'MMMM DD, YYYY',
14
- threadScheduler: '', // Passing empty string resolves moment.js format to ISO8601 standard like 2020-04-12T09:49:59Z;
15
- monthDayYear12hTime: 'MMM D, YYYY h:mm A',
16
- amPmTime: 'h:mm A',
17
- yearMonthDay: 'YYYY-MM-DD',
18
- shortedMonthName: 'MMM'
19
- };
20
-
21
- const peroids = {
22
- days: 'days',
23
- months: 'months',
24
- years: 'years'
25
- };
26
-
27
- const inviteActionDateOffset = {
28
- oneDay: 1,
29
- twoDays: 2,
30
- threeDays: 3,
31
- fourDays: 4,
32
- fiveDays: 5,
33
- tenDays: 10,
34
- fifteenDays: 15
35
- };
36
-
37
- const getOneYearAgoDate = format => moment().utc().subtract(1, peroids.years).format(format || formats.threadScheduler);
38
- const getTwoHundredDaysAgoDate = format => moment().utc().subtract(200, peroids.days).format(format || formats.threadScheduler);
39
- const getSixMonthAgoDate = format => moment().utc().subtract(6, peroids.months).format(format || formats.threadScheduler);
40
- const getFortyFiveDaysAgoDate = format => moment().utc().subtract(45, peroids.days).format(format || formats.threadScheduler);
41
- const getOneMonthAgoDate = format => moment().utc().subtract(1, peroids.months).format(format || formats.threadScheduler);
42
- const getFifteenDaysAgoDate = format => moment().utc().subtract(15, peroids.days).format(format || formats.threadScheduler);
43
- const getTenDaysAgoDate = format => moment().utc().subtract(10, peroids.days).format(format || formats.threadScheduler);
44
- const getEightDaysAgoDate = format => moment().utc().subtract(8, peroids.days).format(format || formats.threadScheduler);
45
- const getFiveDaysAgoDate = format => moment().utc().subtract(5, peroids.days).format(format || formats.threadScheduler);
46
- const getTwoDaysAgoDate = format => moment().utc().subtract(2, peroids.days).format(format || formats.threadScheduler);
47
- const getOneDayAgoDate = format => moment().utc().subtract(1, peroids.days).format(format || formats.threadScheduler);
48
- const getThirtyFiveDaysAgoDate = format => moment().utc().subtract(35, peroids.days).format(format || formats.threadScheduler);
49
- const getCurrentDate = format => moment().utc().format(format || formats.threadScheduler);
50
- const getDateInOneDay = format => moment().utc().add(1, peroids.days).format(format || formats.threadScheduler);
51
- const getDateinSixDays = format => moment().utc().add(6, peroids.days).format(format || formats.threadScheduler);
52
- const getDateInTwoMonths = format => moment().utc().add(2, peroids.months).format(format || formats.dayMonthYear);
53
- const getDateinThirteenDays = format => moment().utc().add(13, peroids.days).format(format || formats.threadScheduler);
54
- const getDateinTwentyNineDays = format => moment().utc().add(29, peroids.days).format(format || formats.threadScheduler);
55
- const getOneWeekAgoDate = () => moment().utc().subtract(7, peroids.days).format(formats.dayMonthYear);
56
- const getOneWeekAheadDate = () => moment().utc().add(7, peroids.days).format(formats.dayMonthYear);
57
-
58
- const getLogTimestamp = () => {
59
- return moment().format(formats.logTimeStampFormat);
60
- };
61
-
62
- const extractDateFromDateTime = date => {
63
- let extractedDate = date;
64
-
65
- if (date != null && date.length > 10) {
66
- extractedDate = date.substr(0, 10);
67
- }
68
-
69
- return extractedDate;
70
- };
71
-
72
- function waitFor(num) {
73
- return {
74
- mSeconds: new Promise(resolve => {
75
- setTimeout(resolve, num);
76
- }),
77
- seconds: new Promise(resolve => {
78
- setTimeout(resolve, num * 1000);
79
- })
80
- };
81
- }
82
-
83
- function getDayInMilliseconds() {
84
- return secondsInDay * millisecondsToSeconds;
85
- }
86
-
87
- function getPreviousDateByDays(days) {
88
- return new Date(new Date().getTime() - getDayInMilliseconds() * days);
89
- }
90
-
91
- const getInvitationDatesForNotResponsiveVendor = function() {
92
- const twoDaysAgoUtc = getTwoDaysAgoDate();
93
- const fiveDaysAgoUtc = getFiveDaysAgoDate();
94
- const eightDaysAgoUtc = getEightDaysAgoDate();
95
-
96
- return [twoDaysAgoUtc, fiveDaysAgoUtc, eightDaysAgoUtc];
97
- };
98
-
99
- const getInviteActionOffsetInDaysForNotResponsiveVendor = function() {
100
- return [inviteActionDateOffset.twoDays, inviteActionDateOffset.threeDays, inviteActionDateOffset.threeDays];
101
- };
102
-
103
- const getInvitationDatesForNotResponsiveTenant = function() {
104
- const fiveDaysAgoUtc = getFiveDaysAgoDate();
105
- const tenDaysAgoUtc = getTenDaysAgoDate();
106
- const fifteenDaysAgoUtc = getFifteenDaysAgoDate();
107
-
108
- return [fiveDaysAgoUtc, tenDaysAgoUtc, fifteenDaysAgoUtc];
109
- };
110
-
111
- const getInviteActionOffsetInDaysForNotResponsiveTenant = function() {
112
- return [inviteActionDateOffset.fiveDays, inviteActionDateOffset.fiveDays, inviteActionDateOffset.fiveDays];
113
- };
114
-
115
- const isDateAfterOther = (date, other) => {
116
- return moment(date).isAfter(other);
117
- };
118
-
119
- const getAutomaticRenewalsExpirationDates = function() {
120
- const inTwentyNineDaysUtc = getDateinTwentyNineDays();
121
- const inThirteenDaysUtc = getDateinThirteenDays();
122
- const inSixDaysUtc = getDateinSixDays();
123
- const todayUtc = getCurrentDate();
124
-
125
- return [inTwentyNineDaysUtc, inThirteenDaysUtc, inSixDaysUtc, todayUtc];
126
- };
127
-
128
- const convertDateToNewFormat = (value, currentFormat, newFormat = formats.dayMonthYear) => {
129
- return moment(value, currentFormat).format(newFormat);
130
- };
131
-
132
- const convertDateToLongInt = value => {
133
- return Date.parse(value);
134
- };
135
-
136
- const convertDateStringFormatToISOString = dateStringFormat => {
137
- return new Date(dateStringFormat).toISOString();
138
- };
139
-
140
- module.exports = {
141
- formats,
142
- getOneYearAgoDate,
143
- getTwoHundredDaysAgoDate,
144
- getSixMonthAgoDate,
145
- getFortyFiveDaysAgoDate,
146
- getOneMonthAgoDate,
147
- getFifteenDaysAgoDate,
148
- getTenDaysAgoDate,
149
- getEightDaysAgoDate,
150
- getFiveDaysAgoDate,
151
- getTwoDaysAgoDate,
152
- getOneDayAgoDate,
153
- getThirtyFiveDaysAgoDate,
154
- getCurrentDate,
155
- getDateInOneDay,
156
- getDateinSixDays,
157
- getDateinThirteenDays,
158
- getDateinTwentyNineDays,
159
- getDateInTwoMonths,
160
- getInvitationDatesForNotResponsiveVendor,
161
- getInviteActionOffsetInDaysForNotResponsiveVendor,
162
- getInvitationDatesForNotResponsiveTenant,
163
- getInviteActionOffsetInDaysForNotResponsiveTenant,
164
- getAutomaticRenewalsExpirationDates,
165
- getLogTimestamp,
166
- getDayInMilliseconds,
167
- extractDateFromDateTime,
168
- getPreviousDateByDays,
169
- waitFor,
170
- isDateAfterOther,
171
- convertDateToNewFormat,
172
- getOneWeekAgoDate,
173
- getOneWeekAheadDate,
174
- convertDateToLongInt,
175
- convertDateStringFormatToISOString,
176
- inviteActionDateOffset
177
- };
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
+ monthDYear: 'MMM D, YYYY',
11
+ monthDayYear_noZeroPrefix: 'MMM D, YYYY',
12
+ dateTime: 'YYYY/MM/DD-hh:mm:ss',
13
+ fullMonthDayYear: 'MMMM DD, YYYY',
14
+ threadScheduler: '', // Passing empty string resolves moment.js format to ISO8601 standard like 2020-04-12T09:49:59Z;
15
+ monthDayYear12hTime: 'MMM D, YYYY h:mm A',
16
+ amPmTime: 'h:mm A',
17
+ yearMonthDay: 'YYYY-MM-DD',
18
+ shortedMonthName: 'MMM'
19
+ };
20
+
21
+ const peroids = {
22
+ days: 'days',
23
+ months: 'months',
24
+ years: 'years'
25
+ };
26
+
27
+ const inviteActionDateOffset = {
28
+ oneDay: 1,
29
+ twoDays: 2,
30
+ threeDays: 3,
31
+ fourDays: 4,
32
+ fiveDays: 5,
33
+ tenDays: 10,
34
+ fifteenDays: 15
35
+ };
36
+
37
+ const getOneYearAgoDate = format => moment().utc().subtract(1, peroids.years).format(format || formats.threadScheduler);
38
+ const getTwoHundredDaysAgoDate = format => moment().utc().subtract(200, peroids.days).format(format || formats.threadScheduler);
39
+ const getSixMonthAgoDate = format => moment().utc().subtract(6, peroids.months).format(format || formats.threadScheduler);
40
+ const getFortyFiveDaysAgoDate = format => moment().utc().subtract(45, peroids.days).format(format || formats.threadScheduler);
41
+ const getOneMonthAgoDate = format => moment().utc().subtract(1, peroids.months).format(format || formats.threadScheduler);
42
+ const getFifteenDaysAgoDate = format => moment().utc().subtract(15, peroids.days).format(format || formats.threadScheduler);
43
+ const getTenDaysAgoDate = format => moment().utc().subtract(10, peroids.days).format(format || formats.threadScheduler);
44
+ const getEightDaysAgoDate = format => moment().utc().subtract(8, peroids.days).format(format || formats.threadScheduler);
45
+ const getFiveDaysAgoDate = format => moment().utc().subtract(5, peroids.days).format(format || formats.threadScheduler);
46
+ const getTwoDaysAgoDate = format => moment().utc().subtract(2, peroids.days).format(format || formats.threadScheduler);
47
+ const getOneDayAgoDate = format => moment().utc().subtract(1, peroids.days).format(format || formats.threadScheduler);
48
+ const getThirtyFiveDaysAgoDate = format => moment().utc().subtract(35, peroids.days).format(format || formats.threadScheduler);
49
+ const getCurrentDate = format => moment().utc().format(format || formats.threadScheduler);
50
+ const getDateInOneDay = format => moment().utc().add(1, peroids.days).format(format || formats.threadScheduler);
51
+ const getDateinSixDays = format => moment().utc().add(6, peroids.days).format(format || formats.threadScheduler);
52
+ const getDateInTwoMonths = format => moment().utc().add(2, peroids.months).format(format || formats.dayMonthYear);
53
+ const getDateinThirteenDays = format => moment().utc().add(13, peroids.days).format(format || formats.threadScheduler);
54
+ const getDateinTwentyNineDays = format => moment().utc().add(29, peroids.days).format(format || formats.threadScheduler);
55
+ const getOneWeekAgoDate = () => moment().utc().subtract(7, peroids.days).format(formats.dayMonthYear);
56
+ const getOneWeekAheadDate = () => moment().utc().add(7, peroids.days).format(formats.dayMonthYear);
57
+
58
+ const getLogTimestamp = () => {
59
+ return moment().format(formats.logTimeStampFormat);
60
+ };
61
+
62
+ const extractDateFromDateTime = date => {
63
+ let extractedDate = date;
64
+
65
+ if (date != null && date.length > 10) {
66
+ extractedDate = date.substr(0, 10);
67
+ }
68
+
69
+ return extractedDate;
70
+ };
71
+
72
+ function waitFor(num) {
73
+ return {
74
+ mSeconds: new Promise(resolve => {
75
+ setTimeout(resolve, num);
76
+ }),
77
+ seconds: new Promise(resolve => {
78
+ setTimeout(resolve, num * 1000);
79
+ })
80
+ };
81
+ }
82
+
83
+ function getDayInMilliseconds() {
84
+ return secondsInDay * millisecondsToSeconds;
85
+ }
86
+
87
+ function getPreviousDateByDays(days) {
88
+ return new Date(new Date().getTime() - getDayInMilliseconds() * days);
89
+ }
90
+
91
+ const getInvitationDatesForNotResponsiveVendor = function() {
92
+ const twoDaysAgoUtc = getTwoDaysAgoDate();
93
+ const fiveDaysAgoUtc = getFiveDaysAgoDate();
94
+ const eightDaysAgoUtc = getEightDaysAgoDate();
95
+
96
+ return [twoDaysAgoUtc, fiveDaysAgoUtc, eightDaysAgoUtc];
97
+ };
98
+
99
+ const getInviteActionOffsetInDaysForNotResponsiveVendor = function() {
100
+ return [inviteActionDateOffset.twoDays, inviteActionDateOffset.threeDays, inviteActionDateOffset.threeDays];
101
+ };
102
+
103
+ const getInvitationDatesForNotResponsiveTenant = function() {
104
+ const fiveDaysAgoUtc = getFiveDaysAgoDate();
105
+ const tenDaysAgoUtc = getTenDaysAgoDate();
106
+ const fifteenDaysAgoUtc = getFifteenDaysAgoDate();
107
+
108
+ return [fiveDaysAgoUtc, tenDaysAgoUtc, fifteenDaysAgoUtc];
109
+ };
110
+
111
+ const getInviteActionOffsetInDaysForNotResponsiveTenant = function() {
112
+ return [inviteActionDateOffset.fiveDays, inviteActionDateOffset.fiveDays, inviteActionDateOffset.fiveDays];
113
+ };
114
+
115
+ const isDateAfterOther = (date, other) => {
116
+ return moment(date).isAfter(other);
117
+ };
118
+
119
+ const getAutomaticRenewalsExpirationDates = function() {
120
+ const inTwentyNineDaysUtc = getDateinTwentyNineDays();
121
+ const inThirteenDaysUtc = getDateinThirteenDays();
122
+ const inSixDaysUtc = getDateinSixDays();
123
+ const todayUtc = getCurrentDate();
124
+
125
+ return [inTwentyNineDaysUtc, inThirteenDaysUtc, inSixDaysUtc, todayUtc];
126
+ };
127
+
128
+ const convertDateToNewFormat = (value, currentFormat, newFormat = formats.dayMonthYear) => {
129
+ return moment(value, currentFormat).format(newFormat);
130
+ };
131
+
132
+ const convertDateToLongInt = value => {
133
+ return Date.parse(value);
134
+ };
135
+
136
+ const convertDateStringFormatToISOString = dateStringFormat => {
137
+ return new Date(dateStringFormat).toISOString();
138
+ };
139
+
140
+ module.exports = {
141
+ formats,
142
+ getOneYearAgoDate,
143
+ getTwoHundredDaysAgoDate,
144
+ getSixMonthAgoDate,
145
+ getFortyFiveDaysAgoDate,
146
+ getOneMonthAgoDate,
147
+ getFifteenDaysAgoDate,
148
+ getTenDaysAgoDate,
149
+ getEightDaysAgoDate,
150
+ getFiveDaysAgoDate,
151
+ getTwoDaysAgoDate,
152
+ getOneDayAgoDate,
153
+ getThirtyFiveDaysAgoDate,
154
+ getCurrentDate,
155
+ getDateInOneDay,
156
+ getDateinSixDays,
157
+ getDateinThirteenDays,
158
+ getDateinTwentyNineDays,
159
+ getDateInTwoMonths,
160
+ getInvitationDatesForNotResponsiveVendor,
161
+ getInviteActionOffsetInDaysForNotResponsiveVendor,
162
+ getInvitationDatesForNotResponsiveTenant,
163
+ getInviteActionOffsetInDaysForNotResponsiveTenant,
164
+ getAutomaticRenewalsExpirationDates,
165
+ getLogTimestamp,
166
+ getDayInMilliseconds,
167
+ extractDateFromDateTime,
168
+ getPreviousDateByDays,
169
+ waitFor,
170
+ isDateAfterOther,
171
+ convertDateToNewFormat,
172
+ getOneWeekAgoDate,
173
+ getOneWeekAheadDate,
174
+ convertDateToLongInt,
175
+ convertDateStringFormatToISOString,
176
+ inviteActionDateOffset
177
+ };
@@ -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 };