@lendi/integrations-transform 1.5.8 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +1 -1
- package/lib/logger.d.ts +1 -2
- package/lib/logger.js +3 -3
- package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
- package/lib/transform-events/generate-asset-liability-link.js +12 -12
- package/lib/transform-events/generate-credit-report-rebuilt.js +13 -13
- package/lib/transform-events/generate-employment.d.ts +1 -1
- package/lib/transform-events/generate-employment.js +33 -34
- package/lib/transform-events/generate-required-document.d.ts +1 -7
- package/lib/transform-events/generate-required-document.js +37 -54
- package/lib/transform-events/transform-applicant.d.ts +2 -1
- package/lib/transform-events/transform-applicant.js +57 -63
- package/lib/transform-events/transform-application-workflow.d.ts +0 -1
- package/lib/transform-events/transform-application-workflow.js +7 -8
- package/lib/transform-events/transform-application.d.ts +3 -1
- package/lib/transform-events/transform-application.js +23 -24
- package/lib/transform-events/transform-asset-address.d.ts +8 -2
- package/lib/transform-events/transform-asset-address.js +22 -18
- package/lib/transform-events/transform-asset.d.ts +7 -1
- package/lib/transform-events/transform-asset.js +112 -122
- package/lib/transform-events/transform-expenses.d.ts +4 -0
- package/lib/transform-events/transform-expenses.js +31 -29
- package/lib/transform-events/transform-funding-position.d.ts +2 -2
- package/lib/transform-events/transform-funding-position.js +23 -26
- package/lib/transform-events/transform-income.d.ts +8 -1
- package/lib/transform-events/transform-income.js +87 -97
- package/lib/transform-events/transform-liability.d.ts +4 -1
- package/lib/transform-events/transform-liability.js +42 -41
- package/lib/transform-events/transform-percent-owned.d.ts +1 -0
- package/lib/transform-events/transform-percent-owned.js +8 -11
- package/lib/types/enum-mappings/alieo-frequency.js +23 -24
- package/lib/types/enum-mappings/asset-type.js +15 -16
- package/lib/types/enum-mappings/builder-type.js +7 -8
- package/lib/types/enum-mappings/construction-type.js +8 -9
- package/lib/types/enum-mappings/country-code.js +244 -245
- package/lib/types/enum-mappings/employment-basis.js +10 -11
- package/lib/types/enum-mappings/expense-frequency.js +9 -10
- package/lib/types/enum-mappings/funding-position.js +6 -6
- package/lib/types/enum-mappings/government-benefits.js +8 -9
- 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.js +13 -14
- package/lib/types/enum-mappings/income-type.js +14 -15
- package/lib/types/enum-mappings/index.js +1 -1
- package/lib/types/enum-mappings/liability-payment-type.js +7 -8
- package/lib/types/enum-mappings/liability-type.js +19 -20
- package/lib/types/enum-mappings/living-expense.js +28 -29
- package/lib/types/enum-mappings/marital-status.js +10 -11
- package/lib/types/enum-mappings/postcode.js +12 -13
- package/lib/types/enum-mappings/preferred-repayment.js +8 -9
- package/lib/types/enum-mappings/proof-of-identity.js +8 -9
- package/lib/types/enum-mappings/property-expense-category.js +9 -10
- package/lib/types/enum-mappings/public-financial-asset.js +10 -11
- package/lib/types/enum-mappings/public-primary-purpose.js +7 -8
- package/lib/types/enum-mappings/public-property-status.js +9 -10
- package/lib/types/enum-mappings/public-property-type.js +21 -22
- package/lib/types/enum-mappings/residency-status.js +9 -10
- package/lib/types/enum-mappings/title-gender.js +11 -12
- package/lib/types/enum-mappings/title.js +11 -12
- package/lib/types/enum-mappings/to-be-purchased.js +4 -4
- package/lib/types/enum-mappings/to-be-used-as-security.js +4 -4
- package/lib/types/enum-mappings/transaction-type.js +7 -8
- package/lib/types/enum-mappings/verification.js +11 -12
- package/lib/types/events/applicant-delete.js +1 -1
- package/lib/types/events/application-workflow.js +1 -1
- package/lib/types/events/asset-delete.js +1 -1
- package/lib/types/events/asset-liability-relation-delete.js +1 -1
- package/lib/types/events/credit-report-retrieved.js +1 -1
- package/lib/types/events/employment-delete.js +1 -1
- package/lib/types/events/expense-delete.js +1 -1
- package/lib/types/events/funding-position.js +1 -1
- package/lib/types/events/income-delete.js +1 -1
- package/lib/types/events/liability-delete.js +1 -1
- package/lib/types/events/opportunity.js +1 -1
- package/lib/types/events/public-applicant.js +1 -1
- package/lib/types/events/public-application.js +1 -1
- package/lib/types/events/public-asset-liability-relation.js +1 -1
- package/lib/types/events/public-asset.js +1 -1
- package/lib/types/events/public-employment.js +1 -1
- package/lib/types/events/public-expense.js +1 -1
- package/lib/types/events/public-funding-position.js +1 -1
- package/lib/types/events/public-income.js +1 -1
- package/lib/types/events/public-liability.js +1 -1
- package/lib/types/events/public-required-document.js +1 -1
- package/lib/types/partial-application.js +1 -1
- package/lib/types/recursive-partial.js +1 -1
- package/lib/update-application/merge-application.d.ts +1 -1
- package/lib/update-application/merge-application.js +41 -34
- package/lib/update-application/update-primary-applicant.d.ts +1 -4
- package/lib/update-application/update-primary-applicant.js +12 -31
- package/lib/utils/address-tools.d.ts +3 -1
- package/lib/utils/address-tools.js +40 -42
- package/lib/utils/clean-up.d.ts +1 -1
- package/lib/utils/clean-up.js +6 -6
- package/lib/utils/formatYesNo.d.ts +0 -1
- package/lib/utils/formatYesNo.js +3 -4
- package/lib/utils/generate-address.d.ts +3 -2
- package/lib/utils/generate-address.js +21 -25
- package/lib/utils/get-financial-institution.d.ts +1 -0
- package/lib/utils/get-financial-institution.js +6 -5
- package/lib/utils/is-asset-type.js +2 -2
- package/lib/utils/is-income-type.d.ts +2 -0
- package/lib/utils/is-income-type.js +15 -21
- package/lib/utils/iso-date.d.ts +0 -1
- package/lib/utils/iso-date.js +3 -4
- package/lib/utils/normalise-date.js +6 -6
- package/lib/utils/round-decimal.js +1 -1
- package/package.json +14 -17
package/lib/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
/* istanbul ignore file */
|
|
18
18
|
__exportStar(require("./transform-events/transform-applicant"), exports);
|
|
19
19
|
__exportStar(require("./transform-events/transform-application"), exports);
|
package/lib/logger.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const logger: pino.Logger;
|
|
1
|
+
export declare const logger: import("@lendi/logging").Logger;
|
package/lib/logger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logger = void 0;
|
|
4
|
-
|
|
5
|
-
exports.logger =
|
|
4
|
+
const logging_1 = require("@lendi/logging");
|
|
5
|
+
exports.logger = (0, logging_1.createLogger)({ name: 'integrations-transform', messageKey: 'message' });
|
|
@@ -3,6 +3,8 @@ import { AssetAndLiabilityRelation } from '../types/events/public-asset-liabilit
|
|
|
3
3
|
* Generates a partial application from the partial asset and liability event.
|
|
4
4
|
*
|
|
5
5
|
* @param assetLiabilityLink: A partial asset and liability event.
|
|
6
|
-
* @
|
|
6
|
+
* @param assetLiabilityLink:.applicationId
|
|
7
|
+
* @param assetLiabilityLink:.relation
|
|
8
|
+
* @returns partialApplication: A partial internal request.
|
|
7
9
|
*/
|
|
8
10
|
export declare function generateAssetLiabilityLink({ applicationId, relation }: AssetAndLiabilityRelation): {};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateAssetLiabilityLink = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
6
|
/**
|
|
7
7
|
* Generates a partial application from the partial asset and liability event.
|
|
8
8
|
*
|
|
9
9
|
* @param assetLiabilityLink: A partial asset and liability event.
|
|
10
|
-
* @
|
|
10
|
+
* @param assetLiabilityLink:.applicationId
|
|
11
|
+
* @param assetLiabilityLink:.relation
|
|
12
|
+
* @returns partialApplication: A partial internal request.
|
|
11
13
|
*/
|
|
12
|
-
function generateAssetLiabilityLink(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var assetLiabilityMapping = {
|
|
14
|
+
function generateAssetLiabilityLink({ applicationId, relation }) {
|
|
15
|
+
const partialApplication = {};
|
|
16
|
+
const assetLiabilityMapping = {
|
|
16
17
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
17
|
-
liabilityId:
|
|
18
|
-
assetId:
|
|
18
|
+
liabilityId: `${application_paths_1.paths.Liability}.@UniqueID`,
|
|
19
|
+
assetId: `${application_paths_1.paths.Liability}.Security[0].@x_Security`,
|
|
19
20
|
};
|
|
20
21
|
(0, lodash_1.set)(partialApplication, assetLiabilityMapping.applicationId, applicationId);
|
|
21
|
-
for (
|
|
22
|
-
var _c = _b[_i], key = _c[0], value = _c[1];
|
|
22
|
+
for (const [key, value] of Object.entries(relation)) {
|
|
23
23
|
if (assetLiabilityMapping[key]) {
|
|
24
24
|
(0, lodash_1.set)(partialApplication, assetLiabilityMapping[key], value);
|
|
25
25
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateCreditReportRebuilt = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
7
7
|
/**
|
|
8
8
|
* Generates LIXI compliant `Attachment` and `CreditAssessment` objects which
|
|
9
9
|
* use credit report data fetched from Equifax.
|
|
@@ -11,27 +11,27 @@ var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/applic
|
|
|
11
11
|
* @param {CreditReportPayload} creditReport - Credit report rebuilt event.
|
|
12
12
|
*/
|
|
13
13
|
function generateCreditReportRebuilt(creditReport) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const { applicantId, raw, source } = creditReport;
|
|
15
|
+
const id = `${applicantId}-creditReport`;
|
|
16
|
+
const attachment = {
|
|
17
17
|
'@Filename': 'Credit Report',
|
|
18
18
|
'@UniqueID': id,
|
|
19
19
|
InlineAttachment: {
|
|
20
|
-
$: raw
|
|
21
|
-
}
|
|
20
|
+
$: raw,
|
|
21
|
+
},
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
const report = {
|
|
24
24
|
'@RequestDateTime': new Date().toISOString(),
|
|
25
25
|
'@Source': source,
|
|
26
26
|
'@x_Party': applicantId,
|
|
27
27
|
Content: [
|
|
28
28
|
{
|
|
29
29
|
'@Type': lixi_internal_request_1.ReportContentTypeList.XML,
|
|
30
|
-
'@x_Attachment': id
|
|
30
|
+
'@x_Attachment': id,
|
|
31
31
|
},
|
|
32
|
-
]
|
|
32
|
+
],
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
const partialApplication = {};
|
|
35
35
|
// Set application id, attachment and credit assessment report.
|
|
36
36
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, creditReport.applicationId);
|
|
37
37
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.Attachment, [attachment]);
|
|
@@ -3,6 +3,6 @@ import { Payload } from '../types/events/public-employment';
|
|
|
3
3
|
* Generates a partial application from a employment event.
|
|
4
4
|
*
|
|
5
5
|
* @param employment a employment event payload.
|
|
6
|
-
* @
|
|
6
|
+
* @returns partialApplication an incomplete application.
|
|
7
7
|
*/
|
|
8
8
|
export declare function generateEmployment(employment: Payload): {};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateEmployment = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
7
|
+
const logger_1 = require("../logger");
|
|
8
|
+
const public_employment_1 = require("../types/events/public-employment");
|
|
9
|
+
const enum_mappings_1 = require("../types/enum-mappings");
|
|
10
10
|
/**
|
|
11
11
|
* Generates a partial application from a employment event.
|
|
12
12
|
*
|
|
13
13
|
* @param employment a employment event payload.
|
|
14
|
-
* @
|
|
14
|
+
* @returns partialApplication an incomplete application.
|
|
15
15
|
*/
|
|
16
16
|
function generateEmployment(employment) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const partialApplication = {};
|
|
18
|
+
let employmentPath = application_paths_1.paths.PAYG;
|
|
19
|
+
let isEmployed = false;
|
|
20
|
+
const { applicationId } = employment;
|
|
21
21
|
// Each one Employment object can only contain one of the three types. Set the three object to undefined so that the
|
|
22
22
|
// other two types will be removed from the final result.
|
|
23
23
|
// @pliu 19/11/19
|
|
@@ -29,7 +29,7 @@ function generateEmployment(employment) {
|
|
|
29
29
|
isEmployed = true;
|
|
30
30
|
employmentPath = application_paths_1.paths.PAYG;
|
|
31
31
|
// Setting default for onProbation. If field exists in event value will get overwritten.
|
|
32
|
-
(0, lodash_1.set)(partialApplication,
|
|
32
|
+
(0, lodash_1.set)(partialApplication, `${employmentPath}.@OnProbation`, lixi_internal_request_1.YesNoList.No);
|
|
33
33
|
break;
|
|
34
34
|
case public_employment_1.EmploymentType.SelfEmployed:
|
|
35
35
|
isEmployed = true;
|
|
@@ -37,27 +37,26 @@ function generateEmployment(employment) {
|
|
|
37
37
|
break;
|
|
38
38
|
case public_employment_1.EmploymentType.NotWorking:
|
|
39
39
|
employmentPath = application_paths_1.paths.NotEmployed;
|
|
40
|
-
(0, lodash_1.set)(partialApplication,
|
|
41
|
-
(0, lodash_1.set)(partialApplication,
|
|
40
|
+
(0, lodash_1.set)(partialApplication, `${employmentPath}.Income.@OtherIncomeAmount`, 0);
|
|
41
|
+
(0, lodash_1.set)(partialApplication, `${employmentPath}.Income.@OtherIncomeFrequency`, lixi_internal_request_1.List.Fortnightly);
|
|
42
42
|
break;
|
|
43
43
|
default:
|
|
44
|
-
logger_1.logger.warn({ message:
|
|
44
|
+
logger_1.logger.warn({ message: `Unknown EmploymentType ${employment.employmentType}`, applicationId });
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
const employmentMapping = {
|
|
47
47
|
applicationId: application_paths_1.paths.ApplicationId,
|
|
48
|
-
applicantId:
|
|
49
|
-
id:
|
|
50
|
-
abn:
|
|
51
|
-
businessName:
|
|
52
|
-
type:
|
|
53
|
-
employmentBasis:
|
|
54
|
-
startDate:
|
|
55
|
-
endDate:
|
|
56
|
-
role:
|
|
57
|
-
onProbation:
|
|
48
|
+
applicantId: `${application_paths_1.paths.PersonApplicant}.@UniqueID`,
|
|
49
|
+
id: `${employmentPath}.@UniqueID`,
|
|
50
|
+
abn: `${application_paths_1.paths.RelatedCompany}.@ABN`,
|
|
51
|
+
businessName: `${application_paths_1.paths.RelatedCompany}.@BusinessName`,
|
|
52
|
+
type: `${employmentPath}.@Status`,
|
|
53
|
+
employmentBasis: `${employmentPath}.@Basis`,
|
|
54
|
+
startDate: `${employmentPath}.@StartDate`,
|
|
55
|
+
endDate: `${employmentPath}.@EndDate`,
|
|
56
|
+
role: `${employmentPath}.@Occupation`,
|
|
57
|
+
onProbation: `${employmentPath}.@OnProbation`,
|
|
58
58
|
};
|
|
59
|
-
for (
|
|
60
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
59
|
+
for (const [key, value] of Object.entries(employment)) {
|
|
61
60
|
if (employmentMapping[key]) {
|
|
62
61
|
switch (key) {
|
|
63
62
|
case 'type':
|
|
@@ -76,20 +75,20 @@ function generateEmployment(employment) {
|
|
|
76
75
|
case 'id':
|
|
77
76
|
(0, lodash_1.set)(partialApplication, employmentMapping[key], value);
|
|
78
77
|
if (isEmployed) {
|
|
79
|
-
(0, lodash_1.set)(partialApplication,
|
|
80
|
-
(0, lodash_1.set)(partialApplication,
|
|
78
|
+
(0, lodash_1.set)(partialApplication, `${employmentPath}.@x_Employer`, `${value}-businessName`);
|
|
79
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.RelatedCompany}.@UniqueID`, `${value}-businessName`);
|
|
81
80
|
}
|
|
82
81
|
break;
|
|
83
82
|
case 'onProbation':
|
|
84
83
|
if (employment.employmentType === public_employment_1.EmploymentType.Employee) {
|
|
85
|
-
|
|
84
|
+
const onProbation = value ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No;
|
|
86
85
|
(0, lodash_1.set)(partialApplication, employmentMapping[key], onProbation);
|
|
87
86
|
}
|
|
88
87
|
break;
|
|
89
88
|
case 'role':
|
|
90
|
-
|
|
89
|
+
const { anzsco = {} } = value;
|
|
91
90
|
if (anzsco.code) {
|
|
92
|
-
(0, lodash_1.set)(partialApplication,
|
|
91
|
+
(0, lodash_1.set)(partialApplication, `${employmentPath}.@ANZSCOOccupationCode`, anzsco.code.toString());
|
|
93
92
|
}
|
|
94
93
|
if (anzsco.occupation) {
|
|
95
94
|
(0, lodash_1.set)(partialApplication, employmentMapping[key], anzsco.occupation);
|
|
@@ -5,7 +5,6 @@ import { EConsent, Identification, Payload as RequiredDocumentPayload } from '..
|
|
|
5
5
|
* Gets the applicant gender from the identification data
|
|
6
6
|
*
|
|
7
7
|
* @param identification Identification data
|
|
8
|
-
*
|
|
9
8
|
* @returns The gender of the applicant
|
|
10
9
|
*/
|
|
11
10
|
export declare const getApplicantGenderFromIdentification: (identification: Identification) => string;
|
|
@@ -13,7 +12,6 @@ export declare const getApplicantGenderFromIdentification: (identification: Iden
|
|
|
13
12
|
* Gets full name on document from the identification data
|
|
14
13
|
*
|
|
15
14
|
* @param identification Identification data
|
|
16
|
-
*
|
|
17
15
|
* @returns The full name on document
|
|
18
16
|
*/
|
|
19
17
|
export declare const getNameOnDocument: (identification: Identification) => string;
|
|
@@ -21,7 +19,6 @@ export declare const getNameOnDocument: (identification: Identification) => stri
|
|
|
21
19
|
* Transforms identification data into a partial proof of identity document
|
|
22
20
|
*
|
|
23
21
|
* @param identification Identification data
|
|
24
|
-
*
|
|
25
22
|
* @returns Partial proof of identity object
|
|
26
23
|
*/
|
|
27
24
|
export declare const transformIdentification: (identification: Identification) => Partial<ProofOfIdentity>;
|
|
@@ -29,7 +26,6 @@ export declare const transformIdentification: (identification: Identification) =
|
|
|
29
26
|
* Generates partial details for document used to verify identity
|
|
30
27
|
*
|
|
31
28
|
* @param requiredDocument RequiredDocumentCreated/RequiredDocumentUpdated event payload
|
|
32
|
-
*
|
|
33
29
|
* @returns Partial proof of identity document object
|
|
34
30
|
*/
|
|
35
31
|
export declare const generateProofOfIdentity: (requiredDocument: RequiredDocumentPayload) => Partial<ProofOfIdentity>;
|
|
@@ -37,7 +33,6 @@ export declare const generateProofOfIdentity: (requiredDocument: RequiredDocumen
|
|
|
37
33
|
* Generates an applicants disclosure details mapping for the partial application
|
|
38
34
|
*
|
|
39
35
|
* @param eConsent E-Consent detials from the RequiredDocumentCreated/RequqiredDocumentUpdated event payload
|
|
40
|
-
*
|
|
41
36
|
* @returns Applicant disclosure details for partial application
|
|
42
37
|
*/
|
|
43
38
|
export declare const generatePersonApplicantPrivacy: (eConsent: EConsent) => PersonApplicantPrivacy;
|
|
@@ -45,7 +40,6 @@ export declare const generatePersonApplicantPrivacy: (eConsent: EConsent) => Per
|
|
|
45
40
|
* Transforms a RequiredDocumentCreated or RequiredDocumentUpdated event payload into a partial application
|
|
46
41
|
*
|
|
47
42
|
* @param requiredDocument A RequiredDocumentCreated or RequiredDocumentUpdated event payload
|
|
48
|
-
*
|
|
49
|
-
* @return A partial application
|
|
43
|
+
* @returns A partial application
|
|
50
44
|
*/
|
|
51
45
|
export declare function transformRequiredDocument(requiredDocument: RequiredDocumentPayload): {};
|
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
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;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.transformRequiredDocument = exports.generatePersonApplicantPrivacy = exports.generateProofOfIdentity = exports.transformIdentification = exports.getNameOnDocument = exports.getApplicantGenderFromIdentification = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
5
|
+
const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const enum_mappings_1 = require("../types/enum-mappings");
|
|
8
|
+
const enum_mappings_2 = require("../types/enum-mappings");
|
|
9
|
+
const enum_mappings_3 = require("../types/enum-mappings");
|
|
10
|
+
const verification_1 = require("../types/enum-mappings/verification");
|
|
11
|
+
const public_required_document_1 = require("../types/events/public-required-document");
|
|
12
|
+
const formatYesNo_1 = require("../utils/formatYesNo");
|
|
13
|
+
const iso_date_1 = require("../utils/iso-date");
|
|
25
14
|
/**
|
|
26
15
|
* Gets the applicant gender from the identification data
|
|
27
16
|
*
|
|
28
17
|
* @param identification Identification data
|
|
29
|
-
*
|
|
30
18
|
* @returns The gender of the applicant
|
|
31
19
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
const getApplicantGenderFromIdentification = (identification) => {
|
|
21
|
+
const { gender, idTitle } = identification;
|
|
34
22
|
return gender ? (0, lodash_1.capitalize)(gender) : enum_mappings_3.titleGenderMapping[idTitle || public_required_document_1.IDTitle.Unknown];
|
|
35
23
|
};
|
|
36
24
|
exports.getApplicantGenderFromIdentification = getApplicantGenderFromIdentification;
|
|
@@ -38,16 +26,15 @@ exports.getApplicantGenderFromIdentification = getApplicantGenderFromIdentificat
|
|
|
38
26
|
* Gets full name on document from the identification data
|
|
39
27
|
*
|
|
40
28
|
* @param identification Identification data
|
|
41
|
-
*
|
|
42
29
|
* @returns The full name on document
|
|
43
30
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return [idFirstName, idMiddleName, idLastName].reduce(
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
const getNameOnDocument = (identification) => {
|
|
32
|
+
const { idFirstName, idMiddleName, idLastName } = identification;
|
|
33
|
+
return [idFirstName, idMiddleName, idLastName].reduce((fullName, nameComponent) => {
|
|
34
|
+
let newFullName = fullName;
|
|
35
|
+
const nameSubstring = nameComponent === null || nameComponent === void 0 ? void 0 : nameComponent.trim();
|
|
49
36
|
if (nameSubstring) {
|
|
50
|
-
newFullName +=
|
|
37
|
+
newFullName += `${fullName ? ' ' : ''}${nameSubstring}`;
|
|
51
38
|
}
|
|
52
39
|
return newFullName;
|
|
53
40
|
}, '');
|
|
@@ -57,17 +44,16 @@ exports.getNameOnDocument = getNameOnDocument;
|
|
|
57
44
|
* Transforms identification data into a partial proof of identity document
|
|
58
45
|
*
|
|
59
46
|
* @param identification Identification data
|
|
60
|
-
*
|
|
61
47
|
* @returns Partial proof of identity object
|
|
62
48
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return
|
|
49
|
+
const transformIdentification = (identification) => {
|
|
50
|
+
const { australianState, idNumber, idType, issuingCountry = public_required_document_1.IssuingCountry.Australia } = identification;
|
|
51
|
+
const nameOnDocument = (0, exports.getNameOnDocument)(identification);
|
|
52
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, (nameOnDocument && { '@NameOnDocument': nameOnDocument })), (idNumber && { '@DocumentNumber': idNumber })), (australianState && { '@PlaceOfIssue': australianState })), (idType === public_required_document_1.IDType.Passport && issuingCountry !== public_required_document_1.IssuingCountry.Australia
|
|
67
53
|
? {
|
|
68
54
|
'@DocumentType': lixi_internal_request_1.DocumentTypeList.InternationalPassport,
|
|
69
55
|
'@CountryOfIssue': enum_mappings_1.countryCodeMapping[issuingCountry],
|
|
70
|
-
'@PlaceOfIssue': enum_mappings_1.countryCodeMapping[issuingCountry]
|
|
56
|
+
'@PlaceOfIssue': enum_mappings_1.countryCodeMapping[issuingCountry],
|
|
71
57
|
}
|
|
72
58
|
: { '@DocumentType': enum_mappings_2.proofOfIdentityMapping[idType] }));
|
|
73
59
|
};
|
|
@@ -76,26 +62,24 @@ exports.transformIdentification = transformIdentification;
|
|
|
76
62
|
* Generates partial details for document used to verify identity
|
|
77
63
|
*
|
|
78
64
|
* @param requiredDocument RequiredDocumentCreated/RequiredDocumentUpdated event payload
|
|
79
|
-
*
|
|
80
65
|
* @returns Partial proof of identity document object
|
|
81
66
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return
|
|
67
|
+
const generateProofOfIdentity = (requiredDocument) => {
|
|
68
|
+
const { id, status, expiryDate, identification } = requiredDocument;
|
|
69
|
+
return Object.assign(Object.assign(Object.assign({ '@UniqueID': id, '@CountryOfIssue': lixi_internal_request_1.CountryCodeList.Au, '@PlaceOfIssue': lixi_internal_request_1.CountryCodeList.Au }, (expiryDate && { '@ExpiryDate': (0, iso_date_1.isoDate)(expiryDate) })), (status && { '@PhotographVerified': verification_1.verificationMapping[status] })), (identification && (0, exports.transformIdentification)(identification)));
|
|
85
70
|
};
|
|
86
71
|
exports.generateProofOfIdentity = generateProofOfIdentity;
|
|
87
72
|
/**
|
|
88
73
|
* Generates an applicants disclosure details mapping for the partial application
|
|
89
74
|
*
|
|
90
75
|
* @param eConsent E-Consent detials from the RequiredDocumentCreated/RequqiredDocumentUpdated event payload
|
|
91
|
-
*
|
|
92
76
|
* @returns Applicant disclosure details for partial application
|
|
93
77
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
78
|
+
const generatePersonApplicantPrivacy = (eConsent) => {
|
|
79
|
+
const { hasConsented, consentedAt = new Date() } = eConsent;
|
|
96
80
|
return {
|
|
97
81
|
'@CreditAuthoritySigned': (0, formatYesNo_1.formatYesNo)(hasConsented),
|
|
98
|
-
'@DateSigned': (0, iso_date_1.isoDate)(consentedAt)
|
|
82
|
+
'@DateSigned': (0, iso_date_1.isoDate)(consentedAt),
|
|
99
83
|
};
|
|
100
84
|
};
|
|
101
85
|
exports.generatePersonApplicantPrivacy = generatePersonApplicantPrivacy;
|
|
@@ -103,20 +87,19 @@ exports.generatePersonApplicantPrivacy = generatePersonApplicantPrivacy;
|
|
|
103
87
|
* Transforms a RequiredDocumentCreated or RequiredDocumentUpdated event payload into a partial application
|
|
104
88
|
*
|
|
105
89
|
* @param requiredDocument A RequiredDocumentCreated or RequiredDocumentUpdated event payload
|
|
106
|
-
*
|
|
107
|
-
* @return A partial application
|
|
90
|
+
* @returns A partial application
|
|
108
91
|
*/
|
|
109
92
|
function transformRequiredDocument(requiredDocument) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
(0, lodash_1.set)(partialApplication,
|
|
93
|
+
const partialApplication = {};
|
|
94
|
+
const { applicantId, applicationId, identification, eConsent } = requiredDocument;
|
|
95
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@UniqueID`, applicantId);
|
|
113
96
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
114
97
|
if (identification) {
|
|
115
|
-
(0, lodash_1.set)(partialApplication,
|
|
116
|
-
(0, lodash_1.set)(partialApplication,
|
|
98
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@Gender`, (0, exports.getApplicantGenderFromIdentification)(identification));
|
|
99
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.ProofOfIdentity}`, (0, exports.generateProofOfIdentity)(requiredDocument));
|
|
117
100
|
}
|
|
118
101
|
if (eConsent) {
|
|
119
|
-
(0, lodash_1.set)(partialApplication,
|
|
102
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Privacy}`, (0, exports.generatePersonApplicantPrivacy)(eConsent));
|
|
120
103
|
}
|
|
121
104
|
return partialApplication;
|
|
122
105
|
}
|
|
@@ -5,7 +5,8 @@ export declare const booleanMapping: (input?: boolean) => YesNoList;
|
|
|
5
5
|
* Transforms a partial Applicant event to a partial LIXI application.
|
|
6
6
|
*
|
|
7
7
|
* @param applicant: A partial applicant.
|
|
8
|
-
* @
|
|
8
|
+
* @param applicant
|
|
9
|
+
* @returns partialApplication an incomplete application.
|
|
9
10
|
*/
|
|
10
11
|
export declare function transformApplicant(applicant: ApplicantPayload): {};
|
|
11
12
|
/**
|