@lendi/integrations-transform 1.6.0 → 1.6.3
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/CHANGELOG.md +7 -0
- package/lib/index.js +26 -10
- package/lib/logger.js +5 -2
- package/lib/schemas/public-application-event.json +7 -0
- package/lib/transform-events/generate-asset-liability-link.js +12 -8
- package/lib/transform-events/generate-credit-report-rebuilt.js +12 -8
- package/lib/transform-events/generate-employment.js +41 -37
- package/lib/transform-events/generate-required-document.d.ts +1 -2
- package/lib/transform-events/generate-required-document.js +41 -32
- package/lib/transform-events/transform-applicant.js +60 -53
- package/lib/transform-events/transform-application-workflow.js +9 -5
- package/lib/transform-events/transform-application.d.ts +6 -8
- package/lib/transform-events/transform-application.js +30 -25
- package/lib/transform-events/transform-asset-address.js +25 -19
- package/lib/transform-events/transform-asset.js +128 -118
- package/lib/transform-events/transform-expenses.js +39 -31
- package/lib/transform-events/transform-funding-position.js +32 -27
- package/lib/transform-events/transform-income.js +73 -65
- package/lib/transform-events/transform-liability.js +59 -55
- package/lib/transform-events/transform-percent-owned.js +7 -3
- package/lib/types/enum-mappings/alieo-frequency.js +22 -19
- package/lib/types/enum-mappings/asset-type.js +16 -13
- package/lib/types/enum-mappings/builder-type.js +8 -5
- package/lib/types/enum-mappings/construction-type.js +9 -6
- package/lib/types/enum-mappings/country-code.js +245 -242
- package/lib/types/enum-mappings/employment-basis.js +11 -8
- package/lib/types/enum-mappings/expense-frequency.js +10 -7
- package/lib/types/enum-mappings/funding-position.js +32 -29
- package/lib/types/enum-mappings/government-benefits.js +9 -6
- package/lib/types/enum-mappings/guarantor-relationship-type.js +15 -12
- package/lib/types/enum-mappings/housing-status.js +14 -11
- package/lib/types/enum-mappings/income-type.js +15 -12
- package/lib/types/enum-mappings/index.js +43 -27
- package/lib/types/enum-mappings/liability-payment-type.js +8 -5
- package/lib/types/enum-mappings/liability-type.js +20 -17
- package/lib/types/enum-mappings/living-expense.js +29 -26
- package/lib/types/enum-mappings/marital-status.js +11 -8
- package/lib/types/enum-mappings/postcode.js +13 -10
- package/lib/types/enum-mappings/preferred-repayment.js +9 -6
- package/lib/types/enum-mappings/proof-of-identity.js +9 -6
- package/lib/types/enum-mappings/property-expense-category.js +10 -7
- package/lib/types/enum-mappings/public-financial-asset.js +11 -8
- package/lib/types/enum-mappings/public-primary-purpose.js +8 -5
- package/lib/types/enum-mappings/public-property-status.js +10 -7
- package/lib/types/enum-mappings/public-property-type.js +22 -19
- package/lib/types/enum-mappings/residency-status.js +10 -7
- package/lib/types/enum-mappings/title-gender.js +12 -9
- package/lib/types/enum-mappings/title.js +12 -9
- package/lib/types/enum-mappings/to-be-purchased.js +7 -4
- package/lib/types/enum-mappings/to-be-used-as-security.js +7 -4
- package/lib/types/enum-mappings/transaction-type.js +8 -5
- package/lib/types/enum-mappings/verification.js +12 -9
- package/lib/types/events/applicant-delete.js +7 -4
- package/lib/types/events/application-workflow.js +13 -10
- package/lib/types/events/asset-delete.js +7 -4
- package/lib/types/events/asset-liability-relation-delete.js +7 -4
- package/lib/types/events/credit-report-retrieved.js +7 -4
- package/lib/types/events/employment-delete.js +5 -2
- package/lib/types/events/expense-delete.js +5 -2
- package/lib/types/events/funding-position.js +9 -6
- package/lib/types/events/income-delete.js +7 -4
- package/lib/types/events/liability-delete.js +5 -2
- package/lib/types/events/opportunity.js +9 -6
- package/lib/types/events/public-applicant.js +31 -28
- package/lib/types/events/public-application.d.ts +1 -0
- package/lib/types/events/public-application.js +29 -26
- package/lib/types/events/public-asset-liability-relation.js +7 -4
- package/lib/types/events/public-asset.js +29 -26
- package/lib/types/events/public-employment.js +21 -18
- package/lib/types/events/public-expense.js +11 -8
- package/lib/types/events/public-funding-position.js +5 -2
- package/lib/types/events/public-income.js +15 -12
- package/lib/types/events/public-liability.js +19 -16
- package/lib/types/events/public-required-document.js +17 -14
- package/lib/types/partial-application.js +2 -1
- package/lib/types/recursive-partial.js +2 -1
- package/lib/update-application/merge-application.js +6 -2
- package/lib/update-application/update-primary-applicant.js +17 -12
- package/lib/utils/address-tools.js +43 -33
- package/lib/utils/clean-up.js +7 -3
- package/lib/utils/formatYesNo.js +6 -2
- package/lib/utils/generate-address.js +26 -21
- package/lib/utils/get-financial-institution.js +8 -4
- package/lib/utils/is-asset-type.js +20 -13
- package/lib/utils/is-income-type.js +58 -45
- package/lib/utils/iso-date.js +6 -2
- package/lib/utils/normalise-date.js +5 -1
- package/lib/utils/round-decimal.js +5 -1
- package/package.json +4 -4
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepMergeApplication = void 0;
|
|
4
|
+
const merge = require("deepmerge");
|
|
2
5
|
const cleanDeep = require('clean-deep');
|
|
3
6
|
/**
|
|
4
7
|
* Deep merges the application and custom handles specific arrays
|
|
@@ -7,7 +10,7 @@ const cleanDeep = require('clean-deep');
|
|
|
7
10
|
* @param existingApplication a saved dynamo application.
|
|
8
11
|
* @returns merged application.
|
|
9
12
|
*/
|
|
10
|
-
|
|
13
|
+
function deepMergeApplication(existingApplication, newApplication) {
|
|
11
14
|
// Array fields with @UniqueIDs
|
|
12
15
|
const listsWithUniqueIds = [
|
|
13
16
|
'Attachment',
|
|
@@ -85,6 +88,7 @@ export function deepMergeApplication(existingApplication, newApplication) {
|
|
|
85
88
|
};
|
|
86
89
|
return cleanDeep(mergedApplication, params);
|
|
87
90
|
}
|
|
91
|
+
exports.deepMergeApplication = deepMergeApplication;
|
|
88
92
|
const arrayItemToReplaceKeys = ['Owner', 'Attendee', 'Shareholder', 'Fee', 'ContributionFunds', 'RentalIncome'];
|
|
89
93
|
/**
|
|
90
94
|
*
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updatePrimaryApplicant = exports.isMultiplePersonApplicantBorrowers = void 0;
|
|
4
|
+
const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
5
|
+
const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const public_applicant_1 = require("../types/events/public-applicant");
|
|
5
8
|
/**
|
|
6
9
|
* Checks if there are more than one person applicants with applicant type borrower
|
|
7
10
|
*
|
|
8
11
|
* @param {PersonApplicants[]} personApplicants - Person applicants on the deep merged application
|
|
9
12
|
* @returns {boolean} - Whether or not there are more than one applicant with applicant type borrower
|
|
10
13
|
*/
|
|
11
|
-
|
|
12
|
-
const totalBorrowerApplicants = personApplicants.filter((applicant) => applicant['@ApplicantType'] === ApplicantTypeList.Borrower).length;
|
|
14
|
+
const isMultiplePersonApplicantBorrowers = (personApplicants) => {
|
|
15
|
+
const totalBorrowerApplicants = personApplicants.filter((applicant) => applicant['@ApplicantType'] === lixi_internal_request_1.ApplicantTypeList.Borrower).length;
|
|
13
16
|
return totalBorrowerApplicants > 1;
|
|
14
17
|
};
|
|
18
|
+
exports.isMultiplePersonApplicantBorrowers = isMultiplePersonApplicantBorrowers;
|
|
15
19
|
/**
|
|
16
20
|
* Updates the primary applicant of the application based on the new primary applicant id
|
|
17
21
|
*
|
|
@@ -19,7 +23,8 @@ export const isMultiplePersonApplicantBorrowers = (personApplicants) => {
|
|
|
19
23
|
* @param {PersonApplicant[]} personApplicants - Person applicants from the updated application after deep merge
|
|
20
24
|
* @returns {PersonApplicant[]} - Updated person applicants
|
|
21
25
|
*/
|
|
22
|
-
|
|
26
|
+
const updatePrimaryApplicant = (newPrimaryApplicantId, personApplicants) => personApplicants.map((applicant) => (Object.assign(Object.assign({}, applicant), { ['@PrimaryApplicant']: applicant['@UniqueID'] === newPrimaryApplicantId ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No })));
|
|
27
|
+
exports.updatePrimaryApplicant = updatePrimaryApplicant;
|
|
23
28
|
/**
|
|
24
29
|
* Updates the primary applicant on the application based on the data in the guarantor applicant event
|
|
25
30
|
*
|
|
@@ -29,13 +34,13 @@ export const updatePrimaryApplicant = (newPrimaryApplicantId, personApplicants)
|
|
|
29
34
|
*/
|
|
30
35
|
const updatePrimaryApplicantUsingGuarantor = (application, applicantPayload) => {
|
|
31
36
|
var _a;
|
|
32
|
-
const updatedApplication = application, personApplicants = get(application, paths.PersonApplicants, []);
|
|
37
|
+
const updatedApplication = application, personApplicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
|
|
33
38
|
// Checks if there are more than one borrower in the application and that the applicant type of the applicant event being processed is GUARANTOR
|
|
34
|
-
if (isMultiplePersonApplicantBorrowers(personApplicants) &&
|
|
35
|
-
applicantPayload.applicantType === ApplicantType.Guarantor &&
|
|
39
|
+
if ((0, exports.isMultiplePersonApplicantBorrowers)(personApplicants) &&
|
|
40
|
+
applicantPayload.applicantType === public_applicant_1.ApplicantType.Guarantor &&
|
|
36
41
|
((_a = applicantPayload.guarantorRelationshipToBorrower) === null || _a === void 0 ? void 0 : _a.applicantId)) {
|
|
37
|
-
set(updatedApplication, paths.PersonApplicants, updatePrimaryApplicant(applicantPayload.guarantorRelationshipToBorrower.applicantId, personApplicants));
|
|
42
|
+
(0, lodash_1.set)(updatedApplication, application_paths_1.paths.PersonApplicants, (0, exports.updatePrimaryApplicant)(applicantPayload.guarantorRelationshipToBorrower.applicantId, personApplicants));
|
|
38
43
|
}
|
|
39
44
|
return updatedApplication;
|
|
40
45
|
};
|
|
41
|
-
|
|
46
|
+
exports.default = updatePrimaryApplicantUsingGuarantor;
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* A set of tools for manipulating addresses in LIXI applications.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isOverseasAddress = exports.extractCountryFromFormatted = exports.setCountry = exports.isMissingCountry = exports.rebuildPreviousAddress = exports.rebuildAddress = exports.mapTransform = exports.lixiAddressMapping = exports.australianStates = exports.lixiContactAddressMapping = void 0;
|
|
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
|
+
exports.lixiContactAddressMapping = {
|
|
11
14
|
externalId: {
|
|
12
15
|
path: '@x_ResidentialAddress',
|
|
13
16
|
},
|
|
14
17
|
housingStatus: {
|
|
15
18
|
path: '@HousingStatus',
|
|
16
|
-
transform: (value) => housingStatusMapping[value],
|
|
19
|
+
transform: (value) => housing_status_1.housingStatusMapping[value],
|
|
17
20
|
},
|
|
18
21
|
startDate: {
|
|
19
22
|
path: '@StartDate',
|
|
@@ -22,11 +25,11 @@ export const lixiContactAddressMapping = {
|
|
|
22
25
|
path: '@EndDate',
|
|
23
26
|
},
|
|
24
27
|
};
|
|
25
|
-
|
|
28
|
+
exports.australianStates = Object.values(lixi_internal_request_1.AuStateList);
|
|
26
29
|
/**
|
|
27
30
|
* The transform map used for the LIXI address
|
|
28
31
|
*/
|
|
29
|
-
|
|
32
|
+
exports.lixiAddressMapping = {
|
|
30
33
|
externalId: {
|
|
31
34
|
path: '@UniqueID',
|
|
32
35
|
},
|
|
@@ -35,7 +38,7 @@ export const lixiAddressMapping = {
|
|
|
35
38
|
},
|
|
36
39
|
'residentialAddress.country': {
|
|
37
40
|
path: '@Country',
|
|
38
|
-
transform: (value) => countryCodeMapping[value],
|
|
41
|
+
transform: (value) => country_code_1.countryCodeMapping[value],
|
|
39
42
|
},
|
|
40
43
|
'residentialAddress.postcode': {
|
|
41
44
|
path: '@AustralianPostCode',
|
|
@@ -51,7 +54,7 @@ export const lixiAddressMapping = {
|
|
|
51
54
|
},
|
|
52
55
|
'residentialAddress.standard.streetNumber': {
|
|
53
56
|
path: 'Standard.@StreetNumber',
|
|
54
|
-
transform: (value) => value.substring(0, StreetNumberMaxLength),
|
|
57
|
+
transform: (value) => value.substring(0, generate_address_1.StreetNumberMaxLength),
|
|
55
58
|
},
|
|
56
59
|
'residentialAddress.standard.streetType': {
|
|
57
60
|
path: 'Standard.@StreetType',
|
|
@@ -66,16 +69,17 @@ export const lixiAddressMapping = {
|
|
|
66
69
|
* @param source A source object to be mapped and transformed
|
|
67
70
|
* @param pathMappedTransform A PathMappedTransform to be applied to the source
|
|
68
71
|
*/
|
|
69
|
-
|
|
72
|
+
function mapTransform(source, pathMappedTransform) {
|
|
70
73
|
const finalTransform = {};
|
|
71
74
|
Object.entries(pathMappedTransform).forEach(([key, { transform, path }]) => {
|
|
72
|
-
const sourceValue = get(source, key);
|
|
75
|
+
const sourceValue = (0, lodash_1.get)(source, key);
|
|
73
76
|
if (sourceValue) {
|
|
74
|
-
set(finalTransform, path, (transform === null || transform === void 0 ? void 0 : transform(sourceValue)) || sourceValue);
|
|
77
|
+
(0, lodash_1.set)(finalTransform, path, (transform === null || transform === void 0 ? void 0 : transform(sourceValue)) || sourceValue);
|
|
75
78
|
}
|
|
76
79
|
});
|
|
77
80
|
return finalTransform;
|
|
78
81
|
}
|
|
82
|
+
exports.mapTransform = mapTransform;
|
|
79
83
|
const postcodePathString = 'residentialAddress.postcode';
|
|
80
84
|
const statePathString = 'residentialAddress.state';
|
|
81
85
|
/**
|
|
@@ -84,83 +88,89 @@ const statePathString = 'residentialAddress.state';
|
|
|
84
88
|
* @param eventAddress
|
|
85
89
|
* @param addressId
|
|
86
90
|
*/
|
|
87
|
-
|
|
91
|
+
function rebuildAddress(eventAddress, addressId) {
|
|
88
92
|
if (isMissingCountry(eventAddress)) {
|
|
89
93
|
setCountry(eventAddress);
|
|
90
94
|
}
|
|
91
|
-
if (get(eventAddress, 'residentialAddress.country') !== Countries.Australia) {
|
|
92
|
-
lixiAddressMapping[postcodePathString] = { path: '@OverseasPostCode' };
|
|
93
|
-
lixiAddressMapping[statePathString] = { path: '@OverseasState' };
|
|
95
|
+
if ((0, lodash_1.get)(eventAddress, 'residentialAddress.country') !== public_applicant_1.Countries.Australia) {
|
|
96
|
+
exports.lixiAddressMapping[postcodePathString] = { path: '@OverseasPostCode' };
|
|
97
|
+
exports.lixiAddressMapping[statePathString] = { path: '@OverseasState' };
|
|
94
98
|
}
|
|
95
99
|
else {
|
|
96
|
-
lixiAddressMapping[postcodePathString] = { path: '@AustralianPostCode' };
|
|
97
|
-
lixiAddressMapping[statePathString] = { path: '@AustralianState' };
|
|
100
|
+
exports.lixiAddressMapping[postcodePathString] = { path: '@AustralianPostCode' };
|
|
101
|
+
exports.lixiAddressMapping[statePathString] = { path: '@AustralianState' };
|
|
98
102
|
}
|
|
99
|
-
const lixiAddress = mapTransform(eventAddress, lixiAddressMapping);
|
|
100
|
-
const lixiContactAddress = mapTransform(eventAddress, lixiContactAddressMapping);
|
|
103
|
+
const lixiAddress = mapTransform(eventAddress, exports.lixiAddressMapping);
|
|
104
|
+
const lixiContactAddress = mapTransform(eventAddress, exports.lixiContactAddressMapping);
|
|
101
105
|
lixiAddress['@UniqueID'] = addressId;
|
|
102
106
|
lixiContactAddress['@x_ResidentialAddress'] = addressId;
|
|
103
107
|
return { lixiAddress, lixiContactAddress };
|
|
104
108
|
}
|
|
109
|
+
exports.rebuildAddress = rebuildAddress;
|
|
105
110
|
/**
|
|
106
111
|
* Converts a previous address object from an event model to a LIXI address and corresponding LIXI current address object.
|
|
107
112
|
*
|
|
108
113
|
* @param eventPreviousAddresses
|
|
109
114
|
* @param addressId
|
|
110
115
|
*/
|
|
111
|
-
|
|
116
|
+
function rebuildPreviousAddress(eventPreviousAddresses = [], addressId) {
|
|
112
117
|
if (eventPreviousAddresses.length === 0)
|
|
113
118
|
return null;
|
|
114
119
|
const previousAddress = eventPreviousAddresses.sort((lhs, rhs) => lhs.endDate.localeCompare(rhs.endDate)).pop();
|
|
115
120
|
return rebuildAddress(previousAddress, addressId);
|
|
116
121
|
}
|
|
122
|
+
exports.rebuildPreviousAddress = rebuildPreviousAddress;
|
|
117
123
|
/**
|
|
118
124
|
* Checks if an event is missing country.
|
|
119
125
|
*
|
|
120
126
|
* @param addressEvent
|
|
121
127
|
*/
|
|
122
|
-
|
|
128
|
+
function isMissingCountry(addressEvent) {
|
|
123
129
|
if (addressEvent.residentialAddress && addressEvent.residentialAddress.formatted) {
|
|
124
|
-
return !get(addressEvent, 'residentialAddress.country');
|
|
130
|
+
return !(0, lodash_1.get)(addressEvent, 'residentialAddress.country');
|
|
125
131
|
}
|
|
126
132
|
return false;
|
|
127
133
|
}
|
|
134
|
+
exports.isMissingCountry = isMissingCountry;
|
|
128
135
|
/**
|
|
129
136
|
* Sets the country from the last item on the formatted address.
|
|
130
137
|
*
|
|
131
138
|
* @param address
|
|
132
139
|
*/
|
|
133
|
-
|
|
134
|
-
const formatted = get(address, 'residentialAddress.formatted');
|
|
140
|
+
function setCountry(address) {
|
|
141
|
+
const formatted = (0, lodash_1.get)(address, 'residentialAddress.formatted');
|
|
135
142
|
if (formatted && !address.residentialAddress.country) {
|
|
136
143
|
address.residentialAddress.country = extractCountryFromFormatted(formatted);
|
|
137
144
|
}
|
|
138
145
|
return address;
|
|
139
146
|
}
|
|
147
|
+
exports.setCountry = setCountry;
|
|
140
148
|
/**
|
|
141
149
|
* @description Extract a country from a formatted address.
|
|
142
150
|
* @param {string} formatted - A formatted Address.
|
|
143
151
|
* @returns {Countries} The country extracted from the Address.
|
|
144
152
|
*/
|
|
145
|
-
|
|
153
|
+
function extractCountryFromFormatted(formatted = '') {
|
|
146
154
|
var _a;
|
|
147
155
|
return (_a = formatted === null || formatted === void 0 ? void 0 : formatted.split(',').pop()) === null || _a === void 0 ? void 0 : _a.trim();
|
|
148
156
|
}
|
|
157
|
+
exports.extractCountryFromFormatted = extractCountryFromFormatted;
|
|
149
158
|
/**
|
|
150
159
|
* @description If the address has an overseas country or state, it returns true, defaults to false if no country and state found.
|
|
151
160
|
* @param {Address} address - Asset Address
|
|
152
161
|
* @returns {boolean} - Returns true if overseas address.
|
|
153
162
|
*/
|
|
154
|
-
|
|
163
|
+
function isOverseasAddress({ country, formatted, state } = {}) {
|
|
155
164
|
if (country) {
|
|
156
|
-
return country !== Countries.Australia;
|
|
165
|
+
return country !== public_applicant_1.Countries.Australia;
|
|
157
166
|
}
|
|
158
167
|
if (formatted) {
|
|
159
168
|
const lastPast = extractCountryFromFormatted(formatted);
|
|
160
|
-
return lastPast !== Countries.Australia;
|
|
169
|
+
return lastPast !== public_applicant_1.Countries.Australia;
|
|
161
170
|
}
|
|
162
171
|
if (state) {
|
|
163
|
-
return !australianStates.includes(state);
|
|
172
|
+
return !exports.australianStates.includes(state);
|
|
164
173
|
}
|
|
165
174
|
return false;
|
|
166
175
|
}
|
|
176
|
+
exports.isOverseasAddress = isOverseasAddress;
|
package/lib/utils/clean-up.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanUp = void 0;
|
|
1
4
|
/* istanbul ignore file */
|
|
2
|
-
|
|
5
|
+
const clean_deep_1 = require("clean-deep");
|
|
3
6
|
/**
|
|
4
7
|
* Recursively removes nulls from nested objects and arrays
|
|
5
8
|
*
|
|
6
9
|
* @param payload any
|
|
7
10
|
* @returns result of sanitised object.
|
|
8
11
|
*/
|
|
9
|
-
|
|
12
|
+
function cleanUp(payload) {
|
|
10
13
|
// cleanDeep configurations.
|
|
11
14
|
const params = {
|
|
12
15
|
cleanValues: [],
|
|
@@ -16,5 +19,6 @@ export function cleanUp(payload) {
|
|
|
16
19
|
nullValues: true,
|
|
17
20
|
undefinedValues: true,
|
|
18
21
|
};
|
|
19
|
-
return
|
|
22
|
+
return (0, clean_deep_1.default)(payload, params);
|
|
20
23
|
}
|
|
24
|
+
exports.cleanUp = cleanUp;
|
package/lib/utils/formatYesNo.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatYesNo = void 0;
|
|
4
|
+
const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
2
5
|
/**
|
|
3
6
|
* Formats a value as Yes or No
|
|
4
7
|
*
|
|
5
8
|
* @param isTruthy Some value to be formatted as Yes/No
|
|
6
9
|
* @returns Yes/No
|
|
7
10
|
*/
|
|
8
|
-
|
|
11
|
+
const formatYesNo = (isTruthy) => (isTruthy ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
|
|
12
|
+
exports.formatYesNo = formatYesNo;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateStandard = exports.generateAddress = exports.StreetTypeArray = exports.StreetNumberMaxLength = void 0;
|
|
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
|
+
exports.StreetNumberMaxLength = 16;
|
|
11
|
+
exports.StreetTypeArray = Object.values(lixi_internal_request_1.StreetTypeList);
|
|
9
12
|
const addressMapping = {
|
|
10
13
|
country: '@Country',
|
|
11
14
|
city: '@Suburb',
|
|
@@ -27,16 +30,16 @@ const standardMapping = {
|
|
|
27
30
|
* @param {string} id - Id of asset object.
|
|
28
31
|
* @returns {Partial<AddressType>} A transformed address object.
|
|
29
32
|
*/
|
|
30
|
-
|
|
33
|
+
function generateAddress(address, id) {
|
|
31
34
|
const transformedAddress = {
|
|
32
|
-
'@Country': CountryCodeList.Au,
|
|
35
|
+
'@Country': lixi_internal_request_1.CountryCodeList.Au,
|
|
33
36
|
'@UniqueID': id,
|
|
34
37
|
};
|
|
35
|
-
const country = extractCountryFromFormatted(address.formatted);
|
|
38
|
+
const country = (0, address_tools_1.extractCountryFromFormatted)(address.formatted);
|
|
36
39
|
if (!address.country && country.length > 0) {
|
|
37
40
|
address.country = country;
|
|
38
41
|
}
|
|
39
|
-
if (address.country && address.country !== Countries.Australia) {
|
|
42
|
+
if (address.country && address.country !== public_asset_1.Countries.Australia) {
|
|
40
43
|
addressMapping.postcode = '@OverseasPostCode';
|
|
41
44
|
addressMapping.state = '@OverseasState';
|
|
42
45
|
}
|
|
@@ -44,49 +47,51 @@ export function generateAddress(address, id) {
|
|
|
44
47
|
addressMapping.postcode = '@AustralianPostCode';
|
|
45
48
|
addressMapping.state = '@AustralianState';
|
|
46
49
|
if (!address.postcode && address.state) {
|
|
47
|
-
transformedAddress['@AustralianPostCode'] = postcodeMapping[address.state];
|
|
50
|
+
transformedAddress['@AustralianPostCode'] = postcode_1.postcodeMapping[address.state];
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
for (const [key, value] of Object.entries(address)) {
|
|
51
54
|
if (addressMapping[key]) {
|
|
52
55
|
switch (key) {
|
|
53
56
|
case 'standard':
|
|
54
|
-
set(transformedAddress, addressMapping[key], generateStandard(value));
|
|
57
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], generateStandard(value));
|
|
55
58
|
break;
|
|
56
59
|
case 'country':
|
|
57
|
-
set(transformedAddress, addressMapping[key], countryCodeMapping[value]);
|
|
60
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], country_code_1.countryCodeMapping[value]);
|
|
58
61
|
break;
|
|
59
62
|
default:
|
|
60
|
-
set(transformedAddress, addressMapping[key], value);
|
|
63
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], value);
|
|
61
64
|
break;
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
return transformedAddress;
|
|
66
69
|
}
|
|
70
|
+
exports.generateAddress = generateAddress;
|
|
67
71
|
/**
|
|
68
72
|
* Generates an address standard.
|
|
69
73
|
*
|
|
70
74
|
* @param addressStandard An address standard object.
|
|
71
75
|
* @returns A transformed standard object.
|
|
72
76
|
*/
|
|
73
|
-
|
|
77
|
+
function generateStandard(addressStandard) {
|
|
74
78
|
const transformedStandard = {};
|
|
75
79
|
for (const [key, value] of Object.entries(addressStandard)) {
|
|
76
80
|
if (standardMapping[key]) {
|
|
77
81
|
switch (key) {
|
|
78
82
|
case 'streetNumber':
|
|
79
|
-
set(transformedStandard, standardMapping[key], value.substring(0, StreetNumberMaxLength));
|
|
83
|
+
(0, lodash_1.set)(transformedStandard, standardMapping[key], value.substring(0, exports.StreetNumberMaxLength));
|
|
80
84
|
break;
|
|
81
85
|
case 'streetType':
|
|
82
|
-
const streetType = StreetTypeArray.find((type) => type.toLowerCase() === value.toLowerCase());
|
|
83
|
-
set(transformedStandard, standardMapping[key], streetType || StreetTypeList.Street);
|
|
86
|
+
const streetType = exports.StreetTypeArray.find((type) => type.toLowerCase() === value.toLowerCase());
|
|
87
|
+
(0, lodash_1.set)(transformedStandard, standardMapping[key], streetType || lixi_internal_request_1.StreetTypeList.Street);
|
|
84
88
|
break;
|
|
85
89
|
default:
|
|
86
|
-
set(transformedStandard, standardMapping[key], value);
|
|
90
|
+
(0, lodash_1.set)(transformedStandard, standardMapping[key], value);
|
|
87
91
|
break;
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
return transformedStandard;
|
|
92
96
|
}
|
|
97
|
+
exports.generateStandard = generateStandard;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFinancialInstitution = void 0;
|
|
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);
|
|
3
6
|
/**
|
|
4
7
|
* Returns the financialInstitution value form the Enum based on the index where it was found.
|
|
5
8
|
*
|
|
6
9
|
* @param institution: Institution value from event.
|
|
7
10
|
* @param institution
|
|
8
11
|
*/
|
|
9
|
-
|
|
12
|
+
function getFinancialInstitution(institution) {
|
|
10
13
|
const institutionUpperCased = institution.toUpperCase();
|
|
11
14
|
const financialInstitution = financialInstitutions.find((item) => item.toUpperCase() === institutionUpperCased);
|
|
12
|
-
return financialInstitution || FinancialInstitutionList.Other;
|
|
15
|
+
return financialInstitution || lixi_internal_request_1.FinancialInstitutionList.Other;
|
|
13
16
|
}
|
|
17
|
+
exports.getFinancialInstitution = getFinancialInstitution;
|
|
@@ -1,39 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isOtherAsset = exports.isMotorVehicle = exports.isRealEstateAsset = exports.isFinancialAsset = void 0;
|
|
4
|
+
const public_asset_1 = require("../types/events/public-asset");
|
|
2
5
|
/**
|
|
3
6
|
* @description Checks if the asset is of financial type.
|
|
4
7
|
* @param {Asset} asset asset payload.
|
|
5
8
|
* @returns {boolean} returns true if asset is a financial asset.
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
function isFinancialAsset(asset) {
|
|
8
11
|
return [
|
|
9
|
-
AssetType.Shares,
|
|
10
|
-
AssetType.Superannuation,
|
|
11
|
-
AssetType.TermDeposit,
|
|
12
|
-
AssetType.SavingCheckAccount,
|
|
13
|
-
AssetType.ManagedFunds,
|
|
12
|
+
public_asset_1.AssetType.Shares,
|
|
13
|
+
public_asset_1.AssetType.Superannuation,
|
|
14
|
+
public_asset_1.AssetType.TermDeposit,
|
|
15
|
+
public_asset_1.AssetType.SavingCheckAccount,
|
|
16
|
+
public_asset_1.AssetType.ManagedFunds,
|
|
14
17
|
].includes(asset.type);
|
|
15
18
|
}
|
|
19
|
+
exports.isFinancialAsset = isFinancialAsset;
|
|
16
20
|
/**
|
|
17
21
|
* @description Is Asset a Real Estate Asset.
|
|
18
22
|
* @param {Asset} asset An Asset.
|
|
19
23
|
* @returns {boolean} returns true if Asset is a Real Estate Asset.
|
|
20
24
|
*/
|
|
21
|
-
|
|
22
|
-
return asset.type === AssetType.Property;
|
|
25
|
+
function isRealEstateAsset(asset) {
|
|
26
|
+
return asset.type === public_asset_1.AssetType.Property;
|
|
23
27
|
}
|
|
28
|
+
exports.isRealEstateAsset = isRealEstateAsset;
|
|
24
29
|
/**
|
|
25
30
|
* @description Is Asset a Motor Vehicle.
|
|
26
31
|
* @param {Asset} asset An Asset.
|
|
27
32
|
* @returns {boolean} returns true if an Asset is a vehicle.
|
|
28
33
|
*/
|
|
29
|
-
|
|
30
|
-
return asset.type === AssetType.Vehicle;
|
|
34
|
+
function isMotorVehicle(asset) {
|
|
35
|
+
return asset.type === public_asset_1.AssetType.Vehicle;
|
|
31
36
|
}
|
|
37
|
+
exports.isMotorVehicle = isMotorVehicle;
|
|
32
38
|
/**
|
|
33
39
|
* @description Is Asset of LIXI type `OtherAsset`.
|
|
34
40
|
* @param {Asset} asset An Asset.
|
|
35
41
|
* @returns {boolean} returns true if asset is `OtherAsset`.
|
|
36
42
|
*/
|
|
37
|
-
|
|
38
|
-
return [AssetType.HomeContents, AssetType.Gifts, AssetType.OtherAsset].includes(asset.type);
|
|
43
|
+
function isOtherAsset(asset) {
|
|
44
|
+
return [public_asset_1.AssetType.HomeContents, public_asset_1.AssetType.Gifts, public_asset_1.AssetType.OtherAsset].includes(asset.type);
|
|
39
45
|
}
|
|
46
|
+
exports.isOtherAsset = isOtherAsset;
|