@lendi/integrations-transform 1.6.0 → 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.
Files changed (84) hide show
  1. package/lib/index.js +26 -10
  2. package/lib/logger.js +5 -2
  3. package/lib/transform-events/generate-asset-liability-link.js +12 -8
  4. package/lib/transform-events/generate-credit-report-rebuilt.js +12 -8
  5. package/lib/transform-events/generate-employment.js +41 -37
  6. package/lib/transform-events/generate-required-document.js +41 -32
  7. package/lib/transform-events/transform-applicant.js +60 -53
  8. package/lib/transform-events/transform-application-workflow.js +9 -5
  9. package/lib/transform-events/transform-application.js +22 -18
  10. package/lib/transform-events/transform-asset-address.js +25 -19
  11. package/lib/transform-events/transform-asset.js +128 -118
  12. package/lib/transform-events/transform-expenses.js +39 -31
  13. package/lib/transform-events/transform-funding-position.js +32 -27
  14. package/lib/transform-events/transform-income.js +73 -65
  15. package/lib/transform-events/transform-liability.js +59 -55
  16. package/lib/transform-events/transform-percent-owned.js +7 -3
  17. package/lib/types/enum-mappings/alieo-frequency.js +22 -19
  18. package/lib/types/enum-mappings/asset-type.js +16 -13
  19. package/lib/types/enum-mappings/builder-type.js +8 -5
  20. package/lib/types/enum-mappings/construction-type.js +9 -6
  21. package/lib/types/enum-mappings/country-code.js +245 -242
  22. package/lib/types/enum-mappings/employment-basis.js +11 -8
  23. package/lib/types/enum-mappings/expense-frequency.js +10 -7
  24. package/lib/types/enum-mappings/funding-position.js +32 -29
  25. package/lib/types/enum-mappings/government-benefits.js +9 -6
  26. package/lib/types/enum-mappings/guarantor-relationship-type.js +15 -12
  27. package/lib/types/enum-mappings/housing-status.js +14 -11
  28. package/lib/types/enum-mappings/income-type.js +15 -12
  29. package/lib/types/enum-mappings/index.js +43 -27
  30. package/lib/types/enum-mappings/liability-payment-type.js +8 -5
  31. package/lib/types/enum-mappings/liability-type.js +20 -17
  32. package/lib/types/enum-mappings/living-expense.js +29 -26
  33. package/lib/types/enum-mappings/marital-status.js +11 -8
  34. package/lib/types/enum-mappings/postcode.js +13 -10
  35. package/lib/types/enum-mappings/preferred-repayment.js +9 -6
  36. package/lib/types/enum-mappings/proof-of-identity.js +9 -6
  37. package/lib/types/enum-mappings/property-expense-category.js +10 -7
  38. package/lib/types/enum-mappings/public-financial-asset.js +11 -8
  39. package/lib/types/enum-mappings/public-primary-purpose.js +8 -5
  40. package/lib/types/enum-mappings/public-property-status.js +10 -7
  41. package/lib/types/enum-mappings/public-property-type.js +22 -19
  42. package/lib/types/enum-mappings/residency-status.js +10 -7
  43. package/lib/types/enum-mappings/title-gender.js +12 -9
  44. package/lib/types/enum-mappings/title.js +12 -9
  45. package/lib/types/enum-mappings/to-be-purchased.js +7 -4
  46. package/lib/types/enum-mappings/to-be-used-as-security.js +7 -4
  47. package/lib/types/enum-mappings/transaction-type.js +8 -5
  48. package/lib/types/enum-mappings/verification.js +12 -9
  49. package/lib/types/events/applicant-delete.js +7 -4
  50. package/lib/types/events/application-workflow.js +13 -10
  51. package/lib/types/events/asset-delete.js +7 -4
  52. package/lib/types/events/asset-liability-relation-delete.js +7 -4
  53. package/lib/types/events/credit-report-retrieved.js +7 -4
  54. package/lib/types/events/employment-delete.js +5 -2
  55. package/lib/types/events/expense-delete.js +5 -2
  56. package/lib/types/events/funding-position.js +9 -6
  57. package/lib/types/events/income-delete.js +7 -4
  58. package/lib/types/events/liability-delete.js +5 -2
  59. package/lib/types/events/opportunity.js +9 -6
  60. package/lib/types/events/public-applicant.js +31 -28
  61. package/lib/types/events/public-application.js +29 -26
  62. package/lib/types/events/public-asset-liability-relation.js +7 -4
  63. package/lib/types/events/public-asset.js +29 -26
  64. package/lib/types/events/public-employment.js +21 -18
  65. package/lib/types/events/public-expense.js +11 -8
  66. package/lib/types/events/public-funding-position.js +5 -2
  67. package/lib/types/events/public-income.js +15 -12
  68. package/lib/types/events/public-liability.js +19 -16
  69. package/lib/types/events/public-required-document.js +17 -14
  70. package/lib/types/partial-application.js +2 -1
  71. package/lib/types/recursive-partial.js +2 -1
  72. package/lib/update-application/merge-application.js +6 -2
  73. package/lib/update-application/update-primary-applicant.js +17 -12
  74. package/lib/utils/address-tools.js +43 -33
  75. package/lib/utils/clean-up.js +7 -3
  76. package/lib/utils/formatYesNo.js +6 -2
  77. package/lib/utils/generate-address.js +26 -21
  78. package/lib/utils/get-financial-institution.js +8 -4
  79. package/lib/utils/is-asset-type.js +20 -13
  80. package/lib/utils/is-income-type.js +58 -45
  81. package/lib/utils/iso-date.js +6 -2
  82. package/lib/utils/normalise-date.js +5 -1
  83. package/lib/utils/round-decimal.js +5 -1
  84. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -1,11 +1,27 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
1
17
  /* istanbul ignore file */
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';
18
+ __exportStar(require("./transform-events/transform-applicant"), exports);
19
+ __exportStar(require("./transform-events/transform-application"), exports);
20
+ __exportStar(require("./transform-events/transform-application-workflow"), exports);
21
+ __exportStar(require("./transform-events/transform-income"), exports);
22
+ __exportStar(require("./transform-events/transform-asset"), exports);
23
+ __exportStar(require("./transform-events/transform-expenses"), exports);
24
+ __exportStar(require("./transform-events/transform-liability"), exports);
25
+ __exportStar(require("./transform-events/generate-required-document"), exports);
26
+ __exportStar(require("./transform-events/transform-funding-position"), exports);
27
+ __exportStar(require("./update-application/merge-application"), exports);
package/lib/logger.js CHANGED
@@ -1,2 +1,5 @@
1
- import { createLogger } from '@lendi/logging';
2
- export const logger = createLogger({ name: 'integrations-transform', messageKey: 'message' });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = void 0;
4
+ const logging_1 = require("@lendi/logging");
5
+ exports.logger = (0, logging_1.createLogger)({ name: 'integrations-transform', messageKey: 'message' });
@@ -1,5 +1,8 @@
1
- import { set } from 'lodash';
2
- import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateAssetLiabilityLink = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
3
6
  /**
4
7
  * Generates a partial application from the partial asset and liability event.
5
8
  *
@@ -8,18 +11,19 @@ import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths'
8
11
  * @param assetLiabilityLink:.relation
9
12
  * @returns partialApplication: A partial internal request.
10
13
  */
11
- export function generateAssetLiabilityLink({ applicationId, relation }) {
14
+ function generateAssetLiabilityLink({ applicationId, relation }) {
12
15
  const partialApplication = {};
13
16
  const assetLiabilityMapping = {
14
- applicationId: paths.ApplicationId,
15
- liabilityId: `${paths.Liability}.@UniqueID`,
16
- assetId: `${paths.Liability}.Security[0].@x_Security`,
17
+ applicationId: application_paths_1.paths.ApplicationId,
18
+ liabilityId: `${application_paths_1.paths.Liability}.@UniqueID`,
19
+ assetId: `${application_paths_1.paths.Liability}.Security[0].@x_Security`,
17
20
  };
18
- set(partialApplication, assetLiabilityMapping.applicationId, applicationId);
21
+ (0, lodash_1.set)(partialApplication, assetLiabilityMapping.applicationId, applicationId);
19
22
  for (const [key, value] of Object.entries(relation)) {
20
23
  if (assetLiabilityMapping[key]) {
21
- set(partialApplication, assetLiabilityMapping[key], value);
24
+ (0, lodash_1.set)(partialApplication, assetLiabilityMapping[key], value);
22
25
  }
23
26
  }
24
27
  return partialApplication;
25
28
  }
29
+ exports.generateAssetLiabilityLink = generateAssetLiabilityLink;
@@ -1,13 +1,16 @@
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';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateCreditReportRebuilt = void 0;
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");
4
7
  /**
5
8
  * Generates LIXI compliant `Attachment` and `CreditAssessment` objects which
6
9
  * use credit report data fetched from Equifax.
7
10
  *
8
11
  * @param {CreditReportPayload} creditReport - Credit report rebuilt event.
9
12
  */
10
- export function generateCreditReportRebuilt(creditReport) {
13
+ function generateCreditReportRebuilt(creditReport) {
11
14
  const { applicantId, raw, source } = creditReport;
12
15
  const id = `${applicantId}-creditReport`;
13
16
  const attachment = {
@@ -23,15 +26,16 @@ export function generateCreditReportRebuilt(creditReport) {
23
26
  '@x_Party': applicantId,
24
27
  Content: [
25
28
  {
26
- '@Type': ReportContentTypeList.XML,
29
+ '@Type': lixi_internal_request_1.ReportContentTypeList.XML,
27
30
  '@x_Attachment': id,
28
31
  },
29
32
  ],
30
33
  };
31
34
  const partialApplication = {};
32
35
  // Set application id, attachment and credit assessment report.
33
- set(partialApplication, paths.ApplicationId, creditReport.applicationId);
34
- set(partialApplication, paths.Attachment, [attachment]);
35
- set(partialApplication, paths.Report, [report]);
36
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, creditReport.applicationId);
37
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Attachment, [attachment]);
38
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Report, [report]);
36
39
  return partialApplication;
37
40
  }
41
+ exports.generateCreditReportRebuilt = generateCreditReportRebuilt;
@@ -1,51 +1,54 @@
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';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateEmployment = void 0;
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");
7
10
  /**
8
11
  * Generates a partial application from a employment event.
9
12
  *
10
13
  * @param employment a employment event payload.
11
14
  * @returns partialApplication an incomplete application.
12
15
  */
13
- export function generateEmployment(employment) {
16
+ function generateEmployment(employment) {
14
17
  const partialApplication = {};
15
- let employmentPath = paths.PAYG;
18
+ let employmentPath = application_paths_1.paths.PAYG;
16
19
  let isEmployed = false;
17
20
  const { applicationId } = employment;
18
21
  // Each one Employment object can only contain one of the three types. Set the three object to undefined so that the
19
22
  // other two types will be removed from the final result.
20
23
  // @pliu 19/11/19
21
- set(partialApplication, paths.PAYG, undefined);
22
- set(partialApplication, paths.SelfEmployed, undefined);
23
- set(partialApplication, paths.NotEmployed, undefined);
24
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.PAYG, undefined);
25
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.SelfEmployed, undefined);
26
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.NotEmployed, undefined);
24
27
  switch (employment.employmentType) {
25
- case EmploymentType.Employee:
28
+ case public_employment_1.EmploymentType.Employee:
26
29
  isEmployed = true;
27
- employmentPath = paths.PAYG;
30
+ employmentPath = application_paths_1.paths.PAYG;
28
31
  // Setting default for onProbation. If field exists in event value will get overwritten.
29
- set(partialApplication, `${employmentPath}.@OnProbation`, YesNoList.No);
32
+ (0, lodash_1.set)(partialApplication, `${employmentPath}.@OnProbation`, lixi_internal_request_1.YesNoList.No);
30
33
  break;
31
- case EmploymentType.SelfEmployed:
34
+ case public_employment_1.EmploymentType.SelfEmployed:
32
35
  isEmployed = true;
33
- employmentPath = paths.SelfEmployed;
36
+ employmentPath = application_paths_1.paths.SelfEmployed;
34
37
  break;
35
- case EmploymentType.NotWorking:
36
- employmentPath = paths.NotEmployed;
37
- set(partialApplication, `${employmentPath}.Income.@OtherIncomeAmount`, 0);
38
- set(partialApplication, `${employmentPath}.Income.@OtherIncomeFrequency`, Frequency.Fortnightly);
38
+ case public_employment_1.EmploymentType.NotWorking:
39
+ employmentPath = application_paths_1.paths.NotEmployed;
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);
39
42
  break;
40
43
  default:
41
- logger.warn({ message: `Unknown EmploymentType ${employment.employmentType}`, applicationId });
44
+ logger_1.logger.warn({ message: `Unknown EmploymentType ${employment.employmentType}`, applicationId });
42
45
  }
43
46
  const employmentMapping = {
44
- applicationId: paths.ApplicationId,
45
- applicantId: `${paths.PersonApplicant}.@UniqueID`,
47
+ applicationId: application_paths_1.paths.ApplicationId,
48
+ applicantId: `${application_paths_1.paths.PersonApplicant}.@UniqueID`,
46
49
  id: `${employmentPath}.@UniqueID`,
47
- abn: `${paths.RelatedCompany}.@ABN`,
48
- businessName: `${paths.RelatedCompany}.@BusinessName`,
50
+ abn: `${application_paths_1.paths.RelatedCompany}.@ABN`,
51
+ businessName: `${application_paths_1.paths.RelatedCompany}.@BusinessName`,
49
52
  type: `${employmentPath}.@Status`,
50
53
  employmentBasis: `${employmentPath}.@Basis`,
51
54
  startDate: `${employmentPath}.@StartDate`,
@@ -57,45 +60,46 @@ export function generateEmployment(employment) {
57
60
  if (employmentMapping[key]) {
58
61
  switch (key) {
59
62
  case 'type':
60
- set(partialApplication, employmentMapping[key], capitalize(value));
63
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], (0, lodash_1.capitalize)(value));
61
64
  break;
62
65
  case 'abn':
63
66
  case 'businessName':
64
67
  // Only transform value in RelatedCompany for employed (self employed or employee) employment, otherwise RelatedCompany would missing UniqueID
65
68
  if (isEmployed) {
66
- set(partialApplication, employmentMapping[key], value.toString());
69
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], value.toString());
67
70
  }
68
71
  break;
69
72
  case 'employmentBasis':
70
- set(partialApplication, employmentMapping[key], paygEmploymentBasisMapping[value]);
73
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], enum_mappings_1.paygEmploymentBasisMapping[value]);
71
74
  break;
72
75
  case 'id':
73
- set(partialApplication, employmentMapping[key], value);
76
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], value);
74
77
  if (isEmployed) {
75
- set(partialApplication, `${employmentPath}.@x_Employer`, `${value}-businessName`);
76
- set(partialApplication, `${paths.RelatedCompany}.@UniqueID`, `${value}-businessName`);
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`);
77
80
  }
78
81
  break;
79
82
  case 'onProbation':
80
- if (employment.employmentType === EmploymentType.Employee) {
81
- const onProbation = value ? YesNoList.Yes : YesNoList.No;
82
- set(partialApplication, employmentMapping[key], onProbation);
83
+ if (employment.employmentType === public_employment_1.EmploymentType.Employee) {
84
+ const onProbation = value ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No;
85
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], onProbation);
83
86
  }
84
87
  break;
85
88
  case 'role':
86
89
  const { anzsco = {} } = value;
87
90
  if (anzsco.code) {
88
- set(partialApplication, `${employmentPath}.@ANZSCOOccupationCode`, anzsco.code.toString());
91
+ (0, lodash_1.set)(partialApplication, `${employmentPath}.@ANZSCOOccupationCode`, anzsco.code.toString());
89
92
  }
90
93
  if (anzsco.occupation) {
91
- set(partialApplication, employmentMapping[key], anzsco.occupation);
94
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], anzsco.occupation);
92
95
  }
93
96
  break;
94
97
  default:
95
- set(partialApplication, employmentMapping[key], value);
98
+ (0, lodash_1.set)(partialApplication, employmentMapping[key], value);
96
99
  break;
97
100
  }
98
101
  }
99
102
  }
100
103
  return partialApplication;
101
104
  }
105
+ exports.generateEmployment = generateEmployment;
@@ -1,30 +1,34 @@
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';
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-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");
11
14
  /**
12
15
  * Gets the applicant gender from the identification data
13
16
  *
14
17
  * @param identification Identification data
15
18
  * @returns The gender of the applicant
16
19
  */
17
- export const getApplicantGenderFromIdentification = (identification) => {
20
+ const getApplicantGenderFromIdentification = (identification) => {
18
21
  const { gender, idTitle } = identification;
19
- return gender ? capitalize(gender) : titleGenderMapping[idTitle || IDTitle.Unknown];
22
+ return gender ? (0, lodash_1.capitalize)(gender) : enum_mappings_3.titleGenderMapping[idTitle || public_required_document_1.IDTitle.Unknown];
20
23
  };
24
+ exports.getApplicantGenderFromIdentification = getApplicantGenderFromIdentification;
21
25
  /**
22
26
  * Gets full name on document from the identification data
23
27
  *
24
28
  * @param identification Identification data
25
29
  * @returns The full name on document
26
30
  */
27
- export const getNameOnDocument = (identification) => {
31
+ const getNameOnDocument = (identification) => {
28
32
  const { idFirstName, idMiddleName, idLastName } = identification;
29
33
  return [idFirstName, idMiddleName, idLastName].reduce((fullName, nameComponent) => {
30
34
  let newFullName = fullName;
@@ -35,63 +39,68 @@ export const getNameOnDocument = (identification) => {
35
39
  return newFullName;
36
40
  }, '');
37
41
  };
42
+ exports.getNameOnDocument = getNameOnDocument;
38
43
  /**
39
44
  * Transforms identification data into a partial proof of identity document
40
45
  *
41
46
  * @param identification Identification data
42
47
  * @returns Partial proof of identity object
43
48
  */
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
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
48
53
  ? {
49
- '@DocumentType': DocumentTypeList.InternationalPassport,
50
- '@CountryOfIssue': countryCodeMapping[issuingCountry],
51
- '@PlaceOfIssue': countryCodeMapping[issuingCountry],
54
+ '@DocumentType': lixi_internal_request_1.DocumentTypeList.InternationalPassport,
55
+ '@CountryOfIssue': enum_mappings_1.countryCodeMapping[issuingCountry],
56
+ '@PlaceOfIssue': enum_mappings_1.countryCodeMapping[issuingCountry],
52
57
  }
53
- : { '@DocumentType': proofOfIdentityMapping[idType] }));
58
+ : { '@DocumentType': enum_mappings_2.proofOfIdentityMapping[idType] }));
54
59
  };
60
+ exports.transformIdentification = transformIdentification;
55
61
  /**
56
62
  * Generates partial details for document used to verify identity
57
63
  *
58
64
  * @param requiredDocument RequiredDocumentCreated/RequiredDocumentUpdated event payload
59
65
  * @returns Partial proof of identity document object
60
66
  */
61
- export const generateProofOfIdentity = (requiredDocument) => {
67
+ const generateProofOfIdentity = (requiredDocument) => {
62
68
  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)));
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)));
64
70
  };
71
+ exports.generateProofOfIdentity = generateProofOfIdentity;
65
72
  /**
66
73
  * Generates an applicants disclosure details mapping for the partial application
67
74
  *
68
75
  * @param eConsent E-Consent detials from the RequiredDocumentCreated/RequqiredDocumentUpdated event payload
69
76
  * @returns Applicant disclosure details for partial application
70
77
  */
71
- export const generatePersonApplicantPrivacy = (eConsent) => {
78
+ const generatePersonApplicantPrivacy = (eConsent) => {
72
79
  const { hasConsented, consentedAt = new Date() } = eConsent;
73
80
  return {
74
- '@CreditAuthoritySigned': formatYesNo(hasConsented),
75
- '@DateSigned': isoDate(consentedAt),
81
+ '@CreditAuthoritySigned': (0, formatYesNo_1.formatYesNo)(hasConsented),
82
+ '@DateSigned': (0, iso_date_1.isoDate)(consentedAt),
76
83
  };
77
84
  };
85
+ exports.generatePersonApplicantPrivacy = generatePersonApplicantPrivacy;
78
86
  /**
79
87
  * Transforms a RequiredDocumentCreated or RequiredDocumentUpdated event payload into a partial application
80
88
  *
81
89
  * @param requiredDocument A RequiredDocumentCreated or RequiredDocumentUpdated event payload
82
90
  * @returns A partial application
83
91
  */
84
- export function transformRequiredDocument(requiredDocument) {
92
+ function transformRequiredDocument(requiredDocument) {
85
93
  const partialApplication = {};
86
94
  const { applicantId, applicationId, identification, eConsent } = requiredDocument;
87
- set(partialApplication, `${paths.PersonApplicant}.@UniqueID`, applicantId);
88
- set(partialApplication, paths.ApplicationId, applicationId);
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);
89
97
  if (identification) {
90
- set(partialApplication, `${paths.PersonApplicant}.@Gender`, getApplicantGenderFromIdentification(identification));
91
- set(partialApplication, `${paths.ProofOfIdentity}`, generateProofOfIdentity(requiredDocument));
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));
92
100
  }
93
101
  if (eConsent) {
94
- set(partialApplication, `${paths.Privacy}`, generatePersonApplicantPrivacy(eConsent));
102
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Privacy}`, (0, exports.generatePersonApplicantPrivacy)(eConsent));
95
103
  }
96
104
  return partialApplication;
97
105
  }
106
+ exports.transformRequiredDocument = transformRequiredDocument;
@@ -1,27 +1,31 @@
1
- import { CountryCodeList, YesNoList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
- import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
3
- import { get, omit, set } from 'lodash';
4
- import { rebuildAddress } from '../utils/address-tools';
5
- import { countryCodeMapping, maritalStatusMapping, residencyStatusMapping, titleMapping } from '../types/enum-mappings';
6
- import { ResidencyStatus, Title, } from '../types/events/public-applicant';
7
- import { normaliseDate } from '../utils/normalise-date';
8
- export const booleanMapping = (input = false) => (input === true ? YesNoList.Yes : YesNoList.No);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateDependants = exports.generateContact = exports.transformApplicant = exports.booleanMapping = void 0;
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 address_tools_1 = require("../utils/address-tools");
8
+ const enum_mappings_1 = require("../types/enum-mappings");
9
+ const public_applicant_1 = require("../types/events/public-applicant");
10
+ const normalise_date_1 = require("../utils/normalise-date");
11
+ const booleanMapping = (input = false) => (input === true ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
12
+ exports.booleanMapping = booleanMapping;
9
13
  const applicantMapping = {
10
- applicationId: paths.ApplicationId,
11
- citizenship: `${paths.PersonApplicant}.@Citizenship`,
12
- contact: `${paths.PersonApplicant}.Contact`,
14
+ applicationId: application_paths_1.paths.ApplicationId,
15
+ citizenship: `${application_paths_1.paths.PersonApplicant}.@Citizenship`,
16
+ contact: `${application_paths_1.paths.PersonApplicant}.Contact`,
13
17
  dependants: 'dependants',
14
- dateOfBirth: `${paths.PersonApplicant}.@DateOfBirth`,
15
- firstName: `${paths.PersonApplicant}.PersonName.@FirstName`,
16
- id: `${paths.PersonApplicant}.@UniqueID`,
17
- isFirstHomeBuyer: `${paths.PersonApplicant}.@FirstHomeBuyer`,
18
- isPrimaryApplicant: `${paths.PersonApplicant}.@PrimaryApplicant`,
19
- lastName: `${paths.PersonApplicant}.PersonName.@Surname`,
20
- maritalStatus: `${paths.PersonApplicant}.@MaritalStatus`,
21
- maritalDetails: `${paths.PersonApplicant}.MaritalStatusDetails.@x_Spouse`,
22
- middleName: `${paths.PersonApplicant}.PersonName.@MiddleNames`,
23
- residencyStatus: `${paths.PersonApplicant}.@ResidencyStatus`,
24
- title: `${paths.PersonName}.@NameTitle`,
18
+ dateOfBirth: `${application_paths_1.paths.PersonApplicant}.@DateOfBirth`,
19
+ firstName: `${application_paths_1.paths.PersonApplicant}.PersonName.@FirstName`,
20
+ id: `${application_paths_1.paths.PersonApplicant}.@UniqueID`,
21
+ isFirstHomeBuyer: `${application_paths_1.paths.PersonApplicant}.@FirstHomeBuyer`,
22
+ isPrimaryApplicant: `${application_paths_1.paths.PersonApplicant}.@PrimaryApplicant`,
23
+ lastName: `${application_paths_1.paths.PersonApplicant}.PersonName.@Surname`,
24
+ maritalStatus: `${application_paths_1.paths.PersonApplicant}.@MaritalStatus`,
25
+ maritalDetails: `${application_paths_1.paths.PersonApplicant}.MaritalStatusDetails.@x_Spouse`,
26
+ middleName: `${application_paths_1.paths.PersonApplicant}.PersonName.@MiddleNames`,
27
+ residencyStatus: `${application_paths_1.paths.PersonApplicant}.@ResidencyStatus`,
28
+ title: `${application_paths_1.paths.PersonName}.@NameTitle`,
25
29
  };
26
30
  /**
27
31
  * Transforms a partial Applicant event to a partial LIXI application.
@@ -30,61 +34,62 @@ const applicantMapping = {
30
34
  * @param applicant
31
35
  * @returns partialApplication an incomplete application.
32
36
  */
33
- export function transformApplicant(applicant) {
37
+ function transformApplicant(applicant) {
34
38
  const partialApplication = {};
35
39
  const { id: applicantId, applicationId } = applicant;
36
- set(partialApplication, applicantMapping['isFirstHomeBuyer'], booleanMapping(applicant.isFirstHomeBuyer));
37
- set(partialApplication, applicantMapping['isPrimaryApplicant'], booleanMapping(applicant.isPrimaryApplicant));
38
- set(partialApplication, applicantMapping['title'], titleMapping[applicant.title || Title.Unknown]);
39
- const applicantUpdated = omit(applicant, ['isFirstHomeBuyer', 'isPrimaryApplicant', 'title']);
40
+ (0, lodash_1.set)(partialApplication, applicantMapping['isFirstHomeBuyer'], (0, exports.booleanMapping)(applicant.isFirstHomeBuyer));
41
+ (0, lodash_1.set)(partialApplication, applicantMapping['isPrimaryApplicant'], (0, exports.booleanMapping)(applicant.isPrimaryApplicant));
42
+ (0, lodash_1.set)(partialApplication, applicantMapping['title'], enum_mappings_1.titleMapping[applicant.title || public_applicant_1.Title.Unknown]);
43
+ const applicantUpdated = (0, lodash_1.omit)(applicant, ['isFirstHomeBuyer', 'isPrimaryApplicant', 'title']);
40
44
  for (const [key, value] of Object.entries(applicantUpdated)) {
41
45
  if (applicantMapping[key]) {
42
46
  switch (key) {
43
47
  case 'dateOfBirth':
44
- set(partialApplication, applicantMapping[key], normaliseDate(value));
48
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], (0, normalise_date_1.normaliseDate)(value));
45
49
  break;
46
50
  case 'maritalStatus':
47
- set(partialApplication, applicantMapping[key], maritalStatusMapping[value]);
51
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], enum_mappings_1.maritalStatusMapping[value]);
48
52
  break;
49
53
  case 'citizenship':
50
- set(partialApplication, applicantMapping[key], countryCodeMapping[value]);
54
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], enum_mappings_1.countryCodeMapping[value]);
51
55
  break;
52
56
  case 'residencyStatus':
53
- set(partialApplication, applicantMapping[key], residencyStatusMapping[value]);
57
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], enum_mappings_1.residencyStatusMapping[value]);
54
58
  // Certain bank integrations require the ability to differentiate between permanentResident and Citizen
55
59
  // As lixi does not have a citizen enum for residencyStatus citizen is mapped to permanentResident
56
60
  // Adding a @Citizenship attribute to person applicant gives us the ability to determine citizenship status
57
61
  // If citizen this field will be always added and value will be AU.
58
62
  // @tsilva 21/11/19
59
- if (value === ResidencyStatus.AustralianCitizen) {
60
- set(partialApplication, applicantMapping.citizenship, CountryCodeList.Au);
63
+ if (value === public_applicant_1.ResidencyStatus.AustralianCitizen) {
64
+ (0, lodash_1.set)(partialApplication, applicantMapping.citizenship, lixi_internal_request_1.CountryCodeList.Au);
61
65
  }
62
66
  break;
63
67
  case 'maritalDetails':
64
- const id = get(value, 'applicantId');
68
+ const id = (0, lodash_1.get)(value, 'applicantId');
65
69
  if (id)
66
- set(partialApplication, applicantMapping[key], id);
70
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], id);
67
71
  break;
68
72
  case 'contact':
69
73
  const { lixiContact, lixiAddresses } = generateContact(value, applicantId);
70
- set(partialApplication, applicantMapping[key], lixiContact);
74
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], lixiContact);
71
75
  if (lixiAddresses.length > 0) {
72
- set(partialApplication, paths.Addresses, lixiAddresses);
76
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Addresses, lixiAddresses);
73
77
  }
74
78
  break;
75
79
  case 'dependants':
76
80
  const dependants = generateDependants(value, applicantId);
77
- set(partialApplication, `${paths.Household}.@UniqueID`, `${applicationId}-household`);
78
- set(partialApplication, `${paths.Household}.Dependant`, dependants);
81
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Household}.@UniqueID`, `${applicationId}-household`);
82
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Household}.Dependant`, dependants);
79
83
  break;
80
84
  default:
81
- set(partialApplication, applicantMapping[key], value);
85
+ (0, lodash_1.set)(partialApplication, applicantMapping[key], value);
82
86
  break;
83
87
  }
84
88
  }
85
89
  }
86
90
  return partialApplication;
87
91
  }
92
+ exports.transformApplicant = transformApplicant;
88
93
  const contactMapping = {
89
94
  emailAddress: 'EmailAddress.0.@Email',
90
95
  mobileNumber: 'Mobile.@Number',
@@ -100,7 +105,7 @@ const contactMapping = {
100
105
  * @param contact
101
106
  * @param id
102
107
  */
103
- export function generateContact(contact, id) {
108
+ function generateContact(contact, id) {
104
109
  const lixiContact = {};
105
110
  const lixiAddresses = [];
106
111
  for (const [key, value] of Object.entries(contact)) {
@@ -109,25 +114,25 @@ export function generateContact(contact, id) {
109
114
  case 'currentAddress':
110
115
  {
111
116
  const addressId = `${id}-current`;
112
- const { lixiAddress, lixiContactAddress } = rebuildAddress(value, addressId);
117
+ const { lixiAddress, lixiContactAddress } = (0, address_tools_1.rebuildAddress)(value, addressId);
113
118
  lixiAddresses.push(lixiAddress);
114
- set(lixiContact, contactMapping[key], lixiContactAddress);
119
+ (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
115
120
  }
116
121
  break;
117
122
  case 'postSettlementAddress':
118
123
  {
119
124
  const addressId = `${id}-postSettlement`;
120
- const { lixiAddress, lixiContactAddress } = rebuildAddress({ residentialAddress: value }, addressId);
125
+ const { lixiAddress, lixiContactAddress } = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId);
121
126
  lixiAddresses.push(lixiAddress);
122
- set(lixiContact, contactMapping[key], lixiContactAddress);
127
+ (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
123
128
  }
124
129
  break;
125
130
  case 'mailingAddress':
126
131
  {
127
132
  const addressId = `${id}-mailing`;
128
- const { lixiAddress } = rebuildAddress({ residentialAddress: value }, addressId);
133
+ const { lixiAddress } = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId);
129
134
  lixiAddresses.push(lixiAddress);
130
- set(lixiContact, contactMapping[key], addressId);
135
+ (0, lodash_1.set)(lixiContact, contactMapping[key], addressId);
131
136
  }
132
137
  break;
133
138
  case 'previousAddresses':
@@ -135,32 +140,33 @@ export function generateContact(contact, id) {
135
140
  const addressId = `${id}-previous`;
136
141
  const previousAddresses = value.sort((lhs, rhs) => lhs.endDate.localeCompare(rhs.endDate));
137
142
  const previousAddress = previousAddresses.pop();
138
- const { lixiAddress, lixiContactAddress } = rebuildAddress(previousAddress, addressId);
143
+ const { lixiAddress, lixiContactAddress } = (0, address_tools_1.rebuildAddress)(previousAddress, addressId);
139
144
  lixiAddresses.push(lixiAddress);
140
- set(lixiContact, contactMapping[key], lixiContactAddress);
145
+ (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
141
146
  // PriorAddresses
142
147
  previousAddresses.forEach((address, index) => {
143
- const { lixiAddress, lixiContactAddress } = rebuildAddress(address, `${id}-prior-${index}`);
148
+ const { lixiAddress, lixiContactAddress } = (0, address_tools_1.rebuildAddress)(address, `${id}-prior-${index}`);
144
149
  lixiAddresses.push(lixiAddress);
145
- set(lixiContact, `${contactMapping['priorAddress']}.${index}`, lixiContactAddress);
150
+ (0, lodash_1.set)(lixiContact, `${contactMapping['priorAddress']}.${index}`, lixiContactAddress);
146
151
  });
147
152
  }
148
153
  break;
149
154
  default:
150
- set(lixiContact, contactMapping[key], value);
155
+ (0, lodash_1.set)(lixiContact, contactMapping[key], value);
151
156
  break;
152
157
  }
153
158
  }
154
159
  }
155
160
  return { lixiContact, lixiAddresses };
156
161
  }
162
+ exports.generateContact = generateContact;
157
163
  /**
158
164
  * Generate dependants
159
165
  *
160
166
  * @param dependants
161
167
  * @param id
162
168
  */
163
- export function generateDependants(dependants, id) {
169
+ function generateDependants(dependants, id) {
164
170
  return dependants.map((dependant) => ({
165
171
  '@Age': dependant.age,
166
172
  '@UniqueID': dependant.id,
@@ -171,3 +177,4 @@ export function generateDependants(dependants, id) {
171
177
  ],
172
178
  }));
173
179
  }
180
+ exports.generateDependants = generateDependants;