@lendi/integrations-transform 1.6.0 → 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 +26 -10
- package/lib/logger.js +5 -2
- 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.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.js +22 -18
- 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.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 +2 -2
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformApplicationWorkflow = void 0;
|
|
4
|
+
const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
3
6
|
/**
|
|
4
7
|
* Generates a partial application from an ApplicationWorkflow event
|
|
5
8
|
*
|
|
6
9
|
* @param applicationWorkflowEventPayload ApplicationWorkflow event payload
|
|
7
10
|
* @returns A partial application
|
|
8
11
|
*/
|
|
9
|
-
|
|
12
|
+
function transformApplicationWorkflow(applicationWorkflowEventPayload) {
|
|
10
13
|
const { stage, applicationStage, applicationId } = applicationWorkflowEventPayload, partialApplication = {};
|
|
11
|
-
set(partialApplication, paths.ApplicationId, applicationId);
|
|
14
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
12
15
|
// The stage being defaulted to Unknown caters for LGSF application workflow events having stage as an optional attribute in the future
|
|
13
16
|
const instructionDetails = {
|
|
14
17
|
'@UniqueID': `${applicationId}-stage`,
|
|
15
18
|
'@Details': applicationStage || stage || 'Unknown',
|
|
16
19
|
};
|
|
17
|
-
set(partialApplication, paths.Instructions, instructionDetails);
|
|
20
|
+
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Instructions, instructionDetails);
|
|
18
21
|
return partialApplication;
|
|
19
22
|
}
|
|
23
|
+
exports.transformApplicationWorkflow = transformApplicationWorkflow;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformApplication = void 0;
|
|
4
|
+
const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
5
|
+
const application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
6
|
+
const application_paths_2 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
8
|
+
const enum_mappings_1 = require("../types/enum-mappings/");
|
|
9
|
+
const transform_applicant_1 = require("./transform-applicant");
|
|
7
10
|
/**
|
|
8
11
|
* Transforms a partial opportunity event to a partial internal request.
|
|
9
12
|
*
|
|
@@ -13,23 +16,23 @@ import { booleanMapping } from './transform-applicant';
|
|
|
13
16
|
* @param options
|
|
14
17
|
* @returns partialApplication: A partial internal request.
|
|
15
18
|
*/
|
|
16
|
-
|
|
19
|
+
function transformApplication(opportunity, options = {}) {
|
|
17
20
|
const { uniqueIdSuffix = 'loanDetails', enableRateLock = false } = options;
|
|
18
21
|
const partialApplication = {};
|
|
19
22
|
const opportunityMapping = {
|
|
20
|
-
brand: paths.BusinessName,
|
|
21
|
-
id: paths.ApplicationId,
|
|
22
|
-
paymentType: `${paths.LoanTerm}.@PaymentType`,
|
|
23
|
+
brand: application_paths_2.paths.BusinessName,
|
|
24
|
+
id: application_paths_2.paths.ApplicationId,
|
|
25
|
+
paymentType: `${application_paths_2.paths.LoanTerm}.@PaymentType`,
|
|
23
26
|
preliminary: 'preliminary',
|
|
24
|
-
primaryPurpose: paths.PurposeOfApplication,
|
|
27
|
+
primaryPurpose: application_paths_2.paths.PurposeOfApplication,
|
|
25
28
|
brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description',
|
|
26
29
|
};
|
|
27
|
-
set(partialApplication, `${paths.LoanDetail}.@UniqueID`, `${opportunity.id}-${uniqueIdSuffix}`);
|
|
28
|
-
set(partialApplication, `${
|
|
29
|
-
set(partialApplication, `${
|
|
30
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_2.paths.LoanDetail}.@UniqueID`, `${opportunity.id}-${uniqueIdSuffix}`);
|
|
31
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Instructions}.@UniqueID`, `${opportunity.id}-stage`);
|
|
32
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Instructions}.@Name`, lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
|
|
30
33
|
if (enableRateLock) {
|
|
31
34
|
const { hasOptedInRateLock = false } = opportunity;
|
|
32
|
-
set(partialApplication, `${
|
|
35
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.FeaturesSelected}.@RateLock`, (0, transform_applicant_1.booleanMapping)(hasOptedInRateLock));
|
|
33
36
|
}
|
|
34
37
|
for (const [opportunityKey, opportunityValue] of Object.entries(opportunity)) {
|
|
35
38
|
if (opportunityMapping[opportunityKey]) {
|
|
@@ -38,19 +41,20 @@ export function transformApplication(opportunity, options = {}) {
|
|
|
38
41
|
if (opportunityMapping[key]) {
|
|
39
42
|
switch (key) {
|
|
40
43
|
case 'paymentType':
|
|
41
|
-
set(partialApplication, opportunityMapping[key], preferredRepaymentMapping[value]);
|
|
44
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[key], enum_mappings_1.preferredRepaymentMapping[value]);
|
|
42
45
|
break;
|
|
43
46
|
case 'primaryPurpose':
|
|
44
|
-
set(partialApplication, opportunityMapping[key], transactionTypeMapping[value]);
|
|
47
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[key], enum_mappings_1.transactionTypeMapping[value]);
|
|
45
48
|
break;
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
else {
|
|
51
|
-
set(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
|
|
54
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
return partialApplication;
|
|
56
59
|
}
|
|
60
|
+
exports.transformApplication = transformApplication;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformStandard = exports.transformAddress = exports.standardMapping = exports.getAddressMapping = 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 enum_mappings_1 = require("../types/enum-mappings");
|
|
7
|
+
const address_tools_1 = require("../utils/address-tools");
|
|
5
8
|
/**
|
|
6
9
|
*
|
|
7
10
|
* @param address
|
|
8
11
|
*/
|
|
9
|
-
|
|
12
|
+
function getAddressMapping(address) {
|
|
10
13
|
return {
|
|
11
14
|
city: '@Suburb',
|
|
12
15
|
country: '@Country',
|
|
13
|
-
postcode: isOverseasAddress(address) ? '@OverseasPostCode' : '@AustralianPostCode',
|
|
14
|
-
state: isOverseasAddress(address) ? '@OverseasState' : '@AustralianState',
|
|
16
|
+
postcode: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasPostCode' : '@AustralianPostCode',
|
|
17
|
+
state: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasState' : '@AustralianState',
|
|
15
18
|
standard: 'Standard',
|
|
16
19
|
formatted: '@Country',
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
|
-
|
|
22
|
+
exports.getAddressMapping = getAddressMapping;
|
|
23
|
+
exports.standardMapping = {
|
|
20
24
|
streetName: '@StreetName',
|
|
21
25
|
streetType: '@StreetType',
|
|
22
26
|
streetNumber: '@StreetNumber',
|
|
@@ -33,49 +37,51 @@ export const standardMapping = {
|
|
|
33
37
|
* @param id
|
|
34
38
|
* @returns A transformed address object.
|
|
35
39
|
*/
|
|
36
|
-
|
|
40
|
+
function transformAddress(address, id) {
|
|
37
41
|
const transformedAddress = {
|
|
38
42
|
'@UniqueID': id,
|
|
39
43
|
};
|
|
40
44
|
const addressMapping = getAddressMapping(address);
|
|
41
45
|
// for an Australian address: if no postcode is provided, infer one from the state:
|
|
42
|
-
if (!isOverseasAddress(address) && address.state && !address.postcode) {
|
|
43
|
-
address.postcode = postcodeMapping[address.state];
|
|
46
|
+
if (!(0, address_tools_1.isOverseasAddress)(address) && address.state && !address.postcode) {
|
|
47
|
+
address.postcode = enum_mappings_1.postcodeMapping[address.state];
|
|
44
48
|
}
|
|
45
49
|
for (const [key, value] of Object.entries(address)) {
|
|
46
50
|
if (addressMapping[key]) {
|
|
47
51
|
switch (key) {
|
|
48
52
|
case 'standard':
|
|
49
|
-
set(transformedAddress, addressMapping[key], transformStandard(value));
|
|
53
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], transformStandard(value));
|
|
50
54
|
break;
|
|
51
55
|
case 'country':
|
|
52
|
-
set(transformedAddress, addressMapping[key], isOverseasAddress(address) ? countryCodeMapping[value] : CountryCodeList.Au);
|
|
56
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], (0, address_tools_1.isOverseasAddress)(address) ? enum_mappings_1.countryCodeMapping[value] : lixi_internal_request_1.CountryCodeList.Au);
|
|
53
57
|
break;
|
|
54
58
|
case 'formatted':
|
|
55
59
|
if (!address.country) {
|
|
56
|
-
const country = extractCountryFromFormatted(value);
|
|
57
|
-
set(transformedAddress, addressMapping[key], countryCodeMapping[country]);
|
|
60
|
+
const country = (0, address_tools_1.extractCountryFromFormatted)(value);
|
|
61
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], enum_mappings_1.countryCodeMapping[country]);
|
|
58
62
|
}
|
|
59
63
|
break;
|
|
60
64
|
default:
|
|
61
|
-
set(transformedAddress, addressMapping[key], value);
|
|
65
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], value);
|
|
62
66
|
break;
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
return transformedAddress;
|
|
67
71
|
}
|
|
72
|
+
exports.transformAddress = transformAddress;
|
|
68
73
|
/**
|
|
69
74
|
* @description Generates an address standard.
|
|
70
75
|
* @param {AddressStandard} addressStandard An address standard object.
|
|
71
76
|
* @returns {Partial<Standard>} A transformed standard object.
|
|
72
77
|
*/
|
|
73
|
-
|
|
78
|
+
function transformStandard(addressStandard) {
|
|
74
79
|
const transformedStandard = {};
|
|
75
80
|
for (const [key, value] of Object.entries(addressStandard)) {
|
|
76
|
-
if (standardMapping[key]) {
|
|
77
|
-
set(transformedStandard, standardMapping[key], value);
|
|
81
|
+
if (exports.standardMapping[key]) {
|
|
82
|
+
(0, lodash_1.set)(transformedStandard, exports.standardMapping[key], value);
|
|
78
83
|
}
|
|
79
84
|
}
|
|
80
85
|
return transformedStandard;
|
|
81
86
|
}
|
|
87
|
+
exports.transformStandard = transformStandard;
|