@getjones/test-infra 1.1.2 → 1.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getjones/test-infra",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/env.js CHANGED
@@ -4,6 +4,7 @@ let privateMembers = {
4
4
  credentials: null,
5
5
  environment: null,
6
6
  accountCreationSecret: null,
7
+ threadSchedulerSecret: null
7
8
  };
8
9
 
9
10
  const init = conf => {
package/src/index.js CHANGED
@@ -4,7 +4,9 @@ const init = conf => {
4
4
  env.init(conf);
5
5
  const internalAPI = getInternalAPI();
6
6
  const openAPI = getOpenAPI();
7
- return { internalAPI, openAPI };
7
+ const threadScheduler = require('./saas/thread-scheduler/runner');
8
+
9
+ return { internalAPI, openAPI, threadScheduler };
8
10
  };
9
11
 
10
12
  const getInternalAPI = () => {
@@ -19,6 +21,7 @@ const getInternalAPI = () => {
19
21
 
20
22
  const coi = require('./saas/internal-api/coi');
21
23
  const compliance = require('./saas/internal-api/compliance');
24
+ const users = require('./saas/internal-api/users');
22
25
 
23
26
  const reports = require('./saas/internal-api/reports');
24
27
 
@@ -31,7 +34,8 @@ const getInternalAPI = () => {
31
34
  contractors,
32
35
  coi,
33
36
  compliance,
34
- reports
37
+ reports,
38
+ users,
35
39
  };
36
40
 
37
41
  return internalAPI;
@@ -8,6 +8,8 @@ const Endpoints = {
8
8
  delete: contractorId => `${backendUrl}/saas/contractor/${contractorId}`,
9
9
  archive: contractorId => `${backendUrl}/saas/contractor/${contractorId}/archive`,
10
10
  restore: contractorId => `${backendUrl}/saas/contractor/${contractorId}/restore`,
11
+ edit: contractorId => `${backendUrl}/saas/contractors/${contractorId}/update`,
12
+ updateVendorExpiryDate: contractorId => `${backendUrl}/_saas/automation/contractor/${contractorId}/expiry-date`
11
13
  };
12
14
 
13
15
  const createContractors = async (createContractorModel, context) => {
@@ -34,11 +36,23 @@ const restoreByContractorId = async (contractorId, context) => {
34
36
  return requests.postRequestHandler(Endpoints.restore(contractorId), {}, context);
35
37
  };
36
38
 
39
+ const editContractor = async (editContractorModel, context) => {
40
+ const params = { updateInfoUser: 'EditVendor' };
41
+ return requests.postRequestHandler(Endpoints.edit(editContractorModel.contractorId), editContractorModel, context, {}, params).then(res => res.data);
42
+ };
43
+
44
+ const updateExpiryDate = async (contractorId, expiryDate, policyName) => {
45
+ const data = { [policyName]: expiryDate };
46
+ return requests.postRequestHandler(Endpoints.updateVendorExpiryDate(contractorId), data);
47
+ };
48
+
37
49
  module.exports = {
38
50
  createContractors,
39
51
  getContractorsByAccountId,
40
52
  getContractorById,
41
53
  deleteByContractorId,
42
54
  archiveByContractorId,
43
- restoreByContractorId
55
+ restoreByContractorId,
56
+ editContractor,
57
+ updateExpiryDate
44
58
  };
@@ -1,6 +1,8 @@
1
1
  const contractorsAPI = require('./contractors.api');
2
2
  const { CreateContractorModel } = require('../models/create.contractor.model');
3
+ const { ContractorModel } = require('../models/edit.contractor.model');
3
4
  const { validateType } = require('../../../../common/validations/typeValidations');
5
+ const requests = require('../../common/requests');
4
6
 
5
7
  const createContractors = async (createContractorsModel, context) => {
6
8
  validateType(createContractorsModel, CreateContractorModel);
@@ -30,11 +32,23 @@ const archiveByContractorId = (contractorId, context) => {
30
32
  const restoreByContractorId = (contractorId, context) => {
31
33
  return contractorsAPI.restoreByContractorId(contractorId, context);
32
34
  };
35
+
36
+ const editContractor = async (editContractorModel, context) => {
37
+ validateType(editContractorModel, ContractorModel);
38
+ return contractorsAPI.editContractor(editContractorModel, context);
39
+ };
40
+
41
+ const updateExpiryDate = async (contractorId, expiryDate, policyName) => {
42
+ return contractorsAPI.updateExpiryDate(contractorId, expiryDate, policyName);
43
+ };
44
+
33
45
  module.exports = {
34
46
  createContractors,
35
47
  getContractorsByAccountId,
36
48
  getContractorById,
37
49
  deleteByContractorId,
38
50
  archiveByContractorId,
39
- restoreByContractorId
51
+ restoreByContractorId,
52
+ editContractor,
53
+ updateExpiryDate
40
54
  };
@@ -1,6 +1,7 @@
1
1
  const createModel = require('./models/create.contractor.model');
2
+ const editModel = require('./models/edit.contractor.model');
2
3
  const services = require('./api/contractors.setup');
3
4
 
4
- const models = { create: createModel };
5
+ const models = { create: createModel, edit:editModel };
5
6
 
6
7
  module.exports = { services, models };
@@ -0,0 +1,24 @@
1
+ const { validateType } = require('../../../../common/validations/typeValidations');
2
+
3
+ function ContractorModel(contractorId, company, emailAddress, tab, tenantRecord) {
4
+ this.contractorId = contractorId;
5
+ this.company = company;
6
+ this.emailAddress = emailAddress;
7
+ this.tab = tab;
8
+ this.tenantRecord = tenantRecord;
9
+
10
+ validateType(tenantRecord, TenantRecordModel);
11
+ validateType(tab, VendorTabModel);
12
+ }
13
+
14
+ function TenantRecordModel(id, companyName, emailAddress) {
15
+ this.id = id;
16
+ this.companyName = companyName;
17
+ this.emailAddress = emailAddress;
18
+ }
19
+
20
+ function VendorTabModel(type){
21
+ this.type = type;
22
+ }
23
+
24
+ module.exports = { ContractorModel, TenantRecordModel, VendorTabModel };
@@ -0,0 +1,29 @@
1
+ const requests = require('../../common/requests');
2
+ const { backendUrl } = require('../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ invite: projectId => `${backendUrl}/saas/project/${projectId}/team-member`,
6
+ getByProjectId: projectId => `${backendUrl}/saas/project/${projectId}/team-members`,
7
+ getByEmail: email => `${backendUrl}/saas/team-member/by-email/${email}`,
8
+ delete: userId => `${backendUrl}/saas/users/${userId}`,
9
+ };
10
+
11
+ const invite = async (projectId, invitedUser, context) => {
12
+ return requests.putRequestHandler(Endpoints.invite(projectId), invitedUser, context).then(
13
+ res => res.data
14
+ );
15
+ };
16
+
17
+ const getUsersByProjectId = async (projectId, context) => {
18
+ return requests.getRequestHandler(Endpoints.getByProjectId(projectId), null, context).then(res => res.data);
19
+ };
20
+
21
+ const getUserByEmail = async (email, context) => {
22
+ return requests.getRequestHandler(Endpoints.getByEmail(email), null, context).then(res => res.data);
23
+ };
24
+
25
+ const deleteUser = async (userId, context) => {
26
+ return requests.deleteRequestHandler(Endpoints.delete(userId), context);
27
+ };
28
+
29
+ module.exports = { invite, getUsersByProjectId, getUserByEmail, deleteUser };
@@ -0,0 +1,19 @@
1
+ const inviteUserAPI = require('./invite.api');
2
+
3
+ const invite = async (projectId, invitedUser, context) => {
4
+ return inviteUserAPI.invite(projectId, invitedUser, context);
5
+ };
6
+
7
+ const getUsersByProjectId = async (projectId, context) => {
8
+ return inviteUserAPI.getUsersByProjectId(projectId, context);
9
+ };
10
+
11
+ const getUserByEmail = async (email, context) => {
12
+ return inviteUserAPI.getUserByEmail(email, context);
13
+ };
14
+
15
+ const deleteUser = (userId, context) => {
16
+ return inviteUserAPI.deleteUser(userId, context);
17
+ };
18
+
19
+ module.exports = { invite, getUsersByProjectId, getUserByEmail, deleteUser };
@@ -0,0 +1,3 @@
1
+ const services = require('./api/invite.setup');
2
+
3
+ module.exports = { services };
@@ -0,0 +1,17 @@
1
+ const requests = require('../internal-api/common/requests');
2
+ const { backendUrl, threadSchedulerSecret } = require('../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ run: `${backendUrl}/threadSchedular/${threadSchedulerSecret}`
6
+ };
7
+
8
+ const runThreadScheduler = ({ contractorIds = null } = {}) => {
9
+ if (contractorIds) {
10
+ contractorIds = contractorIds.reduce((f, s) => `${f},${s}`);
11
+ }
12
+
13
+ const params = { contractorIdsList: contractorIds };
14
+ return requests.getRequestHandler(Endpoints.run, params);
15
+ };
16
+
17
+ module.exports = { runThreadScheduler };