@getjones/test-infra 4.4.5 → 4.4.7

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": "4.4.5",
3
+ "version": "4.4.7",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -6,5 +6,9 @@ module.exports = {
6
6
  isAccountRequirementsEnabled: {
7
7
  on: { isAccountRequirementsEnabled: true },
8
8
  off: { isAccountRequirementsEnabled: false }
9
+ },
10
+ isPolicyVerificationEnabled: {
11
+ on: { hasPolicyVerification: true },
12
+ off: { hasPolicyVerification: false }
9
13
  }
10
14
  };
@@ -4,6 +4,8 @@ const { backendUrl } = require('../../../../env').getEnv();
4
4
  const Endpoints = {
5
5
  getRelatedDocPreSignedUrl: `${backendUrl}/saas/pre-signed-url/upload/document`,
6
6
  getCreatePolicyPreSignedUrl: `${backendUrl}/saas/pre-signed-url/upload/policy`,
7
+ getPolicyFilesForVendorReport: requestId => `${backendUrl}/saas/request/${requestId}/policy-files`,
8
+ createPolicyFiles: requestId => `${backendUrl}/saas/request/${requestId}/policy-files/create`,
7
9
  uploadRelatedDoc: recordId => `${backendUrl}/saas/contractor/${recordId}/document`,
8
10
  fileUpload: `${backendUrl}/file/finalize-upload`
9
11
  };
@@ -16,6 +18,14 @@ const getCreatePolicyPreSignedUrl = (formData, context) => {
16
18
  return requests.postRequestHandler(Endpoints.getCreatePolicyPreSignedUrl, formData, context, formData.getHeaders());
17
19
  };
18
20
 
21
+ const getPolicyFilesForVendorReport = (requestId, context) => {
22
+ return requests.getRequestHandler(Endpoints.getPolicyFilesForVendorReport(requestId), {}, context);
23
+ };
24
+
25
+ const createPolicyFiles = (requestId, policyFileList, context) => {
26
+ return requests.postRequestHandler(Endpoints.createPolicyFiles(requestId), policyFileList , context);
27
+ };
28
+
19
29
  const uploadFileToS3 = (preSignedUrl, file) => {
20
30
  return requests.putRequestHandler(preSignedUrl, file);
21
31
  };
@@ -33,5 +43,7 @@ module.exports = {
33
43
  getCreatePolicyPreSignedUrl,
34
44
  uploadRelatedDoc,
35
45
  uploadFileToS3,
36
- uploadFile
46
+ uploadFile,
47
+ getPolicyFilesForVendorReport,
48
+ createPolicyFiles
37
49
  };
@@ -13,7 +13,7 @@ const getRelatedDocPreSignedUrl = (recordId, context, { filePath }) => {
13
13
  const fileName = path.basename(filePath);
14
14
  formData.append('recordId', recordId);
15
15
  formData.append('fileType', TEMP_DOCUMENTS);
16
- formData.append('fileName', fileName) ;
16
+ formData.append('fileName', fileName);
17
17
 
18
18
  return uploadFileApi.getRelatedDocPreSignedUrl(formData, context);
19
19
  };
@@ -57,8 +57,30 @@ const uploadFile = (recordId, type, fileName) => {
57
57
  return uploadFileApi.uploadFile(formData);
58
58
  };
59
59
 
60
+ const createPolicyFiles = async (requestId, policyFileList, context, { shouldExpectError } = {}) => {
61
+ const createPolicyFilesResponse = await uploadFileApi.createPolicyFiles(requestId, policyFileList, context);
62
+
63
+ if (createPolicyFilesResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
64
+ throw new Error('Failed to create policy files');
65
+ }
66
+
67
+ return createPolicyFilesResponse;
68
+ };
69
+
70
+ const getPolicyFilesForVendorReport = async (requestId, context, { shouldExpectError } = {}) => {
71
+ const policyPreSignedUrlResponse = await uploadFileApi.getPolicyFilesForVendorReport(requestId, context);
72
+
73
+ if (policyPreSignedUrlResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
74
+ throw new Error('Failed to get policy files for PM');
75
+ }
76
+
77
+ return policyPreSignedUrlResponse;
78
+ };
79
+
60
80
  module.exports = {
61
81
  getCreatePolicyPreSignedUrl,
62
82
  uploadRelatedDoc,
63
- uploadFileToS3
83
+ uploadFileToS3,
84
+ createPolicyFiles,
85
+ getPolicyFilesForVendorReport
64
86
  };
@@ -1,3 +1,9 @@
1
1
  const services = require('./api/upload.file.service');
2
2
 
3
- module.exports = { services };
3
+ const { CreatePolicyFileModel } = require('./models/create.policy.file.model');
4
+
5
+ const models = {
6
+ CreatePolicyFileModel
7
+ };
8
+
9
+ module.exports = { services, models };
@@ -0,0 +1,11 @@
1
+ class CreatePolicyFileModel {
2
+ constructor(
3
+ policyFileName,
4
+ policyType
5
+ ) {
6
+ this.policyFileName = policyFileName;
7
+ this.policyType = policyType;
8
+ }
9
+ }
10
+
11
+ module.exports = { CreatePolicyFileModel };
@@ -49,7 +49,7 @@ const getEnabledAndDisabledByEmail = async (email, context) => {
49
49
  const getOrCreateUser = async (email, role, projectsIds, context, { fullName = role, password = credentials.strongPassword } = {}) => {
50
50
  let userResponse = await getUserByEmail(email, context);
51
51
 
52
- if (userResponse.data !== '') {
52
+ if (userResponse.data !== '' && userResponse.status === httpResponseStatusCodes.OK) {
53
53
  const { projectPermissions } = userResponse.data;
54
54
  const projectPermissionsIds = projectPermissions.map(projectPermission => projectPermission.projectId);
55
55