@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
@@ -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;
@@ -1,19 +1,23 @@
1
- import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
2
- import { set } from 'lodash';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformApplicationWorkflow = void 0;
4
+ const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
5
+ const lodash_1 = require("lodash");
3
6
  /**
4
7
  * Generates a partial application from an ApplicationWorkflow event
5
8
  *
6
9
  * @param applicationWorkflowEventPayload ApplicationWorkflow event payload
7
10
  * @returns A partial application
8
11
  */
9
- export function transformApplicationWorkflow(applicationWorkflowEventPayload) {
12
+ function transformApplicationWorkflow(applicationWorkflowEventPayload) {
10
13
  const { stage, applicationStage, applicationId } = applicationWorkflowEventPayload, partialApplication = {};
11
- set(partialApplication, paths.ApplicationId, applicationId);
14
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
12
15
  // The stage being defaulted to Unknown caters for LGSF application workflow events having stage as an optional attribute in the future
13
16
  const instructionDetails = {
14
17
  '@UniqueID': `${applicationId}-stage`,
15
18
  '@Details': applicationStage || stage || 'Unknown',
16
19
  };
17
- set(partialApplication, paths.Instructions, instructionDetails);
20
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Instructions, instructionDetails);
18
21
  return partialApplication;
19
22
  }
23
+ exports.transformApplicationWorkflow = transformApplicationWorkflow;
@@ -1,16 +1,14 @@
1
1
  import { Payload as ApplicationPayload } from '../types/events/public-application';
2
- interface transformApplicationOptions {
2
+ export interface TransformApplicationOptions {
3
3
  uniqueIdSuffix?: string;
4
4
  enableRateLock?: boolean;
5
+ enableFastRefi?: boolean;
5
6
  }
6
7
  /**
7
8
  * Transforms a partial opportunity event to a partial internal request.
8
9
  *
9
- * @param opportunity: Partial opportunity event.
10
- * @param uniqueIdSuffix: Suffix for uniquerId
11
- * @param opportunity
12
- * @param options
13
- * @returns partialApplication: A partial internal request.
10
+ * @param {ApplicationPayload} opportunity Public application event payload
11
+ * @param {TransformApplicationOptions} options Options for transforming the public application event
12
+ * @returns Partial application
14
13
  */
15
- export declare function transformApplication(opportunity: ApplicationPayload, options?: transformApplicationOptions): {};
16
- export {};
14
+ export declare function transformApplication(opportunity: ApplicationPayload, options?: TransformApplicationOptions): {};
@@ -1,35 +1,39 @@
1
- import { EventNameApplicationInstructionsList } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
2
- import { paths as creditProtocolPaths } from '@lendi/integrations-credit-protocol/utils/application-paths';
3
- import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
4
- import { set } from 'lodash';
5
- import { preferredRepaymentMapping, transactionTypeMapping } from '../types/enum-mappings/';
6
- import { booleanMapping } from './transform-applicant';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformApplication = 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-credit-protocol/utils/application-paths");
6
+ const application_paths_2 = require("@lendi/integrations-protocol/lib/utils/application-paths");
7
+ const lodash_1 = require("lodash");
8
+ const enum_mappings_1 = require("../types/enum-mappings/");
9
+ const transform_applicant_1 = require("./transform-applicant");
7
10
  /**
8
11
  * Transforms a partial opportunity event to a partial internal request.
9
12
  *
10
- * @param opportunity: Partial opportunity event.
11
- * @param uniqueIdSuffix: Suffix for uniquerId
12
- * @param opportunity
13
- * @param options
14
- * @returns partialApplication: A partial internal request.
13
+ * @param {ApplicationPayload} opportunity Public application event payload
14
+ * @param {TransformApplicationOptions} options Options for transforming the public application event
15
+ * @returns Partial application
15
16
  */
16
- export function transformApplication(opportunity, options = {}) {
17
- const { uniqueIdSuffix = 'loanDetails', enableRateLock = false } = options;
17
+ function transformApplication(opportunity, options = {}) {
18
+ const { uniqueIdSuffix = 'loanDetails', enableRateLock = false, enableFastRefi = false } = options;
18
19
  const partialApplication = {};
19
20
  const opportunityMapping = {
20
- brand: paths.BusinessName,
21
- id: paths.ApplicationId,
22
- paymentType: `${paths.LoanTerm}.@PaymentType`,
21
+ brand: application_paths_2.paths.BusinessName,
22
+ id: application_paths_2.paths.ApplicationId,
23
+ paymentType: `${application_paths_2.paths.LoanTerm}.@PaymentType`,
23
24
  preliminary: 'preliminary',
24
- primaryPurpose: paths.PurposeOfApplication,
25
+ primaryPurpose: application_paths_2.paths.PurposeOfApplication,
25
26
  brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description',
26
27
  };
27
- set(partialApplication, `${paths.LoanDetail}.@UniqueID`, `${opportunity.id}-${uniqueIdSuffix}`);
28
- set(partialApplication, `${creditProtocolPaths.Instructions}.@UniqueID`, `${opportunity.id}-stage`);
29
- set(partialApplication, `${creditProtocolPaths.Instructions}.@Name`, EventNameApplicationInstructionsList.ApplicationReceived);
28
+ (0, lodash_1.set)(partialApplication, `${application_paths_2.paths.LoanDetail}.@UniqueID`, `${opportunity.id}-${uniqueIdSuffix}`);
29
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Instructions}.@UniqueID`, `${opportunity.id}-stage`);
30
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Instructions}.@Name`, lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
31
+ const { hasOptedInRateLock = false, isFastRefi = false } = opportunity;
30
32
  if (enableRateLock) {
31
- const { hasOptedInRateLock = false } = opportunity;
32
- set(partialApplication, `${creditProtocolPaths.FeaturesSelected}.@RateLock`, booleanMapping(hasOptedInRateLock));
33
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.FeaturesSelected}.@RateLock`, (0, transform_applicant_1.booleanMapping)(hasOptedInRateLock));
34
+ }
35
+ if (enableFastRefi) {
36
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Overview}.@FastRefinance`, (0, transform_applicant_1.booleanMapping)(isFastRefi));
33
37
  }
34
38
  for (const [opportunityKey, opportunityValue] of Object.entries(opportunity)) {
35
39
  if (opportunityMapping[opportunityKey]) {
@@ -38,19 +42,20 @@ export function transformApplication(opportunity, options = {}) {
38
42
  if (opportunityMapping[key]) {
39
43
  switch (key) {
40
44
  case 'paymentType':
41
- set(partialApplication, opportunityMapping[key], preferredRepaymentMapping[value]);
45
+ (0, lodash_1.set)(partialApplication, opportunityMapping[key], enum_mappings_1.preferredRepaymentMapping[value]);
42
46
  break;
43
47
  case 'primaryPurpose':
44
- set(partialApplication, opportunityMapping[key], transactionTypeMapping[value]);
48
+ (0, lodash_1.set)(partialApplication, opportunityMapping[key], enum_mappings_1.transactionTypeMapping[value]);
45
49
  break;
46
50
  }
47
51
  }
48
52
  }
49
53
  }
50
54
  else {
51
- set(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
55
+ (0, lodash_1.set)(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
52
56
  }
53
57
  }
54
58
  }
55
59
  return partialApplication;
56
60
  }
61
+ exports.transformApplication = transformApplication;
@@ -1,22 +1,26 @@
1
- import { CountryCodeList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
- import { set } from 'lodash';
3
- import { countryCodeMapping, postcodeMapping } from '../types/enum-mappings';
4
- import { extractCountryFromFormatted, isOverseasAddress } from '../utils/address-tools';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformStandard = exports.transformAddress = exports.standardMapping = exports.getAddressMapping = 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 enum_mappings_1 = require("../types/enum-mappings");
7
+ const address_tools_1 = require("../utils/address-tools");
5
8
  /**
6
9
  *
7
10
  * @param address
8
11
  */
9
- export function getAddressMapping(address) {
12
+ function getAddressMapping(address) {
10
13
  return {
11
14
  city: '@Suburb',
12
15
  country: '@Country',
13
- postcode: isOverseasAddress(address) ? '@OverseasPostCode' : '@AustralianPostCode',
14
- state: isOverseasAddress(address) ? '@OverseasState' : '@AustralianState',
16
+ postcode: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasPostCode' : '@AustralianPostCode',
17
+ state: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasState' : '@AustralianState',
15
18
  standard: 'Standard',
16
19
  formatted: '@Country',
17
20
  };
18
21
  }
19
- export const standardMapping = {
22
+ exports.getAddressMapping = getAddressMapping;
23
+ exports.standardMapping = {
20
24
  streetName: '@StreetName',
21
25
  streetType: '@StreetType',
22
26
  streetNumber: '@StreetNumber',
@@ -33,49 +37,51 @@ export const standardMapping = {
33
37
  * @param id
34
38
  * @returns A transformed address object.
35
39
  */
36
- export function transformAddress(address, id) {
40
+ function transformAddress(address, id) {
37
41
  const transformedAddress = {
38
42
  '@UniqueID': id,
39
43
  };
40
44
  const addressMapping = getAddressMapping(address);
41
45
  // for an Australian address: if no postcode is provided, infer one from the state:
42
- if (!isOverseasAddress(address) && address.state && !address.postcode) {
43
- address.postcode = postcodeMapping[address.state];
46
+ if (!(0, address_tools_1.isOverseasAddress)(address) && address.state && !address.postcode) {
47
+ address.postcode = enum_mappings_1.postcodeMapping[address.state];
44
48
  }
45
49
  for (const [key, value] of Object.entries(address)) {
46
50
  if (addressMapping[key]) {
47
51
  switch (key) {
48
52
  case 'standard':
49
- set(transformedAddress, addressMapping[key], transformStandard(value));
53
+ (0, lodash_1.set)(transformedAddress, addressMapping[key], transformStandard(value));
50
54
  break;
51
55
  case 'country':
52
- set(transformedAddress, addressMapping[key], isOverseasAddress(address) ? countryCodeMapping[value] : CountryCodeList.Au);
56
+ (0, lodash_1.set)(transformedAddress, addressMapping[key], (0, address_tools_1.isOverseasAddress)(address) ? enum_mappings_1.countryCodeMapping[value] : lixi_internal_request_1.CountryCodeList.Au);
53
57
  break;
54
58
  case 'formatted':
55
59
  if (!address.country) {
56
- const country = extractCountryFromFormatted(value);
57
- set(transformedAddress, addressMapping[key], countryCodeMapping[country]);
60
+ const country = (0, address_tools_1.extractCountryFromFormatted)(value);
61
+ (0, lodash_1.set)(transformedAddress, addressMapping[key], enum_mappings_1.countryCodeMapping[country]);
58
62
  }
59
63
  break;
60
64
  default:
61
- set(transformedAddress, addressMapping[key], value);
65
+ (0, lodash_1.set)(transformedAddress, addressMapping[key], value);
62
66
  break;
63
67
  }
64
68
  }
65
69
  }
66
70
  return transformedAddress;
67
71
  }
72
+ exports.transformAddress = transformAddress;
68
73
  /**
69
74
  * @description Generates an address standard.
70
75
  * @param {AddressStandard} addressStandard An address standard object.
71
76
  * @returns {Partial<Standard>} A transformed standard object.
72
77
  */
73
- export function transformStandard(addressStandard) {
78
+ function transformStandard(addressStandard) {
74
79
  const transformedStandard = {};
75
80
  for (const [key, value] of Object.entries(addressStandard)) {
76
- if (standardMapping[key]) {
77
- set(transformedStandard, standardMapping[key], value);
81
+ if (exports.standardMapping[key]) {
82
+ (0, lodash_1.set)(transformedStandard, exports.standardMapping[key], value);
78
83
  }
79
84
  }
80
85
  return transformedStandard;
81
86
  }
87
+ exports.transformStandard = transformStandard;