@lendi/integrations-transform 1.5.8 → 1.6.1

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.
Files changed (108) hide show
  1. package/lib/index.js +1 -1
  2. package/lib/logger.d.ts +1 -2
  3. package/lib/logger.js +3 -3
  4. package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
  5. package/lib/transform-events/generate-asset-liability-link.js +12 -12
  6. package/lib/transform-events/generate-credit-report-rebuilt.js +13 -13
  7. package/lib/transform-events/generate-employment.d.ts +1 -1
  8. package/lib/transform-events/generate-employment.js +33 -34
  9. package/lib/transform-events/generate-required-document.d.ts +1 -7
  10. package/lib/transform-events/generate-required-document.js +37 -54
  11. package/lib/transform-events/transform-applicant.d.ts +2 -1
  12. package/lib/transform-events/transform-applicant.js +57 -63
  13. package/lib/transform-events/transform-application-workflow.d.ts +0 -1
  14. package/lib/transform-events/transform-application-workflow.js +7 -8
  15. package/lib/transform-events/transform-application.d.ts +3 -1
  16. package/lib/transform-events/transform-application.js +23 -24
  17. package/lib/transform-events/transform-asset-address.d.ts +8 -2
  18. package/lib/transform-events/transform-asset-address.js +22 -18
  19. package/lib/transform-events/transform-asset.d.ts +7 -1
  20. package/lib/transform-events/transform-asset.js +112 -122
  21. package/lib/transform-events/transform-expenses.d.ts +4 -0
  22. package/lib/transform-events/transform-expenses.js +31 -29
  23. package/lib/transform-events/transform-funding-position.d.ts +2 -2
  24. package/lib/transform-events/transform-funding-position.js +23 -26
  25. package/lib/transform-events/transform-income.d.ts +8 -1
  26. package/lib/transform-events/transform-income.js +87 -97
  27. package/lib/transform-events/transform-liability.d.ts +4 -1
  28. package/lib/transform-events/transform-liability.js +42 -41
  29. package/lib/transform-events/transform-percent-owned.d.ts +1 -0
  30. package/lib/transform-events/transform-percent-owned.js +8 -11
  31. package/lib/types/enum-mappings/alieo-frequency.js +23 -24
  32. package/lib/types/enum-mappings/asset-type.js +15 -16
  33. package/lib/types/enum-mappings/builder-type.js +7 -8
  34. package/lib/types/enum-mappings/construction-type.js +8 -9
  35. package/lib/types/enum-mappings/country-code.js +244 -245
  36. package/lib/types/enum-mappings/employment-basis.js +10 -11
  37. package/lib/types/enum-mappings/expense-frequency.js +9 -10
  38. package/lib/types/enum-mappings/funding-position.js +6 -6
  39. package/lib/types/enum-mappings/government-benefits.js +8 -9
  40. package/lib/types/enum-mappings/guarantor-relationship-type.d.ts +3 -0
  41. package/lib/types/enum-mappings/guarantor-relationship-type.js +16 -0
  42. package/lib/types/enum-mappings/housing-status.js +13 -14
  43. package/lib/types/enum-mappings/income-type.js +14 -15
  44. package/lib/types/enum-mappings/index.js +1 -1
  45. package/lib/types/enum-mappings/liability-payment-type.js +7 -8
  46. package/lib/types/enum-mappings/liability-type.js +19 -20
  47. package/lib/types/enum-mappings/living-expense.js +28 -29
  48. package/lib/types/enum-mappings/marital-status.js +10 -11
  49. package/lib/types/enum-mappings/postcode.js +12 -13
  50. package/lib/types/enum-mappings/preferred-repayment.js +8 -9
  51. package/lib/types/enum-mappings/proof-of-identity.js +8 -9
  52. package/lib/types/enum-mappings/property-expense-category.js +9 -10
  53. package/lib/types/enum-mappings/public-financial-asset.js +10 -11
  54. package/lib/types/enum-mappings/public-primary-purpose.js +7 -8
  55. package/lib/types/enum-mappings/public-property-status.js +9 -10
  56. package/lib/types/enum-mappings/public-property-type.js +21 -22
  57. package/lib/types/enum-mappings/residency-status.js +9 -10
  58. package/lib/types/enum-mappings/title-gender.js +11 -12
  59. package/lib/types/enum-mappings/title.js +11 -12
  60. package/lib/types/enum-mappings/to-be-purchased.js +4 -4
  61. package/lib/types/enum-mappings/to-be-used-as-security.js +4 -4
  62. package/lib/types/enum-mappings/transaction-type.js +7 -8
  63. package/lib/types/enum-mappings/verification.js +11 -12
  64. package/lib/types/events/applicant-delete.js +1 -1
  65. package/lib/types/events/application-workflow.js +1 -1
  66. package/lib/types/events/asset-delete.js +1 -1
  67. package/lib/types/events/asset-liability-relation-delete.js +1 -1
  68. package/lib/types/events/credit-report-retrieved.js +1 -1
  69. package/lib/types/events/employment-delete.js +1 -1
  70. package/lib/types/events/expense-delete.js +1 -1
  71. package/lib/types/events/funding-position.js +1 -1
  72. package/lib/types/events/income-delete.js +1 -1
  73. package/lib/types/events/liability-delete.js +1 -1
  74. package/lib/types/events/opportunity.js +1 -1
  75. package/lib/types/events/public-applicant.js +1 -1
  76. package/lib/types/events/public-application.js +1 -1
  77. package/lib/types/events/public-asset-liability-relation.js +1 -1
  78. package/lib/types/events/public-asset.js +1 -1
  79. package/lib/types/events/public-employment.js +1 -1
  80. package/lib/types/events/public-expense.js +1 -1
  81. package/lib/types/events/public-funding-position.js +1 -1
  82. package/lib/types/events/public-income.js +1 -1
  83. package/lib/types/events/public-liability.js +1 -1
  84. package/lib/types/events/public-required-document.js +1 -1
  85. package/lib/types/partial-application.js +1 -1
  86. package/lib/types/recursive-partial.js +1 -1
  87. package/lib/update-application/merge-application.d.ts +1 -1
  88. package/lib/update-application/merge-application.js +41 -34
  89. package/lib/update-application/update-primary-applicant.d.ts +1 -4
  90. package/lib/update-application/update-primary-applicant.js +12 -31
  91. package/lib/utils/address-tools.d.ts +3 -1
  92. package/lib/utils/address-tools.js +40 -42
  93. package/lib/utils/clean-up.d.ts +1 -1
  94. package/lib/utils/clean-up.js +6 -6
  95. package/lib/utils/formatYesNo.d.ts +0 -1
  96. package/lib/utils/formatYesNo.js +3 -4
  97. package/lib/utils/generate-address.d.ts +3 -2
  98. package/lib/utils/generate-address.js +21 -25
  99. package/lib/utils/get-financial-institution.d.ts +1 -0
  100. package/lib/utils/get-financial-institution.js +6 -5
  101. package/lib/utils/is-asset-type.js +2 -2
  102. package/lib/utils/is-income-type.d.ts +2 -0
  103. package/lib/utils/is-income-type.js +15 -21
  104. package/lib/utils/iso-date.d.ts +0 -1
  105. package/lib/utils/iso-date.js +3 -4
  106. package/lib/utils/normalise-date.js +6 -6
  107. package/lib/utils/round-decimal.js +1 -1
  108. package/package.json +14 -17
@@ -2,28 +2,28 @@
2
2
  /**
3
3
  * A set of tools for manipulating addresses in LIXI applications.
4
4
  */
5
- exports.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isOverseasAddress = exports.extractCountryFromFormatted = exports.setCountry = exports.isMissingCountry = exports.rebuildPreviousAddress = exports.rebuildAddress = exports.mapTransform = exports.lixiAddressMapping = exports.australianStates = exports.lixiContactAddressMapping = void 0;
7
- var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
8
- var lodash_1 = require("lodash");
9
- var country_code_1 = require("../types/enum-mappings/country-code");
10
- var housing_status_1 = require("../types/enum-mappings/housing-status");
11
- var public_applicant_1 = require("../types/events/public-applicant");
12
- var generate_address_1 = require("./generate-address");
7
+ const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
8
+ const lodash_1 = require("lodash");
9
+ const country_code_1 = require("../types/enum-mappings/country-code");
10
+ const housing_status_1 = require("../types/enum-mappings/housing-status");
11
+ const public_applicant_1 = require("../types/events/public-applicant");
12
+ const generate_address_1 = require("./generate-address");
13
13
  exports.lixiContactAddressMapping = {
14
14
  externalId: {
15
- path: '@x_ResidentialAddress'
15
+ path: '@x_ResidentialAddress',
16
16
  },
17
17
  housingStatus: {
18
18
  path: '@HousingStatus',
19
- transform: function (value) { return housing_status_1.housingStatusMapping[value]; }
19
+ transform: (value) => housing_status_1.housingStatusMapping[value],
20
20
  },
21
21
  startDate: {
22
- path: '@StartDate'
22
+ path: '@StartDate',
23
23
  },
24
24
  endDate: {
25
- path: '@EndDate'
26
- }
25
+ path: '@EndDate',
26
+ },
27
27
  };
28
28
  exports.australianStates = Object.values(lixi_internal_request_1.AuStateList);
29
29
  /**
@@ -31,37 +31,37 @@ exports.australianStates = Object.values(lixi_internal_request_1.AuStateList);
31
31
  */
32
32
  exports.lixiAddressMapping = {
33
33
  externalId: {
34
- path: '@UniqueID'
34
+ path: '@UniqueID',
35
35
  },
36
36
  'residentialAddress.city': {
37
- path: '@Suburb'
37
+ path: '@Suburb',
38
38
  },
39
39
  'residentialAddress.country': {
40
40
  path: '@Country',
41
- transform: function (value) { return country_code_1.countryCodeMapping[value]; }
41
+ transform: (value) => country_code_1.countryCodeMapping[value],
42
42
  },
43
43
  'residentialAddress.postcode': {
44
- path: '@AustralianPostCode'
44
+ path: '@AustralianPostCode',
45
45
  },
46
46
  'residentialAddress.state': {
47
- path: '@AustralianState'
47
+ path: '@AustralianState',
48
48
  },
49
49
  'residentialAddress.standard.level': {
50
- path: 'Standard.@Level'
50
+ path: 'Standard.@Level',
51
51
  },
52
52
  'residentialAddress.standard.streetName': {
53
- path: 'Standard.@StreetName'
53
+ path: 'Standard.@StreetName',
54
54
  },
55
55
  'residentialAddress.standard.streetNumber': {
56
56
  path: 'Standard.@StreetNumber',
57
- transform: function (value) { return value.substring(0, generate_address_1.StreetNumberMaxLength); }
57
+ transform: (value) => value.substring(0, generate_address_1.StreetNumberMaxLength),
58
58
  },
59
59
  'residentialAddress.standard.streetType': {
60
- path: 'Standard.@StreetType'
60
+ path: 'Standard.@StreetType',
61
61
  },
62
62
  'residentialAddress.standard.unit': {
63
- path: 'Standard.@Unit'
64
- }
63
+ path: 'Standard.@Unit',
64
+ },
65
65
  };
66
66
  /**
67
67
  * Transforms a source object by applying a PathMappedTransform.
@@ -70,10 +70,9 @@ exports.lixiAddressMapping = {
70
70
  * @param pathMappedTransform A PathMappedTransform to be applied to the source
71
71
  */
72
72
  function mapTransform(source, pathMappedTransform) {
73
- var finalTransform = {};
74
- Object.entries(pathMappedTransform).forEach(function (_a) {
75
- var key = _a[0], _b = _a[1], transform = _b.transform, path = _b.path;
76
- var sourceValue = (0, lodash_1.get)(source, key);
73
+ const finalTransform = {};
74
+ Object.entries(pathMappedTransform).forEach(([key, { transform, path }]) => {
75
+ const sourceValue = (0, lodash_1.get)(source, key);
77
76
  if (sourceValue) {
78
77
  (0, lodash_1.set)(finalTransform, path, (transform === null || transform === void 0 ? void 0 : transform(sourceValue)) || sourceValue);
79
78
  }
@@ -81,8 +80,8 @@ function mapTransform(source, pathMappedTransform) {
81
80
  return finalTransform;
82
81
  }
83
82
  exports.mapTransform = mapTransform;
84
- var postcodePathString = 'residentialAddress.postcode';
85
- var statePathString = 'residentialAddress.state';
83
+ const postcodePathString = 'residentialAddress.postcode';
84
+ const statePathString = 'residentialAddress.state';
86
85
  /**
87
86
  * Converts an address object from an event model to a LIXI address and corresponding LIXI contact address object.
88
87
  *
@@ -101,28 +100,29 @@ function rebuildAddress(eventAddress, addressId) {
101
100
  exports.lixiAddressMapping[postcodePathString] = { path: '@AustralianPostCode' };
102
101
  exports.lixiAddressMapping[statePathString] = { path: '@AustralianState' };
103
102
  }
104
- var lixiAddress = mapTransform(eventAddress, exports.lixiAddressMapping);
105
- var lixiContactAddress = mapTransform(eventAddress, exports.lixiContactAddressMapping);
103
+ const lixiAddress = mapTransform(eventAddress, exports.lixiAddressMapping);
104
+ const lixiContactAddress = mapTransform(eventAddress, exports.lixiContactAddressMapping);
106
105
  lixiAddress['@UniqueID'] = addressId;
107
106
  lixiContactAddress['@x_ResidentialAddress'] = addressId;
108
- return { lixiAddress: lixiAddress, lixiContactAddress: lixiContactAddress };
107
+ return { lixiAddress, lixiContactAddress };
109
108
  }
110
109
  exports.rebuildAddress = rebuildAddress;
111
110
  /**
112
- * * Converts a previous address object from an event model to a LIXI address and corresponding LIXI current address object.
111
+ * Converts a previous address object from an event model to a LIXI address and corresponding LIXI current address object.
112
+ *
113
113
  * @param eventPreviousAddresses
114
114
  * @param addressId
115
115
  */
116
- function rebuildPreviousAddress(eventPreviousAddresses, addressId) {
117
- if (eventPreviousAddresses === void 0) { eventPreviousAddresses = []; }
116
+ function rebuildPreviousAddress(eventPreviousAddresses = [], addressId) {
118
117
  if (eventPreviousAddresses.length === 0)
119
118
  return null;
120
- var previousAddress = eventPreviousAddresses.sort(function (lhs, rhs) { return lhs.endDate.localeCompare(rhs.endDate); }).pop();
119
+ const previousAddress = eventPreviousAddresses.sort((lhs, rhs) => lhs.endDate.localeCompare(rhs.endDate)).pop();
121
120
  return rebuildAddress(previousAddress, addressId);
122
121
  }
123
122
  exports.rebuildPreviousAddress = rebuildPreviousAddress;
124
123
  /**
125
124
  * Checks if an event is missing country.
125
+ *
126
126
  * @param addressEvent
127
127
  */
128
128
  function isMissingCountry(addressEvent) {
@@ -138,7 +138,7 @@ exports.isMissingCountry = isMissingCountry;
138
138
  * @param address
139
139
  */
140
140
  function setCountry(address) {
141
- var formatted = (0, lodash_1.get)(address, 'residentialAddress.formatted');
141
+ const formatted = (0, lodash_1.get)(address, 'residentialAddress.formatted');
142
142
  if (formatted && !address.residentialAddress.country) {
143
143
  address.residentialAddress.country = extractCountryFromFormatted(formatted);
144
144
  }
@@ -150,9 +150,8 @@ exports.setCountry = setCountry;
150
150
  * @param {string} formatted - A formatted Address.
151
151
  * @returns {Countries} The country extracted from the Address.
152
152
  */
153
- function extractCountryFromFormatted(formatted) {
153
+ function extractCountryFromFormatted(formatted = '') {
154
154
  var _a;
155
- if (formatted === void 0) { formatted = ''; }
156
155
  return (_a = formatted === null || formatted === void 0 ? void 0 : formatted.split(',').pop()) === null || _a === void 0 ? void 0 : _a.trim();
157
156
  }
158
157
  exports.extractCountryFromFormatted = extractCountryFromFormatted;
@@ -161,13 +160,12 @@ exports.extractCountryFromFormatted = extractCountryFromFormatted;
161
160
  * @param {Address} address - Asset Address
162
161
  * @returns {boolean} - Returns true if overseas address.
163
162
  */
164
- function isOverseasAddress(_a) {
165
- var _b = _a === void 0 ? {} : _a, country = _b.country, formatted = _b.formatted, state = _b.state;
163
+ function isOverseasAddress({ country, formatted, state } = {}) {
166
164
  if (country) {
167
165
  return country !== public_applicant_1.Countries.Australia;
168
166
  }
169
167
  if (formatted) {
170
- var lastPast = extractCountryFromFormatted(formatted);
168
+ const lastPast = extractCountryFromFormatted(formatted);
171
169
  return lastPast !== public_applicant_1.Countries.Australia;
172
170
  }
173
171
  if (state) {
@@ -2,6 +2,6 @@
2
2
  * Recursively removes nulls from nested objects and arrays
3
3
  *
4
4
  * @param payload any
5
- * @return result of sanitised object.
5
+ * @returns result of sanitised object.
6
6
  */
7
7
  export declare function cleanUp<T>(payload: T): Partial<T>;
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cleanUp = void 0;
4
4
  /* istanbul ignore file */
5
- var clean_deep_1 = require("clean-deep");
5
+ const clean_deep_1 = require("clean-deep");
6
6
  /**
7
7
  * Recursively removes nulls from nested objects and arrays
8
8
  *
9
9
  * @param payload any
10
- * @return result of sanitised object.
10
+ * @returns result of sanitised object.
11
11
  */
12
12
  function cleanUp(payload) {
13
13
  // cleanDeep configurations.
14
- var params = {
14
+ const params = {
15
15
  cleanValues: [],
16
16
  emptyArrays: true,
17
17
  emptyObjects: true,
18
18
  emptyStrings: false,
19
19
  nullValues: true,
20
- undefinedValues: true
20
+ undefinedValues: true,
21
21
  };
22
- return (0, clean_deep_1["default"])(payload, params);
22
+ return (0, clean_deep_1.default)(payload, params);
23
23
  }
24
24
  exports.cleanUp = cleanUp;
@@ -3,7 +3,6 @@ import { YesNoList } from '@lendi/integrations-credit-protocol/types/lixi-intern
3
3
  * Formats a value as Yes or No
4
4
  *
5
5
  * @param isTruthy Some value to be formatted as Yes/No
6
- *
7
6
  * @returns Yes/No
8
7
  */
9
8
  export declare const formatYesNo: (isTruthy: any) => YesNoList;
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatYesNo = void 0;
4
- var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
4
+ const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
5
5
  /**
6
6
  * Formats a value as Yes or No
7
7
  *
8
8
  * @param isTruthy Some value to be formatted as Yes/No
9
- *
10
9
  * @returns Yes/No
11
10
  */
12
- var formatYesNo = function (isTruthy) { return (isTruthy ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No); };
11
+ const formatYesNo = (isTruthy) => (isTruthy ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
13
12
  exports.formatYesNo = formatYesNo;
@@ -4,15 +4,16 @@ export declare const StreetNumberMaxLength = 16;
4
4
  export declare const StreetTypeArray: StreetTypeList[];
5
5
  /**
6
6
  * Generates an address for an asset.
7
+ *
7
8
  * @param {Address} address - An address object.
8
9
  * @param {string} id - Id of asset object.
9
- * @return {Partial<AddressType>} A transformed address object.
10
+ * @returns {Partial<AddressType>} A transformed address object.
10
11
  */
11
12
  export declare function generateAddress(address: Address, id: string): Partial<AddressType>;
12
13
  /**
13
14
  * Generates an address standard.
14
15
  *
15
16
  * @param addressStandard An address standard object.
16
- * @return A transformed standard object.
17
+ * @returns A transformed standard object.
17
18
  */
18
19
  export declare function generateStandard(addressStandard: AddressStandard): Standard;
@@ -1,40 +1,41 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateStandard = exports.generateAddress = exports.StreetTypeArray = exports.StreetNumberMaxLength = void 0;
4
- var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
- var lodash_1 = require("lodash");
6
- var country_code_1 = require("..//types/enum-mappings/country-code");
7
- var postcode_1 = require("../types/enum-mappings/postcode");
8
- var public_asset_1 = require("../types/events/public-asset");
9
- var address_tools_1 = require("./address-tools");
4
+ const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
+ const lodash_1 = require("lodash");
6
+ const country_code_1 = require("..//types/enum-mappings/country-code");
7
+ const postcode_1 = require("../types/enum-mappings/postcode");
8
+ const public_asset_1 = require("../types/events/public-asset");
9
+ const address_tools_1 = require("./address-tools");
10
10
  exports.StreetNumberMaxLength = 16;
11
11
  exports.StreetTypeArray = Object.values(lixi_internal_request_1.StreetTypeList);
12
- var addressMapping = {
12
+ const addressMapping = {
13
13
  country: '@Country',
14
14
  city: '@Suburb',
15
15
  postcode: '@AustralianPostCode',
16
16
  state: '@AustralianState',
17
- standard: 'Standard'
17
+ standard: 'Standard',
18
18
  };
19
- var standardMapping = {
19
+ const standardMapping = {
20
20
  streetName: '@StreetName',
21
21
  streetType: '@StreetType',
22
22
  streetNumber: '@StreetNumber',
23
23
  level: '@Level',
24
- unit: '@Unit'
24
+ unit: '@Unit',
25
25
  };
26
26
  /**
27
27
  * Generates an address for an asset.
28
+ *
28
29
  * @param {Address} address - An address object.
29
30
  * @param {string} id - Id of asset object.
30
- * @return {Partial<AddressType>} A transformed address object.
31
+ * @returns {Partial<AddressType>} A transformed address object.
31
32
  */
32
33
  function generateAddress(address, id) {
33
- var transformedAddress = {
34
+ const transformedAddress = {
34
35
  '@Country': lixi_internal_request_1.CountryCodeList.Au,
35
- '@UniqueID': id
36
+ '@UniqueID': id,
36
37
  };
37
- var country = (0, address_tools_1.extractCountryFromFormatted)(address.formatted);
38
+ const country = (0, address_tools_1.extractCountryFromFormatted)(address.formatted);
38
39
  if (!address.country && country.length > 0) {
39
40
  address.country = country;
40
41
  }
@@ -49,8 +50,7 @@ function generateAddress(address, id) {
49
50
  transformedAddress['@AustralianPostCode'] = postcode_1.postcodeMapping[address.state];
50
51
  }
51
52
  }
52
- for (var _i = 0, _a = Object.entries(address); _i < _a.length; _i++) {
53
- var _b = _a[_i], key = _b[0], value = _b[1];
53
+ for (const [key, value] of Object.entries(address)) {
54
54
  if (addressMapping[key]) {
55
55
  switch (key) {
56
56
  case 'standard':
@@ -72,18 +72,18 @@ exports.generateAddress = generateAddress;
72
72
  * Generates an address standard.
73
73
  *
74
74
  * @param addressStandard An address standard object.
75
- * @return A transformed standard object.
75
+ * @returns A transformed standard object.
76
76
  */
77
77
  function generateStandard(addressStandard) {
78
- var transformedStandard = {};
79
- var _loop_1 = function (key, value) {
78
+ const transformedStandard = {};
79
+ for (const [key, value] of Object.entries(addressStandard)) {
80
80
  if (standardMapping[key]) {
81
81
  switch (key) {
82
82
  case 'streetNumber':
83
83
  (0, lodash_1.set)(transformedStandard, standardMapping[key], value.substring(0, exports.StreetNumberMaxLength));
84
84
  break;
85
85
  case 'streetType':
86
- var streetType = exports.StreetTypeArray.find(function (type) { return type.toLowerCase() === value.toLowerCase(); });
86
+ const streetType = exports.StreetTypeArray.find((type) => type.toLowerCase() === value.toLowerCase());
87
87
  (0, lodash_1.set)(transformedStandard, standardMapping[key], streetType || lixi_internal_request_1.StreetTypeList.Street);
88
88
  break;
89
89
  default:
@@ -91,10 +91,6 @@ function generateStandard(addressStandard) {
91
91
  break;
92
92
  }
93
93
  }
94
- };
95
- for (var _i = 0, _a = Object.entries(addressStandard); _i < _a.length; _i++) {
96
- var _b = _a[_i], key = _b[0], value = _b[1];
97
- _loop_1(key, value);
98
94
  }
99
95
  return transformedStandard;
100
96
  }
@@ -3,5 +3,6 @@ import { FinancialInstitutionList } from '@lendi/integrations-protocol/lib/types
3
3
  * Returns the financialInstitution value form the Enum based on the index where it was found.
4
4
  *
5
5
  * @param institution: Institution value from event.
6
+ * @param institution
6
7
  */
7
8
  export declare function getFinancialInstitution(institution: string): FinancialInstitutionList;
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFinancialInstitution = void 0;
4
- var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
- var financialInstitutions = Object.values(lixi_internal_request_1.FinancialInstitutionList);
4
+ const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
+ const financialInstitutions = Object.values(lixi_internal_request_1.FinancialInstitutionList);
6
6
  /**
7
7
  * Returns the financialInstitution value form the Enum based on the index where it was found.
8
8
  *
9
9
  * @param institution: Institution value from event.
10
+ * @param institution
10
11
  */
11
12
  function getFinancialInstitution(institution) {
12
- var institutionUpperCased = institution.toUpperCase();
13
- var financialInstitution = financialInstitutions.find(function (item) { return item.toUpperCase() === institutionUpperCased; });
13
+ const institutionUpperCased = institution.toUpperCase();
14
+ const financialInstitution = financialInstitutions.find((item) => item.toUpperCase() === institutionUpperCased);
14
15
  return financialInstitution || lixi_internal_request_1.FinancialInstitutionList.Other;
15
16
  }
16
17
  exports.getFinancialInstitution = getFinancialInstitution;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isOtherAsset = exports.isMotorVehicle = exports.isRealEstateAsset = exports.isFinancialAsset = void 0;
4
- var public_asset_1 = require("../types/events/public-asset");
4
+ const public_asset_1 = require("../types/events/public-asset");
5
5
  /**
6
6
  * @description Checks if the asset is of financial type.
7
7
  * @param {Asset} asset asset payload.
@@ -65,6 +65,8 @@ export declare function getApplicantId({ percentOwned, employmentId }: Income, a
65
65
  /**
66
66
  * @description Sort Business Income By Year.
67
67
  * @param incomeA Income Details for Self Employed Full Doc.
68
+ * @param incomeA.year
69
+ * @param incomeB.year
68
70
  * @param incomeB Income Details for Self Employed Full Doc.
69
71
  * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
70
72
  */
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sortBusinessIncome = exports.getApplicantId = exports.getApplicantIdFromEmploymentId = exports.hasMatchingEmploymentId = exports.isFullDocOrLowDocIncome = exports.isOtherIncomeWithDesc = exports.isOtherIncome = exports.isRentalIncome = exports.isSelfEmployedIncome = exports.isPaygIncome = exports.otherIncomeList = exports.PAYGList = exports.descriptionOtherIncomeTypes = void 0;
4
- var lodash_1 = require("lodash");
5
- var public_income_1 = require("../types/events/public-income");
4
+ const lodash_1 = require("lodash");
5
+ const public_income_1 = require("../types/events/public-income");
6
6
  exports.descriptionOtherIncomeTypes = [
7
7
  public_income_1.IncomeType.InvestmentIncome,
8
8
  public_income_1.IncomeType.PaygNonVoluntaryDeductionsPreTax,
@@ -89,14 +89,12 @@ exports.isFullDocOrLowDocIncome = isFullDocOrLowDocIncome;
89
89
  * @param {string} employmentId - Employment id being searched for
90
90
  * @returns {boolean} - Whether or not the applicant has an employment with matching employmentId
91
91
  */
92
- var hasMatchingEmploymentId = function (applicant, employmentId) {
93
- return (applicant.Employment || []).some(function (employment) {
94
- var id = (0, lodash_1.get)(employment, 'PAYG.@UniqueID') ||
95
- (0, lodash_1.get)(employment, 'SelfEmployed.@UniqueID') ||
96
- (0, lodash_1.get)(employment, 'NotEmployed.@UniqueID');
97
- return id === employmentId;
98
- });
99
- };
92
+ const hasMatchingEmploymentId = (applicant, employmentId) => (applicant.Employment || []).some((employment) => {
93
+ const id = (0, lodash_1.get)(employment, 'PAYG.@UniqueID') ||
94
+ (0, lodash_1.get)(employment, 'SelfEmployed.@UniqueID') ||
95
+ (0, lodash_1.get)(employment, 'NotEmployed.@UniqueID');
96
+ return id === employmentId;
97
+ });
100
98
  exports.hasMatchingEmploymentId = hasMatchingEmploymentId;
101
99
  /**
102
100
  * Gets the applicant id using the employment id
@@ -106,9 +104,9 @@ exports.hasMatchingEmploymentId = hasMatchingEmploymentId;
106
104
  * @returns {string | undefined} - Applicant id or undefined
107
105
  */
108
106
  function getApplicantIdFromEmploymentId(applicants, employmentId) {
109
- var applicantId;
107
+ let applicantId;
110
108
  if (applicants && employmentId) {
111
- var applicant = applicants.find(function (applicant) { return (0, exports.hasMatchingEmploymentId)(applicant, employmentId); });
109
+ const applicant = applicants.find((applicant) => (0, exports.hasMatchingEmploymentId)(applicant, employmentId));
112
110
  applicantId = applicant === null || applicant === void 0 ? void 0 : applicant['@UniqueID'];
113
111
  }
114
112
  return applicantId;
@@ -120,21 +118,17 @@ exports.getApplicantIdFromEmploymentId = getApplicantIdFromEmploymentId;
120
118
  * @param {PersonApplicant[]} applicants An array of LIXI applicants.
121
119
  * @returns {string | undefined} An applicantId or undefined.
122
120
  */
123
- function getApplicantId(_a, applicants) {
124
- var percentOwned = _a.percentOwned, employmentId = _a.employmentId;
125
- if (applicants === void 0) { applicants = []; }
121
+ function getApplicantId({ percentOwned, employmentId }, applicants = []) {
126
122
  return (0, lodash_1.get)(percentOwned, 'owners[0].applicantId') || getApplicantIdFromEmploymentId(applicants, employmentId);
127
123
  }
128
124
  exports.getApplicantId = getApplicantId;
129
125
  /**
130
126
  * @description Sort Business Income By Year.
131
127
  * @param incomeA Income Details for Self Employed Full Doc.
128
+ * @param incomeA.year
129
+ * @param incomeB.year
132
130
  * @param incomeB Income Details for Self Employed Full Doc.
133
131
  * @returns {0 | < 0 | > 0} Returns a number to be used for sorting income.
134
132
  */
135
- var sortBusinessIncome = function (_a, _b) {
136
- var _c = _a.year, yearA = _c === void 0 ? 0 : _c;
137
- var _d = _b.year, yearB = _d === void 0 ? 0 : _d;
138
- return yearB - yearA;
139
- };
133
+ const sortBusinessIncome = ({ year: yearA = 0 }, { year: yearB = 0 }) => yearB - yearA;
140
134
  exports.sortBusinessIncome = sortBusinessIncome;
@@ -2,7 +2,6 @@
2
2
  * Formats a date to ISO 8601 format with time
3
3
  *
4
4
  * @param {string | Date} str - A string that could be converted to a Date (or) a Date.
5
- *
6
5
  * @returns {string} - A ISO Date format without the time. (yyyy-MM-dd)
7
6
  */
8
7
  export declare const isoDate: (str: string | Date) => string;
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isoDate = void 0;
4
- var date_fns_1 = require("date-fns");
4
+ const date_fns_1 = require("date-fns");
5
5
  /**
6
6
  * Formats a date to ISO 8601 format with time
7
7
  *
8
8
  * @param {string | Date} str - A string that could be converted to a Date (or) a Date.
9
- *
10
9
  * @returns {string} - A ISO Date format without the time. (yyyy-MM-dd)
11
10
  */
12
- var isoDate = function (str) { return (0, date_fns_1.formatISO)(new Date(str), { representation: 'date' }); };
11
+ const isoDate = (str) => (0, date_fns_1.formatISO)(new Date(str), { representation: 'date' });
13
12
  exports.isoDate = isoDate;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normaliseDate = void 0;
4
4
  /**
5
5
  * Accepts any type of data format and normalises it into a consistent format
@@ -8,10 +8,10 @@ exports.normaliseDate = void 0;
8
8
  * @param {any} dateOfBirth - Date string.
9
9
  */
10
10
  function normaliseDate(dateOfBirth) {
11
- var date = new Date(dateOfBirth);
12
- var year = date.getFullYear();
13
- var month = ('0' + (date.getMonth() + 1)).slice(-2);
14
- var day = ('0' + date.getDate()).slice(-2);
15
- return "".concat(year, "-").concat(month, "-").concat(day);
11
+ const date = new Date(dateOfBirth);
12
+ const year = date.getFullYear();
13
+ const month = ('0' + (date.getMonth() + 1)).slice(-2);
14
+ const day = ('0' + date.getDate()).slice(-2);
15
+ return `${year}-${month}-${day}`;
16
16
  }
17
17
  exports.normaliseDate = normaliseDate;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.roundDecimal = void 0;
4
4
  /**
5
5
  * Rounds given value to 2 decimals.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.5.8",
3
+ "version": "1.6.1",
4
4
  "description": "Library for kafka event data transforming",
5
5
  "author": "Integrations <integrations@lendi.com.au>",
6
6
  "homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
@@ -21,39 +21,36 @@
21
21
  "url": "git+ssh://git@bitbucket.org/lendi-dev/integrations-shared-packages.git"
22
22
  },
23
23
  "dependencies": {
24
- "@lendi/integrations-credit-protocol": "1.17.1",
24
+ "@lendi/integrations-credit-protocol": "^1.17.3",
25
25
  "@lendi/integrations-protocol": "2.6.1",
26
+ "@lendi/logging": "^1.0.0",
26
27
  "clean-deep": "^3.4.0",
27
28
  "date-fns": "2.19.0",
28
- "lodash": "^4.17.15",
29
- "pino": "^6.7.0"
29
+ "lodash": "^4.17.15"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@lendi/prettier-config": "^1.0.0",
33
33
  "@lendi/typescript-config": "^2.0.0",
34
- "@types/jest": "^27.4.1",
34
+ "@types/jest": "^28.1.4",
35
35
  "@types/lodash": "^4.14.141",
36
36
  "@types/node": "^12.12.5",
37
- "@types/pino": "^6.3.3",
38
37
  "@types/prettier": "^1.16.1",
39
38
  "@types/sinon": "^7.5.0",
40
- "@typescript-eslint/eslint-plugin": "^4.14.0",
41
- "@typescript-eslint/parser": "^4.14.0",
42
- "eslint-config-prettier": "^7.2.0",
43
- "eslint-plugin-import": "^2.22.1",
44
- "eslint-plugin-prettier": "^3.3.1",
45
- "eslint-plugin-sonarjs": "^0.5.0",
39
+ "@typescript-eslint/eslint-plugin": "^5.21.0",
40
+ "@typescript-eslint/parser": "^5.21.0",
41
+ "eslint": "^8.14.0",
42
+ "eslint-config-prettier": "^8.5.0",
43
+ "eslint-plugin-jsdoc": "^39.2.9",
44
+ "eslint-plugin-prettier": "^4.0.0",
45
+ "eslint-plugin-sonarjs": "^0.13.0",
46
46
  "husky": "^3.0.8",
47
- "jest": "^27.5.1",
47
+ "jest": "^28.1.2",
48
48
  "jest-buildkite-reporter": "^0.2.8",
49
49
  "jest-sonar-reporter": "^2.0.0",
50
50
  "path": "^0.12.7",
51
- "prettier": "^2.2.1",
52
- "prettier-check": "^2.0.0",
53
- "prettier-eslint": "^12.0.0",
54
51
  "quicktype": "15.0.207",
55
52
  "sinon": "^7.4.2",
56
- "ts-jest": "^27.1.4",
53
+ "ts-jest": "^28.0.5",
57
54
  "ts-node": "^8.4.1",
58
55
  "typedoc": "^0.20.36",
59
56
  "typescript": "^4.1.3"