@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.
- package/lib/index.js +1 -1
- package/lib/logger.d.ts +1 -2
- package/lib/logger.js +3 -3
- package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
- package/lib/transform-events/generate-asset-liability-link.js +12 -12
- package/lib/transform-events/generate-credit-report-rebuilt.js +13 -13
- package/lib/transform-events/generate-employment.d.ts +1 -1
- package/lib/transform-events/generate-employment.js +33 -34
- package/lib/transform-events/generate-required-document.d.ts +1 -7
- package/lib/transform-events/generate-required-document.js +37 -54
- package/lib/transform-events/transform-applicant.d.ts +2 -1
- package/lib/transform-events/transform-applicant.js +57 -63
- package/lib/transform-events/transform-application-workflow.d.ts +0 -1
- package/lib/transform-events/transform-application-workflow.js +7 -8
- package/lib/transform-events/transform-application.d.ts +3 -1
- package/lib/transform-events/transform-application.js +23 -24
- package/lib/transform-events/transform-asset-address.d.ts +8 -2
- package/lib/transform-events/transform-asset-address.js +22 -18
- package/lib/transform-events/transform-asset.d.ts +7 -1
- package/lib/transform-events/transform-asset.js +112 -122
- package/lib/transform-events/transform-expenses.d.ts +4 -0
- package/lib/transform-events/transform-expenses.js +31 -29
- package/lib/transform-events/transform-funding-position.d.ts +2 -2
- package/lib/transform-events/transform-funding-position.js +23 -26
- package/lib/transform-events/transform-income.d.ts +8 -1
- package/lib/transform-events/transform-income.js +87 -97
- package/lib/transform-events/transform-liability.d.ts +4 -1
- package/lib/transform-events/transform-liability.js +42 -41
- package/lib/transform-events/transform-percent-owned.d.ts +1 -0
- package/lib/transform-events/transform-percent-owned.js +8 -11
- package/lib/types/enum-mappings/alieo-frequency.js +23 -24
- package/lib/types/enum-mappings/asset-type.js +15 -16
- package/lib/types/enum-mappings/builder-type.js +7 -8
- package/lib/types/enum-mappings/construction-type.js +8 -9
- package/lib/types/enum-mappings/country-code.js +244 -245
- package/lib/types/enum-mappings/employment-basis.js +10 -11
- package/lib/types/enum-mappings/expense-frequency.js +9 -10
- package/lib/types/enum-mappings/funding-position.js +6 -6
- package/lib/types/enum-mappings/government-benefits.js +8 -9
- package/lib/types/enum-mappings/guarantor-relationship-type.d.ts +3 -0
- package/lib/types/enum-mappings/guarantor-relationship-type.js +16 -0
- package/lib/types/enum-mappings/housing-status.js +13 -14
- package/lib/types/enum-mappings/income-type.js +14 -15
- package/lib/types/enum-mappings/index.js +1 -1
- package/lib/types/enum-mappings/liability-payment-type.js +7 -8
- package/lib/types/enum-mappings/liability-type.js +19 -20
- package/lib/types/enum-mappings/living-expense.js +28 -29
- package/lib/types/enum-mappings/marital-status.js +10 -11
- package/lib/types/enum-mappings/postcode.js +12 -13
- package/lib/types/enum-mappings/preferred-repayment.js +8 -9
- package/lib/types/enum-mappings/proof-of-identity.js +8 -9
- package/lib/types/enum-mappings/property-expense-category.js +9 -10
- package/lib/types/enum-mappings/public-financial-asset.js +10 -11
- package/lib/types/enum-mappings/public-primary-purpose.js +7 -8
- package/lib/types/enum-mappings/public-property-status.js +9 -10
- package/lib/types/enum-mappings/public-property-type.js +21 -22
- package/lib/types/enum-mappings/residency-status.js +9 -10
- package/lib/types/enum-mappings/title-gender.js +11 -12
- package/lib/types/enum-mappings/title.js +11 -12
- package/lib/types/enum-mappings/to-be-purchased.js +4 -4
- package/lib/types/enum-mappings/to-be-used-as-security.js +4 -4
- package/lib/types/enum-mappings/transaction-type.js +7 -8
- package/lib/types/enum-mappings/verification.js +11 -12
- package/lib/types/events/applicant-delete.js +1 -1
- package/lib/types/events/application-workflow.js +1 -1
- package/lib/types/events/asset-delete.js +1 -1
- package/lib/types/events/asset-liability-relation-delete.js +1 -1
- package/lib/types/events/credit-report-retrieved.js +1 -1
- package/lib/types/events/employment-delete.js +1 -1
- package/lib/types/events/expense-delete.js +1 -1
- package/lib/types/events/funding-position.js +1 -1
- package/lib/types/events/income-delete.js +1 -1
- package/lib/types/events/liability-delete.js +1 -1
- package/lib/types/events/opportunity.js +1 -1
- package/lib/types/events/public-applicant.js +1 -1
- package/lib/types/events/public-application.js +1 -1
- package/lib/types/events/public-asset-liability-relation.js +1 -1
- package/lib/types/events/public-asset.js +1 -1
- package/lib/types/events/public-employment.js +1 -1
- package/lib/types/events/public-expense.js +1 -1
- package/lib/types/events/public-funding-position.js +1 -1
- package/lib/types/events/public-income.js +1 -1
- package/lib/types/events/public-liability.js +1 -1
- package/lib/types/events/public-required-document.js +1 -1
- package/lib/types/partial-application.js +1 -1
- package/lib/types/recursive-partial.js +1 -1
- package/lib/update-application/merge-application.d.ts +1 -1
- package/lib/update-application/merge-application.js +41 -34
- package/lib/update-application/update-primary-applicant.d.ts +1 -4
- package/lib/update-application/update-primary-applicant.js +12 -31
- package/lib/utils/address-tools.d.ts +3 -1
- package/lib/utils/address-tools.js +40 -42
- package/lib/utils/clean-up.d.ts +1 -1
- package/lib/utils/clean-up.js +6 -6
- package/lib/utils/formatYesNo.d.ts +0 -1
- package/lib/utils/formatYesNo.js +3 -4
- package/lib/utils/generate-address.d.ts +3 -2
- package/lib/utils/generate-address.js +21 -25
- package/lib/utils/get-financial-institution.d.ts +1 -0
- package/lib/utils/get-financial-institution.js +6 -5
- package/lib/utils/is-asset-type.js +2 -2
- package/lib/utils/is-income-type.d.ts +2 -0
- package/lib/utils/is-income-type.js +15 -21
- package/lib/utils/iso-date.d.ts +0 -1
- package/lib/utils/iso-date.js +3 -4
- package/lib/utils/normalise-date.js +6 -6
- package/lib/utils/round-decimal.js +1 -1
- 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
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
74
|
-
Object.entries(pathMappedTransform).forEach(
|
|
75
|
-
|
|
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
|
-
|
|
85
|
-
|
|
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
|
-
|
|
105
|
-
|
|
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
|
|
107
|
+
return { lixiAddress, lixiContactAddress };
|
|
109
108
|
}
|
|
110
109
|
exports.rebuildAddress = rebuildAddress;
|
|
111
110
|
/**
|
|
112
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
168
|
+
const lastPast = extractCountryFromFormatted(formatted);
|
|
171
169
|
return lastPast !== public_applicant_1.Countries.Australia;
|
|
172
170
|
}
|
|
173
171
|
if (state) {
|
package/lib/utils/clean-up.d.ts
CHANGED
package/lib/utils/clean-up.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cleanUp = void 0;
|
|
4
4
|
/* istanbul ignore file */
|
|
5
|
-
|
|
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
|
-
* @
|
|
10
|
+
* @returns result of sanitised object.
|
|
11
11
|
*/
|
|
12
12
|
function cleanUp(payload) {
|
|
13
13
|
// cleanDeep configurations.
|
|
14
|
-
|
|
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
|
|
22
|
+
return (0, clean_deep_1.default)(payload, params);
|
|
23
23
|
}
|
|
24
24
|
exports.cleanUp = cleanUp;
|
package/lib/utils/formatYesNo.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatYesNo = void 0;
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
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
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateStandard = exports.generateAddress = exports.StreetTypeArray = exports.StreetNumberMaxLength = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
* @
|
|
31
|
+
* @returns {Partial<AddressType>} A transformed address object.
|
|
31
32
|
*/
|
|
32
33
|
function generateAddress(address, id) {
|
|
33
|
-
|
|
34
|
+
const transformedAddress = {
|
|
34
35
|
'@Country': lixi_internal_request_1.CountryCodeList.Au,
|
|
35
|
-
'@UniqueID': id
|
|
36
|
+
'@UniqueID': id,
|
|
36
37
|
};
|
|
37
|
-
|
|
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 (
|
|
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
|
-
* @
|
|
75
|
+
* @returns A transformed standard object.
|
|
76
76
|
*/
|
|
77
77
|
function generateStandard(addressStandard) {
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
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
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFinancialInstitution = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isOtherAsset = exports.isMotorVehicle = exports.isRealEstateAsset = exports.isFinancialAsset = void 0;
|
|
4
|
-
|
|
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
|
|
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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
107
|
+
let applicantId;
|
|
110
108
|
if (applicants && employmentId) {
|
|
111
|
-
|
|
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(
|
|
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
|
-
|
|
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;
|
package/lib/utils/iso-date.d.ts
CHANGED
|
@@ -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;
|
package/lib/utils/iso-date.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isoDate = void 0;
|
|
4
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/integrations-transform",
|
|
3
|
-
"version": "1.
|
|
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.
|
|
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": "^
|
|
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": "^
|
|
41
|
-
"@typescript-eslint/parser": "^
|
|
42
|
-
"eslint
|
|
43
|
-
"eslint-
|
|
44
|
-
"eslint-plugin-
|
|
45
|
-
"eslint-plugin-
|
|
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": "^
|
|
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": "^
|
|
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"
|