@getjones/test-infra 2.9.6 → 2.9.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": "2.9.6",
3
+ "version": "2.9.7",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  ICS: 'ICS',
3
3
  PM: 'PM',
4
- AUDITOR: 'AUDITOR',
4
+ AUDITOR: 'Auditor',
5
5
  VENDOR: 'Vendor',
6
6
  auditor: 'Auditor',
7
7
  operator: 'Operator'
@@ -0,0 +1,22 @@
1
+ const isUIConfig = (config, attributesConvertor) => {
2
+ const converterKeys = Object.keys(attributesConvertor);
3
+ const configKeys = Object.keys(config);
4
+
5
+ return converterKeys.some(key => configKeys.includes(key));
6
+ };
7
+
8
+ const objectConvertor = (config, attributesConvertor) => {
9
+ const covertConfig = {};
10
+
11
+ for (const field in config) {
12
+ const attributes = attributesConvertor[field];
13
+ covertConfig[attributes] = JSON.parse(config[field]);
14
+ }
15
+
16
+ return covertConfig;
17
+ };
18
+
19
+ module.exports = {
20
+ isUIConfig,
21
+ objectConvertor
22
+ };
@@ -2,26 +2,6 @@ const cloneObject = object => {
2
2
  return JSON.parse(JSON.stringify(object));
3
3
  };
4
4
 
5
- const isUIConfig = (config, attributesConvertor) => {
6
- const convectorKeys = Object.keys(attributesConvertor);
7
- const configKeys = Object.keys(config);
8
-
9
- return convectorKeys.some(key => configKeys.includes(key));
10
- };
11
-
12
- const objectConvertor = (config, attributesConvertor) => {
13
- const covertConfig = {};
14
-
15
- for (const field in config) {
16
- const attributes = attributesConvertor[field];
17
- covertConfig[attributes] = JSON.parse(config[field]);
18
- }
19
-
20
- return covertConfig;
21
- };
22
-
23
5
  module.exports = {
24
- cloneObject,
25
- isUIConfig,
26
- objectConvertor
6
+ cloneObject
27
7
  };
@@ -21,7 +21,8 @@ const policyNames = {
21
21
  agreement: 'Agreement',
22
22
  certificateHolder: 'Certificate Holder',
23
23
  additionalInformation: 'Additional Information',
24
- additionalInsured: 'Additional Insured'
24
+ additionalInsured: 'Additional Insured',
25
+ businessInterruptionIncomeInsurance: 'Business Interruption / Income Insurance'
25
26
  };
26
27
 
27
28
  const attributeNames = {
@@ -40,7 +41,10 @@ const attributeNames = {
40
41
  coiAuthentication: 'COI authentication',
41
42
  signature: 'Signature',
42
43
  occur: 'Occur',
43
- text: 'text'
44
+ text: 'text',
45
+ indemnityPeriod: 'Indemnity Period',
46
+ actualLossSustained: 'Actual Loss Sustained',
47
+ extraExpense: 'Extra Expense'
44
48
  };
45
49
 
46
50
  module.exports = {
@@ -1,5 +1,6 @@
1
1
  const coreService = require('../api/core/accounts.core.service');
2
2
  const CreateAccountModel = require('../models/core/create.account.model');
3
+ const configsUtil = require('../../../../common/utils/configsUtil');
3
4
 
4
5
  const getOrCreateAccount = (context, accountName, email, { password, type } = {}) => {
5
6
  const createAccountModel = new CreateAccountModel(
@@ -30,21 +31,12 @@ const deleteAccountByName = async (context, accountName) => {
30
31
  };
31
32
 
32
33
  const isUIConfig = config => {
33
- const convectorKeys = Object.keys(attributesConvertor);
34
- const configKeys = Object.keys(config);
35
-
36
- return convectorKeys.some(key => configKeys.includes(key));
34
+ return configsUtil.isUIConfig(config, attributesConvertor);
37
35
  };
38
36
 
39
37
  const parseAccountSettingsConfig = (accountId, settingsConfig) => {
40
- const settings = { accountId };
41
-
42
- for (const field in settingsConfig) {
43
- const attributes = attributesConvertor[field];
44
- settings[attributes] = JSON.parse(settingsConfig[field]);
45
- }
46
-
47
- return settings;
38
+ const settings = configsUtil.objectConvertor(settingsConfig, attributesConvertor);
39
+ return { ... settings, accountId };
48
40
  };
49
41
 
50
42
  module.exports = {
@@ -5,7 +5,7 @@ const Endpoints = {
5
5
  login: `${backendUrl}/logincontroller`,
6
6
  verifyEmail: `${backendUrl}/verify/email`,
7
7
  createOneTimeSession: `${backendUrl}/vendor-app/one-time-session/create`,
8
- verifyRecord: `${backendUrl}/vendor-app/one-time-session/verify/record/undefined`// Due to unused variable "recordId"
8
+ verifyUser: `${backendUrl}/vendor-app/one-time-session/verify-user`
9
9
  };
10
10
 
11
11
  const login = (email, password) => {
@@ -20,8 +20,8 @@ const createOneTimeSession = email => {
20
20
  return requests.postRequestHandler(Endpoints.createOneTimeSession, { email });
21
21
  };
22
22
 
23
- const verifyRecord = (email, oneTimeCode) => {
24
- return requests.getRequestHandler(Endpoints.verifyRecord, { email, oneTimeCode });
23
+ const verifyUser = (email, oneTimeCode) => {
24
+ return requests.postRequestHandler(Endpoints.verifyUser, { email, oneTimeCode });
25
25
  };
26
26
 
27
- module.exports = { login, verifyEmail, createOneTimeSession, verifyRecord };
27
+ module.exports = { login, verifyEmail, createOneTimeSession, verifyUser };
@@ -39,9 +39,9 @@ const createOneTimeSession = email => {
39
39
 
40
40
  const getHubUserCookie = async (email, oneTimeCode) => {
41
41
  try {
42
- const response = await authApi.verifyRecord(email, oneTimeCode);
42
+ const response = await authApi.verifyUser(email, oneTimeCode);
43
43
 
44
- if (response.status !== httpResponseStatusCodes.OK) {
44
+ if (response.status !== httpResponseStatusCodes.OK && response.status !== httpResponseStatusCodes.NO_CONTENT) {
45
45
  throw Error(`Error: ${JSON.stringify(response.data)}`);
46
46
  }
47
47
 
@@ -5,6 +5,7 @@ const auditUtil = require('../../utils/auditUtil');
5
5
  const dataTypeUtils = require('../../../../../common/utils/dataTypeUtils');
6
6
  const { cloneObject } = require('../../../../../common/utils/objectUtils');
7
7
  const complianceUtil = require('../../../../../common/utils/complianceUtil');
8
+ const httpResponseStatusCodes = require('../../../../../common/httpResponseStatusCodes.json');
8
9
 
9
10
  const audit = (auditRequestModel, context) => {
10
11
  validateType(auditRequestModel, AuditRequestModel);
@@ -71,7 +72,13 @@ const getAuditMetadata = async (
71
72
  };
72
73
 
73
74
  const getAuditByRecordId = async (recordId, context, { isRecordDeleted } = {}) => {
74
- return auditApi.getAuditByRecordId(recordId, context, { isRecordDeleted });
75
+ const responseAudit = await auditApi.getAuditByRecordId(recordId, context, { isRecordDeleted });
76
+
77
+ if (responseAudit.status !== httpResponseStatusCodes.OK) {
78
+ throw Error(`Failed to get audits by record id\n${responseAudit}`);
79
+ }
80
+
81
+ return responseAudit.data;
75
82
  };
76
83
 
77
84
  const getAuditEntities = async (recordId, auditData, auditorContext) => {
@@ -26,6 +26,7 @@ const AttributeTypes = new Enum({
26
26
  'ENDORSMENT': 'endorsment',
27
27
  'LIMIT': 'limit',
28
28
  'BOOLEAN': 'boolean',
29
+ 'NUMERIC': 'numeric',
29
30
  'MULTIPLE': 'multiple'
30
31
  }, { name: 'AttributeTypes' });
31
32
 
@@ -2,7 +2,7 @@ const { SignupUserModel } = require('../models/users.model');
2
2
  const { NotificationSettingsModel } = require('../models/notification.settings.model');
3
3
  const usersApi = require('../api/users.api');
4
4
  const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
5
- const objectUtils = require('../../../../common/utils/objectUtils');
5
+ const objectUtils = require('../../../../common/utils/configsUtil');
6
6
 
7
7
  const attributesConvertor = {
8
8
  'COI is not compliant.': 'auditNotCompliant',
@@ -16,8 +16,8 @@ const getProjectsByName = async (apiKey, params) => {
16
16
  return requests.getRequestHandler(Endpoints.getProjectsByName, apiKey, params).then(res => res.data);
17
17
  };
18
18
 
19
- const getAllProjects = async apiKey => {
20
- return requests.getRequestHandler(Endpoints.getAllProjects, apiKey).then(res => res.data);
19
+ const getAllProjects = async (apiKey, params) => {
20
+ return requests.getRequestHandler(Endpoints.getAllProjects, apiKey, params).then(res => res);
21
21
  };
22
22
 
23
23
  const getModifiedProjects = async (apiKey, params) => {
@@ -12,8 +12,8 @@ const updateProject = async (apiKey, projectId, projectData) => {
12
12
  return projectsApi.updateProject(apiKey, projectId, projectData);
13
13
  };
14
14
 
15
- const getAllProjects = async apiKey => {
16
- return projectsApi.getAllProjects(apiKey);
15
+ const getAllProjects = async (apiKey, params) => {
16
+ return projectsApi.getAllProjects(apiKey, params);
17
17
  };
18
18
 
19
19
  const getModifiedProjects = async (apiKey, timestamp) => {
@@ -4,7 +4,8 @@ const { openapiUrl } = require('../../../env').getEnv();
4
4
  const Endpoints = {
5
5
  copyRequirement: sourceRequirementId => `${openapiUrl}/requirement/${sourceRequirementId}/copy`,
6
6
  getRequirementsByTabId: tabId => `${openapiUrl}/tabs/${tabId}/requirements`,
7
- getRequirementsByProjectId: projectId => `${openapiUrl}/properties/${projectId}/requirements`
7
+ getRequirementsByProjectId: projectId => `${openapiUrl}/properties/${projectId}/requirements`,
8
+ getRequirementsList: `${openapiUrl}/requirement/all`
8
9
  };
9
10
 
10
11
  const copyRequirement = (apiKey, sourceRequirementId, newRequirementOverrides) => {
@@ -19,8 +20,13 @@ const getRequirementsByProjectId = (apiKey, projectId, tabType) => {
19
20
  return requests.getRequestHandler(Endpoints.getRequirementsByProjectId(projectId), apiKey, { tabType });
20
21
  };
21
22
 
23
+ const getRequirementsList = (apiKey, params) => {
24
+ return requests.getRequestHandler(Endpoints.getRequirementsList, apiKey, params);
25
+ };
26
+
22
27
  module.exports = {
23
28
  copyRequirement,
24
29
  getRequirementsByTabId,
25
- getRequirementsByProjectId
30
+ getRequirementsByProjectId,
31
+ getRequirementsList
26
32
  };
@@ -25,8 +25,13 @@ const getRequirementsByProjectId = (apiKey, projectId, tabType) => {
25
25
  return requirementsApi.getRequirementsByProjectId(apiKey, projectId, tabType);
26
26
  };
27
27
 
28
+ const getRequirementsList = (apiKey, params) => {
29
+ return requirementsApi.getRequirementsList(apiKey, params);
30
+ };
31
+
28
32
  module.exports = {
29
33
  copyRequirement,
30
34
  getRequirementsByTabId,
31
- getRequirementsByProjectId
35
+ getRequirementsByProjectId,
36
+ getRequirementsList
32
37
  };
@@ -4,7 +4,8 @@ const { openapiUrl, backendUrl } = require('../../../env').getEnv();
4
4
  const Endpoints = {
5
5
  delete: tabId => `${openapiUrl}/tabs/${tabId}`,
6
6
  get: tabId => `${backendUrl}/tabs/${tabId}`,
7
- create: projectId => `${openapiUrl}/properties/${projectId}/tab`
7
+ create: projectId => `${openapiUrl}/properties/${projectId}/tab`,
8
+ getAll: `${openapiUrl}/tabs/all`
8
9
  };
9
10
 
10
11
  const deleteTabById = (tabId, apiKey) => {
@@ -15,4 +16,8 @@ const createTab = (projectId, createTabModel, apiKey) => {
15
16
  return requests.postRequestHandler(Endpoints.create(projectId), apiKey, createTabModel);
16
17
  };
17
18
 
18
- module.exports = { deleteTabById, createTab };
19
+ const getAllTabs = (apiKey, params) => {
20
+ return requests.getRequestHandler(Endpoints.getAll, apiKey, params);
21
+ };
22
+
23
+ module.exports = { deleteTabById, createTab, getAllTabs };
@@ -8,4 +8,7 @@ const createTab = (projectId, createTabModel, apiKey) => {
8
8
  return tabsApi.createTab(projectId, createTabModel, apiKey);
9
9
  };
10
10
 
11
- module.exports = { deleteTabById, createTab };
11
+ const getAllTabs = (apiKey, params) => {
12
+ return tabsApi.getAllTabs(apiKey, params);
13
+ };
14
+ module.exports = { deleteTabById, createTab, getAllTabs };