@lendi/act-credit-decisions-transform 2.0.0
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/README.md +31 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +28 -0
- package/lib/logger.d.ts +1 -0
- package/lib/logger.js +5 -0
- package/lib/schemas/application-workflow-event.json +240 -0
- package/lib/schemas/credit-report-retrieved-event.json +57 -0
- package/lib/schemas/public-applicant-event.json +910 -0
- package/lib/schemas/public-application-event.json +250 -0
- package/lib/schemas/public-asset-event.json +679 -0
- package/lib/schemas/public-asset-liability-relation-delete-event.json +74 -0
- package/lib/schemas/public-asset-liability-relation-event.json +73 -0
- package/lib/schemas/public-create-applicant-event.json +609 -0
- package/lib/schemas/public-delete-applicant-event.json +66 -0
- package/lib/schemas/public-delete-asset-event.json +53 -0
- package/lib/schemas/public-delete-income-event.json +55 -0
- package/lib/schemas/public-employment-delete-event.json +31 -0
- package/lib/schemas/public-employment-event.json +278 -0
- package/lib/schemas/public-expense-delete-event.json +41 -0
- package/lib/schemas/public-expense-event.json +133 -0
- package/lib/schemas/public-funding-position-event.json +419 -0
- package/lib/schemas/public-income-event.json +242 -0
- package/lib/schemas/public-liability-delete-event.json +37 -0
- package/lib/schemas/public-liability-event.json +262 -0
- package/lib/schemas/public-required-document-event.json +366 -0
- package/lib/schemas/public-update-applicant-event.json +606 -0
- package/lib/schemas/sf-opportunity-event-out.json +138 -0
- package/lib/transform-events/generate-asset-liability-link.d.ts +10 -0
- package/lib/transform-events/generate-asset-liability-link.js +29 -0
- package/lib/transform-events/generate-credit-report-rebuilt.d.ts +8 -0
- package/lib/transform-events/generate-credit-report-rebuilt.js +41 -0
- package/lib/transform-events/transform-applicant.d.ts +8 -0
- package/lib/transform-events/transform-applicant.js +180 -0
- package/lib/transform-events/transform-application-workflow.d.ts +8 -0
- package/lib/transform-events/transform-application-workflow.js +30 -0
- package/lib/transform-events/transform-application.d.ts +20 -0
- package/lib/transform-events/transform-application.js +67 -0
- package/lib/transform-events/transform-asset-address.d.ts +25 -0
- package/lib/transform-events/transform-asset-address.js +87 -0
- package/lib/transform-events/transform-asset.d.ts +58 -0
- package/lib/transform-events/transform-asset.js +337 -0
- package/lib/transform-events/transform-employment.d.ts +9 -0
- package/lib/transform-events/transform-employment.js +107 -0
- package/lib/transform-events/transform-expenses.d.ts +41 -0
- package/lib/transform-events/transform-expenses.js +121 -0
- package/lib/transform-events/transform-funding-position.d.ts +21 -0
- package/lib/transform-events/transform-funding-position.js +107 -0
- package/lib/transform-events/transform-income.d.ts +48 -0
- package/lib/transform-events/transform-income.js +260 -0
- package/lib/transform-events/transform-liability.d.ts +12 -0
- package/lib/transform-events/transform-liability.js +117 -0
- package/lib/transform-events/transform-percent-owned.d.ts +10 -0
- package/lib/transform-events/transform-percent-owned.js +22 -0
- package/lib/transform-events/transform-required-document.d.ts +67 -0
- package/lib/transform-events/transform-required-document.js +148 -0
- package/lib/types/enum-mappings/alieo-frequency.d.ts +15 -0
- package/lib/types/enum-mappings/alieo-frequency.js +25 -0
- package/lib/types/enum-mappings/applicant-gender.d.ts +6 -0
- package/lib/types/enum-mappings/applicant-gender.js +11 -0
- package/lib/types/enum-mappings/applicant-type.d.ts +6 -0
- package/lib/types/enum-mappings/applicant-type.js +10 -0
- package/lib/types/enum-mappings/asset-type.d.ts +3 -0
- package/lib/types/enum-mappings/asset-type.js +17 -0
- package/lib/types/enum-mappings/builder-type.d.ts +7 -0
- package/lib/types/enum-mappings/builder-type.js +9 -0
- package/lib/types/enum-mappings/company-structure.d.ts +7 -0
- package/lib/types/enum-mappings/company-structure.js +10 -0
- package/lib/types/enum-mappings/company-type.d.ts +7 -0
- package/lib/types/enum-mappings/company-type.js +11 -0
- package/lib/types/enum-mappings/construction-type.d.ts +7 -0
- package/lib/types/enum-mappings/construction-type.js +10 -0
- package/lib/types/enum-mappings/country-code.d.ts +7 -0
- package/lib/types/enum-mappings/country-code.js +246 -0
- package/lib/types/enum-mappings/employment-basis.d.ts +7 -0
- package/lib/types/enum-mappings/employment-basis.js +12 -0
- package/lib/types/enum-mappings/expense-frequency.d.ts +7 -0
- package/lib/types/enum-mappings/expense-frequency.js +11 -0
- package/lib/types/enum-mappings/funding-position.d.ts +18 -0
- package/lib/types/enum-mappings/funding-position.js +36 -0
- package/lib/types/enum-mappings/government-benefits.d.ts +7 -0
- package/lib/types/enum-mappings/government-benefits.js +10 -0
- 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.d.ts +7 -0
- package/lib/types/enum-mappings/housing-status.js +15 -0
- package/lib/types/enum-mappings/income-type.d.ts +7 -0
- package/lib/types/enum-mappings/income-type.js +16 -0
- package/lib/types/enum-mappings/index.d.ts +27 -0
- package/lib/types/enum-mappings/index.js +43 -0
- package/lib/types/enum-mappings/liability-payment-type.d.ts +7 -0
- package/lib/types/enum-mappings/liability-payment-type.js +9 -0
- package/lib/types/enum-mappings/liability-type.d.ts +7 -0
- package/lib/types/enum-mappings/liability-type.js +21 -0
- package/lib/types/enum-mappings/living-expense.d.ts +7 -0
- package/lib/types/enum-mappings/living-expense.js +31 -0
- package/lib/types/enum-mappings/marital-status.d.ts +7 -0
- package/lib/types/enum-mappings/marital-status.js +12 -0
- package/lib/types/enum-mappings/postcode.d.ts +6 -0
- package/lib/types/enum-mappings/postcode.js +15 -0
- package/lib/types/enum-mappings/preferred-repayment.d.ts +7 -0
- package/lib/types/enum-mappings/preferred-repayment.js +10 -0
- package/lib/types/enum-mappings/proof-of-identity.d.ts +7 -0
- package/lib/types/enum-mappings/proof-of-identity.js +10 -0
- package/lib/types/enum-mappings/property-expense-category.d.ts +7 -0
- package/lib/types/enum-mappings/property-expense-category.js +11 -0
- package/lib/types/enum-mappings/public-financial-asset.d.ts +7 -0
- package/lib/types/enum-mappings/public-financial-asset.js +12 -0
- package/lib/types/enum-mappings/public-primary-purpose.d.ts +7 -0
- package/lib/types/enum-mappings/public-primary-purpose.js +9 -0
- package/lib/types/enum-mappings/public-property-status.d.ts +7 -0
- package/lib/types/enum-mappings/public-property-status.js +11 -0
- package/lib/types/enum-mappings/public-property-type.d.ts +7 -0
- package/lib/types/enum-mappings/public-property-type.js +23 -0
- package/lib/types/enum-mappings/residency-status.d.ts +7 -0
- package/lib/types/enum-mappings/residency-status.js +11 -0
- package/lib/types/enum-mappings/title-gender.d.ts +7 -0
- package/lib/types/enum-mappings/title-gender.js +13 -0
- package/lib/types/enum-mappings/title.d.ts +7 -0
- package/lib/types/enum-mappings/title.js +13 -0
- package/lib/types/enum-mappings/to-be-purchased.d.ts +5 -0
- package/lib/types/enum-mappings/to-be-purchased.js +8 -0
- package/lib/types/enum-mappings/to-be-used-as-security.d.ts +5 -0
- package/lib/types/enum-mappings/to-be-used-as-security.js +8 -0
- package/lib/types/enum-mappings/transaction-type.d.ts +7 -0
- package/lib/types/enum-mappings/transaction-type.js +9 -0
- package/lib/types/enum-mappings/trust.d.ts +7 -0
- package/lib/types/enum-mappings/trust.js +14 -0
- package/lib/types/enum-mappings/verification.d.ts +3 -0
- package/lib/types/enum-mappings/verification.js +13 -0
- package/lib/types/events/applicant-delete.d.ts +42 -0
- package/lib/types/events/applicant-delete.js +15 -0
- package/lib/types/events/application-workflow.d.ts +233 -0
- package/lib/types/events/application-workflow.js +172 -0
- package/lib/types/events/asset-delete.d.ts +33 -0
- package/lib/types/events/asset-delete.js +15 -0
- package/lib/types/events/asset-liability-relation-delete.d.ts +52 -0
- package/lib/types/events/asset-liability-relation-delete.js +15 -0
- package/lib/types/events/credit-report-retrieved.d.ts +36 -0
- package/lib/types/events/credit-report-retrieved.js +15 -0
- package/lib/types/events/employment-delete.d.ts +19 -0
- package/lib/types/events/employment-delete.js +7 -0
- package/lib/types/events/expense-delete.d.ts +21 -0
- package/lib/types/events/expense-delete.js +7 -0
- package/lib/types/events/funding-position.d.ts +116 -0
- package/lib/types/events/funding-position.js +34 -0
- package/lib/types/events/income-delete.d.ts +33 -0
- package/lib/types/events/income-delete.js +15 -0
- package/lib/types/events/liability-delete.d.ts +17 -0
- package/lib/types/events/liability-delete.js +7 -0
- package/lib/types/events/opportunity.d.ts +102 -0
- package/lib/types/events/opportunity.js +47 -0
- package/lib/types/events/public-applicant.d.ts +628 -0
- package/lib/types/events/public-applicant.js +411 -0
- package/lib/types/events/public-application.d.ts +151 -0
- package/lib/types/events/public-application.js +103 -0
- package/lib/types/events/public-asset-liability-relation.d.ts +52 -0
- package/lib/types/events/public-asset-liability-relation.js +15 -0
- package/lib/types/events/public-asset.d.ts +502 -0
- package/lib/types/events/public-asset.js +348 -0
- package/lib/types/events/public-employment.d.ts +121 -0
- package/lib/types/events/public-employment.js +46 -0
- package/lib/types/events/public-expense.d.ts +84 -0
- package/lib/types/events/public-expense.js +51 -0
- package/lib/types/events/public-funding-position.d.ts +341 -0
- package/lib/types/events/public-funding-position.js +20 -0
- package/lib/types/events/public-income.d.ts +144 -0
- package/lib/types/events/public-income.js +65 -0
- package/lib/types/events/public-liability.d.ts +140 -0
- package/lib/types/events/public-liability.js +68 -0
- package/lib/types/events/public-required-document.d.ts +374 -0
- package/lib/types/events/public-required-document.js +297 -0
- package/lib/types/partial-application.d.ts +3 -0
- package/lib/types/partial-application.js +2 -0
- package/lib/types/recursive-partial.d.ts +3 -0
- package/lib/types/recursive-partial.js +2 -0
- package/lib/update-application/merge-application.d.ts +14 -0
- package/lib/update-application/merge-application.js +175 -0
- package/lib/update-application/remove-ids-not-required.d.ts +11 -0
- package/lib/update-application/remove-ids-not-required.js +63 -0
- package/lib/update-application/update-primary-applicant.d.ts +27 -0
- package/lib/update-application/update-primary-applicant.js +46 -0
- package/lib/utils/address-tools.d.ts +84 -0
- package/lib/utils/address-tools.js +176 -0
- package/lib/utils/clean-up.d.ts +7 -0
- package/lib/utils/clean-up.js +24 -0
- package/lib/utils/errors.d.ts +28 -0
- package/lib/utils/errors.js +43 -0
- package/lib/utils/formatYesNo.d.ts +8 -0
- package/lib/utils/formatYesNo.js +12 -0
- package/lib/utils/generate-address.d.ts +19 -0
- package/lib/utils/generate-address.js +97 -0
- package/lib/utils/get-financial-institution.d.ts +8 -0
- package/lib/utils/get-financial-institution.js +17 -0
- package/lib/utils/is-asset-type.d.ts +25 -0
- package/lib/utils/is-asset-type.js +46 -0
- package/lib/utils/is-income-type.d.ts +73 -0
- package/lib/utils/is-income-type.js +134 -0
- package/lib/utils/iso-date.d.ts +7 -0
- package/lib/utils/iso-date.js +12 -0
- package/lib/utils/normalise-date.d.ts +8 -0
- package/lib/utils/normalise-date.js +17 -0
- package/lib/utils/round-decimal.d.ts +6 -0
- package/lib/utils/round-decimal.js +12 -0
- package/package.json +79 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A set of tools for manipulating addresses in LIXI applications.
|
|
3
|
+
*/
|
|
4
|
+
import { AddressType, CurrentAddress, PreviousAddress } from '@lendi/act-eac-integrations-protocol/lib/types/lixi-internal-request';
|
|
5
|
+
import { Address, CommonAddressProperties, Countries, PreviousAddress as InternalPreviousAddress } from '../types/events/public-applicant';
|
|
6
|
+
/**
|
|
7
|
+
* Type definition for functions used to transform types while mapping from event values to LIXI values.
|
|
8
|
+
*/
|
|
9
|
+
export type MappingTransformFunction<I = any, O = any> = (input: I) => O;
|
|
10
|
+
/**
|
|
11
|
+
* Specifies the destination path of the object in dot notation along with an optional data transform function.
|
|
12
|
+
*/
|
|
13
|
+
export interface MappedTransform {
|
|
14
|
+
/**
|
|
15
|
+
* A path in dot notation.
|
|
16
|
+
*/
|
|
17
|
+
path: string;
|
|
18
|
+
/**
|
|
19
|
+
* An optional transform function for the value to be stored at the path.
|
|
20
|
+
*/
|
|
21
|
+
transform?: MappingTransformFunction;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A type defining a record set of path mapped transforms
|
|
25
|
+
*/
|
|
26
|
+
export type PathMappedTransform = Record<string, MappedTransform>;
|
|
27
|
+
export declare const lixiContactAddressMapping: PathMappedTransform;
|
|
28
|
+
export declare const australianStates: string[];
|
|
29
|
+
/**
|
|
30
|
+
* The transform map used for the LIXI address
|
|
31
|
+
*/
|
|
32
|
+
export declare const lixiAddressMapping: PathMappedTransform;
|
|
33
|
+
/**
|
|
34
|
+
* Transforms a source object by applying a PathMappedTransform.
|
|
35
|
+
*
|
|
36
|
+
* @param source A source object to be mapped and transformed
|
|
37
|
+
* @param pathMappedTransform A PathMappedTransform to be applied to the source
|
|
38
|
+
*/
|
|
39
|
+
export declare function mapTransform<T>(source: any, pathMappedTransform: PathMappedTransform): T;
|
|
40
|
+
type EventAddressType = InternalPreviousAddress | CommonAddressProperties;
|
|
41
|
+
export type LixiContactAddressType = CurrentAddress | PreviousAddress;
|
|
42
|
+
export interface AddressTransformedType {
|
|
43
|
+
lixiAddress: AddressType;
|
|
44
|
+
lixiContactAddress: LixiContactAddressType;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts an address object from an event model to a LIXI address and corresponding LIXI contact address object.
|
|
48
|
+
*
|
|
49
|
+
* @param eventAddress
|
|
50
|
+
* @param addressId
|
|
51
|
+
*/
|
|
52
|
+
export declare function rebuildAddress(eventAddress: EventAddressType, addressId: string): AddressTransformedType;
|
|
53
|
+
/**
|
|
54
|
+
* Converts a previous address object from an event model to a LIXI address and corresponding LIXI current address object.
|
|
55
|
+
*
|
|
56
|
+
* @param eventPreviousAddresses
|
|
57
|
+
* @param addressId
|
|
58
|
+
*/
|
|
59
|
+
export declare function rebuildPreviousAddress(eventPreviousAddresses: InternalPreviousAddress[], addressId: string): AddressTransformedType;
|
|
60
|
+
/**
|
|
61
|
+
* Checks if an event is missing country.
|
|
62
|
+
*
|
|
63
|
+
* @param addressEvent
|
|
64
|
+
*/
|
|
65
|
+
export declare function isMissingCountry(addressEvent: EventAddressType): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the country from the last item on the formatted address.
|
|
68
|
+
*
|
|
69
|
+
* @param address
|
|
70
|
+
*/
|
|
71
|
+
export declare function setCountry(address: EventAddressType): EventAddressType;
|
|
72
|
+
/**
|
|
73
|
+
* @description Extract a country from a formatted address.
|
|
74
|
+
* @param {string} formatted - A formatted Address.
|
|
75
|
+
* @returns {Countries} The country extracted from the Address.
|
|
76
|
+
*/
|
|
77
|
+
export declare function extractCountryFromFormatted(formatted?: string): Countries;
|
|
78
|
+
/**
|
|
79
|
+
* @description If the address has an overseas country or state, it returns true, defaults to false if no country and state found.
|
|
80
|
+
* @param {Address} address - Asset Address
|
|
81
|
+
* @returns {boolean} - Returns true if overseas address.
|
|
82
|
+
*/
|
|
83
|
+
export declare function isOverseasAddress({ country, formatted, state }?: Address): boolean;
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A set of tools for manipulating addresses in LIXI applications.
|
|
4
|
+
*/
|
|
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/act-eac-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 = {
|
|
14
|
+
externalId: {
|
|
15
|
+
path: '@x_ResidentialAddress',
|
|
16
|
+
},
|
|
17
|
+
housingStatus: {
|
|
18
|
+
path: '@HousingStatus',
|
|
19
|
+
transform: (value) => housing_status_1.housingStatusMapping[value],
|
|
20
|
+
},
|
|
21
|
+
startDate: {
|
|
22
|
+
path: '@StartDate',
|
|
23
|
+
},
|
|
24
|
+
endDate: {
|
|
25
|
+
path: '@EndDate',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
exports.australianStates = Object.values(lixi_internal_request_1.AuStateList);
|
|
29
|
+
/**
|
|
30
|
+
* The transform map used for the LIXI address
|
|
31
|
+
*/
|
|
32
|
+
exports.lixiAddressMapping = {
|
|
33
|
+
externalId: {
|
|
34
|
+
path: '@UniqueID',
|
|
35
|
+
},
|
|
36
|
+
'residentialAddress.city': {
|
|
37
|
+
path: '@Suburb',
|
|
38
|
+
},
|
|
39
|
+
'residentialAddress.country': {
|
|
40
|
+
path: '@Country',
|
|
41
|
+
transform: (value) => country_code_1.countryCodeMapping[value],
|
|
42
|
+
},
|
|
43
|
+
'residentialAddress.postcode': {
|
|
44
|
+
path: '@AustralianPostCode',
|
|
45
|
+
},
|
|
46
|
+
'residentialAddress.state': {
|
|
47
|
+
path: '@AustralianState',
|
|
48
|
+
},
|
|
49
|
+
'residentialAddress.standard.level': {
|
|
50
|
+
path: 'Standard.@Level',
|
|
51
|
+
},
|
|
52
|
+
'residentialAddress.standard.streetName': {
|
|
53
|
+
path: 'Standard.@StreetName',
|
|
54
|
+
},
|
|
55
|
+
'residentialAddress.standard.streetNumber': {
|
|
56
|
+
path: 'Standard.@StreetNumber',
|
|
57
|
+
transform: (value) => value.substring(0, generate_address_1.StreetNumberMaxLength),
|
|
58
|
+
},
|
|
59
|
+
'residentialAddress.standard.streetType': {
|
|
60
|
+
path: 'Standard.@StreetType',
|
|
61
|
+
},
|
|
62
|
+
'residentialAddress.standard.unit': {
|
|
63
|
+
path: 'Standard.@Unit',
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Transforms a source object by applying a PathMappedTransform.
|
|
68
|
+
*
|
|
69
|
+
* @param source A source object to be mapped and transformed
|
|
70
|
+
* @param pathMappedTransform A PathMappedTransform to be applied to the source
|
|
71
|
+
*/
|
|
72
|
+
function mapTransform(source, pathMappedTransform) {
|
|
73
|
+
const finalTransform = {};
|
|
74
|
+
Object.entries(pathMappedTransform).forEach(([key, { transform, path }]) => {
|
|
75
|
+
const sourceValue = (0, lodash_1.get)(source, key);
|
|
76
|
+
if (sourceValue) {
|
|
77
|
+
(0, lodash_1.set)(finalTransform, path, (transform === null || transform === void 0 ? void 0 : transform(sourceValue)) || sourceValue);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return finalTransform;
|
|
81
|
+
}
|
|
82
|
+
exports.mapTransform = mapTransform;
|
|
83
|
+
const postcodePathString = 'residentialAddress.postcode';
|
|
84
|
+
const statePathString = 'residentialAddress.state';
|
|
85
|
+
/**
|
|
86
|
+
* Converts an address object from an event model to a LIXI address and corresponding LIXI contact address object.
|
|
87
|
+
*
|
|
88
|
+
* @param eventAddress
|
|
89
|
+
* @param addressId
|
|
90
|
+
*/
|
|
91
|
+
function rebuildAddress(eventAddress, addressId) {
|
|
92
|
+
if (isMissingCountry(eventAddress)) {
|
|
93
|
+
setCountry(eventAddress);
|
|
94
|
+
}
|
|
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' };
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
exports.lixiAddressMapping[postcodePathString] = { path: '@AustralianPostCode' };
|
|
101
|
+
exports.lixiAddressMapping[statePathString] = { path: '@AustralianState' };
|
|
102
|
+
}
|
|
103
|
+
const lixiAddress = mapTransform(eventAddress, exports.lixiAddressMapping);
|
|
104
|
+
const lixiContactAddress = mapTransform(eventAddress, exports.lixiContactAddressMapping);
|
|
105
|
+
lixiAddress['@UniqueID'] = addressId;
|
|
106
|
+
lixiContactAddress['@x_ResidentialAddress'] = addressId;
|
|
107
|
+
return { lixiAddress, lixiContactAddress };
|
|
108
|
+
}
|
|
109
|
+
exports.rebuildAddress = rebuildAddress;
|
|
110
|
+
/**
|
|
111
|
+
* Converts a previous address object from an event model to a LIXI address and corresponding LIXI current address object.
|
|
112
|
+
*
|
|
113
|
+
* @param eventPreviousAddresses
|
|
114
|
+
* @param addressId
|
|
115
|
+
*/
|
|
116
|
+
function rebuildPreviousAddress(eventPreviousAddresses = [], addressId) {
|
|
117
|
+
if (eventPreviousAddresses.length === 0)
|
|
118
|
+
return null;
|
|
119
|
+
const previousAddress = eventPreviousAddresses.sort((lhs, rhs) => lhs.endDate.localeCompare(rhs.endDate)).pop();
|
|
120
|
+
return rebuildAddress(previousAddress, addressId);
|
|
121
|
+
}
|
|
122
|
+
exports.rebuildPreviousAddress = rebuildPreviousAddress;
|
|
123
|
+
/**
|
|
124
|
+
* Checks if an event is missing country.
|
|
125
|
+
*
|
|
126
|
+
* @param addressEvent
|
|
127
|
+
*/
|
|
128
|
+
function isMissingCountry(addressEvent) {
|
|
129
|
+
if (addressEvent.residentialAddress && addressEvent.residentialAddress.formatted) {
|
|
130
|
+
return !(0, lodash_1.get)(addressEvent, 'residentialAddress.country');
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
exports.isMissingCountry = isMissingCountry;
|
|
135
|
+
/**
|
|
136
|
+
* Sets the country from the last item on the formatted address.
|
|
137
|
+
*
|
|
138
|
+
* @param address
|
|
139
|
+
*/
|
|
140
|
+
function setCountry(address) {
|
|
141
|
+
const formatted = (0, lodash_1.get)(address, 'residentialAddress.formatted');
|
|
142
|
+
if (formatted && !address.residentialAddress.country) {
|
|
143
|
+
address.residentialAddress.country = extractCountryFromFormatted(formatted);
|
|
144
|
+
}
|
|
145
|
+
return address;
|
|
146
|
+
}
|
|
147
|
+
exports.setCountry = setCountry;
|
|
148
|
+
/**
|
|
149
|
+
* @description Extract a country from a formatted address.
|
|
150
|
+
* @param {string} formatted - A formatted Address.
|
|
151
|
+
* @returns {Countries} The country extracted from the Address.
|
|
152
|
+
*/
|
|
153
|
+
function extractCountryFromFormatted(formatted = '') {
|
|
154
|
+
var _a;
|
|
155
|
+
return (_a = formatted === null || formatted === void 0 ? void 0 : formatted.split(',').pop()) === null || _a === void 0 ? void 0 : _a.trim();
|
|
156
|
+
}
|
|
157
|
+
exports.extractCountryFromFormatted = extractCountryFromFormatted;
|
|
158
|
+
/**
|
|
159
|
+
* @description If the address has an overseas country or state, it returns true, defaults to false if no country and state found.
|
|
160
|
+
* @param {Address} address - Asset Address
|
|
161
|
+
* @returns {boolean} - Returns true if overseas address.
|
|
162
|
+
*/
|
|
163
|
+
function isOverseasAddress({ country, formatted, state } = {}) {
|
|
164
|
+
if (country) {
|
|
165
|
+
return country !== public_applicant_1.Countries.Australia;
|
|
166
|
+
}
|
|
167
|
+
if (formatted) {
|
|
168
|
+
const lastPast = extractCountryFromFormatted(formatted);
|
|
169
|
+
return lastPast !== public_applicant_1.Countries.Australia;
|
|
170
|
+
}
|
|
171
|
+
if (state) {
|
|
172
|
+
return !exports.australianStates.includes(state);
|
|
173
|
+
}
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
exports.isOverseasAddress = isOverseasAddress;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanUp = void 0;
|
|
4
|
+
/* istanbul ignore file */
|
|
5
|
+
const clean_deep_1 = require("clean-deep");
|
|
6
|
+
/**
|
|
7
|
+
* Recursively removes nulls from nested objects and arrays
|
|
8
|
+
*
|
|
9
|
+
* @param payload any
|
|
10
|
+
* @returns result of sanitised object.
|
|
11
|
+
*/
|
|
12
|
+
function cleanUp(payload) {
|
|
13
|
+
// cleanDeep configurations.
|
|
14
|
+
const params = {
|
|
15
|
+
cleanValues: [],
|
|
16
|
+
emptyArrays: true,
|
|
17
|
+
emptyObjects: true,
|
|
18
|
+
emptyStrings: false,
|
|
19
|
+
nullValues: true,
|
|
20
|
+
undefinedValues: true,
|
|
21
|
+
};
|
|
22
|
+
return (0, clean_deep_1.default)(payload, params);
|
|
23
|
+
}
|
|
24
|
+
exports.cleanUp = cleanUp;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum ErrorType {
|
|
2
|
+
ApplicationNotFound = "ApplicationNotFound",
|
|
3
|
+
BaseError = "BaseError",
|
|
4
|
+
DatabaseConditionalWriteError = "DatabaseConditionalWriteError",
|
|
5
|
+
DatabaseError = "DatabaseError",
|
|
6
|
+
Errors = "Errors",
|
|
7
|
+
InternalError = "InternalError",
|
|
8
|
+
InvalidApplication = "InvalidApplication",
|
|
9
|
+
InvalidEvent = "InvalidEvent",
|
|
10
|
+
InvalidEventNoApplicationId = "InvalidEventNoApplicationId",
|
|
11
|
+
InvalidEventNotCritical = "InvalidEventNotCritical",
|
|
12
|
+
OwnershipOutOfBounds = "OwnershipOutOfBounds",
|
|
13
|
+
ResourceNotFound = "ResourceNotFound"
|
|
14
|
+
}
|
|
15
|
+
export declare class BaseError extends Error {
|
|
16
|
+
origin: string;
|
|
17
|
+
path: string[];
|
|
18
|
+
type: ErrorType;
|
|
19
|
+
context: object;
|
|
20
|
+
constructor(message: string, path: string[], origin: string, context?: object);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* InvalidEvent occurs when an incorrect/damaged event has been consumed and
|
|
24
|
+
* found to be invalid against its related schema.
|
|
25
|
+
*/
|
|
26
|
+
export declare class InvalidEvent extends BaseError {
|
|
27
|
+
constructor(message: string, path?: string[], origin?: string, context?: object);
|
|
28
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidEvent = exports.BaseError = exports.ErrorType = void 0;
|
|
4
|
+
var ErrorType;
|
|
5
|
+
(function (ErrorType) {
|
|
6
|
+
ErrorType["ApplicationNotFound"] = "ApplicationNotFound";
|
|
7
|
+
ErrorType["BaseError"] = "BaseError";
|
|
8
|
+
ErrorType["DatabaseConditionalWriteError"] = "DatabaseConditionalWriteError";
|
|
9
|
+
ErrorType["DatabaseError"] = "DatabaseError";
|
|
10
|
+
ErrorType["Errors"] = "Errors";
|
|
11
|
+
ErrorType["InternalError"] = "InternalError";
|
|
12
|
+
ErrorType["InvalidApplication"] = "InvalidApplication";
|
|
13
|
+
ErrorType["InvalidEvent"] = "InvalidEvent";
|
|
14
|
+
ErrorType["InvalidEventNoApplicationId"] = "InvalidEventNoApplicationId";
|
|
15
|
+
ErrorType["InvalidEventNotCritical"] = "InvalidEventNotCritical";
|
|
16
|
+
ErrorType["OwnershipOutOfBounds"] = "OwnershipOutOfBounds";
|
|
17
|
+
ErrorType["ResourceNotFound"] = "ResourceNotFound";
|
|
18
|
+
})(ErrorType = exports.ErrorType || (exports.ErrorType = {}));
|
|
19
|
+
class BaseError extends Error {
|
|
20
|
+
/* istanbul ignore next */
|
|
21
|
+
constructor(message, path = [], origin, context = {}) {
|
|
22
|
+
super(message);
|
|
23
|
+
Object.setPrototypeOf(this, BaseError.prototype);
|
|
24
|
+
this.type = ErrorType.BaseError;
|
|
25
|
+
this.path = path;
|
|
26
|
+
this.origin = origin;
|
|
27
|
+
this.context = context;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.BaseError = BaseError;
|
|
31
|
+
/**
|
|
32
|
+
* InvalidEvent occurs when an incorrect/damaged event has been consumed and
|
|
33
|
+
* found to be invalid against its related schema.
|
|
34
|
+
*/
|
|
35
|
+
class InvalidEvent extends BaseError {
|
|
36
|
+
/* istanbul ignore next */
|
|
37
|
+
constructor(message, path, origin, context) {
|
|
38
|
+
super(message, path, origin, context);
|
|
39
|
+
Object.setPrototypeOf(this, InvalidEvent.prototype);
|
|
40
|
+
this.type = ErrorType.InvalidEvent;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.InvalidEvent = InvalidEvent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { YesNoList } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
|
+
/**
|
|
3
|
+
* Formats a value as Yes or No
|
|
4
|
+
*
|
|
5
|
+
* @param isTruthy Some value to be formatted as Yes/No
|
|
6
|
+
* @returns Yes/No
|
|
7
|
+
*/
|
|
8
|
+
export declare const formatYesNo: (isTruthy: any) => YesNoList;
|
|
@@ -0,0 +1,12 @@
|
|
|
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");
|
|
5
|
+
/**
|
|
6
|
+
* Formats a value as Yes or No
|
|
7
|
+
*
|
|
8
|
+
* @param isTruthy Some value to be formatted as Yes/No
|
|
9
|
+
* @returns Yes/No
|
|
10
|
+
*/
|
|
11
|
+
const formatYesNo = (isTruthy) => (isTruthy ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
|
|
12
|
+
exports.formatYesNo = formatYesNo;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AddressType, Standard, StreetTypeList } from '@lendi/act-eac-integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
import { Address, AddressStandard } from '../types/events/public-asset';
|
|
3
|
+
export declare const StreetNumberMaxLength = 16;
|
|
4
|
+
export declare const StreetTypeArray: StreetTypeList[];
|
|
5
|
+
/**
|
|
6
|
+
* Generates an address for an asset.
|
|
7
|
+
*
|
|
8
|
+
* @param {Address} address - An address object.
|
|
9
|
+
* @param {string} id - Id of asset object.
|
|
10
|
+
* @returns {Partial<AddressType>} A transformed address object.
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateAddress(address: Address, id: string): Partial<AddressType>;
|
|
13
|
+
/**
|
|
14
|
+
* Generates an address standard.
|
|
15
|
+
*
|
|
16
|
+
* @param addressStandard An address standard object.
|
|
17
|
+
* @returns A transformed standard object.
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateStandard(addressStandard: AddressStandard): Standard;
|
|
@@ -0,0 +1,97 @@
|
|
|
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/act-eac-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);
|
|
12
|
+
const addressMapping = {
|
|
13
|
+
country: '@Country',
|
|
14
|
+
city: '@Suburb',
|
|
15
|
+
postcode: '@AustralianPostCode',
|
|
16
|
+
state: '@AustralianState',
|
|
17
|
+
standard: 'Standard',
|
|
18
|
+
};
|
|
19
|
+
const standardMapping = {
|
|
20
|
+
streetName: '@StreetName',
|
|
21
|
+
streetType: '@StreetType',
|
|
22
|
+
streetNumber: '@StreetNumber',
|
|
23
|
+
level: '@Level',
|
|
24
|
+
unit: '@Unit',
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Generates an address for an asset.
|
|
28
|
+
*
|
|
29
|
+
* @param {Address} address - An address object.
|
|
30
|
+
* @param {string} id - Id of asset object.
|
|
31
|
+
* @returns {Partial<AddressType>} A transformed address object.
|
|
32
|
+
*/
|
|
33
|
+
function generateAddress(address, id) {
|
|
34
|
+
const transformedAddress = {
|
|
35
|
+
'@Country': lixi_internal_request_1.CountryCodeList.Au,
|
|
36
|
+
'@UniqueID': id,
|
|
37
|
+
};
|
|
38
|
+
const country = (0, address_tools_1.extractCountryFromFormatted)(address.formatted);
|
|
39
|
+
if (!address.country && country.length > 0) {
|
|
40
|
+
address.country = country;
|
|
41
|
+
}
|
|
42
|
+
if (address.country && address.country !== public_asset_1.Countries.Australia) {
|
|
43
|
+
addressMapping.postcode = '@OverseasPostCode';
|
|
44
|
+
addressMapping.state = '@OverseasState';
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
addressMapping.postcode = '@AustralianPostCode';
|
|
48
|
+
addressMapping.state = '@AustralianState';
|
|
49
|
+
if (!address.postcode && address.state) {
|
|
50
|
+
transformedAddress['@AustralianPostCode'] = postcode_1.postcodeMapping[address.state];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
for (const [key, value] of Object.entries(address)) {
|
|
54
|
+
if (addressMapping[key]) {
|
|
55
|
+
switch (key) {
|
|
56
|
+
case 'standard':
|
|
57
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], generateStandard(value));
|
|
58
|
+
break;
|
|
59
|
+
case 'country':
|
|
60
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], country_code_1.countryCodeMapping[value]);
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], value);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return transformedAddress;
|
|
69
|
+
}
|
|
70
|
+
exports.generateAddress = generateAddress;
|
|
71
|
+
/**
|
|
72
|
+
* Generates an address standard.
|
|
73
|
+
*
|
|
74
|
+
* @param addressStandard An address standard object.
|
|
75
|
+
* @returns A transformed standard object.
|
|
76
|
+
*/
|
|
77
|
+
function generateStandard(addressStandard) {
|
|
78
|
+
const transformedStandard = {};
|
|
79
|
+
for (const [key, value] of Object.entries(addressStandard)) {
|
|
80
|
+
if (standardMapping[key]) {
|
|
81
|
+
switch (key) {
|
|
82
|
+
case 'streetNumber':
|
|
83
|
+
(0, lodash_1.set)(transformedStandard, standardMapping[key], value.substring(0, exports.StreetNumberMaxLength));
|
|
84
|
+
break;
|
|
85
|
+
case 'streetType':
|
|
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);
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
(0, lodash_1.set)(transformedStandard, standardMapping[key], value);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return transformedStandard;
|
|
96
|
+
}
|
|
97
|
+
exports.generateStandard = generateStandard;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FinancialInstitutionList } from '@lendi/act-eac-integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the financialInstitution value form the Enum based on the index where it was found.
|
|
4
|
+
*
|
|
5
|
+
* @param institution: Institution value from event.
|
|
6
|
+
* @param institution
|
|
7
|
+
*/
|
|
8
|
+
export declare function getFinancialInstitution(institution: string): FinancialInstitutionList;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFinancialInstitution = void 0;
|
|
4
|
+
const lixi_internal_request_1 = require("@lendi/act-eac-integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
+
const financialInstitutions = Object.values(lixi_internal_request_1.FinancialInstitutionList);
|
|
6
|
+
/**
|
|
7
|
+
* Returns the financialInstitution value form the Enum based on the index where it was found.
|
|
8
|
+
*
|
|
9
|
+
* @param institution: Institution value from event.
|
|
10
|
+
* @param institution
|
|
11
|
+
*/
|
|
12
|
+
function getFinancialInstitution(institution) {
|
|
13
|
+
const institutionUpperCased = institution.toUpperCase();
|
|
14
|
+
const financialInstitution = financialInstitutions.find((item) => item.toUpperCase() === institutionUpperCased);
|
|
15
|
+
return financialInstitution || lixi_internal_request_1.FinancialInstitutionList.Other;
|
|
16
|
+
}
|
|
17
|
+
exports.getFinancialInstitution = getFinancialInstitution;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Asset } from '../types/events/public-asset';
|
|
2
|
+
/**
|
|
3
|
+
* @description Checks if the asset is of financial type.
|
|
4
|
+
* @param {Asset} asset asset payload.
|
|
5
|
+
* @returns {boolean} returns true if asset is a financial asset.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isFinancialAsset(asset: Asset): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* @description Is Asset a Real Estate Asset.
|
|
10
|
+
* @param {Asset} asset An Asset.
|
|
11
|
+
* @returns {boolean} returns true if Asset is a Real Estate Asset.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isRealEstateAsset(asset: Asset): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @description Is Asset a Motor Vehicle.
|
|
16
|
+
* @param {Asset} asset An Asset.
|
|
17
|
+
* @returns {boolean} returns true if an Asset is a vehicle.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isMotorVehicle(asset: Asset): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description Is Asset of LIXI type `OtherAsset`.
|
|
22
|
+
* @param {Asset} asset An Asset.
|
|
23
|
+
* @returns {boolean} returns true if asset is `OtherAsset`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isOtherAsset(asset: Asset): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
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");
|
|
5
|
+
/**
|
|
6
|
+
* @description Checks if the asset is of financial type.
|
|
7
|
+
* @param {Asset} asset asset payload.
|
|
8
|
+
* @returns {boolean} returns true if asset is a financial asset.
|
|
9
|
+
*/
|
|
10
|
+
function isFinancialAsset(asset) {
|
|
11
|
+
return [
|
|
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,
|
|
17
|
+
].includes(asset.type);
|
|
18
|
+
}
|
|
19
|
+
exports.isFinancialAsset = isFinancialAsset;
|
|
20
|
+
/**
|
|
21
|
+
* @description Is Asset a Real Estate Asset.
|
|
22
|
+
* @param {Asset} asset An Asset.
|
|
23
|
+
* @returns {boolean} returns true if Asset is a Real Estate Asset.
|
|
24
|
+
*/
|
|
25
|
+
function isRealEstateAsset(asset) {
|
|
26
|
+
return asset.type === public_asset_1.AssetType.Property;
|
|
27
|
+
}
|
|
28
|
+
exports.isRealEstateAsset = isRealEstateAsset;
|
|
29
|
+
/**
|
|
30
|
+
* @description Is Asset a Motor Vehicle.
|
|
31
|
+
* @param {Asset} asset An Asset.
|
|
32
|
+
* @returns {boolean} returns true if an Asset is a vehicle.
|
|
33
|
+
*/
|
|
34
|
+
function isMotorVehicle(asset) {
|
|
35
|
+
return asset.type === public_asset_1.AssetType.Vehicle;
|
|
36
|
+
}
|
|
37
|
+
exports.isMotorVehicle = isMotorVehicle;
|
|
38
|
+
/**
|
|
39
|
+
* @description Is Asset of LIXI type `OtherAsset`.
|
|
40
|
+
* @param {Asset} asset An Asset.
|
|
41
|
+
* @returns {boolean} returns true if asset is `OtherAsset`.
|
|
42
|
+
*/
|
|
43
|
+
function isOtherAsset(asset) {
|
|
44
|
+
return [public_asset_1.AssetType.HomeContents, public_asset_1.AssetType.Gifts, public_asset_1.AssetType.OtherAsset].includes(asset.type);
|
|
45
|
+
}
|
|
46
|
+
exports.isOtherAsset = isOtherAsset;
|