@lendi/integrations-transform 1.5.8 → 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 (108) hide show
  1. package/lib/index.js +1 -1
  2. package/lib/logger.d.ts +1 -2
  3. package/lib/logger.js +3 -3
  4. package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
  5. package/lib/transform-events/generate-asset-liability-link.js +12 -12
  6. package/lib/transform-events/generate-credit-report-rebuilt.js +13 -13
  7. package/lib/transform-events/generate-employment.d.ts +1 -1
  8. package/lib/transform-events/generate-employment.js +33 -34
  9. package/lib/transform-events/generate-required-document.d.ts +1 -7
  10. package/lib/transform-events/generate-required-document.js +37 -54
  11. package/lib/transform-events/transform-applicant.d.ts +2 -1
  12. package/lib/transform-events/transform-applicant.js +57 -63
  13. package/lib/transform-events/transform-application-workflow.d.ts +0 -1
  14. package/lib/transform-events/transform-application-workflow.js +7 -8
  15. package/lib/transform-events/transform-application.d.ts +3 -1
  16. package/lib/transform-events/transform-application.js +23 -24
  17. package/lib/transform-events/transform-asset-address.d.ts +8 -2
  18. package/lib/transform-events/transform-asset-address.js +22 -18
  19. package/lib/transform-events/transform-asset.d.ts +7 -1
  20. package/lib/transform-events/transform-asset.js +112 -122
  21. package/lib/transform-events/transform-expenses.d.ts +4 -0
  22. package/lib/transform-events/transform-expenses.js +31 -29
  23. package/lib/transform-events/transform-funding-position.d.ts +2 -2
  24. package/lib/transform-events/transform-funding-position.js +23 -26
  25. package/lib/transform-events/transform-income.d.ts +8 -1
  26. package/lib/transform-events/transform-income.js +87 -97
  27. package/lib/transform-events/transform-liability.d.ts +4 -1
  28. package/lib/transform-events/transform-liability.js +42 -41
  29. package/lib/transform-events/transform-percent-owned.d.ts +1 -0
  30. package/lib/transform-events/transform-percent-owned.js +8 -11
  31. package/lib/types/enum-mappings/alieo-frequency.js +23 -24
  32. package/lib/types/enum-mappings/asset-type.js +15 -16
  33. package/lib/types/enum-mappings/builder-type.js +7 -8
  34. package/lib/types/enum-mappings/construction-type.js +8 -9
  35. package/lib/types/enum-mappings/country-code.js +244 -245
  36. package/lib/types/enum-mappings/employment-basis.js +10 -11
  37. package/lib/types/enum-mappings/expense-frequency.js +9 -10
  38. package/lib/types/enum-mappings/funding-position.js +6 -6
  39. package/lib/types/enum-mappings/government-benefits.js +8 -9
  40. package/lib/types/enum-mappings/guarantor-relationship-type.d.ts +3 -0
  41. package/lib/types/enum-mappings/guarantor-relationship-type.js +16 -0
  42. package/lib/types/enum-mappings/housing-status.js +13 -14
  43. package/lib/types/enum-mappings/income-type.js +14 -15
  44. package/lib/types/enum-mappings/index.js +1 -1
  45. package/lib/types/enum-mappings/liability-payment-type.js +7 -8
  46. package/lib/types/enum-mappings/liability-type.js +19 -20
  47. package/lib/types/enum-mappings/living-expense.js +28 -29
  48. package/lib/types/enum-mappings/marital-status.js +10 -11
  49. package/lib/types/enum-mappings/postcode.js +12 -13
  50. package/lib/types/enum-mappings/preferred-repayment.js +8 -9
  51. package/lib/types/enum-mappings/proof-of-identity.js +8 -9
  52. package/lib/types/enum-mappings/property-expense-category.js +9 -10
  53. package/lib/types/enum-mappings/public-financial-asset.js +10 -11
  54. package/lib/types/enum-mappings/public-primary-purpose.js +7 -8
  55. package/lib/types/enum-mappings/public-property-status.js +9 -10
  56. package/lib/types/enum-mappings/public-property-type.js +21 -22
  57. package/lib/types/enum-mappings/residency-status.js +9 -10
  58. package/lib/types/enum-mappings/title-gender.js +11 -12
  59. package/lib/types/enum-mappings/title.js +11 -12
  60. package/lib/types/enum-mappings/to-be-purchased.js +4 -4
  61. package/lib/types/enum-mappings/to-be-used-as-security.js +4 -4
  62. package/lib/types/enum-mappings/transaction-type.js +7 -8
  63. package/lib/types/enum-mappings/verification.js +11 -12
  64. package/lib/types/events/applicant-delete.js +1 -1
  65. package/lib/types/events/application-workflow.js +1 -1
  66. package/lib/types/events/asset-delete.js +1 -1
  67. package/lib/types/events/asset-liability-relation-delete.js +1 -1
  68. package/lib/types/events/credit-report-retrieved.js +1 -1
  69. package/lib/types/events/employment-delete.js +1 -1
  70. package/lib/types/events/expense-delete.js +1 -1
  71. package/lib/types/events/funding-position.js +1 -1
  72. package/lib/types/events/income-delete.js +1 -1
  73. package/lib/types/events/liability-delete.js +1 -1
  74. package/lib/types/events/opportunity.js +1 -1
  75. package/lib/types/events/public-applicant.js +1 -1
  76. package/lib/types/events/public-application.js +1 -1
  77. package/lib/types/events/public-asset-liability-relation.js +1 -1
  78. package/lib/types/events/public-asset.js +1 -1
  79. package/lib/types/events/public-employment.js +1 -1
  80. package/lib/types/events/public-expense.js +1 -1
  81. package/lib/types/events/public-funding-position.js +1 -1
  82. package/lib/types/events/public-income.js +1 -1
  83. package/lib/types/events/public-liability.js +1 -1
  84. package/lib/types/events/public-required-document.js +1 -1
  85. package/lib/types/partial-application.js +1 -1
  86. package/lib/types/recursive-partial.js +1 -1
  87. package/lib/update-application/merge-application.d.ts +1 -1
  88. package/lib/update-application/merge-application.js +41 -34
  89. package/lib/update-application/update-primary-applicant.d.ts +1 -4
  90. package/lib/update-application/update-primary-applicant.js +12 -31
  91. package/lib/utils/address-tools.d.ts +3 -1
  92. package/lib/utils/address-tools.js +40 -42
  93. package/lib/utils/clean-up.d.ts +1 -1
  94. package/lib/utils/clean-up.js +6 -6
  95. package/lib/utils/formatYesNo.d.ts +0 -1
  96. package/lib/utils/formatYesNo.js +3 -4
  97. package/lib/utils/generate-address.d.ts +3 -2
  98. package/lib/utils/generate-address.js +21 -25
  99. package/lib/utils/get-financial-institution.d.ts +1 -0
  100. package/lib/utils/get-financial-institution.js +6 -5
  101. package/lib/utils/is-asset-type.js +2 -2
  102. package/lib/utils/is-income-type.d.ts +2 -0
  103. package/lib/utils/is-income-type.js +15 -21
  104. package/lib/utils/iso-date.d.ts +0 -1
  105. package/lib/utils/iso-date.js +3 -4
  106. package/lib/utils/normalise-date.js +6 -6
  107. package/lib/utils/round-decimal.js +1 -1
  108. package/package.json +14 -17
@@ -1,50 +1,47 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateDependants = exports.generateContact = exports.transformApplicant = exports.booleanMapping = void 0;
4
- var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
- var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
6
- var lodash_1 = require("lodash");
7
- var address_tools_1 = require("../utils/address-tools");
8
- var enum_mappings_1 = require("../types/enum-mappings");
9
- var public_applicant_1 = require("../types/events/public-applicant");
10
- var normalise_date_1 = require("../utils/normalise-date");
11
- var booleanMapping = function (input) {
12
- if (input === void 0) { input = false; }
13
- return (input === true ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No);
14
- };
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);
15
12
  exports.booleanMapping = booleanMapping;
16
- var applicantMapping = {
13
+ const applicantMapping = {
17
14
  applicationId: application_paths_1.paths.ApplicationId,
18
- citizenship: "".concat(application_paths_1.paths.PersonApplicant, ".@Citizenship"),
19
- contact: "".concat(application_paths_1.paths.PersonApplicant, ".Contact"),
15
+ citizenship: `${application_paths_1.paths.PersonApplicant}.@Citizenship`,
16
+ contact: `${application_paths_1.paths.PersonApplicant}.Contact`,
20
17
  dependants: 'dependants',
21
- dateOfBirth: "".concat(application_paths_1.paths.PersonApplicant, ".@DateOfBirth"),
22
- firstName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@FirstName"),
23
- id: "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"),
24
- isFirstHomeBuyer: "".concat(application_paths_1.paths.PersonApplicant, ".@FirstHomeBuyer"),
25
- isPrimaryApplicant: "".concat(application_paths_1.paths.PersonApplicant, ".@PrimaryApplicant"),
26
- lastName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@Surname"),
27
- maritalStatus: "".concat(application_paths_1.paths.PersonApplicant, ".@MaritalStatus"),
28
- maritalDetails: "".concat(application_paths_1.paths.PersonApplicant, ".MaritalStatusDetails.@x_Spouse"),
29
- middleName: "".concat(application_paths_1.paths.PersonApplicant, ".PersonName.@MiddleNames"),
30
- residencyStatus: "".concat(application_paths_1.paths.PersonApplicant, ".@ResidencyStatus"),
31
- title: "".concat(application_paths_1.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`,
32
29
  };
33
30
  /**
34
31
  * Transforms a partial Applicant event to a partial LIXI application.
35
32
  *
36
33
  * @param applicant: A partial applicant.
37
- * @return partialApplication an incomplete application.
34
+ * @param applicant
35
+ * @returns partialApplication an incomplete application.
38
36
  */
39
37
  function transformApplicant(applicant) {
40
- var partialApplication = {};
41
- var applicantId = applicant.id, applicationId = applicant.applicationId;
38
+ const partialApplication = {};
39
+ const { id: applicantId, applicationId } = applicant;
42
40
  (0, lodash_1.set)(partialApplication, applicantMapping['isFirstHomeBuyer'], (0, exports.booleanMapping)(applicant.isFirstHomeBuyer));
43
41
  (0, lodash_1.set)(partialApplication, applicantMapping['isPrimaryApplicant'], (0, exports.booleanMapping)(applicant.isPrimaryApplicant));
44
42
  (0, lodash_1.set)(partialApplication, applicantMapping['title'], enum_mappings_1.titleMapping[applicant.title || public_applicant_1.Title.Unknown]);
45
- var applicantUpdated = (0, lodash_1.omit)(applicant, ['isFirstHomeBuyer', 'isPrimaryApplicant', 'title']);
46
- for (var _i = 0, _a = Object.entries(applicantUpdated); _i < _a.length; _i++) {
47
- var _b = _a[_i], key = _b[0], value = _b[1];
43
+ const applicantUpdated = (0, lodash_1.omit)(applicant, ['isFirstHomeBuyer', 'isPrimaryApplicant', 'title']);
44
+ for (const [key, value] of Object.entries(applicantUpdated)) {
48
45
  if (applicantMapping[key]) {
49
46
  switch (key) {
50
47
  case 'dateOfBirth':
@@ -68,21 +65,21 @@ function transformApplicant(applicant) {
68
65
  }
69
66
  break;
70
67
  case 'maritalDetails':
71
- var id = (0, lodash_1.get)(value, 'applicantId');
68
+ const id = (0, lodash_1.get)(value, 'applicantId');
72
69
  if (id)
73
70
  (0, lodash_1.set)(partialApplication, applicantMapping[key], id);
74
71
  break;
75
72
  case 'contact':
76
- var _c = generateContact(value, applicantId), lixiContact = _c.lixiContact, lixiAddresses = _c.lixiAddresses;
73
+ const { lixiContact, lixiAddresses } = generateContact(value, applicantId);
77
74
  (0, lodash_1.set)(partialApplication, applicantMapping[key], lixiContact);
78
75
  if (lixiAddresses.length > 0) {
79
76
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.Addresses, lixiAddresses);
80
77
  }
81
78
  break;
82
79
  case 'dependants':
83
- var dependants = generateDependants(value, applicantId);
84
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".@UniqueID"), "".concat(applicationId, "-household"));
85
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Household, ".Dependant"), dependants);
80
+ const dependants = generateDependants(value, applicantId);
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);
86
83
  break;
87
84
  default:
88
85
  (0, lodash_1.set)(partialApplication, applicantMapping[key], value);
@@ -93,14 +90,14 @@ function transformApplicant(applicant) {
93
90
  return partialApplication;
94
91
  }
95
92
  exports.transformApplicant = transformApplicant;
96
- var contactMapping = {
93
+ const contactMapping = {
97
94
  emailAddress: 'EmailAddress.0.@Email',
98
95
  mobileNumber: 'Mobile.@Number',
99
96
  currentAddress: 'CurrentAddress',
100
97
  previousAddresses: 'PreviousAddress',
101
98
  priorAddress: 'PriorAddress',
102
99
  mailingAddress: 'CurrentAddress.@x_MailingAddress',
103
- postSettlementAddress: 'PostSettlementAddress'
100
+ postSettlementAddress: 'PostSettlementAddress',
104
101
  };
105
102
  /**
106
103
  * Generates a LIXI contact from given contact.
@@ -109,51 +106,48 @@ var contactMapping = {
109
106
  * @param id
110
107
  */
111
108
  function generateContact(contact, id) {
112
- var lixiContact = {};
113
- var lixiAddresses = [];
114
- for (var _i = 0, _a = Object.entries(contact); _i < _a.length; _i++) {
115
- var _b = _a[_i], key = _b[0], value = _b[1];
109
+ const lixiContact = {};
110
+ const lixiAddresses = [];
111
+ for (const [key, value] of Object.entries(contact)) {
116
112
  if (contactMapping[key]) {
117
113
  switch (key) {
118
114
  case 'currentAddress':
119
115
  {
120
- var addressId = "".concat(id, "-current");
121
- var _c = (0, address_tools_1.rebuildAddress)(value, addressId), lixiAddress = _c.lixiAddress, lixiContactAddress = _c.lixiContactAddress;
116
+ const addressId = `${id}-current`;
117
+ const { lixiAddress, lixiContactAddress } = (0, address_tools_1.rebuildAddress)(value, addressId);
122
118
  lixiAddresses.push(lixiAddress);
123
119
  (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
124
120
  }
125
121
  break;
126
122
  case 'postSettlementAddress':
127
123
  {
128
- var addressId = "".concat(id, "-postSettlement");
129
- var _d = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId), lixiAddress = _d.lixiAddress, lixiContactAddress = _d.lixiContactAddress;
124
+ const addressId = `${id}-postSettlement`;
125
+ const { lixiAddress, lixiContactAddress } = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId);
130
126
  lixiAddresses.push(lixiAddress);
131
127
  (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
132
128
  }
133
129
  break;
134
130
  case 'mailingAddress':
135
131
  {
136
- var addressId = "".concat(id, "-mailing");
137
- var lixiAddress = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId).lixiAddress;
132
+ const addressId = `${id}-mailing`;
133
+ const { lixiAddress } = (0, address_tools_1.rebuildAddress)({ residentialAddress: value }, addressId);
138
134
  lixiAddresses.push(lixiAddress);
139
135
  (0, lodash_1.set)(lixiContact, contactMapping[key], addressId);
140
136
  }
141
137
  break;
142
138
  case 'previousAddresses':
143
139
  {
144
- var addressId = "".concat(id, "-previous");
145
- var previousAddresses = value.sort(function (lhs, rhs) {
146
- return lhs.endDate.localeCompare(rhs.endDate);
147
- });
148
- var previousAddress = previousAddresses.pop();
149
- var _e = (0, address_tools_1.rebuildAddress)(previousAddress, addressId), lixiAddress = _e.lixiAddress, lixiContactAddress = _e.lixiContactAddress;
140
+ const addressId = `${id}-previous`;
141
+ const previousAddresses = value.sort((lhs, rhs) => lhs.endDate.localeCompare(rhs.endDate));
142
+ const previousAddress = previousAddresses.pop();
143
+ const { lixiAddress, lixiContactAddress } = (0, address_tools_1.rebuildAddress)(previousAddress, addressId);
150
144
  lixiAddresses.push(lixiAddress);
151
145
  (0, lodash_1.set)(lixiContact, contactMapping[key], lixiContactAddress);
152
146
  // PriorAddresses
153
- previousAddresses.forEach(function (address, index) {
154
- var _a = (0, address_tools_1.rebuildAddress)(address, "".concat(id, "-prior-").concat(index)), lixiAddress = _a.lixiAddress, lixiContactAddress = _a.lixiContactAddress;
147
+ previousAddresses.forEach((address, index) => {
148
+ const { lixiAddress, lixiContactAddress } = (0, address_tools_1.rebuildAddress)(address, `${id}-prior-${index}`);
155
149
  lixiAddresses.push(lixiAddress);
156
- (0, lodash_1.set)(lixiContact, "".concat(contactMapping['priorAddress'], ".").concat(index), lixiContactAddress);
150
+ (0, lodash_1.set)(lixiContact, `${contactMapping['priorAddress']}.${index}`, lixiContactAddress);
157
151
  });
158
152
  }
159
153
  break;
@@ -163,7 +157,7 @@ function generateContact(contact, id) {
163
157
  }
164
158
  }
165
159
  }
166
- return { lixiContact: lixiContact, lixiAddresses: lixiAddresses };
160
+ return { lixiContact, lixiAddresses };
167
161
  }
168
162
  exports.generateContact = generateContact;
169
163
  /**
@@ -173,14 +167,14 @@ exports.generateContact = generateContact;
173
167
  * @param id
174
168
  */
175
169
  function generateDependants(dependants, id) {
176
- return dependants.map(function (dependant) { return ({
170
+ return dependants.map((dependant) => ({
177
171
  '@Age': dependant.age,
178
172
  '@UniqueID': dependant.id,
179
173
  FinancialProvider: [
180
174
  {
181
- '@x_Party': id
175
+ '@x_Party': id,
182
176
  },
183
- ]
184
- }); });
177
+ ],
178
+ }));
185
179
  }
186
180
  exports.generateDependants = generateDependants;
@@ -3,7 +3,6 @@ import { PayloadClass as ApplicationWorkflowEventPayload } from '../types/events
3
3
  * Generates a partial application from an ApplicationWorkflow event
4
4
  *
5
5
  * @param applicationWorkflowEventPayload ApplicationWorkflow event payload
6
- *
7
6
  * @returns A partial application
8
7
  */
9
8
  export declare function transformApplicationWorkflow(applicationWorkflowEventPayload: ApplicationWorkflowEventPayload): {};
@@ -1,22 +1,21 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformApplicationWorkflow = void 0;
4
- var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
5
- var lodash_1 = require("lodash");
4
+ const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
5
+ const lodash_1 = require("lodash");
6
6
  /**
7
7
  * Generates a partial application from an ApplicationWorkflow event
8
8
  *
9
9
  * @param applicationWorkflowEventPayload ApplicationWorkflow event payload
10
- *
11
10
  * @returns A partial application
12
11
  */
13
12
  function transformApplicationWorkflow(applicationWorkflowEventPayload) {
14
- var stage = applicationWorkflowEventPayload.stage, applicationStage = applicationWorkflowEventPayload.applicationStage, applicationId = applicationWorkflowEventPayload.applicationId, partialApplication = {};
13
+ const { stage, applicationStage, applicationId } = applicationWorkflowEventPayload, partialApplication = {};
15
14
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
16
15
  // The stage being defaulted to Unknown caters for LGSF application workflow events having stage as an optional attribute in the future
17
- var instructionDetails = {
18
- '@UniqueID': "".concat(applicationId, "-stage"),
19
- '@Details': applicationStage || stage || 'Unknown'
16
+ const instructionDetails = {
17
+ '@UniqueID': `${applicationId}-stage`,
18
+ '@Details': applicationStage || stage || 'Unknown',
20
19
  };
21
20
  (0, lodash_1.set)(partialApplication, application_paths_1.paths.Instructions, instructionDetails);
22
21
  return partialApplication;
@@ -8,7 +8,9 @@ interface transformApplicationOptions {
8
8
  *
9
9
  * @param opportunity: Partial opportunity event.
10
10
  * @param uniqueIdSuffix: Suffix for uniquerId
11
- * @return partialApplication: A partial internal request.
11
+ * @param opportunity
12
+ * @param options
13
+ * @returns partialApplication: A partial internal request.
12
14
  */
13
15
  export declare function transformApplication(opportunity: ApplicationPayload, options?: transformApplicationOptions): {};
14
16
  export {};
@@ -1,44 +1,43 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformApplication = void 0;
4
- var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
5
- var application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
6
- var application_paths_2 = require("@lendi/integrations-protocol/lib/utils/application-paths");
7
- var lodash_1 = require("lodash");
8
- var enum_mappings_1 = require("../types/enum-mappings/");
9
- var transform_applicant_1 = require("./transform-applicant");
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");
10
10
  /**
11
11
  * Transforms a partial opportunity event to a partial internal request.
12
12
  *
13
13
  * @param opportunity: Partial opportunity event.
14
14
  * @param uniqueIdSuffix: Suffix for uniquerId
15
- * @return partialApplication: A partial internal request.
15
+ * @param opportunity
16
+ * @param options
17
+ * @returns partialApplication: A partial internal request.
16
18
  */
17
- function transformApplication(opportunity, options) {
18
- if (options === void 0) { options = {}; }
19
- var _a = options.uniqueIdSuffix, uniqueIdSuffix = _a === void 0 ? 'loanDetails' : _a, _b = options.enableRateLock, enableRateLock = _b === void 0 ? false : _b;
20
- var partialApplication = {};
21
- var opportunityMapping = {
19
+ function transformApplication(opportunity, options = {}) {
20
+ const { uniqueIdSuffix = 'loanDetails', enableRateLock = false } = options;
21
+ const partialApplication = {};
22
+ const opportunityMapping = {
22
23
  brand: application_paths_2.paths.BusinessName,
23
24
  id: application_paths_2.paths.ApplicationId,
24
- paymentType: "".concat(application_paths_2.paths.LoanTerm, ".@PaymentType"),
25
+ paymentType: `${application_paths_2.paths.LoanTerm}.@PaymentType`,
25
26
  preliminary: 'preliminary',
26
27
  primaryPurpose: application_paths_2.paths.PurposeOfApplication,
27
- brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description'
28
+ brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description',
28
29
  };
29
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_2.paths.LoanDetail, ".@UniqueID"), "".concat(opportunity.id, "-").concat(uniqueIdSuffix));
30
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Instructions, ".@UniqueID"), "".concat(opportunity.id, "-stage"));
31
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Instructions, ".@Name"), lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
30
+ (0, lodash_1.set)(partialApplication, `${application_paths_2.paths.LoanDetail}.@UniqueID`, `${opportunity.id}-${uniqueIdSuffix}`);
31
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Instructions}.@UniqueID`, `${opportunity.id}-stage`);
32
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.Instructions}.@Name`, lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
32
33
  if (enableRateLock) {
33
- var _c = opportunity.hasOptedInRateLock, hasOptedInRateLock = _c === void 0 ? false : _c;
34
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.FeaturesSelected, ".@RateLock"), (0, transform_applicant_1.booleanMapping)(hasOptedInRateLock));
34
+ const { hasOptedInRateLock = false } = opportunity;
35
+ (0, lodash_1.set)(partialApplication, `${application_paths_1.paths.FeaturesSelected}.@RateLock`, (0, transform_applicant_1.booleanMapping)(hasOptedInRateLock));
35
36
  }
36
- for (var _i = 0, _d = Object.entries(opportunity); _i < _d.length; _i++) {
37
- var _e = _d[_i], opportunityKey = _e[0], opportunityValue = _e[1];
37
+ for (const [opportunityKey, opportunityValue] of Object.entries(opportunity)) {
38
38
  if (opportunityMapping[opportunityKey]) {
39
39
  if (opportunityKey === 'preliminary') {
40
- for (var _f = 0, _g = Object.entries(opportunityValue); _f < _g.length; _f++) {
41
- var _h = _g[_f], key = _h[0], value = _h[1];
40
+ for (const [key, value] of Object.entries(opportunityValue)) {
42
41
  if (opportunityMapping[key]) {
43
42
  switch (key) {
44
43
  case 'paymentType':
@@ -1,5 +1,9 @@
1
1
  import { AddressType, Standard } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
2
  import { Address, AddressStandard } from '../types/events/public-asset';
3
+ /**
4
+ *
5
+ * @param address
6
+ */
3
7
  export declare function getAddressMapping(address: Address): Record<string, string>;
4
8
  export declare const standardMapping: Record<string, string>;
5
9
  /**
@@ -8,12 +12,14 @@ export declare const standardMapping: Record<string, string>;
8
12
  * @param address: An address object.
9
13
  * @param id: address event id.
10
14
  * @param toBeUsedAsSecurity
11
- * @return A transformed address object.
15
+ * @param address
16
+ * @param id
17
+ * @returns A transformed address object.
12
18
  */
13
19
  export declare function transformAddress(address: Address, id: string): Partial<AddressType>;
14
20
  /**
15
21
  * @description Generates an address standard.
16
22
  * @param {AddressStandard} addressStandard An address standard object.
17
- * @return {Partial<Standard>} A transformed standard object.
23
+ * @returns {Partial<Standard>} A transformed standard object.
18
24
  */
19
25
  export declare function transformStandard(addressStandard: AddressStandard): Partial<Standard>;
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformStandard = exports.transformAddress = exports.standardMapping = exports.getAddressMapping = void 0;
4
- var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
- var lodash_1 = require("lodash");
6
- var enum_mappings_1 = require("../types/enum-mappings");
7
- var address_tools_1 = require("../utils/address-tools");
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");
8
+ /**
9
+ *
10
+ * @param address
11
+ */
8
12
  function getAddressMapping(address) {
9
13
  return {
10
14
  city: '@Suburb',
@@ -12,7 +16,7 @@ function getAddressMapping(address) {
12
16
  postcode: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasPostCode' : '@AustralianPostCode',
13
17
  state: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasState' : '@AustralianState',
14
18
  standard: 'Standard',
15
- formatted: '@Country'
19
+ formatted: '@Country',
16
20
  };
17
21
  }
18
22
  exports.getAddressMapping = getAddressMapping;
@@ -21,7 +25,7 @@ exports.standardMapping = {
21
25
  streetType: '@StreetType',
22
26
  streetNumber: '@StreetNumber',
23
27
  level: '@Level',
24
- unit: '@Unit'
28
+ unit: '@Unit',
25
29
  };
26
30
  /**
27
31
  * Generates an address for an asset.
@@ -29,19 +33,20 @@ exports.standardMapping = {
29
33
  * @param address: An address object.
30
34
  * @param id: address event id.
31
35
  * @param toBeUsedAsSecurity
32
- * @return A transformed address object.
36
+ * @param address
37
+ * @param id
38
+ * @returns A transformed address object.
33
39
  */
34
40
  function transformAddress(address, id) {
35
- var transformedAddress = {
36
- '@UniqueID': id
41
+ const transformedAddress = {
42
+ '@UniqueID': id,
37
43
  };
38
- var addressMapping = getAddressMapping(address);
44
+ const addressMapping = getAddressMapping(address);
39
45
  // for an Australian address: if no postcode is provided, infer one from the state:
40
46
  if (!(0, address_tools_1.isOverseasAddress)(address) && address.state && !address.postcode) {
41
47
  address.postcode = enum_mappings_1.postcodeMapping[address.state];
42
48
  }
43
- for (var _i = 0, _a = Object.entries(address); _i < _a.length; _i++) {
44
- var _b = _a[_i], key = _b[0], value = _b[1];
49
+ for (const [key, value] of Object.entries(address)) {
45
50
  if (addressMapping[key]) {
46
51
  switch (key) {
47
52
  case 'standard':
@@ -52,7 +57,7 @@ function transformAddress(address, id) {
52
57
  break;
53
58
  case 'formatted':
54
59
  if (!address.country) {
55
- var country = (0, address_tools_1.extractCountryFromFormatted)(value);
60
+ const country = (0, address_tools_1.extractCountryFromFormatted)(value);
56
61
  (0, lodash_1.set)(transformedAddress, addressMapping[key], enum_mappings_1.countryCodeMapping[country]);
57
62
  }
58
63
  break;
@@ -68,12 +73,11 @@ exports.transformAddress = transformAddress;
68
73
  /**
69
74
  * @description Generates an address standard.
70
75
  * @param {AddressStandard} addressStandard An address standard object.
71
- * @return {Partial<Standard>} A transformed standard object.
76
+ * @returns {Partial<Standard>} A transformed standard object.
72
77
  */
73
78
  function transformStandard(addressStandard) {
74
- var transformedStandard = {};
75
- for (var _i = 0, _a = Object.entries(addressStandard); _i < _a.length; _i++) {
76
- var _b = _a[_i], key = _b[0], value = _b[1];
79
+ const transformedStandard = {};
80
+ for (const [key, value] of Object.entries(addressStandard)) {
77
81
  if (exports.standardMapping[key]) {
78
82
  (0, lodash_1.set)(transformedStandard, exports.standardMapping[key], value);
79
83
  }
@@ -12,7 +12,7 @@ export declare const residentialTypeList: string[];
12
12
  * Generates a partial internal request from a partial public asset event.
13
13
  *
14
14
  * @param {Payload} asset - A partial public asset.
15
- * @return {PartialApplication} A partial InternalRequest.
15
+ * @returns {PartialApplication} A partial InternalRequest.
16
16
  */
17
17
  export declare function transformAsset({ asset, applicationId, id }: Payload): PartialApplication;
18
18
  /**
@@ -33,20 +33,26 @@ export declare function getAssetMapping(asset: Asset): Record<string, string>;
33
33
  * @param percentOwned: owners of the property
34
34
  * @param assetId: Asset id
35
35
  * @param propertyExpenses: propertyExpenses items
36
+ * @param percentOwned
37
+ * @param assetId
38
+ * @param propertyExpenses
36
39
  */
37
40
  export declare function generateLivingExpenses(percentOwned: PercentOwned, assetId: string, propertyExpenses: PropertyExpense[]): LivingExpense[];
38
41
  /**
39
42
  * Creates PropertyExpense array on RealEstateAsset from the same array on the event.
43
+ *
40
44
  * @param propertyExpenses
41
45
  */
42
46
  export declare function generatePropertyExpenses(propertyExpenses: PropertyExpense[]): LIXIPropertyExpense[];
43
47
  /**
44
48
  * Determines the occupancy based on the list of property expense types available.
49
+ *
45
50
  * @param propertyExpenses
46
51
  */
47
52
  export declare function determineOccupancy(propertyExpenses: PropertyExpense[]): OccupancyList;
48
53
  /**
49
54
  * Calculates the correct amount and frequency.
55
+ *
50
56
  * @param expense
51
57
  */
52
58
  export declare function normalizeAmounts(expense: PropertyExpense): PropertyExpense;