@lendi/act-credit-decisions-transform 2.0.31 → 2.0.32
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.
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { PersonApplicantPrivacy, ProofOfIdentity } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
2
|
import { EConsent, Identification, Payload as RequiredDocumentPayload, Status } from '../types/events/public-required-document';
|
|
3
3
|
import { PartialApplication } from '../types/partial-application';
|
|
4
|
-
interface TransformRequiredDocumentOptions {
|
|
5
|
-
readonly secondIDEnabled?: boolean;
|
|
6
|
-
}
|
|
7
4
|
/**
|
|
8
5
|
* Gets the applicant gender from the identification data
|
|
9
6
|
*
|
|
@@ -24,29 +21,26 @@ export declare const getNameOnDocument: (identification: Identification) => stri
|
|
|
24
21
|
* Transforms issued location data of an ID document
|
|
25
22
|
*
|
|
26
23
|
* @param {Identification} identification Identification data
|
|
27
|
-
* @param {boolean} secondIDEnabled Whether or not second Id functionality is enabled
|
|
28
24
|
*
|
|
29
25
|
* @returns {Partial<ProofOfIdentity>} Partial proof of identity object
|
|
30
26
|
*/
|
|
31
|
-
export declare const transformIDIssuedLocation: (identification: Identification
|
|
27
|
+
export declare const transformIDIssuedLocation: (identification: Identification) => Partial<ProofOfIdentity>;
|
|
32
28
|
/**
|
|
33
29
|
* Transforms the verification status data of the ID document
|
|
34
30
|
*
|
|
35
31
|
* @param {Status} status Verification status of the ID document
|
|
36
|
-
* @param {boolean} secondIDEnabled Whether or not secondID mapping is enabled
|
|
37
32
|
*
|
|
38
33
|
* @returns {Partial<ProofOfIdentity>} Partial proof of identity
|
|
39
34
|
*/
|
|
40
|
-
export declare const transformVerificationStatus: (status: Status | undefined
|
|
35
|
+
export declare const transformVerificationStatus: (status: Status | undefined) => Partial<ProofOfIdentity>;
|
|
41
36
|
/**
|
|
42
37
|
* Generates a partial proof of identity object
|
|
43
38
|
*
|
|
44
39
|
* @param {RequiredDocumentPayload} requiredDocumentEventPayload RequiredDocumentCreated/RequiredDocumentUpdated event payload
|
|
45
|
-
* @param {TransformRequiredDocumentOptions} options - Options from generating partial proof of identity
|
|
46
40
|
*
|
|
47
41
|
* @returns {Partial<ProofOfIdentity>} Partial proof of identity document object
|
|
48
42
|
*/
|
|
49
|
-
export declare const generateProofOfIdentity: (requiredDocumentEventPayload: RequiredDocumentPayload
|
|
43
|
+
export declare const generateProofOfIdentity: (requiredDocumentEventPayload: RequiredDocumentPayload) => Partial<ProofOfIdentity>;
|
|
50
44
|
/**
|
|
51
45
|
* Generates an applicants disclosure details mapping for the partial application
|
|
52
46
|
*
|
|
@@ -59,9 +53,7 @@ export declare const generatePersonApplicantPrivacy: (eConsent: EConsent) => Per
|
|
|
59
53
|
* Transforms a RequiredDocumentCreated/RequiredDocumentUpdated event payload into a partial application
|
|
60
54
|
*
|
|
61
55
|
* @param {RequiredDocumentPayload} requiredDocEventPayload A RequiredDocumentCreated/RequiredDocumentUpdated event payload
|
|
62
|
-
* @param {TransformRequiredDocumentOptions} options Required document event transformation options
|
|
63
56
|
*
|
|
64
57
|
* @returns {PartialApplication} A partial application
|
|
65
58
|
*/
|
|
66
|
-
export declare const transformRequiredDocument: (requiredDocEventPayload: RequiredDocumentPayload
|
|
67
|
-
export {};
|
|
59
|
+
export declare const transformRequiredDocument: (requiredDocEventPayload: RequiredDocumentPayload) => PartialApplication;
|
|
@@ -46,16 +46,19 @@ exports.getNameOnDocument = getNameOnDocument;
|
|
|
46
46
|
* Transforms issued location data of an ID document
|
|
47
47
|
*
|
|
48
48
|
* @param {Identification} identification Identification data
|
|
49
|
-
* @param {boolean} secondIDEnabled Whether or not second Id functionality is enabled
|
|
50
49
|
*
|
|
51
50
|
* @returns {Partial<ProofOfIdentity>} Partial proof of identity object
|
|
52
51
|
*/
|
|
53
|
-
const transformIDIssuedLocation = (identification
|
|
52
|
+
const transformIDIssuedLocation = (identification) => {
|
|
54
53
|
const { australianState, idType, issuingCountry = public_required_document_1.IssuingCountry.Australia } = identification;
|
|
55
54
|
let transformedIssuedLocation = {};
|
|
56
55
|
if (idType === public_required_document_1.IDType.Passport && issuingCountry !== public_required_document_1.IssuingCountry.Australia) {
|
|
57
56
|
const foreignCountryOfIssue = enum_mappings_1.countryCodeMapping[issuingCountry];
|
|
58
|
-
transformedIssuedLocation =
|
|
57
|
+
transformedIssuedLocation = {
|
|
58
|
+
'@DocumentType': lixi_internal_request_1.DocumentTypeList.InternationalPassport,
|
|
59
|
+
'@CountryOfIssue': foreignCountryOfIssue,
|
|
60
|
+
'@PlaceOfIssue': foreignCountryOfIssue,
|
|
61
|
+
};
|
|
59
62
|
}
|
|
60
63
|
else {
|
|
61
64
|
transformedIssuedLocation = {
|
|
@@ -71,20 +74,16 @@ exports.transformIDIssuedLocation = transformIDIssuedLocation;
|
|
|
71
74
|
* Transforms the verification status data of the ID document
|
|
72
75
|
*
|
|
73
76
|
* @param {Status} status Verification status of the ID document
|
|
74
|
-
* @param {boolean} secondIDEnabled Whether or not secondID mapping is enabled
|
|
75
77
|
*
|
|
76
78
|
* @returns {Partial<ProofOfIdentity>} Partial proof of identity
|
|
77
79
|
*/
|
|
78
|
-
const transformVerificationStatus = (status
|
|
80
|
+
const transformVerificationStatus = (status) => {
|
|
79
81
|
let transformedVerification = {};
|
|
80
82
|
if (status) {
|
|
81
83
|
const verificationStatus = verification_1.verificationMapping[status];
|
|
82
|
-
transformedVerification =
|
|
83
|
-
'@
|
|
84
|
-
|
|
85
|
-
'@SignatureVerified': verificationStatus,
|
|
86
|
-
'@ResidentialAddressVerified': verificationStatus,
|
|
87
|
-
}));
|
|
84
|
+
transformedVerification = {
|
|
85
|
+
'@PhotographVerified': verificationStatus,
|
|
86
|
+
};
|
|
88
87
|
}
|
|
89
88
|
return transformedVerification;
|
|
90
89
|
};
|
|
@@ -93,19 +92,14 @@ exports.transformVerificationStatus = transformVerificationStatus;
|
|
|
93
92
|
* Generates a partial proof of identity object
|
|
94
93
|
*
|
|
95
94
|
* @param {RequiredDocumentPayload} requiredDocumentEventPayload RequiredDocumentCreated/RequiredDocumentUpdated event payload
|
|
96
|
-
* @param {TransformRequiredDocumentOptions} options - Options from generating partial proof of identity
|
|
97
95
|
*
|
|
98
96
|
* @returns {Partial<ProofOfIdentity>} Partial proof of identity document object
|
|
99
97
|
*/
|
|
100
|
-
const generateProofOfIdentity = (requiredDocumentEventPayload
|
|
101
|
-
const { secondIDEnabled = false } = options;
|
|
98
|
+
const generateProofOfIdentity = (requiredDocumentEventPayload) => {
|
|
102
99
|
const { id, status, expiryDate, identification } = requiredDocumentEventPayload;
|
|
103
100
|
const nameOnDocument = (0, exports.getNameOnDocument)(identification);
|
|
104
101
|
const { idNumber } = identification;
|
|
105
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(
|
|
106
|
-
'@DocumentCategory': lixi_internal_request_1.DocumentCategoryList.Photographic,
|
|
107
|
-
'@Original': lixi_internal_request_1.YesNoList.Yes,
|
|
108
|
-
}));
|
|
102
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ '@UniqueID': id }, (expiryDate && { '@ExpiryDate': (0, iso_date_1.isoDate)(expiryDate) })), (0, exports.transformVerificationStatus)(status)), (nameOnDocument && { '@NameOnDocument': nameOnDocument })), (idNumber && { '@DocumentNumber': idNumber })), (0, exports.transformIDIssuedLocation)(identification));
|
|
109
103
|
};
|
|
110
104
|
exports.generateProofOfIdentity = generateProofOfIdentity;
|
|
111
105
|
/**
|
|
@@ -127,18 +121,17 @@ exports.generatePersonApplicantPrivacy = generatePersonApplicantPrivacy;
|
|
|
127
121
|
* Transforms a RequiredDocumentCreated/RequiredDocumentUpdated event payload into a partial application
|
|
128
122
|
*
|
|
129
123
|
* @param {RequiredDocumentPayload} requiredDocEventPayload A RequiredDocumentCreated/RequiredDocumentUpdated event payload
|
|
130
|
-
* @param {TransformRequiredDocumentOptions} options Required document event transformation options
|
|
131
124
|
*
|
|
132
125
|
* @returns {PartialApplication} A partial application
|
|
133
126
|
*/
|
|
134
|
-
const transformRequiredDocument = (requiredDocEventPayload
|
|
127
|
+
const transformRequiredDocument = (requiredDocEventPayload) => {
|
|
135
128
|
const partialApplication = {};
|
|
136
129
|
const { applicantId, applicationId, identification, eConsent } = requiredDocEventPayload;
|
|
137
130
|
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@UniqueID`, applicantId);
|
|
138
131
|
(0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
|
|
139
132
|
if (identification) {
|
|
140
133
|
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@Gender`, (0, exports.getApplicantGenderFromIdentification)(identification));
|
|
141
|
-
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.ProofOfIdentity}`, (0, exports.generateProofOfIdentity)(requiredDocEventPayload
|
|
134
|
+
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.ProofOfIdentity}`, (0, exports.generateProofOfIdentity)(requiredDocEventPayload));
|
|
142
135
|
}
|
|
143
136
|
if (eConsent) {
|
|
144
137
|
(0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Privacy}`, (0, exports.generatePersonApplicantPrivacy)(eConsent));
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
interface DeepMergeOptions {
|
|
2
|
-
readonly secondIDEnabled?: boolean;
|
|
3
|
-
}
|
|
4
1
|
/**
|
|
5
2
|
* Deep merges the application and custom handles specific arrays
|
|
6
3
|
*
|
|
7
4
|
* @param existingApplication a saved dynamo application.
|
|
8
5
|
* @param newApplication new application coming from events.
|
|
9
|
-
* @param {DeepMergeOptions} options Deep merge options
|
|
10
6
|
*
|
|
11
7
|
* @returns merged application.
|
|
12
8
|
*/
|
|
13
|
-
export declare function deepMergeApplication(existingApplication: object | undefined, newApplication: object
|
|
14
|
-
export {};
|
|
9
|
+
export declare function deepMergeApplication(existingApplication: object | undefined, newApplication: object): any;
|
|
@@ -8,15 +8,13 @@ const cleanDeep = require('clean-deep');
|
|
|
8
8
|
*
|
|
9
9
|
* @param existingApplication a saved dynamo application.
|
|
10
10
|
* @param newApplication new application coming from events.
|
|
11
|
-
* @param {DeepMergeOptions} options Deep merge options
|
|
12
11
|
*
|
|
13
12
|
* @returns merged application.
|
|
14
13
|
*/
|
|
15
|
-
function deepMergeApplication(existingApplication, newApplication
|
|
14
|
+
function deepMergeApplication(existingApplication, newApplication) {
|
|
16
15
|
if (!existingApplication) {
|
|
17
16
|
return newApplication;
|
|
18
17
|
}
|
|
19
|
-
const { secondIDEnabled = false } = options;
|
|
20
18
|
// Array fields with @UniqueIDs
|
|
21
19
|
const listsWithUniqueIds = [
|
|
22
20
|
'Attachment',
|
|
@@ -35,9 +33,6 @@ function deepMergeApplication(existingApplication, newApplication, options = {})
|
|
|
35
33
|
'RelatedPerson',
|
|
36
34
|
'TrustApplicant',
|
|
37
35
|
];
|
|
38
|
-
if (secondIDEnabled) {
|
|
39
|
-
listsWithUniqueIds.push('ProofOfIdentity');
|
|
40
|
-
}
|
|
41
36
|
// Array fields with @x_Party
|
|
42
37
|
const listsWithXParty = ['Report'];
|
|
43
38
|
// Array fields with @x_Owner
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/act-credit-decisions-transform",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.32",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Library for kafka event data transforming",
|
|
6
6
|
"author": "Integrations <integrations@lendi.com.au>",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@lendi/integrations-credit-protocol": "1.18.8",
|
|
26
26
|
"@lendi/act-eac-integrations-protocol": "3.1.13",
|
|
27
27
|
"clean-deep": "^3.4.0",
|
|
28
|
-
"date-fns": "
|
|
28
|
+
"date-fns": "4.1.0",
|
|
29
29
|
"lodash": "^4.17.15"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|