@lendi/integrations-transform 1.6.0 → 1.6.3

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 (89) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/index.js +26 -10
  3. package/lib/logger.js +5 -2
  4. package/lib/schemas/public-application-event.json +7 -0
  5. package/lib/transform-events/generate-asset-liability-link.js +12 -8
  6. package/lib/transform-events/generate-credit-report-rebuilt.js +12 -8
  7. package/lib/transform-events/generate-employment.js +41 -37
  8. package/lib/transform-events/generate-required-document.d.ts +1 -2
  9. package/lib/transform-events/generate-required-document.js +41 -32
  10. package/lib/transform-events/transform-applicant.js +60 -53
  11. package/lib/transform-events/transform-application-workflow.js +9 -5
  12. package/lib/transform-events/transform-application.d.ts +6 -8
  13. package/lib/transform-events/transform-application.js +30 -25
  14. package/lib/transform-events/transform-asset-address.js +25 -19
  15. package/lib/transform-events/transform-asset.js +128 -118
  16. package/lib/transform-events/transform-expenses.js +39 -31
  17. package/lib/transform-events/transform-funding-position.js +32 -27
  18. package/lib/transform-events/transform-income.js +73 -65
  19. package/lib/transform-events/transform-liability.js +59 -55
  20. package/lib/transform-events/transform-percent-owned.js +7 -3
  21. package/lib/types/enum-mappings/alieo-frequency.js +22 -19
  22. package/lib/types/enum-mappings/asset-type.js +16 -13
  23. package/lib/types/enum-mappings/builder-type.js +8 -5
  24. package/lib/types/enum-mappings/construction-type.js +9 -6
  25. package/lib/types/enum-mappings/country-code.js +245 -242
  26. package/lib/types/enum-mappings/employment-basis.js +11 -8
  27. package/lib/types/enum-mappings/expense-frequency.js +10 -7
  28. package/lib/types/enum-mappings/funding-position.js +32 -29
  29. package/lib/types/enum-mappings/government-benefits.js +9 -6
  30. package/lib/types/enum-mappings/guarantor-relationship-type.js +15 -12
  31. package/lib/types/enum-mappings/housing-status.js +14 -11
  32. package/lib/types/enum-mappings/income-type.js +15 -12
  33. package/lib/types/enum-mappings/index.js +43 -27
  34. package/lib/types/enum-mappings/liability-payment-type.js +8 -5
  35. package/lib/types/enum-mappings/liability-type.js +20 -17
  36. package/lib/types/enum-mappings/living-expense.js +29 -26
  37. package/lib/types/enum-mappings/marital-status.js +11 -8
  38. package/lib/types/enum-mappings/postcode.js +13 -10
  39. package/lib/types/enum-mappings/preferred-repayment.js +9 -6
  40. package/lib/types/enum-mappings/proof-of-identity.js +9 -6
  41. package/lib/types/enum-mappings/property-expense-category.js +10 -7
  42. package/lib/types/enum-mappings/public-financial-asset.js +11 -8
  43. package/lib/types/enum-mappings/public-primary-purpose.js +8 -5
  44. package/lib/types/enum-mappings/public-property-status.js +10 -7
  45. package/lib/types/enum-mappings/public-property-type.js +22 -19
  46. package/lib/types/enum-mappings/residency-status.js +10 -7
  47. package/lib/types/enum-mappings/title-gender.js +12 -9
  48. package/lib/types/enum-mappings/title.js +12 -9
  49. package/lib/types/enum-mappings/to-be-purchased.js +7 -4
  50. package/lib/types/enum-mappings/to-be-used-as-security.js +7 -4
  51. package/lib/types/enum-mappings/transaction-type.js +8 -5
  52. package/lib/types/enum-mappings/verification.js +12 -9
  53. package/lib/types/events/applicant-delete.js +7 -4
  54. package/lib/types/events/application-workflow.js +13 -10
  55. package/lib/types/events/asset-delete.js +7 -4
  56. package/lib/types/events/asset-liability-relation-delete.js +7 -4
  57. package/lib/types/events/credit-report-retrieved.js +7 -4
  58. package/lib/types/events/employment-delete.js +5 -2
  59. package/lib/types/events/expense-delete.js +5 -2
  60. package/lib/types/events/funding-position.js +9 -6
  61. package/lib/types/events/income-delete.js +7 -4
  62. package/lib/types/events/liability-delete.js +5 -2
  63. package/lib/types/events/opportunity.js +9 -6
  64. package/lib/types/events/public-applicant.js +31 -28
  65. package/lib/types/events/public-application.d.ts +1 -0
  66. package/lib/types/events/public-application.js +29 -26
  67. package/lib/types/events/public-asset-liability-relation.js +7 -4
  68. package/lib/types/events/public-asset.js +29 -26
  69. package/lib/types/events/public-employment.js +21 -18
  70. package/lib/types/events/public-expense.js +11 -8
  71. package/lib/types/events/public-funding-position.js +5 -2
  72. package/lib/types/events/public-income.js +15 -12
  73. package/lib/types/events/public-liability.js +19 -16
  74. package/lib/types/events/public-required-document.js +17 -14
  75. package/lib/types/partial-application.js +2 -1
  76. package/lib/types/recursive-partial.js +2 -1
  77. package/lib/update-application/merge-application.js +6 -2
  78. package/lib/update-application/update-primary-applicant.js +17 -12
  79. package/lib/utils/address-tools.js +43 -33
  80. package/lib/utils/clean-up.js +7 -3
  81. package/lib/utils/formatYesNo.js +6 -2
  82. package/lib/utils/generate-address.js +26 -21
  83. package/lib/utils/get-financial-institution.js +8 -4
  84. package/lib/utils/is-asset-type.js +20 -13
  85. package/lib/utils/is-income-type.js +58 -45
  86. package/lib/utils/iso-date.js +6 -2
  87. package/lib/utils/normalise-date.js +5 -1
  88. package/lib/utils/round-decimal.js +5 -1
  89. package/package.json +4 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # 1.6.0
2
+
3
+ BREAKING CHANGES
4
+ * Change to module `commonjs` to make it compatible with existing codebase
5
+
6
+ Changes
7
+ * Upgrade `@lendi/integrations-protocol` to `v2.6.4`
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' });
@@ -122,6 +122,10 @@
122
122
  "hasOptedInRateLock": {
123
123
  "type": "boolean"
124
124
  },
125
+ "isFastRefi": {
126
+ "description": "Indication that this application is a FASTRefi product, for quicker settlements on applicable refinance applications",
127
+ "type": "boolean"
128
+ },
125
129
  "payload": {
126
130
  "type": "object",
127
131
  "additionalProperties": false,
@@ -153,6 +157,9 @@
153
157
  "hasOptedInRateLock": {
154
158
  "$ref": "#/definitions/hasOptedInRateLock"
155
159
  },
160
+ "isFastRefi": {
161
+ "$ref": "#/definitions/isFastRefi"
162
+ },
156
163
  "preliminary": {
157
164
  "type": "object",
158
165
  "additionalProperties": false,
@@ -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,5 +1,4 @@
1
- import { PersonApplicantPrivacy } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
2
- import { ProofOfIdentity } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
1
+ import { PersonApplicantPrivacy, ProofOfIdentity } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
3
2
  import { EConsent, Identification, Payload as RequiredDocumentPayload } from '../types/events/public-required-document';
4
3
  /**
5
4
  * Gets the applicant gender from the identification data
@@ -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-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");
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;