@getjones/test-infra 2.1.2 → 2.1.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 (135) hide show
  1. package/package.json +29 -29
  2. package/src/common/commonFlows/index.js +3 -3
  3. package/src/common/commonFlows/records/records.js +71 -71
  4. package/src/common/httpResponseStatusCodes.json +11 -11
  5. package/src/common/requests/apiKeyAuth/requests.js +38 -38
  6. package/src/common/requests/cookieAuth/requests.js +40 -40
  7. package/src/common/requests/requestHandlers.js +60 -60
  8. package/src/common/utils/dataTypeUtils.js +41 -0
  9. package/src/common/utils/numberUtils.js +22 -22
  10. package/src/common/utils/timeUtils.js +167 -162
  11. package/src/common/validations/errorValidation.js +16 -16
  12. package/src/common/validations/typeValidations.js +36 -36
  13. package/src/env.js +45 -45
  14. package/src/index.js +71 -69
  15. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
  16. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +77 -77
  17. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  18. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  19. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  20. package/src/saas/internal-api/accounts/api/settings/settings.service.js +24 -24
  21. package/src/saas/internal-api/accounts/index.js +20 -20
  22. package/src/saas/internal-api/accounts/models/core/create.account.model.js +15 -15
  23. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +23 -21
  24. package/src/saas/internal-api/accounts/utils/utils.js +32 -32
  25. package/src/saas/internal-api/auth/api/auth.api.js +18 -12
  26. package/src/saas/internal-api/auth/api/auth.service.js +75 -47
  27. package/src/saas/internal-api/auth/index.js +3 -3
  28. package/src/saas/internal-api/coi/api/coi.api.js +34 -34
  29. package/src/saas/internal-api/coi/api/coi.service.js +22 -22
  30. package/src/saas/internal-api/coi/consts/uploaderTypes.js +7 -7
  31. package/src/saas/internal-api/coi/index.js +13 -13
  32. package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
  33. package/src/saas/internal-api/coi/utils/utils.js +48 -48
  34. package/src/saas/internal-api/compliance/api/audit/audit.api.js +41 -40
  35. package/src/saas/internal-api/compliance/api/audit/audit.service.js +151 -33
  36. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  37. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  38. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  39. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +24 -24
  40. package/src/saas/internal-api/compliance/api/waive/waive.api.js +21 -21
  41. package/src/saas/internal-api/compliance/api/waive/waive.service.js +15 -15
  42. package/src/saas/internal-api/compliance/consts/audit.js +81 -81
  43. package/src/saas/internal-api/compliance/index.js +28 -28
  44. package/src/saas/internal-api/compliance/models/audit/audit.model.js +84 -84
  45. package/src/saas/internal-api/compliance/models/waive/waive.model.js +45 -45
  46. package/src/saas/internal-api/compliance/utils/util.js +173 -218
  47. package/src/saas/internal-api/contractors/api/contractors.api.js +141 -141
  48. package/src/saas/internal-api/contractors/api/contractors.service.js +123 -123
  49. package/src/saas/internal-api/contractors/index.js +8 -8
  50. package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
  51. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -60
  52. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  53. package/src/saas/internal-api/dashboardInnerPage/api/recordList.api.js +12 -0
  54. package/src/saas/internal-api/dashboardInnerPage/api/recordList.service.js +7 -0
  55. package/src/saas/internal-api/dashboardInnerPage/index.js +5 -0
  56. package/src/saas/internal-api/dashboardInnerPage/models/dashboard.filter.criteria.model.js +38 -0
  57. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  58. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +127 -127
  59. package/src/saas/internal-api/dbEmails/consts/consts.js +3 -3
  60. package/src/saas/internal-api/dbEmails/index.js +4 -4
  61. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
  62. package/src/saas/internal-api/dbEmails/utils/util.js +59 -59
  63. package/src/saas/internal-api/globalRecord/api/global.record.api.js +76 -76
  64. package/src/saas/internal-api/globalRecord/api/global.record.service.js +83 -83
  65. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  66. package/src/saas/internal-api/globalRecord/index.js +6 -6
  67. package/src/saas/internal-api/globalRecord/models/global.record.model.js +43 -43
  68. package/src/saas/internal-api/globalRecord/utils/util.js +148 -148
  69. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  70. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  71. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  72. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  73. package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
  74. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  75. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +17 -17
  76. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  77. package/src/saas/internal-api/projects/index.js +24 -24
  78. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  79. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  80. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +39 -39
  81. package/src/saas/internal-api/projects/utils/utils.js +82 -82
  82. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  83. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
  84. package/src/saas/internal-api/recordNotes/index.js +3 -3
  85. package/src/saas/internal-api/reports/api/reports.api.js +39 -39
  86. package/src/saas/internal-api/reports/api/reports.service.js +34 -34
  87. package/src/saas/internal-api/reports/consts/consts.js +63 -63
  88. package/src/saas/internal-api/reports/index.js +15 -15
  89. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  90. package/src/saas/internal-api/requests/api/requests.api.js +54 -54
  91. package/src/saas/internal-api/requests/api/requests.service.js +51 -51
  92. package/src/saas/internal-api/requests/index.js +14 -14
  93. package/src/saas/internal-api/requests/models/create.request.model.js +22 -22
  94. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  95. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  96. package/src/saas/internal-api/requests/utils.js +8 -8
  97. package/src/saas/internal-api/requirements/api/requirements.api.js +27 -27
  98. package/src/saas/internal-api/requirements/api/requirements.service.js +23 -23
  99. package/src/saas/internal-api/requirements/consts/attributeTypes.json +6 -0
  100. package/src/saas/internal-api/requirements/index.js +6 -6
  101. package/src/saas/internal-api/requirements/models/create.requirement.model.js +45 -45
  102. package/src/saas/internal-api/requirements/utils/utils.js +88 -0
  103. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  104. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  105. package/src/saas/internal-api/serviceArea/index.js +4 -4
  106. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  107. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  108. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  109. package/src/saas/internal-api/tabs/index.js +3 -3
  110. package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
  111. package/src/saas/internal-api/thread-scheduler/runner.js +13 -13
  112. package/src/saas/internal-api/users/api/users.api.js +77 -77
  113. package/src/saas/internal-api/users/api/users.service.js +101 -101
  114. package/src/saas/internal-api/users/index.js +4 -4
  115. package/src/saas/internal-api/users/models/users.model.js +31 -31
  116. package/src/saas/internal-api/users/utils/util.js +14 -14
  117. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  118. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  119. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  120. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  121. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  122. package/src/saas/openapi/projects/projects.api.js +59 -59
  123. package/src/saas/openapi/projects/projects.service.js +44 -44
  124. package/src/saas/openapi/requests/index.js +6 -6
  125. package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
  126. package/src/saas/openapi/requests/requests.api.js +20 -20
  127. package/src/saas/openapi/requests/requests.service.js +18 -18
  128. package/src/saas/openapi/requirements/index.js +6 -6
  129. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  130. package/src/saas/openapi/requirements/requirements.api.js +12 -12
  131. package/src/saas/openapi/requirements/requirements.service.js +20 -20
  132. package/src/saas/openapi/tabs/tabs.api.js +13 -13
  133. package/src/saas/openapi/tabs/tabs.service.js +7 -7
  134. package/tests/env.test.js +40 -40
  135. package/tests/validation.test.js +83 -83
@@ -1,162 +1,167 @@
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
-
40
- const getLogTimestamp = () => {
41
- return moment().format(formats.logTimeStampFormat);
42
- };
43
-
44
- const getCurrentFormattedDate = () => {
45
- return new Date().toISOString();
46
- };
47
-
48
- const getDateWithOffset = (date, offsetInDays) => {
49
- date.setDate(date.getDate() + offsetInDays);
50
- return date;
51
- };
52
-
53
- const getAuditDateFormat = date => {
54
- const year = date.getUTCFullYear();
55
- const month = date.getUTCMonth() + 1; //getMonth is zero-based
56
- const day = date.getUTCDate();
57
-
58
- return `${month}/${day}/${year}`;
59
- };
60
-
61
- const getYearMonthDayFormat = date => {
62
- const year = date.getUTCFullYear();
63
- const month = String(date.getUTCMonth() + 1).length === 1 ? `0${(date.getUTCMonth() + 1)}` : (date.getUTCMonth() + 1);
64
- const day = String(date.getUTCDate()).length === 1 ? `0${date.getUTCDate()}` : date.getUTCDate();
65
-
66
- return `${year}-${month}-${day}`;
67
- };
68
-
69
- const dateToIsoFormat = date => {
70
- return new Date(date).toISOString();
71
- };
72
-
73
- const extractDateFromDateTime = date => {
74
- let extractedDate = date;
75
-
76
- if (date != null && date.length > 10) {
77
- extractedDate = date.substr(0, 10);
78
- }
79
-
80
- return extractedDate;
81
- };
82
-
83
- function waitFor(num) {
84
- return {
85
- mSeconds: new Promise(resolve => {
86
- setTimeout(resolve, num);
87
- }),
88
- seconds: new Promise(resolve => {
89
- setTimeout(resolve, num * 1000);
90
- })
91
- };
92
- }
93
-
94
- function getDayInMilliseconds() {
95
- return secondsInDay * millisecondsToSeconds;
96
- }
97
-
98
- function getPreviousDateByDays(days) {
99
- return new Date(new Date().getTime() - getDayInMilliseconds() * days);
100
- }
101
-
102
- const getInvitationDatesForNotResponsiveVendor = function() {
103
- const twoDaysAgoUtc = getTwoDaysAgoDate();
104
- const fiveDaysAgoUtc = getFiveDaysAgoDate();
105
- const eightDaysAgoUtc = getEightDaysAgoDate();
106
-
107
- return [twoDaysAgoUtc, fiveDaysAgoUtc, eightDaysAgoUtc];
108
- };
109
-
110
- const getInvitationDatesForNotResponsiveTenant = function() {
111
- const fiveDaysAgoUtc = getFiveDaysAgoDate();
112
- const tenDaysAgoUtc = getTenDaysAgoDate();
113
- const fifteenDaysAgoUtc = getFifteenDaysAgoDate();
114
-
115
- return [fiveDaysAgoUtc, tenDaysAgoUtc, fifteenDaysAgoUtc];
116
- };
117
-
118
- const isDateAfterOther = (date, other) => {
119
- return moment(date).isAfter(other);
120
- };
121
-
122
- const getAutomaticRenewalsExpirationDates = function() {
123
- const inTwentyNineDaysUtc = getDateinTwentyNineDays();
124
- const inThirteenDaysUtc = getDateinThirteenDays();
125
- const inSixDaysUtc = getDateinSixDays();
126
- const todayUtc = getCurrentDate();
127
-
128
- return [inTwentyNineDaysUtc, inThirteenDaysUtc, inSixDaysUtc, todayUtc];
129
- };
130
-
131
- module.exports = {
132
- formats,
133
- getOneYearAgoDate,
134
- getSixMonthAgoDate,
135
- getOneMonthAgoDate,
136
- getFifteenDaysAgoDate,
137
- getTenDaysAgoDate,
138
- getEightDaysAgoDate,
139
- getFiveDaysAgoDate,
140
- getTwoDaysAgoDate,
141
- getOneDayAgoDate,
142
- getThirtyFiveDaysAgoDate,
143
- getCurrentDate,
144
- getDateInOneDay,
145
- getDateinSixDays,
146
- getDateinThirteenDays,
147
- getDateinTwentyNineDays,
148
- getInvitationDatesForNotResponsiveVendor,
149
- getInvitationDatesForNotResponsiveTenant,
150
- getAutomaticRenewalsExpirationDates,
151
- getLogTimestamp,
152
- getCurrentFormattedDate,
153
- getAuditDateFormat,
154
- getDateWithOffset,
155
- getYearMonthDayFormat,
156
- dateToIsoFormat,
157
- getDayInMilliseconds,
158
- extractDateFromDateTime,
159
- getPreviousDateByDays,
160
- waitFor,
161
- isDateAfterOther
162
- };
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
+
40
+ const getLogTimestamp = () => {
41
+ return moment().format(formats.logTimeStampFormat);
42
+ };
43
+
44
+ const getCurrentFormattedDate = () => {
45
+ return new Date().toISOString();
46
+ };
47
+
48
+ const getDateWithOffset = (date, offsetInDays) => {
49
+ date.setDate(date.getDate() + offsetInDays);
50
+ return date;
51
+ };
52
+
53
+ const getAuditDateFormat = date => {
54
+ const year = date.getUTCFullYear();
55
+ const month = date.getUTCMonth() + 1; //getMonth is zero-based
56
+ const day = date.getUTCDate();
57
+
58
+ return `${month}/${day}/${year}`;
59
+ };
60
+
61
+ const getYearMonthDayFormat = date => {
62
+ const year = date.getUTCFullYear();
63
+ const month = String(date.getUTCMonth() + 1).length === 1 ? `0${(date.getUTCMonth() + 1)}` : (date.getUTCMonth() + 1);
64
+ const day = String(date.getUTCDate()).length === 1 ? `0${date.getUTCDate()}` : date.getUTCDate();
65
+
66
+ return `${year}-${month}-${day}`;
67
+ };
68
+
69
+ const dateToIsoFormat = date => {
70
+ return new Date(date).toISOString();
71
+ };
72
+
73
+ const extractDateFromDateTime = date => {
74
+ let extractedDate = date;
75
+
76
+ if (date != null && date.length > 10) {
77
+ extractedDate = date.substr(0, 10);
78
+ }
79
+
80
+ return extractedDate;
81
+ };
82
+
83
+ function waitFor(num) {
84
+ return {
85
+ mSeconds: new Promise(resolve => {
86
+ setTimeout(resolve, num);
87
+ }),
88
+ seconds: new Promise(resolve => {
89
+ setTimeout(resolve, num * 1000);
90
+ })
91
+ };
92
+ }
93
+
94
+ function getDayInMilliseconds() {
95
+ return secondsInDay * millisecondsToSeconds;
96
+ }
97
+
98
+ function getPreviousDateByDays(days) {
99
+ return new Date(new Date().getTime() - getDayInMilliseconds() * days);
100
+ }
101
+
102
+ const getInvitationDatesForNotResponsiveVendor = function() {
103
+ const twoDaysAgoUtc = getTwoDaysAgoDate();
104
+ const fiveDaysAgoUtc = getFiveDaysAgoDate();
105
+ const eightDaysAgoUtc = getEightDaysAgoDate();
106
+
107
+ return [twoDaysAgoUtc, fiveDaysAgoUtc, eightDaysAgoUtc];
108
+ };
109
+
110
+ const getInvitationDatesForNotResponsiveTenant = function() {
111
+ const fiveDaysAgoUtc = getFiveDaysAgoDate();
112
+ const tenDaysAgoUtc = getTenDaysAgoDate();
113
+ const fifteenDaysAgoUtc = getFifteenDaysAgoDate();
114
+
115
+ return [fiveDaysAgoUtc, tenDaysAgoUtc, fifteenDaysAgoUtc];
116
+ };
117
+
118
+ const isDateAfterOther = (date, other) => {
119
+ return moment(date).isAfter(other);
120
+ };
121
+
122
+ const getAutomaticRenewalsExpirationDates = function() {
123
+ const inTwentyNineDaysUtc = getDateinTwentyNineDays();
124
+ const inThirteenDaysUtc = getDateinThirteenDays();
125
+ const inSixDaysUtc = getDateinSixDays();
126
+ const todayUtc = getCurrentDate();
127
+
128
+ return [inTwentyNineDaysUtc, inThirteenDaysUtc, inSixDaysUtc, todayUtc];
129
+ };
130
+
131
+ const convertDateToNewFormat = (value, currentFormat, newFormat = formats.dayMonthYear) => {
132
+ return moment(value, currentFormat).format(newFormat);
133
+ };
134
+
135
+ module.exports = {
136
+ formats,
137
+ getOneYearAgoDate,
138
+ getSixMonthAgoDate,
139
+ getOneMonthAgoDate,
140
+ getFifteenDaysAgoDate,
141
+ getTenDaysAgoDate,
142
+ getEightDaysAgoDate,
143
+ getFiveDaysAgoDate,
144
+ getTwoDaysAgoDate,
145
+ getOneDayAgoDate,
146
+ getThirtyFiveDaysAgoDate,
147
+ getCurrentDate,
148
+ getDateInOneDay,
149
+ getDateinSixDays,
150
+ getDateinThirteenDays,
151
+ getDateinTwentyNineDays,
152
+ getInvitationDatesForNotResponsiveVendor,
153
+ getInvitationDatesForNotResponsiveTenant,
154
+ getAutomaticRenewalsExpirationDates,
155
+ getLogTimestamp,
156
+ getCurrentFormattedDate,
157
+ getAuditDateFormat,
158
+ getDateWithOffset,
159
+ getYearMonthDayFormat,
160
+ dateToIsoFormat,
161
+ getDayInMilliseconds,
162
+ extractDateFromDateTime,
163
+ getPreviousDateByDays,
164
+ waitFor,
165
+ isDateAfterOther,
166
+ convertDateToNewFormat
167
+ };
@@ -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 };
package/src/env.js CHANGED
@@ -1,45 +1,45 @@
1
- let privateMembers = {
2
- backendUrl: null,
3
- openapiUrl: null,
4
- nodeBackendUrl: null,
5
- credentials: null,
6
- environment: null,
7
- accountCreationSecret: null,
8
- threadSchedulerSecret: null,
9
- nodeBackendSecret: null,
10
- dbEmailsSecrets: null
11
- };
12
-
13
- const init = conf => {
14
- privateMembers = Object.assign(privateMembers, conf);
15
- requiredValidation({
16
- backendUrl: privateMembers.backendUrl,
17
- openapiUrl: privateMembers.openapiUrl,
18
- nodeBackendUrl: privateMembers.nodeBackendUrl,
19
- environment: privateMembers.environment
20
- });
21
- };
22
-
23
- const requiredValidation = object => {
24
- const invalidKeys = [];
25
- Object.keys(object).forEach(key => {
26
- if (!object[key]) {
27
- invalidKeys.push(` '${key}'`);
28
- }
29
- });
30
-
31
- if (invalidKeys.length > 0) {
32
- throw Error(`Missing required configuration on your environment variables.\nThe missing env-vars are:${invalidKeys}`);
33
- }
34
- };
35
-
36
- const isLocalhost = () => {
37
- return privateMembers.backendUrl.includes('localhost');
38
- };
39
-
40
- module.exports = {
41
- init,
42
- getEnv: () => privateMembers,
43
- requiredValidation,
44
- isLocalhost
45
- };
1
+ let privateMembers = {
2
+ backendUrl: null,
3
+ openapiUrl: null,
4
+ nodeBackendUrl: null,
5
+ credentials: null,
6
+ environment: null,
7
+ accountCreationSecret: null,
8
+ threadSchedulerSecret: null,
9
+ nodeBackendSecret: null,
10
+ dbEmailsSecrets: null
11
+ };
12
+
13
+ const init = conf => {
14
+ privateMembers = Object.assign(privateMembers, conf);
15
+ requiredValidation({
16
+ backendUrl: privateMembers.backendUrl,
17
+ openapiUrl: privateMembers.openapiUrl,
18
+ nodeBackendUrl: privateMembers.nodeBackendUrl,
19
+ environment: privateMembers.environment
20
+ });
21
+ };
22
+
23
+ const requiredValidation = object => {
24
+ const invalidKeys = [];
25
+ Object.keys(object).forEach(key => {
26
+ if (!object[key]) {
27
+ invalidKeys.push(` '${key}'`);
28
+ }
29
+ });
30
+
31
+ if (invalidKeys.length > 0) {
32
+ throw Error(`Missing required configuration on your environment variables.\nThe missing env-vars are:${invalidKeys}`);
33
+ }
34
+ };
35
+
36
+ const isLocalhost = () => {
37
+ return privateMembers.backendUrl.includes('localhost');
38
+ };
39
+
40
+ module.exports = {
41
+ init,
42
+ getEnv: () => privateMembers,
43
+ requiredValidation,
44
+ isLocalhost
45
+ };
package/src/index.js CHANGED
@@ -1,69 +1,71 @@
1
- const env = require('./env');
2
-
3
- const init = conf => {
4
- env.init(conf);
5
- const internalAPI = getInternalAPI();
6
- const openAPI = getOpenAPI();
7
-
8
- return { internalAPI, openAPI };
9
- };
10
-
11
- const getInternalAPI = () => {
12
- const auth = require('./saas/internal-api/auth');
13
- const accounts = require('./saas/internal-api/accounts');
14
-
15
- const projects = require('./saas/internal-api/projects');
16
- const tabs = require('./saas/internal-api/tabs');
17
-
18
- const requirements = require('./saas/internal-api/requirements');
19
- const contractors = require('./saas/internal-api/contractors');
20
- const requests = require('./saas/internal-api/requests');
21
-
22
- const coi = require('./saas/internal-api/coi');
23
- const compliance = require('./saas/internal-api/compliance');
24
- const users = require('./saas/internal-api/users');
25
-
26
- const reports = require('./saas/internal-api/reports');
27
- const charts = require('./saas/internal-api/homepageCharts');
28
-
29
- const globalRecord = require('./saas/internal-api/globalRecord');
30
- const vendorProfile = require('./saas/internal-api/vendorProfile');
31
- const serviceArea = require('./saas/internal-api/serviceArea');
32
-
33
- const threadScheduler = require('./saas/internal-api/thread-scheduler/runner');
34
- const dbEmails = require('./saas/internal-api/dbEmails/index');
35
-
36
- const internalAPI = {
37
- auth,
38
- accounts,
39
- projects,
40
- tabs,
41
- requirements,
42
- contractors,
43
- requests,
44
- coi,
45
- compliance,
46
- reports,
47
- users,
48
- charts,
49
- globalRecord,
50
- vendorProfile,
51
- serviceArea,
52
- threadScheduler,
53
- dbEmails
54
- };
55
-
56
- return internalAPI;
57
- };
58
-
59
- const getOpenAPI = () => {
60
- const accounts = require('./saas/openapi/accounts/accounts.service');
61
- const tabs = require('./saas/openapi/tabs/tabs.service');
62
- const requests = require('./saas/openapi/requests');
63
- const projects = require('./saas/openapi/projects/projects.service');
64
- const requirements = require('./saas/openapi/requirements');
65
- const openAPI = { accounts, tabs, requests, projects, requirements };
66
- return openAPI;
67
- };
68
-
69
- module.exports = init;
1
+ const env = require('./env');
2
+
3
+ const init = conf => {
4
+ env.init(conf);
5
+ const internalAPI = getInternalAPI();
6
+ const openAPI = getOpenAPI();
7
+
8
+ return { internalAPI, openAPI };
9
+ };
10
+
11
+ const getInternalAPI = () => {
12
+ const auth = require('./saas/internal-api/auth');
13
+ const accounts = require('./saas/internal-api/accounts');
14
+
15
+ const projects = require('./saas/internal-api/projects');
16
+ const tabs = require('./saas/internal-api/tabs');
17
+
18
+ const requirements = require('./saas/internal-api/requirements');
19
+ const contractors = require('./saas/internal-api/contractors');
20
+ const requests = require('./saas/internal-api/requests');
21
+
22
+ const coi = require('./saas/internal-api/coi');
23
+ const compliance = require('./saas/internal-api/compliance');
24
+ const users = require('./saas/internal-api/users');
25
+
26
+ const reports = require('./saas/internal-api/reports');
27
+ const charts = require('./saas/internal-api/homepageCharts');
28
+ const dashboardInnerPage = require('./saas/internal-api/dashboardInnerPage');
29
+
30
+ const globalRecord = require('./saas/internal-api/globalRecord');
31
+ const vendorProfile = require('./saas/internal-api/vendorProfile');
32
+ const serviceArea = require('./saas/internal-api/serviceArea');
33
+
34
+ const threadScheduler = require('./saas/internal-api/thread-scheduler/runner');
35
+ const dbEmails = require('./saas/internal-api/dbEmails/index');
36
+
37
+ const internalAPI = {
38
+ auth,
39
+ accounts,
40
+ projects,
41
+ tabs,
42
+ requirements,
43
+ contractors,
44
+ requests,
45
+ coi,
46
+ compliance,
47
+ reports,
48
+ users,
49
+ charts,
50
+ dashboardInnerPage,
51
+ globalRecord,
52
+ vendorProfile,
53
+ serviceArea,
54
+ threadScheduler,
55
+ dbEmails
56
+ };
57
+
58
+ return internalAPI;
59
+ };
60
+
61
+ const getOpenAPI = () => {
62
+ const accounts = require('./saas/openapi/accounts/accounts.service');
63
+ const tabs = require('./saas/openapi/tabs/tabs.service');
64
+ const requests = require('./saas/openapi/requests');
65
+ const projects = require('./saas/openapi/projects/projects.service');
66
+ const requirements = require('./saas/openapi/requirements');
67
+ const openAPI = { accounts, tabs, requests, projects, requirements };
68
+ return openAPI;
69
+ };
70
+
71
+ module.exports = init;