@getjones/test-infra 1.4.0 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getjones/test-infra",
3
- "version": "1.4.0",
3
+ "version": "1.4.4",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -10,4 +10,27 @@ const validateDateString = dateString => {
10
10
  }
11
11
  };
12
12
 
13
- module.exports = { validateType, validateDateString };
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/index.js CHANGED
@@ -26,6 +26,7 @@ const getInternalAPI = () => {
26
26
  const charts = require('./saas/internal-api/homepageCharts');
27
27
 
28
28
  const globalRecord = require('./saas/internal-api/globalRecord');
29
+ const vendorProfile = require('./saas/internal-api/vendorProfile');
29
30
 
30
31
  const threadScheduler = require('./saas/internal-api/thread-scheduler/runner');
31
32
 
@@ -42,6 +43,7 @@ const getInternalAPI = () => {
42
43
  users,
43
44
  charts,
44
45
  globalRecord,
46
+ vendorProfile,
45
47
  threadScheduler
46
48
  };
47
49
 
@@ -19,8 +19,8 @@ const isReaudit = (contractorId, context) => {
19
19
  return requests.getRequestHandler(Endpoints.isReaudit(contractorId), {}, context);
20
20
  };
21
21
 
22
- const getAuditorContractorList = (page, accountId, context) => {
23
- return requests.getRequestHandler(Endpoints.auditorContractorList, { page, accountId }, context);
22
+ const getAuditorContractorList = (auditListParametersModel, context) => {
23
+ return requests.postRequestHandler(Endpoints.auditorContractorList, auditListParametersModel, context);
24
24
  };
25
25
 
26
26
  const getContractorDetailsForAudit = (contractorId, context) => {
@@ -1,5 +1,5 @@
1
1
  const auditApi = require('./audit.api');
2
- const { AuditRequestModel } = require('../../models/audit/audit.model');
2
+ const { AuditRequestModel, AuditListParametersModel } = require('../../models/audit/audit.model');
3
3
  const { validateType } = require('../../../../../common/validations/typeValidations');
4
4
 
5
5
  const audit = (auditRequestModel, context) => {
@@ -11,8 +11,9 @@ const isReaudit = (contractorId, context) => {
11
11
  return auditApi.isReaudit(contractorId, context);
12
12
  };
13
13
 
14
- const getAuditorContractorList = (page, accountId, context) => {
15
- return auditApi.getAuditorContractorList(page, accountId, context);
14
+ const getAuditorContractorList = (auditListParametersModel, context) => {
15
+ validateType(auditListParametersModel, AuditListParametersModel);
16
+ return auditApi.getAuditorContractorList(auditListParametersModel, context);
16
17
  };
17
18
 
18
19
  const getContractorDetailsForAudit = (contractorId, context) => {
@@ -1,4 +1,4 @@
1
- const { validateType } = require('../../../../../common/validations/typeValidations');
1
+ const { validateType, validateInteger, validateArray, validateDateString } = require('../../../../../common/validations/typeValidations');
2
2
 
3
3
  const COI_AUDIT_STATUSES = {
4
4
  NOT_AUDITED: '0',
@@ -80,10 +80,29 @@ class AuditDatesModel {
80
80
  }
81
81
  }
82
82
 
83
+ class AuditListParametersModel {
84
+ constructor(page, accountIds, { fromDate, toDate } = {}) {
85
+ validateInteger(page, { min: 1 });
86
+ validateArray(accountIds);
87
+
88
+ if (fromDate) {
89
+ validateDateString(fromDate);
90
+ }
91
+
92
+ if (toDate) {
93
+ validateDateString(toDate);
94
+ }
95
+
96
+ this.page = page;
97
+ this.filters = { accountIds, fromDate, toDate };
98
+ }
99
+ }
100
+
83
101
  module.exports = {
84
102
  AuditRequestModel,
85
103
  AuditEntityModel,
86
104
  AuditDatesModel,
105
+ AuditListParametersModel,
87
106
  COI_AUDIT_STATUSES,
88
107
  AUDIT_ENTITY_STATUSES,
89
108
  AUDIT_ATTRIBUTE_NAMES,
@@ -11,8 +11,9 @@ const Endpoints = {
11
11
  edit: contractorId => `${backendUrl}/saas/contractors/${contractorId}/update`,
12
12
  updateVendorExpiryDate: contractorId => `${backendUrl}/_saas/automation/contractor/${contractorId}/expiry-date`,
13
13
  assignMptToProperties: (accountId, tenantId) => `${backendUrl}/saas/account/${accountId}/multi-properties/${tenantId}`,
14
- searchInAutocomplete: ({ projectId, searchWord }) =>
15
- `${backendUrl}/saas/contractors/search/audited?&projectId=${projectId}&searchWord=${searchWord}`
14
+ searchInAutocomplete: ({ tabId, searchWord }) =>
15
+ `${backendUrl}/saas/contractors/search/audited?&tabId=${tabId}&searchWord=${searchWord}`,
16
+ automationUpdateContractorUploadDate: contractorId => `${backendUrl}/saas/automation/contractor/${contractorId}/upload-date`
16
17
  };
17
18
 
18
19
  const createContractor = (createContractorModel, context) => {
@@ -35,7 +36,7 @@ const archiveByContractorId = (contractorId, context) => {
35
36
  return requests.deleteRequestHandler(Endpoints.archive(contractorId), context);
36
37
  };
37
38
 
38
- const restoreByContractorId = (recordVerificationModel, context) => {
39
+ const restoreContractor = (recordVerificationModel, context) => {
39
40
  return requests.postRequestHandler(Endpoints.restore(recordVerificationModel.contractorId), recordVerificationModel, context);
40
41
  };
41
42
 
@@ -65,8 +66,13 @@ const getContractorsByTabId = (tabId, context, activityStatus) => {
65
66
  return requests.postRequestHandler(Endpoints.get, body, context);
66
67
  };
67
68
 
68
- const searchInAutocomplete = ({ projectId, searchWord }, context) => {
69
- return requests.getRequestHandler(Endpoints.searchInAutocomplete({ projectId, searchWord }), {}, context);
69
+ const searchInAutocomplete = ({ tabId, searchWord }, context) => {
70
+ return requests.getRequestHandler(Endpoints.searchInAutocomplete({ tabId, searchWord }), {}, context);
71
+ };
72
+
73
+ const updateContractorUploadDate = (contractorId, uploadDate, context) => {
74
+ const url = `${Endpoints.automationUpdateContractorUploadDate(contractorId) }?uploadDate=${uploadDate.toISOString()}`;
75
+ return requests.patchRequestHandler(url, context);
70
76
  };
71
77
 
72
78
  module.exports = {
@@ -75,10 +81,11 @@ module.exports = {
75
81
  getContractorById,
76
82
  deleteByContractorId,
77
83
  archiveByContractorId,
78
- restoreByContractorId,
84
+ restoreContractor,
79
85
  editContractor,
80
86
  updateExpiryDate,
81
87
  assignMptToProperties,
82
88
  getContractorsByTabId,
83
- searchInAutocomplete
89
+ searchInAutocomplete,
90
+ updateContractorUploadDate
84
91
  };
@@ -29,9 +29,9 @@ const archiveByContractorId = (contractorId, context) => {
29
29
  return contractorsAPI.archiveByContractorId(contractorId, context);
30
30
  };
31
31
 
32
- const restoreByContractorId = (recordVerificationModel, context) => {
32
+ const restoreContractor = (recordVerificationModel, context) => {
33
33
  validateType(recordVerificationModel, RecordModifyDateVerificationModel);
34
- return contractorsAPI.restoreByContractorId(recordVerificationModel, context);
34
+ return contractorsAPI.restoreContractor(recordVerificationModel, context);
35
35
  };
36
36
 
37
37
  const editContractor = (editContractorModel, context) => {
@@ -52,8 +52,13 @@ const assignMptToProperties = (assignToMptModel, context) => {
52
52
  return contractorsAPI.assignMptToProperties(assignToMptModel, context);
53
53
  };
54
54
 
55
- const searchInAutoComplete = ({ projectId, searchWord }, context) => {
56
- return contractorsAPI.searchInAutocomplete({ projectId, searchWord }, context);
55
+ const searchInAutoComplete = ({ tabId, searchWord }, context) => {
56
+ return contractorsAPI.searchInAutocomplete({ tabId, searchWord }, context);
57
+ };
58
+
59
+ const updateContractorUploadDate = (contractorId, uploadDate, context) => {
60
+ validateType(uploadDate, Date);
61
+ return contractorsAPI.updateContractorUploadDate(contractorId, uploadDate, context);
57
62
  };
58
63
 
59
64
  module.exports = {
@@ -62,10 +67,11 @@ module.exports = {
62
67
  getContractorById,
63
68
  deleteByContractorId,
64
69
  archiveByContractorId,
65
- restoreByContractorId,
70
+ restoreContractor,
66
71
  editContractor,
67
72
  updateExpiryDate,
68
73
  getContractorsByTabId,
69
74
  assignMptToProperties,
70
- searchInAutoComplete
75
+ searchInAutoComplete,
76
+ updateContractorUploadDate
71
77
  };
@@ -1,7 +1,8 @@
1
1
  const createModel = require('./models/create.contractor.model');
2
2
  const editModel = require('./models/edit.contractor.model');
3
+ const verificationModel = require('./models/verification.contractor.model');
3
4
  const services = require('./api/contractors.service');
4
5
 
5
- const models = { create: createModel, edit: editModel };
6
+ const models = { create: createModel, edit: editModel, verification: verificationModel };
6
7
 
7
8
  module.exports = { services, models };
@@ -15,7 +15,8 @@ class CreateGlobalRecordModel {
15
15
  primaryEmail,
16
16
  dba,
17
17
  lastPublishUserName,
18
- __v
18
+ __v,
19
+ recordType
19
20
  } = {}
20
21
  ) {
21
22
  this.id = id;
@@ -33,6 +34,7 @@ class CreateGlobalRecordModel {
33
34
  this.dba = dba;
34
35
  this.lastPublishUserName = lastPublishUserName;
35
36
  this.__v = __v;
37
+ this.recordType = recordType;
36
38
  }
37
39
  }
38
40
 
@@ -35,7 +35,8 @@ const createGlobalRecordConfig = (
35
35
  dba: '',
36
36
  primaryEmail: '',
37
37
  serviceAreas: [getServiceArea(serviceArea)],
38
- __v: 0
38
+ __v: 0,
39
+ recordType: ['Vendors']
39
40
  };
40
41
  };
41
42
 
@@ -75,7 +76,8 @@ const createGlobalRecordModel = config => {
75
76
  primaryEmail: config.primaryEmail,
76
77
  dba: config.dba,
77
78
  lastPublishUserName: config.lastPublishUserName,
78
- __v: config.__v
79
+ __v: config.__v,
80
+ recordType: config.recordType
79
81
  }
80
82
  );
81
83
  };
@@ -16,7 +16,8 @@ function UpdateProjectModel(
16
16
  tenantSolutionEnabled = 0,
17
17
  onboardingEnabled = 0,
18
18
  automaticRenewalEnabled = 0,
19
- onboardedVendors = 0
19
+ onboardedVendors = 0,
20
+ compliantVendorQuotationEnabled = 0
20
21
  ) {
21
22
  this.projectId = projectId;
22
23
  this.projectName = name;
@@ -28,6 +29,7 @@ function UpdateProjectModel(
28
29
  this.projectStartDate = startDate;
29
30
  this.projectEndDate = endDate;
30
31
  this.onboardedVendors = onboardedVendors;
32
+ this.compliantVendorQuotationEnabled = compliantVendorQuotationEnabled;
31
33
 
32
34
  this.city = city;
33
35
  this.state = state;
@@ -25,7 +25,8 @@ module.exports = UpdateProjectSettingsModel;
25
25
  const defaultMarketplace = {
26
26
  marketplaceEnabled: false,
27
27
  marketplacePreApproved: false,
28
- marketplaceOnboardedVendors: false
28
+ marketplaceOnboardedVendors: false,
29
+ marketplaceCompliantVendorQuotationEnabled: false
29
30
  };
30
31
  const defaultAutoGaps = {
31
32
  Guests: false,
@@ -2,13 +2,19 @@ const requests = require('../../../../common/requests/cookieAuth/requests');
2
2
  const { backendUrl } = require('../../../../env').getEnv();
3
3
 
4
4
  const Endpoints = {
5
- getVendorProfileJson: (contractorId, requirementId) => `${backendUrl}/saas/vendorProfile/contractor/${contractorId}/requirement/${requirementId}/immediateComplianceReport`
5
+ getVendorProfileJson: (contractorId, requirementId) => `${backendUrl}/saas/vendorProfile/contractor/${contractorId}/requirement/${requirementId}/immediateComplianceReport`,
6
+ shouldShowRecordProfile: recordId => `${backendUrl}/saas/record-profile/record/${recordId}/should-show-record-profile`
6
7
  };
7
8
 
8
9
  const createVendorProfileReport = async (contractorId, requirementId, context) => {
9
10
  return requests.getRequestHandler(Endpoints.getVendorProfileJson(contractorId, requirementId), {}, context);
10
11
  };
11
12
 
13
+ const getShouldShowRecordProfile = async (recordId, context) => {
14
+ return requests.getRequestHandler(Endpoints.shouldShowRecordProfile(recordId), {}, context);
15
+ };
16
+
12
17
  module.exports = {
18
+ getShouldShowRecordProfile,
13
19
  createVendorProfileReport
14
20
  };
@@ -3,6 +3,12 @@ const vendorProfileApi = require('./vendor.profile.api');
3
3
  const createVendorProfileReport = async (contractorId, requirementId, context) => {
4
4
  return vendorProfileApi.createVendorProfileReport(contractorId, requirementId, context);
5
5
  };
6
+
7
+ const getShouldShowRecordProfile = async (recordId, context) => {
8
+ return vendorProfileApi.getShouldShowRecordProfile(recordId, context);
9
+ };
10
+
6
11
  module.exports = {
12
+ getShouldShowRecordProfile,
7
13
  createVendorProfileReport
8
14
  };
@@ -1,6 +1,6 @@
1
- const { expect } = require('chai');;
1
+ const { expect } = require('chai');
2
2
 
3
- const { validateDateString } = require('../src/common/validations/typeValidations');
3
+ const { validateDateString, validateInteger, validateArray } = require('../src/common/validations/typeValidations');
4
4
  const VALID_DATE_STRINGS = Object.freeze([
5
5
  '2022-08-03T11:47:07.499Z',
6
6
  '2022-08-03T14:16:27.000+0000'
@@ -24,7 +24,6 @@ const INVALID_DATE_STRINGS = Object.freeze([
24
24
  '2022-08-03a14:16:27.000+0000',
25
25
  '2022-08-03T14:16:2.000+0000',
26
26
  'asd1q2123'
27
-
28
27
  ]);
29
28
 
30
29
  describe('Validation | Test Validation functions', function() {
@@ -39,4 +38,46 @@ describe('Validation | Test Validation functions', function() {
39
38
  expect(() => validateDateString(dateString), `Expect string: '${dateString}' to fail date validation.`).to.throw(TypeError);
40
39
  }
41
40
  });
41
+
42
+ it('Should throw error for invalid integers', () => {
43
+ for (let i = -1; i < 3 ; i++) {
44
+ const number = i.toString();
45
+ expect(() => validateInteger(number)).to.throw(TypeError);
46
+ expect(() => validateInteger(number, { min: 4 })).to.throw(TypeError);
47
+ expect(() => validateInteger(number, { max: -11 })).to.throw(TypeError);
48
+ expect(() => validateInteger(number, { min: -100, max: -5 })).to.throw(TypeError);
49
+ }
50
+ });
51
+
52
+ it('Should throw error for out of range integers', () => {
53
+ for (let i = -1; i < 3 ; i++) {
54
+ expect(() => validateInteger(i, { min: 4 })).to.throw(RangeError);
55
+ expect(() => validateInteger(i, { max: -11 })).to.throw(RangeError);
56
+ expect(() => validateInteger(i, { min: -100, max: -5 })).to.throw(RangeError);
57
+ }
58
+ });
59
+
60
+ it('Should throw error for invalid arrays', () => {
61
+ expect(() => validateArray(undefined)).to.throw(TypeError);
62
+ expect(() => validateArray(null)).to.throw(TypeError);
63
+ expect(() => validateArray()).to.throw(TypeError);
64
+ expect(() => validateArray({})).to.throw(TypeError);
65
+ expect(() => validateArray({ 1: 2 })).to.throw(TypeError);
66
+ expect(() => validateArray(new Set())).to.throw(TypeError);
67
+ });
68
+
69
+ it('Should not throw error for valid integers', () => {
70
+ for (let i = -1; i < 3 ; i++) {
71
+ expect(() => validateInteger(i)).to.not.throw();
72
+ expect(() => validateInteger(i, { min: -4 })).to.not.throw();
73
+ expect(() => validateInteger(i, { max: 5 })).to.not.throw();
74
+ expect(() => validateInteger(i, { min: -100, max: 4 })).to.not.throw();
75
+ }
76
+ });
77
+
78
+ it('Should not throw error for valid arrays', () => {
79
+ expect(() => validateArray([])).to.not.throw(TypeError);
80
+ expect(() => validateArray([1, 2, 3])).to.not.throw(TypeError);
81
+ expect(() => validateArray(['a'])).to.not.throw(TypeError);
82
+ });
42
83
  });