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