@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,8 +1,8 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toBeUsedAsSecurityMapping = void 0;
4
- var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
4
+ const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
5
5
  exports.toBeUsedAsSecurityMapping = {
6
- "true": lixi_internal_request_1.YesNoList.Yes,
7
- "false": lixi_internal_request_1.YesNoList.No
6
+ true: lixi_internal_request_1.YesNoList.Yes,
7
+ false: lixi_internal_request_1.YesNoList.No,
8
8
  };
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
- var _a;
3
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.transactionTypeMapping = void 0;
5
- var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
6
- var public_application_1 = require("../events/public-application");
7
- exports.transactionTypeMapping = (_a = {},
8
- _a[public_application_1.PrimaryPurpose.NewPurchase] = lixi_internal_request_1.PurposeOfApplicationList.PurchaseRealEstate,
9
- _a[public_application_1.PrimaryPurpose.Refinance] = lixi_internal_request_1.PurposeOfApplicationList.RefinanceHomeLoan,
10
- _a);
4
+ const lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
5
+ const public_application_1 = require("../events/public-application");
6
+ exports.transactionTypeMapping = {
7
+ [public_application_1.PrimaryPurpose.NewPurchase]: lixi_internal_request_1.PurposeOfApplicationList.PurchaseRealEstate,
8
+ [public_application_1.PrimaryPurpose.Refinance]: lixi_internal_request_1.PurposeOfApplicationList.RefinanceHomeLoan,
9
+ };
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
- var _a;
3
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.verificationMapping = void 0;
5
- var public_required_document_1 = require("../events/public-required-document");
6
- var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
7
- exports.verificationMapping = (_a = {},
8
- _a[public_required_document_1.Status.Expired] = lixi_internal_request_1.YesNoList.No,
9
- _a[public_required_document_1.Status.FailedVerification] = lixi_internal_request_1.YesNoList.No,
10
- _a[public_required_document_1.Status.NotRequired] = lixi_internal_request_1.YesNoList.No,
11
- _a[public_required_document_1.Status.PendingUpload] = lixi_internal_request_1.YesNoList.No,
12
- _a[public_required_document_1.Status.Verified] = lixi_internal_request_1.YesNoList.Yes,
13
- _a[public_required_document_1.Status.PendingVerification] = lixi_internal_request_1.YesNoList.No,
14
- _a);
4
+ const public_required_document_1 = require("../events/public-required-document");
5
+ const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
6
+ exports.verificationMapping = {
7
+ [public_required_document_1.Status.Expired]: lixi_internal_request_1.YesNoList.No,
8
+ [public_required_document_1.Status.FailedVerification]: lixi_internal_request_1.YesNoList.No,
9
+ [public_required_document_1.Status.NotRequired]: lixi_internal_request_1.YesNoList.No,
10
+ [public_required_document_1.Status.PendingUpload]: lixi_internal_request_1.YesNoList.No,
11
+ [public_required_document_1.Status.Verified]: lixi_internal_request_1.YesNoList.Yes,
12
+ [public_required_document_1.Status.PendingVerification]: lixi_internal_request_1.YesNoList.No,
13
+ };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.ActionedByRole = void 0;
4
4
  /**
5
5
  * role of the user that made the action
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.Status = exports.Stage = exports.ConfirmedPrimaryPurpose = exports.ApplicationStage = void 0;
4
4
  /**
5
5
  * Application stage in Lendi Group Salesforce
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.ActionedByRole = void 0;
4
4
  /**
5
5
  * role of the user that made the action
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.ActionedByRole = void 0;
4
4
  /**
5
5
  * role of the user that made the action
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.Source = void 0;
4
4
  /**
5
5
  * A list of credit report service provider
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = void 0;
4
4
  var Type;
5
5
  (function (Type) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = void 0;
4
4
  var Type;
5
5
  (function (Type) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.DetailType = exports.Category = void 0;
4
4
  var Category;
5
5
  (function (Category) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.ActionedByRole = void 0;
4
4
  /**
5
5
  * role of the user that made the action
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = void 0;
4
4
  var Type;
5
5
  (function (Type) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.Stage = exports.Brand = void 0;
4
4
  /**
5
5
  * Brand of an Opportunity, taken from Record Type in Salesforce
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.Title = exports.ResidencyStatus = exports.ActionedByRole = exports.MaritalStatus = exports.InvitationStatus = exports.GuarantorRelationshipToBorrowerType = exports.Gender = exports.Entity = exports.EmploymentType = exports.CreditStatus = exports.HousingStatusList = exports.Countries = exports.ApplicantType = void 0;
4
4
  var ApplicantType;
5
5
  (function (ApplicantType) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PublicApplicationType = exports.Urgency = exports.RefinancingReason = exports.PurchaseSituation = exports.PurchaseReason = exports.PrimaryPurpose = exports.PaymentType = exports.EligibleForFHOG = exports.DesiredFeature = exports.ContributionType = exports.ActionedByRole = exports.BrokerPrimaryPurpose = exports.Brand = void 0;
4
4
  var Brand;
5
5
  (function (Brand) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.ActionedByRole = void 0;
4
4
  /**
5
5
  * role of the user that made the action
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PublicAssetType = exports.ActionedByRole = exports.ZoneType = exports.AssetType = exports.PropertyType = exports.PropertyStatus = exports.PropertyExpenseType = exports.Frequency = exports.PrimaryPurpose = exports.Proportions = exports.ConstructionType = exports.BuilderType = exports.Countries = void 0;
4
4
  var Countries;
5
5
  (function (Countries) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PublicEmploymentType = exports.PayloadType = exports.ActionedByRole = exports.MaternityLeaveReturnBasis = exports.EmploymentType = exports.EmploymentBasis = exports.AustralianStates = exports.CompanyType = exports.BusinessStructure = void 0;
4
4
  var BusinessStructure;
5
5
  (function (BusinessStructure) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PublicExpenseType = exports.ActionedByRole = exports.ExpenseType = exports.Frequency = void 0;
4
4
  var Frequency;
5
5
  (function (Frequency) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = void 0;
4
4
  var Type;
5
5
  (function (Type) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PublicIncomeType = exports.ActionedByRole = exports.IncomeType = exports.Proportions = exports.Frequency = exports.BenefitType = void 0;
4
4
  var BenefitType;
5
5
  (function (BenefitType) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.ActionedByRole = exports.LiabilityType = exports.RepaymentTypeDetails = exports.RepaymentFrequency = exports.Proportions = exports.InterestType = exports.ClearingFromOtherSource = void 0;
4
4
  var ClearingFromOtherSource;
5
5
  (function (ClearingFromOtherSource) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Type = exports.Status = exports.IssuingCountry = exports.IDType = exports.IDTitle = exports.Gender = exports.AustralianState = void 0;
4
4
  var AustralianState;
5
5
  (function (AustralianState) {
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,6 +3,6 @@
3
3
  *
4
4
  * @param newApplication new application coming from events.
5
5
  * @param existingApplication a saved dynamo application.
6
- * @return merged application.
6
+ * @returns merged application.
7
7
  */
8
8
  export declare function deepMergeApplication(existingApplication: object | undefined, newApplication: object): any;
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deepMergeApplication = void 0;
4
- var merge = require("deepmerge");
5
- var cleanDeep = require('clean-deep');
4
+ const merge = require("deepmerge");
5
+ const cleanDeep = require('clean-deep');
6
6
  /**
7
7
  * Deep merges the application and custom handles specific arrays
8
8
  *
9
9
  * @param newApplication new application coming from events.
10
10
  * @param existingApplication a saved dynamo application.
11
- * @return merged application.
11
+ * @returns merged application.
12
12
  */
13
13
  function deepMergeApplication(existingApplication, newApplication) {
14
14
  // Array fields with @UniqueIDs
15
- var listsWithUniqueIds = [
15
+ const listsWithUniqueIds = [
16
16
  'Attachment',
17
17
  'Address',
18
18
  'CompanyApplicant',
@@ -29,22 +29,22 @@ function deepMergeApplication(existingApplication, newApplication) {
29
29
  'RelatedPerson',
30
30
  ];
31
31
  // Array fields with @x_Party
32
- var listsWithXParty = ['Report'];
32
+ const listsWithXParty = ['Report'];
33
33
  // Array fields with @x_Owner
34
- var listsWithXOwner = ['RentalIncome'];
34
+ const listsWithXOwner = ['RentalIncome'];
35
35
  // Array fields with @x_Applicant
36
- var listsWithXApplicant = ['Applicant'];
36
+ const listsWithXApplicant = ['Applicant'];
37
37
  // Array fields with @x_ResidentialAddress
38
- var listsWithXResidentialAddress = ['PriorAddress'];
38
+ const listsWithXResidentialAddress = ['PriorAddress'];
39
39
  // Array fields with @x_Guarantor
40
- var listsWithXGuarantor = ['Guarantor'];
40
+ const listsWithXGuarantor = ['Guarantor'];
41
41
  // Curried function which takes a uniqueKey and returns a function which will either replace
42
42
  // or merge the item in the array based on the uniqueKey
43
43
  if (!existingApplication) {
44
44
  return newApplication;
45
45
  }
46
- var mergeItems = function (uniqueKey) {
47
- return function (existingItem, newItem) {
46
+ const mergeItems = (uniqueKey) => {
47
+ return (existingItem, newItem) => {
48
48
  // if not array continue with merge
49
49
  if (!Array.isArray(newItem)) {
50
50
  return merge(existingItem, newItem, options);
@@ -52,75 +52,82 @@ function deepMergeApplication(existingApplication, newApplication) {
52
52
  return findArrayItemAndMerge(existingItem, newItem, uniqueKey, options);
53
53
  };
54
54
  };
55
- var options = {
56
- customMerge: function (key) {
57
- if (listsWithUniqueIds.find(function (item) { return item === key; })) {
55
+ const options = {
56
+ customMerge: (key) => {
57
+ if (listsWithUniqueIds.find((item) => item === key)) {
58
58
  return mergeItems('@UniqueID');
59
59
  }
60
- if (listsWithXParty.find(function (item) { return item === key; })) {
60
+ if (listsWithXParty.find((item) => item === key)) {
61
61
  return mergeItems('@x_Party');
62
62
  }
63
- if (listsWithXOwner.find(function (item) { return item === key; })) {
63
+ if (listsWithXOwner.find((item) => item === key)) {
64
64
  return mergeItems('@x_Owner');
65
65
  }
66
- if (listsWithXResidentialAddress.find(function (item) { return item === key; })) {
66
+ if (listsWithXResidentialAddress.find((item) => item === key)) {
67
67
  return mergeItems('@x_ResidentialAddress');
68
68
  }
69
- if (listsWithXApplicant.find(function (item) { return item === key; })) {
69
+ if (listsWithXApplicant.find((item) => item === key)) {
70
70
  return mergeItems('@x_Applicant');
71
71
  }
72
- if (listsWithXGuarantor.find(function (item) { return item === key; })) {
72
+ if (listsWithXGuarantor.find((item) => item === key)) {
73
73
  return mergeItems('@x_Guarantor');
74
74
  }
75
75
  return mergeItems(key);
76
- }
76
+ },
77
77
  };
78
- var mergedApplication = merge(existingApplication, newApplication, options);
78
+ const mergedApplication = merge(existingApplication, newApplication, options);
79
79
  // Default configurations of cleanDeep for reference.
80
- var params = {
80
+ const params = {
81
81
  cleanValues: [],
82
82
  emptyArrays: true,
83
83
  emptyObjects: true,
84
84
  emptyStrings: true,
85
85
  NaNValues: true,
86
86
  nullValues: true,
87
- undefinedValues: true
87
+ undefinedValues: true,
88
88
  };
89
89
  return cleanDeep(mergedApplication, params);
90
90
  }
91
91
  exports.deepMergeApplication = deepMergeApplication;
92
- var arrayItemToReplaceKeys = ['Owner', 'Attendee', 'Shareholder', 'Fee', 'ContributionFunds', 'RentalIncome'];
92
+ const arrayItemToReplaceKeys = ['Owner', 'Attendee', 'Shareholder', 'Fee', 'ContributionFunds', 'RentalIncome'];
93
+ /**
94
+ *
95
+ * @param existingItem
96
+ * @param newItem
97
+ * @param uniqueKey
98
+ * @param options
99
+ */
93
100
  function findArrayItemAndMerge(existingItem, newItem, uniqueKey, options) {
94
101
  // For some Key, overwritten the old value with the new data so no merge is happening.
95
102
  if (arrayItemToReplaceKeys.includes(uniqueKey))
96
103
  return newItem;
97
- if (uniqueKey === 'Income' && existingItem && existingItem.some(function (item) { return item['@StartDate']; })) {
104
+ if (uniqueKey === 'Income' && existingItem && existingItem.some((item) => item['@StartDate'])) {
98
105
  // Income array in CompanyApplicant
99
106
  return newItem;
100
107
  }
101
- if (uniqueKey === 'Income' && existingItem && existingItem.some(function (item) { return item.BusinessActivityStatement; })) {
108
+ if (uniqueKey === 'Income' && existingItem && existingItem.some((item) => item.BusinessActivityStatement)) {
102
109
  // Income array in CompanyApplicant for Low Doc applications
103
110
  return newItem;
104
111
  }
105
112
  // Copying existing array
106
- var mergedArray = existingItem.slice();
113
+ const mergedArray = existingItem.slice();
107
114
  // Searching whether item in the new array exists in existing array
108
- newItem.forEach(function (item) {
109
- var indexOfItem = mergedArray.findIndex(function (existingItem) {
115
+ newItem.forEach((item) => {
116
+ const indexOfItem = mergedArray.findIndex((existingItem) => {
110
117
  // TODO [CORE-2160] how to identify employment without go a level down.
111
118
  // Employment needs to go one level deeper to check if the @UniqueID already exist.
112
119
  if (uniqueKey === 'Employment') {
113
- var currentEmploymentKeys = Object.keys(item);
114
- var existingEmploymentKeys = Object.keys(existingItem);
120
+ const currentEmploymentKeys = Object.keys(item);
121
+ const existingEmploymentKeys = Object.keys(existingItem);
115
122
  if (currentEmploymentKeys.length && existingEmploymentKeys.length) {
116
123
  // Get the unique id from the field with proper value for current employment. The types with undefined value
117
124
  // are present in order to remove the related types from existing application. These undefined types will be
118
125
  // removed from payload immediately after deep merging.
119
126
  // @pliu 19/11/19
120
- var currentEmployment = currentEmploymentKeys.find(function (key) { return item[key]; });
127
+ const currentEmployment = currentEmploymentKeys.find((key) => item[key]);
121
128
  // Each employment can only have one of three types.
122
129
  // @pliu 19/11/19
123
- var existingEmployment = existingEmploymentKeys[0];
130
+ const existingEmployment = existingEmploymentKeys[0];
124
131
  if (currentEmployment && existingEmployment) {
125
132
  return existingItem[existingEmployment]['@UniqueID'] === item[currentEmployment]['@UniqueID'];
126
133
  }
@@ -5,16 +5,14 @@ import { Payload } from '../types/events/public-applicant';
5
5
  * Checks if there are more than one person applicants with applicant type borrower
6
6
  *
7
7
  * @param {PersonApplicants[]} personApplicants - Person applicants on the deep merged application
8
- *
9
8
  * @returns {boolean} - Whether or not there are more than one applicant with applicant type borrower
10
9
  */
11
10
  export declare const isMultiplePersonApplicantBorrowers: (personApplicants: PersonApplicant[]) => boolean;
12
11
  /**
13
12
  * Updates the primary applicant of the application based on the new primary applicant id
14
13
  *
15
- * @param {String} newPrimaryApplicantId - New primary applicant id
14
+ * @param {string} newPrimaryApplicantId - New primary applicant id
16
15
  * @param {PersonApplicant[]} personApplicants - Person applicants from the updated application after deep merge
17
- *
18
16
  * @returns {PersonApplicant[]} - Updated person applicants
19
17
  */
20
18
  export declare const updatePrimaryApplicant: (newPrimaryApplicantId: string, personApplicants: PersonApplicant[]) => PersonApplicant[];
@@ -23,7 +21,6 @@ export declare const updatePrimaryApplicant: (newPrimaryApplicantId: string, per
23
21
  *
24
22
  * @param {PartialApplication} application - Application after deep merge
25
23
  * @param {Payload} applicantPayload - Public applicant event payload
26
- *
27
24
  * @returns {PartialApplication} - Updated application
28
25
  */
29
26
  declare const updatePrimaryApplicantUsingGuarantor: (application: PartialApplication, applicantPayload: Payload) => PartialApplication;
@@ -1,59 +1,40 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.updatePrimaryApplicant = exports.isMultiplePersonApplicantBorrowers = void 0;
15
- var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
16
- var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
17
- var lodash_1 = require("lodash");
18
- var public_applicant_1 = require("../types/events/public-applicant");
4
+ const application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
5
+ const lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types/lixi-internal-request");
6
+ const lodash_1 = require("lodash");
7
+ const public_applicant_1 = require("../types/events/public-applicant");
19
8
  /**
20
9
  * Checks if there are more than one person applicants with applicant type borrower
21
10
  *
22
11
  * @param {PersonApplicants[]} personApplicants - Person applicants on the deep merged application
23
- *
24
12
  * @returns {boolean} - Whether or not there are more than one applicant with applicant type borrower
25
13
  */
26
- var isMultiplePersonApplicantBorrowers = function (personApplicants) {
27
- var totalBorrowerApplicants = personApplicants.filter(function (applicant) { return applicant['@ApplicantType'] === lixi_internal_request_1.ApplicantTypeList.Borrower; }).length;
14
+ const isMultiplePersonApplicantBorrowers = (personApplicants) => {
15
+ const totalBorrowerApplicants = personApplicants.filter((applicant) => applicant['@ApplicantType'] === lixi_internal_request_1.ApplicantTypeList.Borrower).length;
28
16
  return totalBorrowerApplicants > 1;
29
17
  };
30
18
  exports.isMultiplePersonApplicantBorrowers = isMultiplePersonApplicantBorrowers;
31
19
  /**
32
20
  * Updates the primary applicant of the application based on the new primary applicant id
33
21
  *
34
- * @param {String} newPrimaryApplicantId - New primary applicant id
22
+ * @param {string} newPrimaryApplicantId - New primary applicant id
35
23
  * @param {PersonApplicant[]} personApplicants - Person applicants from the updated application after deep merge
36
- *
37
24
  * @returns {PersonApplicant[]} - Updated person applicants
38
25
  */
39
- var updatePrimaryApplicant = function (newPrimaryApplicantId, personApplicants) {
40
- return personApplicants.map(function (applicant) {
41
- var _a;
42
- return (__assign(__assign({}, applicant), (_a = {}, _a['@PrimaryApplicant'] = applicant['@UniqueID'] === newPrimaryApplicantId ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No, _a)));
43
- });
44
- };
26
+ const updatePrimaryApplicant = (newPrimaryApplicantId, personApplicants) => personApplicants.map((applicant) => (Object.assign(Object.assign({}, applicant), { ['@PrimaryApplicant']: applicant['@UniqueID'] === newPrimaryApplicantId ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No })));
45
27
  exports.updatePrimaryApplicant = updatePrimaryApplicant;
46
28
  /**
47
29
  * Updates the primary applicant on the application based on the data in the guarantor applicant event
48
30
  *
49
31
  * @param {PartialApplication} application - Application after deep merge
50
32
  * @param {Payload} applicantPayload - Public applicant event payload
51
- *
52
33
  * @returns {PartialApplication} - Updated application
53
34
  */
54
- var updatePrimaryApplicantUsingGuarantor = function (application, applicantPayload) {
35
+ const updatePrimaryApplicantUsingGuarantor = (application, applicantPayload) => {
55
36
  var _a;
56
- var updatedApplication = application, personApplicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
37
+ const updatedApplication = application, personApplicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
57
38
  // Checks if there are more than one borrower in the application and that the applicant type of the applicant event being processed is GUARANTOR
58
39
  if ((0, exports.isMultiplePersonApplicantBorrowers)(personApplicants) &&
59
40
  applicantPayload.applicantType === public_applicant_1.ApplicantType.Guarantor &&
@@ -62,4 +43,4 @@ var updatePrimaryApplicantUsingGuarantor = function (application, applicantPaylo
62
43
  }
63
44
  return updatedApplication;
64
45
  };
65
- exports["default"] = updatePrimaryApplicantUsingGuarantor;
46
+ exports.default = updatePrimaryApplicantUsingGuarantor;
@@ -51,13 +51,15 @@ export interface AddressTransformedType {
51
51
  */
52
52
  export declare function rebuildAddress(eventAddress: EventAddressType, addressId: string): AddressTransformedType;
53
53
  /**
54
- * * Converts a previous address object from an event model to a LIXI address and corresponding LIXI current address object.
54
+ * Converts a previous address object from an event model to a LIXI address and corresponding LIXI current address object.
55
+ *
55
56
  * @param eventPreviousAddresses
56
57
  * @param addressId
57
58
  */
58
59
  export declare function rebuildPreviousAddress(eventPreviousAddresses: InternalPreviousAddress[], addressId: string): AddressTransformedType;
59
60
  /**
60
61
  * Checks if an event is missing country.
62
+ *
61
63
  * @param addressEvent
62
64
  */
63
65
  export declare function isMissingCountry(addressEvent: EventAddressType): boolean;