@lendi/integrations-transform 1.6.3 → 1.6.4

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 CHANGED
@@ -5,6 +5,6 @@ export * from './transform-events/transform-income';
5
5
  export * from './transform-events/transform-asset';
6
6
  export * from './transform-events/transform-expenses';
7
7
  export * from './transform-events/transform-liability';
8
- export * from './transform-events/generate-required-document';
8
+ export * from './transform-events/transform-required-document';
9
9
  export * from './transform-events/transform-funding-position';
10
10
  export * from './update-application/merge-application';
package/lib/index.js CHANGED
@@ -22,6 +22,6 @@ __exportStar(require("./transform-events/transform-income"), exports);
22
22
  __exportStar(require("./transform-events/transform-asset"), exports);
23
23
  __exportStar(require("./transform-events/transform-expenses"), exports);
24
24
  __exportStar(require("./transform-events/transform-liability"), exports);
25
- __exportStar(require("./transform-events/generate-required-document"), exports);
25
+ __exportStar(require("./transform-events/transform-required-document"), exports);
26
26
  __exportStar(require("./transform-events/transform-funding-position"), exports);
27
27
  __exportStar(require("./update-application/merge-application"), exports);
@@ -0,0 +1,67 @@
1
+ import { PersonApplicantPrivacy, ProofOfIdentity } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
2
+ import { EConsent, Identification, Payload as RequiredDocumentPayload, Status } from '../types/events/public-required-document';
3
+ import { PartialApplication } from '../types/partial-application';
4
+ interface TransformRequiredDocumentOptions {
5
+ readonly secondIDEnabled?: boolean;
6
+ }
7
+ /**
8
+ * Gets the applicant gender from the identification data
9
+ *
10
+ * @param {Identification} identification Identification data
11
+ *
12
+ * @returns The gender of the applicant
13
+ */
14
+ export declare const getApplicantGenderFromIdentification: (identification: Identification) => string;
15
+ /**
16
+ * Gets full name on document from the identification data
17
+ *
18
+ * @param {Identification} identification Identification data
19
+ *
20
+ * @returns {string} The full name on document
21
+ */
22
+ export declare const getNameOnDocument: (identification: Identification) => string;
23
+ /**
24
+ * Transforms issued location data of an ID document
25
+ *
26
+ * @param {Identification} identification Identification data
27
+ * @param {boolean} secondIDEnabled Whether or not second Id functionality is enabled
28
+ *
29
+ * @returns {Partial<ProofOfIdentity>} Partial proof of identity object
30
+ */
31
+ export declare const transformIDIssuedLocation: (identification: Identification, secondIDEnabled?: boolean) => Partial<ProofOfIdentity>;
32
+ /**
33
+ * Transforms the verification status data of the ID document
34
+ *
35
+ * @param {Status} status Verification status of the ID document
36
+ * @param {boolean} secondIDEnabled Whether or not secondID mapping is enabled
37
+ *
38
+ * @returns {Partial<ProofOfIdentity>} Partial proof of identity
39
+ */
40
+ export declare const transformVerificationStatus: (status: Status | undefined, secondIDEnabled?: boolean) => Partial<ProofOfIdentity>;
41
+ /**
42
+ * Generates a partial proof of identity object
43
+ *
44
+ * @param {RequiredDocumentPayload} requiredDocumentEventPayload RequiredDocumentCreated/RequiredDocumentUpdated event payload
45
+ * @param {TransformRequiredDocumentOptions} options - Options from generating partial proof of identity
46
+ *
47
+ * @returns {Partial<ProofOfIdentity>} Partial proof of identity document object
48
+ */
49
+ export declare const generateProofOfIdentity: (requiredDocumentEventPayload: RequiredDocumentPayload, options?: TransformRequiredDocumentOptions) => Partial<ProofOfIdentity>;
50
+ /**
51
+ * Generates an applicants disclosure details mapping for the partial application
52
+ *
53
+ * @param {EConsent} eConsent E-Consent detials from the RequiredDocumentCreated/RequqiredDocumentUpdated event payload
54
+ *
55
+ * @returns {PersonApplicantPrivacy} Applicant disclosure details for partial application
56
+ */
57
+ export declare const generatePersonApplicantPrivacy: (eConsent: EConsent) => PersonApplicantPrivacy;
58
+ /**
59
+ * Transforms a RequiredDocumentCreated/RequiredDocumentUpdated event payload into a partial application
60
+ *
61
+ * @param {RequiredDocumentPayload} requiredDocEventPayload A RequiredDocumentCreated/RequiredDocumentUpdated event payload
62
+ * @param {TransformRequiredDocumentOptions} options Required document event transformation options
63
+ *
64
+ * @returns {PartialApplication} A partial application
65
+ */
66
+ export declare const transformRequiredDocument: (requiredDocEventPayload: RequiredDocumentPayload, options?: TransformRequiredDocumentOptions) => PartialApplication;
67
+ export {};
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformRequiredDocument = exports.generatePersonApplicantPrivacy = exports.generateProofOfIdentity = exports.transformVerificationStatus = exports.transformIDIssuedLocation = exports.getNameOnDocument = exports.getApplicantGenderFromIdentification = void 0;
4
+ const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/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");
14
+ /**
15
+ * Gets the applicant gender from the identification data
16
+ *
17
+ * @param {Identification} identification Identification data
18
+ *
19
+ * @returns The gender of the applicant
20
+ */
21
+ const getApplicantGenderFromIdentification = (identification) => {
22
+ const { gender, idTitle } = identification;
23
+ return gender ? (0, lodash_1.capitalize)(gender) : enum_mappings_3.titleGenderMapping[idTitle || public_required_document_1.IDTitle.Unknown];
24
+ };
25
+ exports.getApplicantGenderFromIdentification = getApplicantGenderFromIdentification;
26
+ /**
27
+ * Gets full name on document from the identification data
28
+ *
29
+ * @param {Identification} identification Identification data
30
+ *
31
+ * @returns {string} The full name on document
32
+ */
33
+ const getNameOnDocument = (identification) => {
34
+ const { idFirstName, idMiddleName, idLastName } = identification;
35
+ return [idFirstName, idMiddleName, idLastName].reduce((fullName, nameComponent) => {
36
+ let newFullName = fullName;
37
+ const nameSubstring = nameComponent === null || nameComponent === void 0 ? void 0 : nameComponent.trim();
38
+ if (nameSubstring) {
39
+ newFullName += `${fullName ? ' ' : ''}${nameSubstring}`;
40
+ }
41
+ return newFullName;
42
+ }, '');
43
+ };
44
+ exports.getNameOnDocument = getNameOnDocument;
45
+ /**
46
+ * Transforms issued location data of an ID document
47
+ *
48
+ * @param {Identification} identification Identification data
49
+ * @param {boolean} secondIDEnabled Whether or not second Id functionality is enabled
50
+ *
51
+ * @returns {Partial<ProofOfIdentity>} Partial proof of identity object
52
+ */
53
+ const transformIDIssuedLocation = (identification, secondIDEnabled = false) => {
54
+ const { australianState, idType, issuingCountry = public_required_document_1.IssuingCountry.Australia } = identification;
55
+ let transformedIssuedLocation = {};
56
+ if (idType === public_required_document_1.IDType.Passport && issuingCountry !== public_required_document_1.IssuingCountry.Australia) {
57
+ const foreignCountryOfIssue = enum_mappings_1.countryCodeMapping[issuingCountry];
58
+ transformedIssuedLocation = Object.assign({ '@DocumentType': lixi_internal_request_1.DocumentTypeList.InternationalPassport, '@CountryOfIssue': foreignCountryOfIssue, '@PlaceOfIssue': foreignCountryOfIssue }, (secondIDEnabled && { '@ResidentialAddressVerified': lixi_internal_request_1.YesNoList.No }));
59
+ }
60
+ else {
61
+ transformedIssuedLocation = {
62
+ '@CountryOfIssue': lixi_internal_request_1.CountryCodeList.Au,
63
+ '@PlaceOfIssue': australianState || lixi_internal_request_1.CountryCodeList.Au,
64
+ '@DocumentType': enum_mappings_2.proofOfIdentityMapping[idType],
65
+ };
66
+ }
67
+ return transformedIssuedLocation;
68
+ };
69
+ exports.transformIDIssuedLocation = transformIDIssuedLocation;
70
+ /**
71
+ * Transforms the verification status data of the ID document
72
+ *
73
+ * @param {Status} status Verification status of the ID document
74
+ * @param {boolean} secondIDEnabled Whether or not secondID mapping is enabled
75
+ *
76
+ * @returns {Partial<ProofOfIdentity>} Partial proof of identity
77
+ */
78
+ const transformVerificationStatus = (status, secondIDEnabled = false) => {
79
+ let transformedVerification = {};
80
+ if (status) {
81
+ const verificationStatus = verification_1.verificationMapping[status];
82
+ transformedVerification = Object.assign({ '@PhotographVerified': verificationStatus }, (secondIDEnabled && {
83
+ '@DOBVerified': verificationStatus,
84
+ '@NameVerified': verificationStatus,
85
+ '@SignatureVerified': verificationStatus,
86
+ '@ResidentialAddressVerified': verificationStatus,
87
+ }));
88
+ }
89
+ return transformedVerification;
90
+ };
91
+ exports.transformVerificationStatus = transformVerificationStatus;
92
+ /**
93
+ * Generates a partial proof of identity object
94
+ *
95
+ * @param {RequiredDocumentPayload} requiredDocumentEventPayload RequiredDocumentCreated/RequiredDocumentUpdated event payload
96
+ * @param {TransformRequiredDocumentOptions} options - Options from generating partial proof of identity
97
+ *
98
+ * @returns {Partial<ProofOfIdentity>} Partial proof of identity document object
99
+ */
100
+ const generateProofOfIdentity = (requiredDocumentEventPayload, options = {}) => {
101
+ const { secondIDEnabled = false } = options;
102
+ const { id, status, expiryDate, identification } = requiredDocumentEventPayload;
103
+ const nameOnDocument = (0, exports.getNameOnDocument)(identification);
104
+ const { idNumber } = identification;
105
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ '@UniqueID': id }, (expiryDate && { '@ExpiryDate': (0, iso_date_1.isoDate)(expiryDate) })), (0, exports.transformVerificationStatus)(status, secondIDEnabled)), (nameOnDocument && { '@NameOnDocument': nameOnDocument })), (idNumber && { '@DocumentNumber': idNumber })), (0, exports.transformIDIssuedLocation)(identification, secondIDEnabled)), (secondIDEnabled && {
106
+ '@DocumentCategory': lixi_internal_request_1.DocumentCategoryList.Photographic,
107
+ '@Original': lixi_internal_request_1.YesNoList.Yes,
108
+ }));
109
+ };
110
+ exports.generateProofOfIdentity = generateProofOfIdentity;
111
+ /**
112
+ * Generates an applicants disclosure details mapping for the partial application
113
+ *
114
+ * @param {EConsent} eConsent E-Consent detials from the RequiredDocumentCreated/RequqiredDocumentUpdated event payload
115
+ *
116
+ * @returns {PersonApplicantPrivacy} Applicant disclosure details for partial application
117
+ */
118
+ const generatePersonApplicantPrivacy = (eConsent) => {
119
+ const { hasConsented, consentedAt = new Date() } = eConsent;
120
+ return {
121
+ '@CreditAuthoritySigned': (0, formatYesNo_1.formatYesNo)(hasConsented),
122
+ '@DateSigned': (0, iso_date_1.isoDate)(consentedAt),
123
+ };
124
+ };
125
+ exports.generatePersonApplicantPrivacy = generatePersonApplicantPrivacy;
126
+ /**
127
+ * Transforms a RequiredDocumentCreated/RequiredDocumentUpdated event payload into a partial application
128
+ *
129
+ * @param {RequiredDocumentPayload} requiredDocEventPayload A RequiredDocumentCreated/RequiredDocumentUpdated event payload
130
+ * @param {TransformRequiredDocumentOptions} options Required document event transformation options
131
+ *
132
+ * @returns {PartialApplication} A partial application
133
+ */
134
+ const transformRequiredDocument = (requiredDocEventPayload, options) => {
135
+ const partialApplication = {};
136
+ const { applicantId, applicationId, identification, eConsent } = requiredDocEventPayload;
137
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@UniqueID`, applicantId);
138
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
139
+ if (identification) {
140
+ (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, options));
142
+ }
143
+ if (eConsent) {
144
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Privacy}`, (0, exports.generatePersonApplicantPrivacy)(eConsent));
145
+ }
146
+ return partialApplication;
147
+ };
148
+ exports.transformRequiredDocument = transformRequiredDocument;
@@ -1,7 +1,3 @@
1
1
  import { Status } from '../events/public-required-document';
2
2
  import { YesNoList } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
3
- declare type VerificationMapping = {
4
- [key in Status]: YesNoList;
5
- };
6
- export declare const verificationMapping: VerificationMapping;
7
- export {};
3
+ export declare const verificationMapping: Record<Status, YesNoList>;
@@ -1,8 +1,14 @@
1
+ interface DeepMergeOptions {
2
+ readonly secondIDEnabled?: boolean;
3
+ }
1
4
  /**
2
5
  * Deep merges the application and custom handles specific arrays
3
6
  *
4
- * @param newApplication new application coming from events.
5
7
  * @param existingApplication a saved dynamo application.
8
+ * @param newApplication new application coming from events.
9
+ * @param {DeepMergeOptions} options Deep merge options
10
+ *
6
11
  * @returns merged application.
7
12
  */
8
- export declare function deepMergeApplication(existingApplication: object | undefined, newApplication: object): any;
13
+ export declare function deepMergeApplication(existingApplication: object | undefined, newApplication: object, options?: DeepMergeOptions): any;
14
+ export {};
@@ -6,11 +6,17 @@ const cleanDeep = require('clean-deep');
6
6
  /**
7
7
  * Deep merges the application and custom handles specific arrays
8
8
  *
9
- * @param newApplication new application coming from events.
10
9
  * @param existingApplication a saved dynamo application.
10
+ * @param newApplication new application coming from events.
11
+ * @param {DeepMergeOptions} options Deep merge options
12
+ *
11
13
  * @returns merged application.
12
14
  */
13
- function deepMergeApplication(existingApplication, newApplication) {
15
+ function deepMergeApplication(existingApplication, newApplication, options = {}) {
16
+ if (!existingApplication) {
17
+ return newApplication;
18
+ }
19
+ const { secondIDEnabled = false } = options;
14
20
  // Array fields with @UniqueIDs
15
21
  const listsWithUniqueIds = [
16
22
  'Attachment',
@@ -28,6 +34,9 @@ function deepMergeApplication(existingApplication, newApplication) {
28
34
  'RelatedCompany',
29
35
  'RelatedPerson',
30
36
  ];
37
+ if (secondIDEnabled) {
38
+ listsWithUniqueIds.push('ProofOfIdentity');
39
+ }
31
40
  // Array fields with @x_Party
32
41
  const listsWithXParty = ['Report'];
33
42
  // Array fields with @x_Owner
@@ -40,19 +49,16 @@ function deepMergeApplication(existingApplication, newApplication) {
40
49
  const listsWithXGuarantor = ['Guarantor'];
41
50
  // Curried function which takes a uniqueKey and returns a function which will either replace
42
51
  // or merge the item in the array based on the uniqueKey
43
- if (!existingApplication) {
44
- return newApplication;
45
- }
46
52
  const mergeItems = (uniqueKey) => {
47
53
  return (existingItem, newItem) => {
48
54
  // if not array continue with merge
49
55
  if (!Array.isArray(newItem)) {
50
- return merge(existingItem, newItem, options);
56
+ return merge(existingItem, newItem, mergeOptions);
51
57
  }
52
- return findArrayItemAndMerge(existingItem, newItem, uniqueKey, options);
58
+ return findArrayItemAndMerge(existingItem, newItem, uniqueKey, mergeOptions);
53
59
  };
54
60
  };
55
- const options = {
61
+ const mergeOptions = {
56
62
  customMerge: (key) => {
57
63
  if (listsWithUniqueIds.find((item) => item === key)) {
58
64
  return mergeItems('@UniqueID');
@@ -75,7 +81,7 @@ function deepMergeApplication(existingApplication, newApplication) {
75
81
  return mergeItems(key);
76
82
  },
77
83
  };
78
- const mergedApplication = merge(existingApplication, newApplication, options);
84
+ const mergedApplication = merge(existingApplication, newApplication, mergeOptions);
79
85
  // Default configurations of cleanDeep for reference.
80
86
  const params = {
81
87
  cleanValues: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
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",
@@ -1,44 +0,0 @@
1
- import { PersonApplicantPrivacy, ProofOfIdentity } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
2
- import { EConsent, Identification, Payload as RequiredDocumentPayload } from '../types/events/public-required-document';
3
- /**
4
- * Gets the applicant gender from the identification data
5
- *
6
- * @param identification Identification data
7
- * @returns The gender of the applicant
8
- */
9
- export declare const getApplicantGenderFromIdentification: (identification: Identification) => string;
10
- /**
11
- * Gets full name on document from the identification data
12
- *
13
- * @param identification Identification data
14
- * @returns The full name on document
15
- */
16
- export declare const getNameOnDocument: (identification: Identification) => string;
17
- /**
18
- * Transforms identification data into a partial proof of identity document
19
- *
20
- * @param identification Identification data
21
- * @returns Partial proof of identity object
22
- */
23
- export declare const transformIdentification: (identification: Identification) => Partial<ProofOfIdentity>;
24
- /**
25
- * Generates partial details for document used to verify identity
26
- *
27
- * @param requiredDocument RequiredDocumentCreated/RequiredDocumentUpdated event payload
28
- * @returns Partial proof of identity document object
29
- */
30
- export declare const generateProofOfIdentity: (requiredDocument: RequiredDocumentPayload) => Partial<ProofOfIdentity>;
31
- /**
32
- * Generates an applicants disclosure details mapping for the partial application
33
- *
34
- * @param eConsent E-Consent detials from the RequiredDocumentCreated/RequqiredDocumentUpdated event payload
35
- * @returns Applicant disclosure details for partial application
36
- */
37
- export declare const generatePersonApplicantPrivacy: (eConsent: EConsent) => PersonApplicantPrivacy;
38
- /**
39
- * Transforms a RequiredDocumentCreated or RequiredDocumentUpdated event payload into a partial application
40
- *
41
- * @param requiredDocument A RequiredDocumentCreated or RequiredDocumentUpdated event payload
42
- * @returns A partial application
43
- */
44
- export declare function transformRequiredDocument(requiredDocument: RequiredDocumentPayload): {};
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformRequiredDocument = exports.generatePersonApplicantPrivacy = exports.generateProofOfIdentity = exports.transformIdentification = exports.getNameOnDocument = exports.getApplicantGenderFromIdentification = void 0;
4
- const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/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");
14
- /**
15
- * Gets the applicant gender from the identification data
16
- *
17
- * @param identification Identification data
18
- * @returns The gender of the applicant
19
- */
20
- const getApplicantGenderFromIdentification = (identification) => {
21
- const { gender, idTitle } = identification;
22
- return gender ? (0, lodash_1.capitalize)(gender) : enum_mappings_3.titleGenderMapping[idTitle || public_required_document_1.IDTitle.Unknown];
23
- };
24
- exports.getApplicantGenderFromIdentification = getApplicantGenderFromIdentification;
25
- /**
26
- * Gets full name on document from the identification data
27
- *
28
- * @param identification Identification data
29
- * @returns The full name on document
30
- */
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();
36
- if (nameSubstring) {
37
- newFullName += `${fullName ? ' ' : ''}${nameSubstring}`;
38
- }
39
- return newFullName;
40
- }, '');
41
- };
42
- exports.getNameOnDocument = getNameOnDocument;
43
- /**
44
- * Transforms identification data into a partial proof of identity document
45
- *
46
- * @param identification Identification data
47
- * @returns Partial proof of identity object
48
- */
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
53
- ? {
54
- '@DocumentType': lixi_internal_request_1.DocumentTypeList.InternationalPassport,
55
- '@CountryOfIssue': enum_mappings_1.countryCodeMapping[issuingCountry],
56
- '@PlaceOfIssue': enum_mappings_1.countryCodeMapping[issuingCountry],
57
- }
58
- : { '@DocumentType': enum_mappings_2.proofOfIdentityMapping[idType] }));
59
- };
60
- exports.transformIdentification = transformIdentification;
61
- /**
62
- * Generates partial details for document used to verify identity
63
- *
64
- * @param requiredDocument RequiredDocumentCreated/RequiredDocumentUpdated event payload
65
- * @returns Partial proof of identity document object
66
- */
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)));
70
- };
71
- exports.generateProofOfIdentity = generateProofOfIdentity;
72
- /**
73
- * Generates an applicants disclosure details mapping for the partial application
74
- *
75
- * @param eConsent E-Consent detials from the RequiredDocumentCreated/RequqiredDocumentUpdated event payload
76
- * @returns Applicant disclosure details for partial application
77
- */
78
- const generatePersonApplicantPrivacy = (eConsent) => {
79
- const { hasConsented, consentedAt = new Date() } = eConsent;
80
- return {
81
- '@CreditAuthoritySigned': (0, formatYesNo_1.formatYesNo)(hasConsented),
82
- '@DateSigned': (0, iso_date_1.isoDate)(consentedAt),
83
- };
84
- };
85
- exports.generatePersonApplicantPrivacy = generatePersonApplicantPrivacy;
86
- /**
87
- * Transforms a RequiredDocumentCreated or RequiredDocumentUpdated event payload into a partial application
88
- *
89
- * @param requiredDocument A RequiredDocumentCreated or RequiredDocumentUpdated event payload
90
- * @returns A partial application
91
- */
92
- function transformRequiredDocument(requiredDocument) {
93
- const partialApplication = {};
94
- const { applicantId, applicationId, identification, eConsent } = requiredDocument;
95
- (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.PersonApplicant}.@UniqueID`, applicantId);
96
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
97
- if (identification) {
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));
100
- }
101
- if (eConsent) {
102
- (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Privacy}`, (0, exports.generatePersonApplicantPrivacy)(eConsent));
103
- }
104
- return partialApplication;
105
- }
106
- exports.transformRequiredDocument = transformRequiredDocument;