@lendi/integrations-transform 1.0.7 → 1.1.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.d.ts +7 -0
- package/lib/index.js +20 -0
- package/lib/logger.d.ts +2 -0
- package/lib/logger.js +5 -0
- package/lib/schemas/credit-report-retrieved-event.json +57 -0
- package/lib/schemas/public-applicant-event.json +652 -0
- package/lib/schemas/public-application-event.json +224 -0
- package/lib/schemas/public-asset-event.json +633 -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 +610 -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 +302 -0
- package/lib/schemas/public-expense-delete-event.json +41 -0
- package/lib/schemas/public-expense-event.json +132 -0
- package/lib/schemas/public-funding-position-event.json +289 -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 +234 -0
- package/lib/schemas/public-required-document-event.json +98 -0
- package/lib/schemas/public-update-applicant-event.json +607 -0
- package/lib/schemas/sf-opportunity-event-out.json +138 -0
- package/lib/transform-events/generate-asset-liability-link.d.ts +8 -0
- package/lib/transform-events/generate-asset-liability-link.js +29 -0
- package/lib/transform-events/generate-asset.d.ts +17 -0
- package/lib/transform-events/generate-asset.js +178 -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/generate-employment.d.ts +8 -0
- package/lib/transform-events/generate-employment.js +106 -0
- package/lib/transform-events/generate-funding-position.d.ts +18 -0
- package/lib/transform-events/generate-funding-position.js +82 -0
- package/lib/transform-events/generate-income.d.ts +37 -0
- package/lib/transform-events/generate-income.js +254 -0
- package/lib/transform-events/generate-liability.d.ts +8 -0
- package/lib/transform-events/generate-liability.js +87 -0
- package/lib/transform-events/generate-lixi-percentowned.d.ts +9 -0
- package/lib/transform-events/generate-lixi-percentowned.js +24 -0
- package/lib/transform-events/generate-opportunity.d.ts +8 -0
- package/lib/transform-events/generate-opportunity.js +32 -0
- package/lib/transform-events/generate-required-document.d.ts +8 -0
- package/lib/transform-events/generate-required-document.js +54 -0
- package/lib/transform-events/transform-applicant.d.ts +33 -0
- package/lib/transform-events/transform-applicant.js +189 -0
- package/lib/transform-events/transform-application.d.ts +8 -0
- package/lib/transform-events/transform-application.js +54 -0
- package/lib/transform-events/transform-expenses.d.ts +37 -0
- package/lib/transform-events/transform-expenses.js +121 -0
- package/lib/types/enum-mappings/alieo-frequency.d.ts +15 -0
- package/lib/types/enum-mappings/alieo-frequency.js +26 -0
- package/lib/types/enum-mappings/country-code.d.ts +7 -0
- package/lib/types/enum-mappings/country-code.js +247 -0
- package/lib/types/enum-mappings/employment-basis.d.ts +7 -0
- package/lib/types/enum-mappings/employment-basis.js +13 -0
- package/lib/types/enum-mappings/expense-frequency.d.ts +7 -0
- package/lib/types/enum-mappings/expense-frequency.js +12 -0
- package/lib/types/enum-mappings/funding-position.d.ts +18 -0
- package/lib/types/enum-mappings/funding-position.js +34 -0
- package/lib/types/enum-mappings/government-benefits.d.ts +7 -0
- package/lib/types/enum-mappings/government-benefits.js +11 -0
- package/lib/types/enum-mappings/housing-status.d.ts +7 -0
- package/lib/types/enum-mappings/housing-status.js +16 -0
- package/lib/types/enum-mappings/income-type.d.ts +7 -0
- package/lib/types/enum-mappings/income-type.js +17 -0
- package/lib/types/enum-mappings/liability-payment-type.d.ts +7 -0
- package/lib/types/enum-mappings/liability-payment-type.js +10 -0
- package/lib/types/enum-mappings/liability-type.d.ts +7 -0
- package/lib/types/enum-mappings/liability-type.js +22 -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 +13 -0
- package/lib/types/enum-mappings/postcode.d.ts +6 -0
- package/lib/types/enum-mappings/postcode.js +16 -0
- package/lib/types/enum-mappings/preferred-repayment.d.ts +7 -0
- package/lib/types/enum-mappings/preferred-repayment.js +11 -0
- package/lib/types/enum-mappings/proof-of-identity.d.ts +7 -0
- package/lib/types/enum-mappings/proof-of-identity.js +11 -0
- package/lib/types/enum-mappings/public-financial-asset.d.ts +7 -0
- package/lib/types/enum-mappings/public-financial-asset.js +13 -0
- package/lib/types/enum-mappings/public-primary-purpose.d.ts +7 -0
- package/lib/types/enum-mappings/public-primary-purpose.js +10 -0
- package/lib/types/enum-mappings/public-property-status.d.ts +7 -0
- package/lib/types/enum-mappings/public-property-status.js +12 -0
- package/lib/types/enum-mappings/public-property-type.d.ts +7 -0
- package/lib/types/enum-mappings/public-property-type.js +24 -0
- package/lib/types/enum-mappings/residency-status.d.ts +7 -0
- package/lib/types/enum-mappings/residency-status.js +12 -0
- package/lib/types/enum-mappings/title-gender.d.ts +7 -0
- package/lib/types/enum-mappings/title-gender.js +14 -0
- package/lib/types/enum-mappings/title.d.ts +7 -0
- package/lib/types/enum-mappings/title.js +14 -0
- package/lib/types/enum-mappings/transaction-type.d.ts +7 -0
- package/lib/types/enum-mappings/transaction-type.js +10 -0
- package/lib/types/events/applicant-delete.d.ts +42 -0
- package/lib/types/events/applicant-delete.js +15 -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 +485 -0
- package/lib/types/events/public-applicant.js +343 -0
- package/lib/types/events/public-application.d.ts +145 -0
- package/lib/types/events/public-application.js +100 -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 +469 -0
- package/lib/types/events/public-asset.js +319 -0
- package/lib/types/events/public-employment.d.ts +190 -0
- package/lib/types/events/public-employment.js +69 -0
- package/lib/types/events/public-expense.d.ts +83 -0
- package/lib/types/events/public-expense.js +50 -0
- package/lib/types/events/public-funding-position.d.ts +226 -0
- package/lib/types/events/public-funding-position.js +7 -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 +133 -0
- package/lib/types/events/public-liability.js +68 -0
- package/lib/types/events/public-required-document.d.ts +99 -0
- package/lib/types/events/public-required-document.js +44 -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/utils/address-tools.d.ts +69 -0
- package/lib/utils/address-tools.js +146 -0
- package/lib/utils/clean-up.d.ts +7 -0
- package/lib/utils/clean-up.js +24 -0
- package/lib/utils/generate-address.d.ts +19 -0
- package/lib/utils/generate-address.js +102 -0
- package/lib/utils/get-financial-institution.d.ts +7 -0
- package/lib/utils/get-financial-institution.js +16 -0
- package/lib/utils/is-income-type.d.ts +83 -0
- package/lib/utils/is-income-type.js +166 -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 +10 -7
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Required Document event schema
|
|
3
|
+
*/
|
|
4
|
+
export interface PublicRequiredDocument {
|
|
5
|
+
payload: Payload;
|
|
6
|
+
type: Type;
|
|
7
|
+
/**
|
|
8
|
+
* schema version
|
|
9
|
+
*/
|
|
10
|
+
version: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Payload {
|
|
13
|
+
/**
|
|
14
|
+
* Application ID
|
|
15
|
+
*/
|
|
16
|
+
applicantId: string;
|
|
17
|
+
/**
|
|
18
|
+
* Application ID
|
|
19
|
+
*/
|
|
20
|
+
applicationId: string;
|
|
21
|
+
/**
|
|
22
|
+
* Created at ISO date time
|
|
23
|
+
*/
|
|
24
|
+
createdAt?: string;
|
|
25
|
+
eConsent?: EConsent;
|
|
26
|
+
/**
|
|
27
|
+
* Required Document ID
|
|
28
|
+
*/
|
|
29
|
+
id: string;
|
|
30
|
+
identification?: Identification;
|
|
31
|
+
/**
|
|
32
|
+
* Status
|
|
33
|
+
*/
|
|
34
|
+
status?: Status;
|
|
35
|
+
}
|
|
36
|
+
export interface EConsent {
|
|
37
|
+
/**
|
|
38
|
+
* Consented at ISO date time
|
|
39
|
+
*/
|
|
40
|
+
consentedAt?: string;
|
|
41
|
+
/**
|
|
42
|
+
* eConsent
|
|
43
|
+
*/
|
|
44
|
+
hasConsented: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface Identification {
|
|
47
|
+
/**
|
|
48
|
+
* Gender (can be null if migrated from SF as they do not have this field)
|
|
49
|
+
*/
|
|
50
|
+
gender?: Gender | null;
|
|
51
|
+
/**
|
|
52
|
+
* ID Number
|
|
53
|
+
*/
|
|
54
|
+
idNumber: string;
|
|
55
|
+
/**
|
|
56
|
+
* ID Title (can be null if migrated from SF as they do not have this field)
|
|
57
|
+
*/
|
|
58
|
+
idTitle?: IDTitle | null;
|
|
59
|
+
/**
|
|
60
|
+
* ID Type
|
|
61
|
+
*/
|
|
62
|
+
idType: IDType;
|
|
63
|
+
}
|
|
64
|
+
export declare enum Gender {
|
|
65
|
+
Female = "FEMALE",
|
|
66
|
+
Male = "MALE"
|
|
67
|
+
}
|
|
68
|
+
export declare enum IDTitle {
|
|
69
|
+
DR = "DR",
|
|
70
|
+
MS = "MS",
|
|
71
|
+
Miss = "MISS",
|
|
72
|
+
Mr = "MR",
|
|
73
|
+
Mrs = "MRS",
|
|
74
|
+
Other = "OTHER",
|
|
75
|
+
Unknown = "UNKNOWN"
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* ID Type
|
|
79
|
+
*/
|
|
80
|
+
export declare enum IDType {
|
|
81
|
+
AustralianDriverLicense = "australian_driver_license",
|
|
82
|
+
NationalIDCard = "national_id_card",
|
|
83
|
+
Passport = "passport"
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Status
|
|
87
|
+
*/
|
|
88
|
+
export declare enum Status {
|
|
89
|
+
Expired = "expired",
|
|
90
|
+
FailedVerification = "failed_verification",
|
|
91
|
+
NotRequired = "not_required",
|
|
92
|
+
PendingUpload = "pending_upload",
|
|
93
|
+
PendingVerification = "pending_verification",
|
|
94
|
+
Verified = "verified"
|
|
95
|
+
}
|
|
96
|
+
export declare enum Type {
|
|
97
|
+
RequiredDocumentCreated = "RequiredDocumentCreated",
|
|
98
|
+
RequiredDocumentUpdated = "RequiredDocumentUpdated"
|
|
99
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.Type = exports.Status = exports.IDType = exports.IDTitle = exports.Gender = void 0;
|
|
4
|
+
var Gender;
|
|
5
|
+
(function (Gender) {
|
|
6
|
+
Gender["Female"] = "FEMALE";
|
|
7
|
+
Gender["Male"] = "MALE";
|
|
8
|
+
})(Gender = exports.Gender || (exports.Gender = {}));
|
|
9
|
+
var IDTitle;
|
|
10
|
+
(function (IDTitle) {
|
|
11
|
+
IDTitle["DR"] = "DR";
|
|
12
|
+
IDTitle["MS"] = "MS";
|
|
13
|
+
IDTitle["Miss"] = "MISS";
|
|
14
|
+
IDTitle["Mr"] = "MR";
|
|
15
|
+
IDTitle["Mrs"] = "MRS";
|
|
16
|
+
IDTitle["Other"] = "OTHER";
|
|
17
|
+
IDTitle["Unknown"] = "UNKNOWN";
|
|
18
|
+
})(IDTitle = exports.IDTitle || (exports.IDTitle = {}));
|
|
19
|
+
/**
|
|
20
|
+
* ID Type
|
|
21
|
+
*/
|
|
22
|
+
var IDType;
|
|
23
|
+
(function (IDType) {
|
|
24
|
+
IDType["AustralianDriverLicense"] = "australian_driver_license";
|
|
25
|
+
IDType["NationalIDCard"] = "national_id_card";
|
|
26
|
+
IDType["Passport"] = "passport";
|
|
27
|
+
})(IDType = exports.IDType || (exports.IDType = {}));
|
|
28
|
+
/**
|
|
29
|
+
* Status
|
|
30
|
+
*/
|
|
31
|
+
var Status;
|
|
32
|
+
(function (Status) {
|
|
33
|
+
Status["Expired"] = "expired";
|
|
34
|
+
Status["FailedVerification"] = "failed_verification";
|
|
35
|
+
Status["NotRequired"] = "not_required";
|
|
36
|
+
Status["PendingUpload"] = "pending_upload";
|
|
37
|
+
Status["PendingVerification"] = "pending_verification";
|
|
38
|
+
Status["Verified"] = "verified";
|
|
39
|
+
})(Status = exports.Status || (exports.Status = {}));
|
|
40
|
+
var Type;
|
|
41
|
+
(function (Type) {
|
|
42
|
+
Type["RequiredDocumentCreated"] = "RequiredDocumentCreated";
|
|
43
|
+
Type["RequiredDocumentUpdated"] = "RequiredDocumentUpdated";
|
|
44
|
+
})(Type = exports.Type || (exports.Type = {}));
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A set of tools for manipulating addresses in LIXI applications.
|
|
3
|
+
*/
|
|
4
|
+
import { AddressType, CurrentAddress, PreviousAddress } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
5
|
+
import { CommonAddressProperties, 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 declare 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 declare type PathMappedTransform = Record<string, MappedTransform>;
|
|
27
|
+
export declare const lixiContactAddressMapping: PathMappedTransform;
|
|
28
|
+
/**
|
|
29
|
+
* The transform map used for the LIXI address
|
|
30
|
+
*/
|
|
31
|
+
export declare const lixiAddressMapping: PathMappedTransform;
|
|
32
|
+
/**
|
|
33
|
+
* Transforms a source object by applying a PathMappedTransform.
|
|
34
|
+
*
|
|
35
|
+
* @param source A source object to be mapped and transformed
|
|
36
|
+
* @param pathMappedTransform A PathMappedTransform to be applied to the source
|
|
37
|
+
*/
|
|
38
|
+
export declare function mapTransform<T>(source: any, pathMappedTransform: PathMappedTransform): T;
|
|
39
|
+
declare type EventAddressType = InternalPreviousAddress | CommonAddressProperties;
|
|
40
|
+
export declare type LixiContactAddressType = CurrentAddress | PreviousAddress;
|
|
41
|
+
export interface AddressTransformedType {
|
|
42
|
+
lixiAddress: AddressType;
|
|
43
|
+
lixiContactAddress: LixiContactAddressType;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Converts an address object from an event model to a LIXI address and corresponding LIXI contact address object.
|
|
47
|
+
*
|
|
48
|
+
* @param eventAddress
|
|
49
|
+
* @param addressId
|
|
50
|
+
*/
|
|
51
|
+
export declare function rebuildAddress(eventAddress: EventAddressType, addressId: string): AddressTransformedType;
|
|
52
|
+
/**
|
|
53
|
+
* * Converts a previous address object from an event model to a LIXI address and corresponding LIXI current address object.
|
|
54
|
+
* @param eventPreviousAddresses
|
|
55
|
+
* @param addressId
|
|
56
|
+
*/
|
|
57
|
+
export declare function rebuildPreviousAddress(eventPreviousAddresses: InternalPreviousAddress[], addressId: string): AddressTransformedType;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if an event is missing country.
|
|
60
|
+
* @param addressEvent
|
|
61
|
+
*/
|
|
62
|
+
export declare function isMissingCountry(addressEvent: EventAddressType): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Sets the country from the last item on the formatted address.
|
|
65
|
+
*
|
|
66
|
+
* @param address
|
|
67
|
+
*/
|
|
68
|
+
export declare function setCountry(address: EventAddressType): EventAddressType;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A set of tools for manipulating addresses in LIXI applications.
|
|
4
|
+
*/
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.setCountry = exports.isMissingCountry = exports.rebuildPreviousAddress = exports.rebuildAddress = exports.mapTransform = exports.lixiAddressMapping = exports.lixiContactAddressMapping = void 0;
|
|
7
|
+
var lodash_1 = require("lodash");
|
|
8
|
+
var country_code_1 = require("../types/enum-mappings/country-code");
|
|
9
|
+
var housing_status_1 = require("../types/enum-mappings/housing-status");
|
|
10
|
+
var public_applicant_1 = require("../types/events/public-applicant");
|
|
11
|
+
var generate_address_1 = require("./generate-address");
|
|
12
|
+
exports.lixiContactAddressMapping = {
|
|
13
|
+
externalId: {
|
|
14
|
+
path: '@x_ResidentialAddress'
|
|
15
|
+
},
|
|
16
|
+
housingStatus: {
|
|
17
|
+
path: '@HousingStatus',
|
|
18
|
+
transform: function (value) { return housing_status_1.housingStatusMapping[value]; }
|
|
19
|
+
},
|
|
20
|
+
startDate: {
|
|
21
|
+
path: '@StartDate'
|
|
22
|
+
},
|
|
23
|
+
endDate: {
|
|
24
|
+
path: '@EndDate'
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The transform map used for the LIXI address
|
|
29
|
+
*/
|
|
30
|
+
exports.lixiAddressMapping = {
|
|
31
|
+
externalId: {
|
|
32
|
+
path: '@UniqueID'
|
|
33
|
+
},
|
|
34
|
+
'residentialAddress.city': {
|
|
35
|
+
path: '@Suburb'
|
|
36
|
+
},
|
|
37
|
+
'residentialAddress.country': {
|
|
38
|
+
path: '@Country',
|
|
39
|
+
transform: function (value) { return country_code_1.countryCodeMapping[value]; }
|
|
40
|
+
},
|
|
41
|
+
'residentialAddress.postcode': {
|
|
42
|
+
path: '@AustralianPostCode'
|
|
43
|
+
},
|
|
44
|
+
'residentialAddress.state': {
|
|
45
|
+
path: '@AustralianState'
|
|
46
|
+
},
|
|
47
|
+
'residentialAddress.standard.level': {
|
|
48
|
+
path: 'Standard.@Level'
|
|
49
|
+
},
|
|
50
|
+
'residentialAddress.standard.streetName': {
|
|
51
|
+
path: 'Standard.@StreetName'
|
|
52
|
+
},
|
|
53
|
+
'residentialAddress.standard.streetNumber': {
|
|
54
|
+
path: 'Standard.@StreetNumber',
|
|
55
|
+
transform: function (value) { return value.substring(0, generate_address_1.StreetNumberMaxLength); }
|
|
56
|
+
},
|
|
57
|
+
'residentialAddress.standard.streetType': {
|
|
58
|
+
path: 'Standard.@StreetType'
|
|
59
|
+
},
|
|
60
|
+
'residentialAddress.standard.unit': {
|
|
61
|
+
path: 'Standard.@Unit'
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Transforms a source object by applying a PathMappedTransform.
|
|
66
|
+
*
|
|
67
|
+
* @param source A source object to be mapped and transformed
|
|
68
|
+
* @param pathMappedTransform A PathMappedTransform to be applied to the source
|
|
69
|
+
*/
|
|
70
|
+
function mapTransform(source, pathMappedTransform) {
|
|
71
|
+
var finalTransform = {};
|
|
72
|
+
Object.entries(pathMappedTransform).forEach(function (_a) {
|
|
73
|
+
var key = _a[0], _b = _a[1], transform = _b.transform, path = _b.path;
|
|
74
|
+
var sourceValue = (0, lodash_1.get)(source, key);
|
|
75
|
+
if (sourceValue) {
|
|
76
|
+
(0, lodash_1.set)(finalTransform, path, (transform === null || transform === void 0 ? void 0 : transform(sourceValue)) || sourceValue);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return finalTransform;
|
|
80
|
+
}
|
|
81
|
+
exports.mapTransform = mapTransform;
|
|
82
|
+
var postcodePathString = 'residentialAddress.postcode';
|
|
83
|
+
var statePathString = 'residentialAddress.state';
|
|
84
|
+
/**
|
|
85
|
+
* Converts an address object from an event model to a LIXI address and corresponding LIXI contact address object.
|
|
86
|
+
*
|
|
87
|
+
* @param eventAddress
|
|
88
|
+
* @param addressId
|
|
89
|
+
*/
|
|
90
|
+
function rebuildAddress(eventAddress, addressId) {
|
|
91
|
+
if (isMissingCountry(eventAddress)) {
|
|
92
|
+
setCountry(eventAddress);
|
|
93
|
+
}
|
|
94
|
+
if ((0, lodash_1.get)(eventAddress, 'residentialAddress.country') !== public_applicant_1.Countries.Australia) {
|
|
95
|
+
exports.lixiAddressMapping[postcodePathString] = { path: '@OverseasPostCode' };
|
|
96
|
+
exports.lixiAddressMapping[statePathString] = { path: '@OverseasState' };
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
exports.lixiAddressMapping[postcodePathString] = { path: '@AustralianPostCode' };
|
|
100
|
+
exports.lixiAddressMapping[statePathString] = { path: '@AustralianState' };
|
|
101
|
+
}
|
|
102
|
+
var lixiAddress = mapTransform(eventAddress, exports.lixiAddressMapping);
|
|
103
|
+
var lixiContactAddress = mapTransform(eventAddress, exports.lixiContactAddressMapping);
|
|
104
|
+
lixiAddress['@UniqueID'] = addressId;
|
|
105
|
+
lixiContactAddress['@x_ResidentialAddress'] = addressId;
|
|
106
|
+
return { lixiAddress: lixiAddress, lixiContactAddress: lixiContactAddress };
|
|
107
|
+
}
|
|
108
|
+
exports.rebuildAddress = rebuildAddress;
|
|
109
|
+
/**
|
|
110
|
+
* * Converts a previous address object from an event model to a LIXI address and corresponding LIXI current address object.
|
|
111
|
+
* @param eventPreviousAddresses
|
|
112
|
+
* @param addressId
|
|
113
|
+
*/
|
|
114
|
+
function rebuildPreviousAddress(eventPreviousAddresses, addressId) {
|
|
115
|
+
if (eventPreviousAddresses === void 0) { eventPreviousAddresses = []; }
|
|
116
|
+
if (eventPreviousAddresses.length === 0)
|
|
117
|
+
return null;
|
|
118
|
+
var previousAddress = eventPreviousAddresses.sort(function (lhs, rhs) { return lhs.endDate.localeCompare(rhs.endDate); }).pop();
|
|
119
|
+
return rebuildAddress(previousAddress, addressId);
|
|
120
|
+
}
|
|
121
|
+
exports.rebuildPreviousAddress = rebuildPreviousAddress;
|
|
122
|
+
/**
|
|
123
|
+
* Checks if an event is missing country.
|
|
124
|
+
* @param addressEvent
|
|
125
|
+
*/
|
|
126
|
+
function isMissingCountry(addressEvent) {
|
|
127
|
+
if (addressEvent.residentialAddress && addressEvent.residentialAddress.formatted) {
|
|
128
|
+
return !(0, lodash_1.get)(addressEvent, 'residentialAddress.country');
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
exports.isMissingCountry = isMissingCountry;
|
|
133
|
+
/**
|
|
134
|
+
* Sets the country from the last item on the formatted address.
|
|
135
|
+
*
|
|
136
|
+
* @param address
|
|
137
|
+
*/
|
|
138
|
+
function setCountry(address) {
|
|
139
|
+
var _a;
|
|
140
|
+
var formatted = (0, lodash_1.get)(address, 'residentialAddress.formatted');
|
|
141
|
+
if (formatted && !address.residentialAddress.country) {
|
|
142
|
+
address.residentialAddress.country = (_a = formatted.split(',').pop()) === null || _a === void 0 ? void 0 : _a.trim();
|
|
143
|
+
}
|
|
144
|
+
return address;
|
|
145
|
+
}
|
|
146
|
+
exports.setCountry = setCountry;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.cleanUp = void 0;
|
|
4
|
+
/* istanbul ignore file */
|
|
5
|
+
var clean_deep_1 = require("clean-deep");
|
|
6
|
+
/**
|
|
7
|
+
* Recursively removes nulls from nested objects and arrays
|
|
8
|
+
*
|
|
9
|
+
* @param payload any
|
|
10
|
+
* @return result of sanitised object.
|
|
11
|
+
*/
|
|
12
|
+
function cleanUp(payload) {
|
|
13
|
+
// cleanDeep configurations.
|
|
14
|
+
var 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,19 @@
|
|
|
1
|
+
import { AddressType, Standard, StreetTypeList } from '@lendi/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: An address object.
|
|
9
|
+
* @param id: Id of asset object.
|
|
10
|
+
* @return 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
|
+
* @return A transformed standard object.
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateStandard(addressStandard: AddressStandard): Standard;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.generateStandard = exports.generateAddress = exports.StreetTypeArray = exports.StreetNumberMaxLength = void 0;
|
|
4
|
+
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
+
var lodash_1 = require("lodash");
|
|
6
|
+
var country_code_1 = require("..//types/enum-mappings/country-code");
|
|
7
|
+
var postcode_1 = require("../types/enum-mappings/postcode");
|
|
8
|
+
var public_asset_1 = require("../types/events/public-asset");
|
|
9
|
+
exports.StreetNumberMaxLength = 16;
|
|
10
|
+
var addressMapping = {
|
|
11
|
+
country: '@Country',
|
|
12
|
+
city: '@Suburb',
|
|
13
|
+
postcode: '@AustralianPostCode',
|
|
14
|
+
state: '@AustralianState',
|
|
15
|
+
standard: 'Standard'
|
|
16
|
+
};
|
|
17
|
+
var standardMapping = {
|
|
18
|
+
streetName: '@StreetName',
|
|
19
|
+
streetType: '@StreetType',
|
|
20
|
+
streetNumber: '@StreetNumber',
|
|
21
|
+
level: '@Level',
|
|
22
|
+
unit: '@Unit'
|
|
23
|
+
};
|
|
24
|
+
exports.StreetTypeArray = Object.values(lixi_internal_request_1.StreetTypeList);
|
|
25
|
+
/**
|
|
26
|
+
* Generates an address for an asset.
|
|
27
|
+
|
|
28
|
+
* @param address: An address object.
|
|
29
|
+
* @param id: Id of asset object.
|
|
30
|
+
* @return A transformed address object.
|
|
31
|
+
*/
|
|
32
|
+
function generateAddress(address, id) {
|
|
33
|
+
var _a;
|
|
34
|
+
var transformedAddress = {
|
|
35
|
+
'@Country': lixi_internal_request_1.CountryCodeList.Au,
|
|
36
|
+
'@UniqueID': id
|
|
37
|
+
};
|
|
38
|
+
var country = (((_a = address.formatted) === null || _a === void 0 ? void 0 : _a.split(',').pop()) || '').trim();
|
|
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 (var _i = 0, _b = Object.entries(address); _i < _b.length; _i++) {
|
|
54
|
+
var _c = _b[_i], key = _c[0], value = _c[1];
|
|
55
|
+
if (addressMapping[key]) {
|
|
56
|
+
switch (key) {
|
|
57
|
+
case 'standard':
|
|
58
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], generateStandard(value));
|
|
59
|
+
break;
|
|
60
|
+
case 'country':
|
|
61
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], country_code_1.countryCodeMapping[value]);
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], value);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return transformedAddress;
|
|
70
|
+
}
|
|
71
|
+
exports.generateAddress = generateAddress;
|
|
72
|
+
/**
|
|
73
|
+
* Generates an address standard.
|
|
74
|
+
*
|
|
75
|
+
* @param addressStandard An address standard object.
|
|
76
|
+
* @return A transformed standard object.
|
|
77
|
+
*/
|
|
78
|
+
function generateStandard(addressStandard) {
|
|
79
|
+
var transformedStandard = {};
|
|
80
|
+
var _loop_1 = function (key, value) {
|
|
81
|
+
if (standardMapping[key]) {
|
|
82
|
+
switch (key) {
|
|
83
|
+
case 'streetNumber':
|
|
84
|
+
(0, lodash_1.set)(transformedStandard, standardMapping[key], value.substring(0, exports.StreetNumberMaxLength));
|
|
85
|
+
break;
|
|
86
|
+
case 'streetType':
|
|
87
|
+
var streetType = exports.StreetTypeArray.find(function (type) { return type.toLowerCase() === value.toLowerCase(); });
|
|
88
|
+
(0, lodash_1.set)(transformedStandard, standardMapping[key], streetType || lixi_internal_request_1.StreetTypeList.Street);
|
|
89
|
+
break;
|
|
90
|
+
default:
|
|
91
|
+
(0, lodash_1.set)(transformedStandard, standardMapping[key], value);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
for (var _i = 0, _a = Object.entries(addressStandard); _i < _a.length; _i++) {
|
|
97
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
98
|
+
_loop_1(key, value);
|
|
99
|
+
}
|
|
100
|
+
return transformedStandard;
|
|
101
|
+
}
|
|
102
|
+
exports.generateStandard = generateStandard;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FinancialInstitutionList } from '@lendi/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
|
+
*/
|
|
7
|
+
export declare function getFinancialInstitution(institution: string): FinancialInstitutionList;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.getFinancialInstitution = void 0;
|
|
4
|
+
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
+
var financialInstitutions = Object.values(lixi_internal_request_1.FinancialInstitutionList);
|
|
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
|
+
*/
|
|
11
|
+
function getFinancialInstitution(institution) {
|
|
12
|
+
var institutionUpperCased = institution.toUpperCase();
|
|
13
|
+
var financialInstitution = financialInstitutions.find(function (item) { return item.toUpperCase() === institutionUpperCased; });
|
|
14
|
+
return financialInstitution || lixi_internal_request_1.FinancialInstitutionList.Other;
|
|
15
|
+
}
|
|
16
|
+
exports.getFinancialInstitution = getFinancialInstitution;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { PersonApplicant } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
import { IncomeType, Income, IncomeBusinessDetails } from '../types/events/public-income';
|
|
3
|
+
export declare const descriptionOtherIncomeTypes: string[];
|
|
4
|
+
export declare const PAYGList: string[];
|
|
5
|
+
/**
|
|
6
|
+
* @description Is income type one of the PAYG income.
|
|
7
|
+
* @param {string} incomeType Income type.
|
|
8
|
+
* @returns {boolean} Returns true if Income type is a PAYG Income.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isPaygIncome(incomeType: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* @description Is income type SelfEmployedBusinessIncome.
|
|
13
|
+
* @param {string} incomeType Income type.
|
|
14
|
+
* @returns {boolean} Returns true if Income type is SelfEmployedBusinessIncome.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isSelfEmployedIncome(incomeType: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* @description Is income type Rental Income.
|
|
19
|
+
* @param {IncomeType} incomeType Income type.
|
|
20
|
+
* @returns {boolean} true if Income type is Rental Income.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isRentalIncome(incomeType: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* @description Is Income type one of OtherIncome types.
|
|
25
|
+
* @param {IncomeType} incomeType Income Type.
|
|
26
|
+
* @returns {boolean} returns true for other income.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isOtherIncome(incomeType: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @description Is Self Employed Full Doc or Low Doc Income
|
|
31
|
+
* @param incomeType Income Type from Event
|
|
32
|
+
* @returns {boolean} True if either Full Doc or Low Doc Self Employed Income.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isFullDocOrLowDocIncome(incomeType: IncomeType): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @description Checks if an Income event is a valid rental income event.
|
|
37
|
+
* @param {Income} income Income.
|
|
38
|
+
* @returns {boolean} true if event is a valid Rental Income.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isValidRentalIncomeEvent({ assetId, type: incomeType }: Income): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @description Is event valid PAYG income event.
|
|
43
|
+
* @param {Income} income Income.
|
|
44
|
+
* @param {PersonApplicant[]} applicants An array of applicants.
|
|
45
|
+
* @returns {boolean} true if Income type is a PAYG value and event is valid PAYG event.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isValidPaygIncomeEvent({ percentOwned, employmentId, type: incomeType }: Income, applicants?: PersonApplicant[]): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* @description Checks if an Income event is a valid self-employment income event.
|
|
50
|
+
* @param {Income} income Income.
|
|
51
|
+
* @param {PersonApplicant[]} applicants An array of applicants.
|
|
52
|
+
* @returns {boolean} Returns true if event is a valid self employment income event.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isValidSelfEmployedIncomeEvent({ percentOwned, employmentId, type: incomeType }: Income, applicants?: PersonApplicant[]): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* @description Get the employment ids for an applicant for a specific employment type.
|
|
57
|
+
* @param {PersonApplicant} applicant An applicant
|
|
58
|
+
* @param {string} key Employment type key: PAYG or SelfEmployed.
|
|
59
|
+
* @returns {string[]} An array of employment ids for the applicant of the specified type.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getEmploymentIds(applicant: PersonApplicant, key: 'PAYG' | 'SelfEmployed'): string[];
|
|
62
|
+
/**
|
|
63
|
+
* @description Get applicantId from an array of applicants given an employmentId and employmentType.
|
|
64
|
+
* @param {PersonApplicant[]} applicants An array of applicants.
|
|
65
|
+
* @param {string} employmentId EmploymentId
|
|
66
|
+
* @param {string} key Employment type: PAYG or SelfEmployed
|
|
67
|
+
* @returns {string | undefined} Returns applicantId or undefined.
|
|
68
|
+
*/
|
|
69
|
+
export declare function getStoredApplicantId(applicants: PersonApplicant[], employmentId: string, key: 'PAYG' | 'SelfEmployed'): string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* @description Get an applicantId from the event or the applicants.
|
|
72
|
+
* @param {Income} income Income.
|
|
73
|
+
* @param {PersonApplicant[]} applicants An array of LIXI applicants.
|
|
74
|
+
* @returns {string | undefined} An applicantId or undefined.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getApplicantId({ percentOwned, employmentId }: Income, applicants?: PersonApplicant[]): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* @description Sort Business Income By Year.
|
|
79
|
+
* @param incomeA Income Details for Self Employed Full Doc.
|
|
80
|
+
* @param incomeB Income Details for Self Employed Full Doc.
|
|
81
|
+
* @returns {0 | - 1 | 1} Returns a number to be used for sorting income.
|
|
82
|
+
*/
|
|
83
|
+
export declare function sortBusinessIncome({ year: yearA }: IncomeBusinessDetails, { year: yearB }: IncomeBusinessDetails): number;
|