@getjones/test-infra 2.11.0 → 2.11.2

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.11.0",
3
+ "version": "2.11.2",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -3,7 +3,7 @@ const env = require('../../../../../env');
3
3
  const accountsAPI = require('./accounts.core.api');
4
4
  const CreateAccountModel = require('../../models/core/create.account.model');
5
5
  const { validateType } = require('../../../../../common/validations/typeValidations');
6
- const httpResponseStatusCodes = require('../../../../../../../../packages/test-infra/src/common/httpResponseStatusCodes.json');
6
+ const httpResponseStatusCodes = require('../../../../../common/httpResponseStatusCodes.json');
7
7
 
8
8
  const { accountCreationSecret } = env.getEnv();
9
9
 
@@ -49,8 +49,8 @@ const deleteByContractorId = (contractorId, context) => {
49
49
  return requests.deleteRequestHandler(Endpoints.delete(contractorId), context);
50
50
  };
51
51
 
52
- const archiveByContractorId = (contractorId, context) => {
53
- return requests.deleteRequestHandler(Endpoints.archive(contractorId), context);
52
+ const archiveRecord = (recordVerificationModel, context) => {
53
+ return requests.deleteRequestHandler(Endpoints.archive(recordVerificationModel.contractorId), context, {}, {}, recordVerificationModel);
54
54
  };
55
55
 
56
56
  const restoreRecord = (recordVerificationModel, context) => {
@@ -146,7 +146,7 @@ module.exports = {
146
146
  getContractorById,
147
147
  getRecordHistory,
148
148
  deleteByContractorId,
149
- archiveByContractorId,
149
+ archiveRecord,
150
150
  restoreRecord,
151
151
  editContractor,
152
152
  updateInviteDate,
@@ -28,8 +28,9 @@ const getRecordHistory = (contractorId, context) => {
28
28
  return contractorsAPI.getRecordHistory(contractorId, context);
29
29
  };
30
30
 
31
- const archiveByContractorId = (contractorId, context) => {
32
- return contractorsAPI.archiveByContractorId(contractorId, context);
31
+ const archiveRecord = (recordVerificationModel, context) => {
32
+ validateType(recordVerificationModel, RecordModifyDateVerificationModel);
33
+ return contractorsAPI.archiveRecord(recordVerificationModel, context);
33
34
  };
34
35
 
35
36
  const restoreRecord = (recordVerificationModel, context) => {
@@ -172,7 +173,7 @@ module.exports = {
172
173
  getContractorsByAccountId,
173
174
  getContractorById,
174
175
  getRecordHistory,
175
- archiveByContractorId,
176
+ archiveRecord,
176
177
  restoreRecord,
177
178
  editContractor,
178
179
  updateInviteDate,
@@ -2,5 +2,6 @@
2
2
  "endorsment": "ENDORSMENT",
3
3
  "limit": "LIMIT",
4
4
  "boolean": "BOOLEAN",
5
- "multiple": "MULTIPLE"
5
+ "multiple": "MULTIPLE",
6
+ "numeric": "NUMERIC"
6
7
  }
@@ -4,19 +4,30 @@ const { UpdateRequirementModel } = require('../models/update.requirement.model')
4
4
  const { AttributeModel, PolicyModel, AttributeTypes } = require('../models/policy.model');
5
5
  const { CreateRequirementModel } = require('../models/create.requirement.model');
6
6
 
7
- const convertNumericValuesToNumberType = function(value) {
7
+ const customAttributes = {
8
+ Including: 'multiple',
9
+ indemnityPeriod: 'Indemnity Period'
10
+ };
11
+
12
+ const convertNumericValuesToNumberType = function(value, attributeName) {
8
13
  if (dataTypeUtils.isString(value) && value.startsWith('$')) {
9
14
  return Number(value.replace(/[$,]/g, ''));
10
15
  }
11
16
 
17
+ if (attributeName === customAttributes.indemnityPeriod) {
18
+ return Number(value);
19
+ }
20
+
12
21
  return value;
13
22
  };
14
23
 
15
- const preparePolicyAttributesTypes = function(value) {
16
- const attributesValue = convertNumericValuesToNumberType(value);
24
+ const preparePolicyAttributesTypes = function(value, attributeName) {
25
+ const attributesValue = convertNumericValuesToNumberType(value, attributeName);
17
26
 
18
27
  if (dataTypeUtils.isNumber(attributesValue)) {
19
- return AttributeTypes.get(attributeTypes.limit);
28
+ return attributeName === customAttributes.indemnityPeriod ?
29
+ AttributeTypes.get(attributeTypes.numeric) :
30
+ AttributeTypes.get(attributeTypes.limit);
20
31
  }
21
32
 
22
33
  if (dataTypeUtils.isBoolean(attributesValue)) {
@@ -46,12 +57,14 @@ const parseRequirementConfig = function(config) {
46
57
 
47
58
  if (dataTypeUtils.isObject(config[policy])) {
48
59
  for (const attribute in config[policy]) {
60
+ const attributeName = customAttributes[attribute] || attribute;
61
+
49
62
  attributes.push({
50
- name: attribute,
51
- type: preparePolicyAttributesTypes(config[policy][attribute]),
52
- values: attribute === 'Including' ?
63
+ name: attributeName,
64
+ type: preparePolicyAttributesTypes(config[policy][attribute], attributeName),
65
+ values: attributeName === customAttributes.Including ?
53
66
  config[policy][attribute].split(', ') :
54
- [convertNumericValuesToNumberType(config[policy][attribute])]
67
+ [convertNumericValuesToNumberType(config[policy][attribute], attributeName)]
55
68
  });
56
69
  };
57
70
  } else {