@lendi/integrations-transform 1.4.0 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +1 -5
- package/lib/schemas/public-applicant-event.json +31 -0
- package/lib/transform-events/transform-asset.js +1 -1
- package/lib/types/enum-mappings/construction-type.js +1 -1
- package/lib/types/enum-mappings/index.js +1 -5
- package/lib/types/events/public-applicant.d.ts +20 -0
- package/lib/types/events/public-applicant.js +16 -1
- package/lib/update-application/update-primary-applicant.d.ts +30 -0
- package/lib/update-application/update-primary-applicant.js +63 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -63,6 +63,34 @@
|
|
|
63
63
|
"enum": ["EMPLOYEE", "SELF_EMPLOYED", "UNKNOWN"],
|
|
64
64
|
"description": "applicant's employment type"
|
|
65
65
|
},
|
|
66
|
+
"guarantorRelationshipToBorrowerApplicantId": {
|
|
67
|
+
"$ref": "#/definitions/id",
|
|
68
|
+
"description": "Applicant Id of borrower that has relationship with guarantor."
|
|
69
|
+
},
|
|
70
|
+
"guarantorRelationshipToBorrowerType": {
|
|
71
|
+
"enum": ["Father", "Mother", "Spouse", "Brother", "Sister", "Son", "Daughter", "Other Relative", "Other"],
|
|
72
|
+
"description": "The relationship between borrower and guarantor."
|
|
73
|
+
},
|
|
74
|
+
"guarantorRelationshipToBorrowerTypeOther": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"description": "Description of relationship between borrower and guarantor when other."
|
|
77
|
+
},
|
|
78
|
+
"guarantorRelationshipToBorrowerDefinition": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"additionalProperties": false,
|
|
81
|
+
"properties": {
|
|
82
|
+
"applicantId": {
|
|
83
|
+
"$ref": "#/definitions/guarantorRelationshipToBorrowerApplicantId"
|
|
84
|
+
},
|
|
85
|
+
"type": {
|
|
86
|
+
"$ref": "#/definitions/guarantorRelationshipToBorrowerType"
|
|
87
|
+
},
|
|
88
|
+
"typeOther": {
|
|
89
|
+
"$ref": "#/definitions/guarantorRelationshipToBorrowerTypeOther"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"required": ["applicantId", "type"]
|
|
93
|
+
},
|
|
66
94
|
"isPrimaryApplicant": {
|
|
67
95
|
"type": "boolean"
|
|
68
96
|
},
|
|
@@ -568,6 +596,9 @@
|
|
|
568
596
|
"employmentType": {
|
|
569
597
|
"$ref": "#/definitions/employmentType"
|
|
570
598
|
},
|
|
599
|
+
"guarantorRelationshipToBorrower": {
|
|
600
|
+
"$ref": "#/definitions/guarantorRelationshipToBorrowerDefinition"
|
|
601
|
+
},
|
|
571
602
|
"isPrimaryApplicant": {
|
|
572
603
|
"$ref": "#/definitions/isPrimaryApplicant"
|
|
573
604
|
},
|
|
@@ -110,7 +110,7 @@ function transformAsset(_a) {
|
|
|
110
110
|
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyExpense"), propertyExpenses);
|
|
111
111
|
var livingExpenses = generateLivingExpenses(asset.percentOwned, id, value);
|
|
112
112
|
(0, lodash_1.set)(partialApplication, assetMapping[key], livingExpenses);
|
|
113
|
-
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, "
|
|
113
|
+
(0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@Occupancy"), determineOccupancy(value));
|
|
114
114
|
break;
|
|
115
115
|
case 'propertyStatus':
|
|
116
116
|
(0, lodash_1.set)(partialApplication, assetMapping[key], enum_mappings_1.propertyStatusMapping[value]);
|
|
@@ -6,6 +6,6 @@ var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types
|
|
|
6
6
|
var public_asset_1 = require("../events/public-asset");
|
|
7
7
|
exports.constructionTypeMapping = (_a = {},
|
|
8
8
|
_a[public_asset_1.ConstructionType.BuildAProperty] = lixi_internal_request_1.ConstructionTypeList.FullConstruction,
|
|
9
|
-
_a[public_asset_1.ConstructionType.KnockdownRebuild] = lixi_internal_request_1.ConstructionTypeList.
|
|
9
|
+
_a[public_asset_1.ConstructionType.KnockdownRebuild] = lixi_internal_request_1.ConstructionTypeList.HomeExtension,
|
|
10
10
|
_a[public_asset_1.ConstructionType.StructuralRenovations] = lixi_internal_request_1.ConstructionTypeList.Renovation,
|
|
11
11
|
_a);
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -36,6 +36,7 @@ export interface Payload {
|
|
|
36
36
|
entity?: Entity;
|
|
37
37
|
firstName?: string;
|
|
38
38
|
gender?: Gender;
|
|
39
|
+
guarantorRelationshipToBorrower?: GuarantorRelationshipToBorrowerDefinition;
|
|
39
40
|
hasSelfEmploymentProof?: boolean;
|
|
40
41
|
/**
|
|
41
42
|
* uuid of applicant
|
|
@@ -429,6 +430,25 @@ export declare enum Gender {
|
|
|
429
430
|
Undisclosed = "UNDISCLOSED",
|
|
430
431
|
Unknown = "UNKNOWN"
|
|
431
432
|
}
|
|
433
|
+
export interface GuarantorRelationshipToBorrowerDefinition {
|
|
434
|
+
applicantId: string;
|
|
435
|
+
type: GuarantorRelationshipToBorrowerType;
|
|
436
|
+
typeOther?: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* The relationship between borrower and guarantor.
|
|
440
|
+
*/
|
|
441
|
+
export declare enum GuarantorRelationshipToBorrowerType {
|
|
442
|
+
Brother = "Brother",
|
|
443
|
+
Daughter = "Daughter",
|
|
444
|
+
Father = "Father",
|
|
445
|
+
Mother = "Mother",
|
|
446
|
+
Other = "Other",
|
|
447
|
+
OtherRelative = "Other Relative",
|
|
448
|
+
Sister = "Sister",
|
|
449
|
+
Son = "Son",
|
|
450
|
+
Spouse = "Spouse"
|
|
451
|
+
}
|
|
432
452
|
/**
|
|
433
453
|
* different invitation statuses an applicant can have
|
|
434
454
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.Type = exports.Title = exports.ResidencyStatus = exports.ActionedByRole = exports.MaritalStatus = exports.InvitationStatus = exports.Gender = exports.Entity = exports.EmploymentType = exports.CreditStatus = exports.HousingStatusList = exports.Countries = exports.ApplicantType = void 0;
|
|
3
|
+
exports.Type = exports.Title = exports.ResidencyStatus = exports.ActionedByRole = exports.MaritalStatus = exports.InvitationStatus = exports.GuarantorRelationshipToBorrowerType = exports.Gender = exports.Entity = exports.EmploymentType = exports.CreditStatus = exports.HousingStatusList = exports.Countries = exports.ApplicantType = void 0;
|
|
4
4
|
var ApplicantType;
|
|
5
5
|
(function (ApplicantType) {
|
|
6
6
|
ApplicantType["Borrower"] = "BORROWER";
|
|
@@ -294,6 +294,21 @@ var Gender;
|
|
|
294
294
|
Gender["Undisclosed"] = "UNDISCLOSED";
|
|
295
295
|
Gender["Unknown"] = "UNKNOWN";
|
|
296
296
|
})(Gender = exports.Gender || (exports.Gender = {}));
|
|
297
|
+
/**
|
|
298
|
+
* The relationship between borrower and guarantor.
|
|
299
|
+
*/
|
|
300
|
+
var GuarantorRelationshipToBorrowerType;
|
|
301
|
+
(function (GuarantorRelationshipToBorrowerType) {
|
|
302
|
+
GuarantorRelationshipToBorrowerType["Brother"] = "Brother";
|
|
303
|
+
GuarantorRelationshipToBorrowerType["Daughter"] = "Daughter";
|
|
304
|
+
GuarantorRelationshipToBorrowerType["Father"] = "Father";
|
|
305
|
+
GuarantorRelationshipToBorrowerType["Mother"] = "Mother";
|
|
306
|
+
GuarantorRelationshipToBorrowerType["Other"] = "Other";
|
|
307
|
+
GuarantorRelationshipToBorrowerType["OtherRelative"] = "Other Relative";
|
|
308
|
+
GuarantorRelationshipToBorrowerType["Sister"] = "Sister";
|
|
309
|
+
GuarantorRelationshipToBorrowerType["Son"] = "Son";
|
|
310
|
+
GuarantorRelationshipToBorrowerType["Spouse"] = "Spouse";
|
|
311
|
+
})(GuarantorRelationshipToBorrowerType = exports.GuarantorRelationshipToBorrowerType || (exports.GuarantorRelationshipToBorrowerType = {}));
|
|
297
312
|
/**
|
|
298
313
|
* different invitation statuses an applicant can have
|
|
299
314
|
*/
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PersonApplicant } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
|
+
import { PartialApplication } from '../types/partial-application';
|
|
3
|
+
import { Payload } from '../types/events/public-applicant';
|
|
4
|
+
/**
|
|
5
|
+
* Checks if there are more than one person applicants with applicant type borrower
|
|
6
|
+
*
|
|
7
|
+
* @param {PersonApplicants[]} personApplicants - Person applicants on the deep merged application
|
|
8
|
+
*
|
|
9
|
+
* @returns {boolean} - Whether or not there are more than one applicant with applicant type borrower
|
|
10
|
+
*/
|
|
11
|
+
export declare const isMultiplePersonApplicantBorrowers: (personApplicants: PersonApplicant[]) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Updates the primary applicant of the application based on the new primary applicant id
|
|
14
|
+
*
|
|
15
|
+
* @param {String} newPrimaryApplicantId - New primary applicant id
|
|
16
|
+
* @param {PersonApplicant[]} personApplicants - Person applicants from the updated application after deep merge
|
|
17
|
+
*
|
|
18
|
+
* @returns {PersonApplicant[]} - Updated person applicants
|
|
19
|
+
*/
|
|
20
|
+
export declare const updatePrimaryApplicant: (newPrimaryApplicantId: string, personApplicants: PersonApplicant[]) => PersonApplicant[];
|
|
21
|
+
/**
|
|
22
|
+
* Updates the primary applicant on the application based on the data in the guarantor applicant event
|
|
23
|
+
*
|
|
24
|
+
* @param {PartialApplication} application - Application after deep merge
|
|
25
|
+
* @param {Payload} applicantPayload - Public applicant event payload
|
|
26
|
+
*
|
|
27
|
+
* @returns {PartialApplication} - Updated application
|
|
28
|
+
*/
|
|
29
|
+
declare const updatePrimaryApplicantUsingGuarantor: (application: PartialApplication, applicantPayload: Payload) => PartialApplication;
|
|
30
|
+
export default updatePrimaryApplicantUsingGuarantor;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
exports.__esModule = true;
|
|
14
|
+
exports.updatePrimaryApplicant = exports.isMultiplePersonApplicantBorrowers = void 0;
|
|
15
|
+
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
16
|
+
var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
|
|
17
|
+
var lodash_1 = require("lodash");
|
|
18
|
+
var public_applicant_1 = require("../types/events/public-applicant");
|
|
19
|
+
/**
|
|
20
|
+
* Checks if there are more than one person applicants with applicant type borrower
|
|
21
|
+
*
|
|
22
|
+
* @param {PersonApplicants[]} personApplicants - Person applicants on the deep merged application
|
|
23
|
+
*
|
|
24
|
+
* @returns {boolean} - Whether or not there are more than one applicant with applicant type borrower
|
|
25
|
+
*/
|
|
26
|
+
var isMultiplePersonApplicantBorrowers = function (personApplicants) {
|
|
27
|
+
var totalBorrowerApplicants = personApplicants.filter(function (applicant) { return applicant['@ApplicantType'] === lixi_internal_request_1.ApplicantTypeList.Borrower; }).length;
|
|
28
|
+
return totalBorrowerApplicants > 1;
|
|
29
|
+
};
|
|
30
|
+
exports.isMultiplePersonApplicantBorrowers = isMultiplePersonApplicantBorrowers;
|
|
31
|
+
/**
|
|
32
|
+
* Updates the primary applicant of the application based on the new primary applicant id
|
|
33
|
+
*
|
|
34
|
+
* @param {String} newPrimaryApplicantId - New primary applicant id
|
|
35
|
+
* @param {PersonApplicant[]} personApplicants - Person applicants from the updated application after deep merge
|
|
36
|
+
*
|
|
37
|
+
* @returns {PersonApplicant[]} - Updated person applicants
|
|
38
|
+
*/
|
|
39
|
+
var updatePrimaryApplicant = function (newPrimaryApplicantId, personApplicants) {
|
|
40
|
+
return personApplicants.map(function (applicant) {
|
|
41
|
+
var _a;
|
|
42
|
+
return (__assign(__assign({}, applicant), (_a = {}, _a['@PrimaryApplicant'] = applicant['@UniqueID'] === newPrimaryApplicantId ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No, _a)));
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
exports.updatePrimaryApplicant = updatePrimaryApplicant;
|
|
46
|
+
/**
|
|
47
|
+
* Updates the primary applicant on the application based on the data in the guarantor applicant event
|
|
48
|
+
*
|
|
49
|
+
* @param {PartialApplication} application - Application after deep merge
|
|
50
|
+
* @param {Payload} applicantPayload - Public applicant event payload
|
|
51
|
+
*
|
|
52
|
+
* @returns {PartialApplication} - Updated application
|
|
53
|
+
*/
|
|
54
|
+
var updatePrimaryApplicantUsingGuarantor = function (application, applicantPayload) {
|
|
55
|
+
var updatedApplication = application, personApplicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
|
|
56
|
+
// Checks if there are more than one borrower in the application and that the applicant type of the applicant event being processed is GUARANTOR
|
|
57
|
+
if ((0, exports.isMultiplePersonApplicantBorrowers)(personApplicants) &&
|
|
58
|
+
applicantPayload.applicantType === public_applicant_1.ApplicantType.Guarantor) {
|
|
59
|
+
(0, lodash_1.set)(updatedApplication, application_paths_1.paths.PersonApplicants, (0, exports.updatePrimaryApplicant)(applicantPayload.guarantorRelationshipToBorrower.applicantId, personApplicants));
|
|
60
|
+
}
|
|
61
|
+
return updatedApplication;
|
|
62
|
+
};
|
|
63
|
+
exports["default"] = updatePrimaryApplicantUsingGuarantor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/integrations-transform",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "Library for kafka event data transforming",
|
|
5
5
|
"author": "Integrations <integrations@lendi.com.au>",
|
|
6
6
|
"homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
|