@lendi/integrations-transform 1.5.7 → 1.6.0

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 (109) hide show
  1. package/lib/index.js +10 -26
  2. package/lib/logger.d.ts +1 -2
  3. package/lib/logger.js +2 -5
  4. package/lib/schemas/application-workflow-event.json +1 -1
  5. package/lib/transform-events/generate-asset-liability-link.d.ts +3 -1
  6. package/lib/transform-events/generate-asset-liability-link.js +14 -18
  7. package/lib/transform-events/generate-credit-report-rebuilt.js +17 -21
  8. package/lib/transform-events/generate-employment.d.ts +1 -1
  9. package/lib/transform-events/generate-employment.js +51 -56
  10. package/lib/transform-events/generate-required-document.d.ts +1 -7
  11. package/lib/transform-events/generate-required-document.js +43 -69
  12. package/lib/transform-events/transform-applicant.d.ts +2 -1
  13. package/lib/transform-events/transform-applicant.js +78 -91
  14. package/lib/transform-events/transform-application-workflow.d.ts +0 -1
  15. package/lib/transform-events/transform-application-workflow.js +9 -14
  16. package/lib/transform-events/transform-application.d.ts +3 -1
  17. package/lib/transform-events/transform-application.js +28 -33
  18. package/lib/transform-events/transform-asset-address.d.ts +8 -2
  19. package/lib/transform-events/transform-asset-address.js +35 -37
  20. package/lib/transform-events/transform-asset.d.ts +7 -1
  21. package/lib/transform-events/transform-asset.js +164 -184
  22. package/lib/transform-events/transform-expenses.d.ts +4 -0
  23. package/lib/transform-events/transform-expenses.js +52 -58
  24. package/lib/transform-events/transform-funding-position.d.ts +2 -2
  25. package/lib/transform-events/transform-funding-position.js +38 -46
  26. package/lib/transform-events/transform-income.d.ts +8 -1
  27. package/lib/transform-events/transform-income.js +121 -139
  28. package/lib/transform-events/transform-liability.d.ts +4 -1
  29. package/lib/transform-events/transform-liability.js +62 -65
  30. package/lib/transform-events/transform-percent-owned.d.ts +1 -0
  31. package/lib/transform-events/transform-percent-owned.js +7 -14
  32. package/lib/types/enum-mappings/alieo-frequency.js +22 -26
  33. package/lib/types/enum-mappings/asset-type.js +14 -18
  34. package/lib/types/enum-mappings/builder-type.js +6 -10
  35. package/lib/types/enum-mappings/construction-type.js +7 -11
  36. package/lib/types/enum-mappings/country-code.js +243 -247
  37. package/lib/types/enum-mappings/employment-basis.js +9 -13
  38. package/lib/types/enum-mappings/expense-frequency.js +8 -12
  39. package/lib/types/enum-mappings/funding-position.js +29 -32
  40. package/lib/types/enum-mappings/government-benefits.js +7 -11
  41. package/lib/types/enum-mappings/guarantor-relationship-type.d.ts +3 -0
  42. package/lib/types/enum-mappings/guarantor-relationship-type.js +13 -0
  43. package/lib/types/enum-mappings/housing-status.js +12 -16
  44. package/lib/types/enum-mappings/income-type.js +13 -17
  45. package/lib/types/enum-mappings/index.js +27 -43
  46. package/lib/types/enum-mappings/liability-payment-type.js +6 -10
  47. package/lib/types/enum-mappings/liability-type.js +18 -22
  48. package/lib/types/enum-mappings/living-expense.js +27 -31
  49. package/lib/types/enum-mappings/marital-status.js +9 -13
  50. package/lib/types/enum-mappings/postcode.js +11 -15
  51. package/lib/types/enum-mappings/preferred-repayment.js +7 -11
  52. package/lib/types/enum-mappings/proof-of-identity.js +7 -11
  53. package/lib/types/enum-mappings/property-expense-category.js +8 -12
  54. package/lib/types/enum-mappings/public-financial-asset.js +9 -13
  55. package/lib/types/enum-mappings/public-primary-purpose.js +6 -10
  56. package/lib/types/enum-mappings/public-property-status.js +8 -12
  57. package/lib/types/enum-mappings/public-property-type.js +20 -24
  58. package/lib/types/enum-mappings/residency-status.js +8 -12
  59. package/lib/types/enum-mappings/title-gender.js +10 -14
  60. package/lib/types/enum-mappings/title.js +10 -14
  61. package/lib/types/enum-mappings/to-be-purchased.js +4 -7
  62. package/lib/types/enum-mappings/to-be-used-as-security.js +4 -7
  63. package/lib/types/enum-mappings/transaction-type.js +6 -10
  64. package/lib/types/enum-mappings/verification.js +10 -14
  65. package/lib/types/events/applicant-delete.js +4 -7
  66. package/lib/types/events/application-workflow.js +10 -13
  67. package/lib/types/events/asset-delete.js +4 -7
  68. package/lib/types/events/asset-liability-relation-delete.js +4 -7
  69. package/lib/types/events/credit-report-retrieved.js +4 -7
  70. package/lib/types/events/employment-delete.js +2 -5
  71. package/lib/types/events/expense-delete.js +2 -5
  72. package/lib/types/events/funding-position.js +6 -9
  73. package/lib/types/events/income-delete.js +4 -7
  74. package/lib/types/events/liability-delete.js +2 -5
  75. package/lib/types/events/opportunity.js +6 -9
  76. package/lib/types/events/public-applicant.js +28 -31
  77. package/lib/types/events/public-application.js +26 -29
  78. package/lib/types/events/public-asset-liability-relation.js +4 -7
  79. package/lib/types/events/public-asset.js +26 -29
  80. package/lib/types/events/public-employment.js +18 -21
  81. package/lib/types/events/public-expense.js +8 -11
  82. package/lib/types/events/public-funding-position.js +2 -5
  83. package/lib/types/events/public-income.js +12 -15
  84. package/lib/types/events/public-liability.js +16 -19
  85. package/lib/types/events/public-required-document.js +14 -17
  86. package/lib/types/partial-application.js +1 -2
  87. package/lib/types/recursive-partial.js +1 -2
  88. package/lib/update-application/merge-application.d.ts +1 -1
  89. package/lib/update-application/merge-application.js +41 -38
  90. package/lib/update-application/update-primary-applicant.d.ts +1 -4
  91. package/lib/update-application/update-primary-applicant.js +14 -38
  92. package/lib/utils/address-tools.d.ts +3 -1
  93. package/lib/utils/address-tools.js +56 -68
  94. package/lib/utils/clean-up.d.ts +1 -1
  95. package/lib/utils/clean-up.js +6 -10
  96. package/lib/utils/formatYesNo.d.ts +0 -1
  97. package/lib/utils/formatYesNo.js +2 -7
  98. package/lib/utils/generate-address.d.ts +3 -2
  99. package/lib/utils/generate-address.js +33 -42
  100. package/lib/utils/get-financial-institution.d.ts +1 -0
  101. package/lib/utils/get-financial-institution.js +7 -10
  102. package/lib/utils/is-asset-type.js +13 -20
  103. package/lib/utils/is-income-type.d.ts +2 -0
  104. package/lib/utils/is-income-type.js +50 -69
  105. package/lib/utils/iso-date.d.ts +0 -1
  106. package/lib/utils/iso-date.js +2 -7
  107. package/lib/utils/normalise-date.js +6 -10
  108. package/lib/utils/round-decimal.js +1 -5
  109. package/package.json +14 -17
package/lib/index.js CHANGED
@@ -1,27 +1,11 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- exports.__esModule = true;
17
1
  /* istanbul ignore file */
18
- __exportStar(require("./transform-events/transform-applicant"), exports);
19
- __exportStar(require("./transform-events/transform-application"), exports);
20
- __exportStar(require("./transform-events/transform-application-workflow"), exports);
21
- __exportStar(require("./transform-events/transform-income"), exports);
22
- __exportStar(require("./transform-events/transform-asset"), exports);
23
- __exportStar(require("./transform-events/transform-expenses"), exports);
24
- __exportStar(require("./transform-events/transform-liability"), exports);
25
- __exportStar(require("./transform-events/generate-required-document"), exports);
26
- __exportStar(require("./transform-events/transform-funding-position"), exports);
27
- __exportStar(require("./update-application/merge-application"), exports);
2
+ export * from './transform-events/transform-applicant';
3
+ export * from './transform-events/transform-application';
4
+ export * from './transform-events/transform-application-workflow';
5
+ export * from './transform-events/transform-income';
6
+ export * from './transform-events/transform-asset';
7
+ export * from './transform-events/transform-expenses';
8
+ export * from './transform-events/transform-liability';
9
+ export * from './transform-events/generate-required-document';
10
+ export * from './transform-events/transform-funding-position';
11
+ export * from './update-application/merge-application';
package/lib/logger.d.ts CHANGED
@@ -1,2 +1 @@
1
- import * as pino from 'pino';
2
- export declare const logger: pino.Logger;
1
+ export declare const logger: import("@lendi/logging").Logger;
package/lib/logger.js CHANGED
@@ -1,5 +1,2 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.logger = void 0;
4
- var pino = require("pino");
5
- exports.logger = pino({ name: 'integrations-transform', messageKey: 'message' });
1
+ import { createLogger } from '@lendi/logging';
2
+ export const logger = createLogger({ name: 'integrations-transform', messageKey: 'message' });
@@ -156,7 +156,7 @@
156
156
  },
157
157
  "applicationStatus": {
158
158
  "type": "string",
159
- "description": "Application status in Lendi Group Salesforce",
159
+ "description": "Application status in Lendi Group Salesforce"
160
160
  },
161
161
  "confirmedPrimaryPurpose": {
162
162
  "type": "string",
@@ -3,6 +3,8 @@ import { AssetAndLiabilityRelation } from '../types/events/public-asset-liabilit
3
3
  * Generates a partial application from the partial asset and liability event.
4
4
  *
5
5
  * @param assetLiabilityLink: A partial asset and liability event.
6
- * @return partialApplication: A partial internal request.
6
+ * @param assetLiabilityLink:.applicationId
7
+ * @param assetLiabilityLink:.relation
8
+ * @returns partialApplication: A partial internal request.
7
9
  */
8
10
  export declare function generateAssetLiabilityLink({ applicationId, relation }: AssetAndLiabilityRelation): {};
@@ -1,29 +1,25 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.generateAssetLiabilityLink = void 0;
4
- var lodash_1 = require("lodash");
5
- var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
1
+ import { set } from 'lodash';
2
+ import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
6
3
  /**
7
4
  * Generates a partial application from the partial asset and liability event.
8
5
  *
9
6
  * @param assetLiabilityLink: A partial asset and liability event.
10
- * @return partialApplication: A partial internal request.
7
+ * @param assetLiabilityLink:.applicationId
8
+ * @param assetLiabilityLink:.relation
9
+ * @returns partialApplication: A partial internal request.
11
10
  */
12
- function generateAssetLiabilityLink(_a) {
13
- var applicationId = _a.applicationId, relation = _a.relation;
14
- var partialApplication = {};
15
- var assetLiabilityMapping = {
16
- applicationId: application_paths_1.paths.ApplicationId,
17
- liabilityId: "".concat(application_paths_1.paths.Liability, ".@UniqueID"),
18
- assetId: "".concat(application_paths_1.paths.Liability, ".Security[0].@x_Security")
11
+ export function generateAssetLiabilityLink({ applicationId, relation }) {
12
+ const partialApplication = {};
13
+ const assetLiabilityMapping = {
14
+ applicationId: paths.ApplicationId,
15
+ liabilityId: `${paths.Liability}.@UniqueID`,
16
+ assetId: `${paths.Liability}.Security[0].@x_Security`,
19
17
  };
20
- (0, lodash_1.set)(partialApplication, assetLiabilityMapping.applicationId, applicationId);
21
- for (var _i = 0, _b = Object.entries(relation); _i < _b.length; _i++) {
22
- var _c = _b[_i], key = _c[0], value = _c[1];
18
+ set(partialApplication, assetLiabilityMapping.applicationId, applicationId);
19
+ for (const [key, value] of Object.entries(relation)) {
23
20
  if (assetLiabilityMapping[key]) {
24
- (0, lodash_1.set)(partialApplication, assetLiabilityMapping[key], value);
21
+ set(partialApplication, assetLiabilityMapping[key], value);
25
22
  }
26
23
  }
27
24
  return partialApplication;
28
25
  }
29
- exports.generateAssetLiabilityLink = generateAssetLiabilityLink;
@@ -1,41 +1,37 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.generateCreditReportRebuilt = 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 application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
1
+ import { ReportContentTypeList, } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
+ import { set } from 'lodash';
3
+ import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
7
4
  /**
8
5
  * Generates LIXI compliant `Attachment` and `CreditAssessment` objects which
9
6
  * use credit report data fetched from Equifax.
10
7
  *
11
8
  * @param {CreditReportPayload} creditReport - Credit report rebuilt event.
12
9
  */
13
- function generateCreditReportRebuilt(creditReport) {
14
- var applicantId = creditReport.applicantId, raw = creditReport.raw, source = creditReport.source;
15
- var id = "".concat(applicantId, "-creditReport");
16
- var attachment = {
10
+ export function generateCreditReportRebuilt(creditReport) {
11
+ const { applicantId, raw, source } = creditReport;
12
+ const id = `${applicantId}-creditReport`;
13
+ const attachment = {
17
14
  '@Filename': 'Credit Report',
18
15
  '@UniqueID': id,
19
16
  InlineAttachment: {
20
- $: raw
21
- }
17
+ $: raw,
18
+ },
22
19
  };
23
- var report = {
20
+ const report = {
24
21
  '@RequestDateTime': new Date().toISOString(),
25
22
  '@Source': source,
26
23
  '@x_Party': applicantId,
27
24
  Content: [
28
25
  {
29
- '@Type': lixi_internal_request_1.ReportContentTypeList.XML,
30
- '@x_Attachment': id
26
+ '@Type': ReportContentTypeList.XML,
27
+ '@x_Attachment': id,
31
28
  },
32
- ]
29
+ ],
33
30
  };
34
- var partialApplication = {};
31
+ const partialApplication = {};
35
32
  // Set application id, attachment and credit assessment report.
36
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, creditReport.applicationId);
37
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.Attachment, [attachment]);
38
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.Report, [report]);
33
+ set(partialApplication, paths.ApplicationId, creditReport.applicationId);
34
+ set(partialApplication, paths.Attachment, [attachment]);
35
+ set(partialApplication, paths.Report, [report]);
39
36
  return partialApplication;
40
37
  }
41
- exports.generateCreditReportRebuilt = generateCreditReportRebuilt;
@@ -3,6 +3,6 @@ import { Payload } from '../types/events/public-employment';
3
3
  * Generates a partial application from a employment event.
4
4
  *
5
5
  * @param employment a employment event payload.
6
- * @return partialApplication an incomplete application.
6
+ * @returns partialApplication an incomplete application.
7
7
  */
8
8
  export declare function generateEmployment(employment: Payload): {};
@@ -1,106 +1,101 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.generateEmployment = 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 application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
7
- var logger_1 = require("../logger");
8
- var public_employment_1 = require("../types/events/public-employment");
9
- var enum_mappings_1 = require("../types/enum-mappings");
1
+ import { List as Frequency, YesNoList } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
+ import { set, capitalize } from 'lodash';
3
+ import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
4
+ import { logger } from '../logger';
5
+ import { EmploymentType } from '../types/events/public-employment';
6
+ import { paygEmploymentBasisMapping } from '../types/enum-mappings';
10
7
  /**
11
8
  * Generates a partial application from a employment event.
12
9
  *
13
10
  * @param employment a employment event payload.
14
- * @return partialApplication an incomplete application.
11
+ * @returns partialApplication an incomplete application.
15
12
  */
16
- function generateEmployment(employment) {
17
- var partialApplication = {};
18
- var employmentPath = application_paths_1.paths.PAYG;
19
- var isEmployed = false;
20
- var applicationId = employment.applicationId;
13
+ export function generateEmployment(employment) {
14
+ const partialApplication = {};
15
+ let employmentPath = paths.PAYG;
16
+ let isEmployed = false;
17
+ const { applicationId } = employment;
21
18
  // Each one Employment object can only contain one of the three types. Set the three object to undefined so that the
22
19
  // other two types will be removed from the final result.
23
20
  // @pliu 19/11/19
24
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.PAYG, undefined);
25
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.SelfEmployed, undefined);
26
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.NotEmployed, undefined);
21
+ set(partialApplication, paths.PAYG, undefined);
22
+ set(partialApplication, paths.SelfEmployed, undefined);
23
+ set(partialApplication, paths.NotEmployed, undefined);
27
24
  switch (employment.employmentType) {
28
- case public_employment_1.EmploymentType.Employee:
25
+ case EmploymentType.Employee:
29
26
  isEmployed = true;
30
- employmentPath = application_paths_1.paths.PAYG;
27
+ employmentPath = paths.PAYG;
31
28
  // Setting default for onProbation. If field exists in event value will get overwritten.
32
- (0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".@OnProbation"), lixi_internal_request_1.YesNoList.No);
29
+ set(partialApplication, `${employmentPath}.@OnProbation`, YesNoList.No);
33
30
  break;
34
- case public_employment_1.EmploymentType.SelfEmployed:
31
+ case EmploymentType.SelfEmployed:
35
32
  isEmployed = true;
36
- employmentPath = application_paths_1.paths.SelfEmployed;
33
+ employmentPath = paths.SelfEmployed;
37
34
  break;
38
- case public_employment_1.EmploymentType.NotWorking:
39
- employmentPath = application_paths_1.paths.NotEmployed;
40
- (0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".Income.@OtherIncomeAmount"), 0);
41
- (0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".Income.@OtherIncomeFrequency"), lixi_internal_request_1.List.Fortnightly);
35
+ case EmploymentType.NotWorking:
36
+ employmentPath = paths.NotEmployed;
37
+ set(partialApplication, `${employmentPath}.Income.@OtherIncomeAmount`, 0);
38
+ set(partialApplication, `${employmentPath}.Income.@OtherIncomeFrequency`, Frequency.Fortnightly);
42
39
  break;
43
40
  default:
44
- logger_1.logger.warn({ message: "Unknown EmploymentType ".concat(employment.employmentType), applicationId: applicationId });
41
+ logger.warn({ message: `Unknown EmploymentType ${employment.employmentType}`, applicationId });
45
42
  }
46
- var employmentMapping = {
47
- applicationId: application_paths_1.paths.ApplicationId,
48
- applicantId: "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"),
49
- id: "".concat(employmentPath, ".@UniqueID"),
50
- abn: "".concat(application_paths_1.paths.RelatedCompany, ".@ABN"),
51
- businessName: "".concat(application_paths_1.paths.RelatedCompany, ".@BusinessName"),
52
- type: "".concat(employmentPath, ".@Status"),
53
- employmentBasis: "".concat(employmentPath, ".@Basis"),
54
- startDate: "".concat(employmentPath, ".@StartDate"),
55
- endDate: "".concat(employmentPath, ".@EndDate"),
56
- role: "".concat(employmentPath, ".@Occupation"),
57
- onProbation: "".concat(employmentPath, ".@OnProbation")
43
+ const employmentMapping = {
44
+ applicationId: paths.ApplicationId,
45
+ applicantId: `${paths.PersonApplicant}.@UniqueID`,
46
+ id: `${employmentPath}.@UniqueID`,
47
+ abn: `${paths.RelatedCompany}.@ABN`,
48
+ businessName: `${paths.RelatedCompany}.@BusinessName`,
49
+ type: `${employmentPath}.@Status`,
50
+ employmentBasis: `${employmentPath}.@Basis`,
51
+ startDate: `${employmentPath}.@StartDate`,
52
+ endDate: `${employmentPath}.@EndDate`,
53
+ role: `${employmentPath}.@Occupation`,
54
+ onProbation: `${employmentPath}.@OnProbation`,
58
55
  };
59
- for (var _i = 0, _a = Object.entries(employment); _i < _a.length; _i++) {
60
- var _b = _a[_i], key = _b[0], value = _b[1];
56
+ for (const [key, value] of Object.entries(employment)) {
61
57
  if (employmentMapping[key]) {
62
58
  switch (key) {
63
59
  case 'type':
64
- (0, lodash_1.set)(partialApplication, employmentMapping[key], (0, lodash_1.capitalize)(value));
60
+ set(partialApplication, employmentMapping[key], capitalize(value));
65
61
  break;
66
62
  case 'abn':
67
63
  case 'businessName':
68
64
  // Only transform value in RelatedCompany for employed (self employed or employee) employment, otherwise RelatedCompany would missing UniqueID
69
65
  if (isEmployed) {
70
- (0, lodash_1.set)(partialApplication, employmentMapping[key], value.toString());
66
+ set(partialApplication, employmentMapping[key], value.toString());
71
67
  }
72
68
  break;
73
69
  case 'employmentBasis':
74
- (0, lodash_1.set)(partialApplication, employmentMapping[key], enum_mappings_1.paygEmploymentBasisMapping[value]);
70
+ set(partialApplication, employmentMapping[key], paygEmploymentBasisMapping[value]);
75
71
  break;
76
72
  case 'id':
77
- (0, lodash_1.set)(partialApplication, employmentMapping[key], value);
73
+ set(partialApplication, employmentMapping[key], value);
78
74
  if (isEmployed) {
79
- (0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".@x_Employer"), "".concat(value, "-businessName"));
80
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RelatedCompany, ".@UniqueID"), "".concat(value, "-businessName"));
75
+ set(partialApplication, `${employmentPath}.@x_Employer`, `${value}-businessName`);
76
+ set(partialApplication, `${paths.RelatedCompany}.@UniqueID`, `${value}-businessName`);
81
77
  }
82
78
  break;
83
79
  case 'onProbation':
84
- if (employment.employmentType === public_employment_1.EmploymentType.Employee) {
85
- var onProbation = value ? lixi_internal_request_1.YesNoList.Yes : lixi_internal_request_1.YesNoList.No;
86
- (0, lodash_1.set)(partialApplication, employmentMapping[key], onProbation);
80
+ if (employment.employmentType === EmploymentType.Employee) {
81
+ const onProbation = value ? YesNoList.Yes : YesNoList.No;
82
+ set(partialApplication, employmentMapping[key], onProbation);
87
83
  }
88
84
  break;
89
85
  case 'role':
90
- var _c = value.anzsco, anzsco = _c === void 0 ? {} : _c;
86
+ const { anzsco = {} } = value;
91
87
  if (anzsco.code) {
92
- (0, lodash_1.set)(partialApplication, "".concat(employmentPath, ".@ANZSCOOccupationCode"), anzsco.code.toString());
88
+ set(partialApplication, `${employmentPath}.@ANZSCOOccupationCode`, anzsco.code.toString());
93
89
  }
94
90
  if (anzsco.occupation) {
95
- (0, lodash_1.set)(partialApplication, employmentMapping[key], anzsco.occupation);
91
+ set(partialApplication, employmentMapping[key], anzsco.occupation);
96
92
  }
97
93
  break;
98
94
  default:
99
- (0, lodash_1.set)(partialApplication, employmentMapping[key], value);
95
+ set(partialApplication, employmentMapping[key], value);
100
96
  break;
101
97
  }
102
98
  }
103
99
  }
104
100
  return partialApplication;
105
101
  }
106
- exports.generateEmployment = generateEmployment;
@@ -5,7 +5,6 @@ import { EConsent, Identification, Payload as RequiredDocumentPayload } from '..
5
5
  * Gets the applicant gender from the identification data
6
6
  *
7
7
  * @param identification Identification data
8
- *
9
8
  * @returns The gender of the applicant
10
9
  */
11
10
  export declare const getApplicantGenderFromIdentification: (identification: Identification) => string;
@@ -13,7 +12,6 @@ export declare const getApplicantGenderFromIdentification: (identification: Iden
13
12
  * Gets full name on document from the identification data
14
13
  *
15
14
  * @param identification Identification data
16
- *
17
15
  * @returns The full name on document
18
16
  */
19
17
  export declare const getNameOnDocument: (identification: Identification) => string;
@@ -21,7 +19,6 @@ export declare const getNameOnDocument: (identification: Identification) => stri
21
19
  * Transforms identification data into a partial proof of identity document
22
20
  *
23
21
  * @param identification Identification data
24
- *
25
22
  * @returns Partial proof of identity object
26
23
  */
27
24
  export declare const transformIdentification: (identification: Identification) => Partial<ProofOfIdentity>;
@@ -29,7 +26,6 @@ export declare const transformIdentification: (identification: Identification) =
29
26
  * Generates partial details for document used to verify identity
30
27
  *
31
28
  * @param requiredDocument RequiredDocumentCreated/RequiredDocumentUpdated event payload
32
- *
33
29
  * @returns Partial proof of identity document object
34
30
  */
35
31
  export declare const generateProofOfIdentity: (requiredDocument: RequiredDocumentPayload) => Partial<ProofOfIdentity>;
@@ -37,7 +33,6 @@ export declare const generateProofOfIdentity: (requiredDocument: RequiredDocumen
37
33
  * Generates an applicants disclosure details mapping for the partial application
38
34
  *
39
35
  * @param eConsent E-Consent detials from the RequiredDocumentCreated/RequqiredDocumentUpdated event payload
40
- *
41
36
  * @returns Applicant disclosure details for partial application
42
37
  */
43
38
  export declare const generatePersonApplicantPrivacy: (eConsent: EConsent) => PersonApplicantPrivacy;
@@ -45,7 +40,6 @@ export declare const generatePersonApplicantPrivacy: (eConsent: EConsent) => Per
45
40
  * Transforms a RequiredDocumentCreated or RequiredDocumentUpdated event payload into a partial application
46
41
  *
47
42
  * @param requiredDocument A RequiredDocumentCreated or RequiredDocumentUpdated event payload
48
- *
49
- * @return A partial application
43
+ * @returns A partial application
50
44
  */
51
45
  export declare function transformRequiredDocument(requiredDocument: RequiredDocumentPayload): {};
@@ -1,123 +1,97 @@
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;
14
- exports.transformRequiredDocument = exports.generatePersonApplicantPrivacy = exports.generateProofOfIdentity = exports.transformIdentification = exports.getNameOnDocument = exports.getApplicantGenderFromIdentification = void 0;
15
- var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
16
- var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
17
- var lodash_1 = require("lodash");
18
- var enum_mappings_1 = require("../types/enum-mappings");
19
- var enum_mappings_2 = require("../types/enum-mappings");
20
- var enum_mappings_3 = require("../types/enum-mappings");
21
- var verification_1 = require("../types/enum-mappings/verification");
22
- var public_required_document_1 = require("../types/events/public-required-document");
23
- var formatYesNo_1 = require("../utils/formatYesNo");
24
- var iso_date_1 = require("../utils/iso-date");
1
+ import { CountryCodeList, DocumentTypeList, } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
2
+ import { paths } from '@lendi/integrations-protocol/lib/utils/application-paths';
3
+ import { capitalize, set } from 'lodash';
4
+ import { countryCodeMapping } from '../types/enum-mappings';
5
+ import { proofOfIdentityMapping } from '../types/enum-mappings';
6
+ import { titleGenderMapping } from '../types/enum-mappings';
7
+ import { verificationMapping } from '../types/enum-mappings/verification';
8
+ import { IDTitle, IDType, IssuingCountry, } from '../types/events/public-required-document';
9
+ import { formatYesNo } from '../utils/formatYesNo';
10
+ import { isoDate } from '../utils/iso-date';
25
11
  /**
26
12
  * Gets the applicant gender from the identification data
27
13
  *
28
14
  * @param identification Identification data
29
- *
30
15
  * @returns The gender of the applicant
31
16
  */
32
- var getApplicantGenderFromIdentification = function (identification) {
33
- var gender = identification.gender, idTitle = identification.idTitle;
34
- return gender ? (0, lodash_1.capitalize)(gender) : enum_mappings_3.titleGenderMapping[idTitle || public_required_document_1.IDTitle.Unknown];
17
+ export const getApplicantGenderFromIdentification = (identification) => {
18
+ const { gender, idTitle } = identification;
19
+ return gender ? capitalize(gender) : titleGenderMapping[idTitle || IDTitle.Unknown];
35
20
  };
36
- exports.getApplicantGenderFromIdentification = getApplicantGenderFromIdentification;
37
21
  /**
38
22
  * Gets full name on document from the identification data
39
23
  *
40
24
  * @param identification Identification data
41
- *
42
25
  * @returns The full name on document
43
26
  */
44
- var getNameOnDocument = function (identification) {
45
- var idFirstName = identification.idFirstName, idMiddleName = identification.idMiddleName, idLastName = identification.idLastName;
46
- return [idFirstName, idMiddleName, idLastName].reduce(function (fullName, nameComponent) {
47
- var newFullName = fullName;
48
- var nameSubstring = nameComponent === null || nameComponent === void 0 ? void 0 : nameComponent.trim();
27
+ export const getNameOnDocument = (identification) => {
28
+ const { idFirstName, idMiddleName, idLastName } = identification;
29
+ return [idFirstName, idMiddleName, idLastName].reduce((fullName, nameComponent) => {
30
+ let newFullName = fullName;
31
+ const nameSubstring = nameComponent === null || nameComponent === void 0 ? void 0 : nameComponent.trim();
49
32
  if (nameSubstring) {
50
- newFullName += "".concat(fullName ? ' ' : '').concat(nameSubstring);
33
+ newFullName += `${fullName ? ' ' : ''}${nameSubstring}`;
51
34
  }
52
35
  return newFullName;
53
36
  }, '');
54
37
  };
55
- exports.getNameOnDocument = getNameOnDocument;
56
38
  /**
57
39
  * Transforms identification data into a partial proof of identity document
58
40
  *
59
41
  * @param identification Identification data
60
- *
61
42
  * @returns Partial proof of identity object
62
43
  */
63
- var transformIdentification = function (identification) {
64
- var australianState = identification.australianState, idNumber = identification.idNumber, idType = identification.idType, _a = identification.issuingCountry, issuingCountry = _a === void 0 ? public_required_document_1.IssuingCountry.Australia : _a;
65
- var nameOnDocument = (0, exports.getNameOnDocument)(identification);
66
- return __assign(__assign(__assign(__assign({}, (nameOnDocument && { '@NameOnDocument': nameOnDocument })), (idNumber && { '@DocumentNumber': idNumber })), (australianState && { '@PlaceOfIssue': australianState })), (idType === public_required_document_1.IDType.Passport && issuingCountry !== public_required_document_1.IssuingCountry.Australia
44
+ export const transformIdentification = (identification) => {
45
+ const { australianState, idNumber, idType, issuingCountry = IssuingCountry.Australia } = identification;
46
+ const nameOnDocument = getNameOnDocument(identification);
47
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (nameOnDocument && { '@NameOnDocument': nameOnDocument })), (idNumber && { '@DocumentNumber': idNumber })), (australianState && { '@PlaceOfIssue': australianState })), (idType === IDType.Passport && issuingCountry !== IssuingCountry.Australia
67
48
  ? {
68
- '@DocumentType': lixi_internal_request_1.DocumentTypeList.InternationalPassport,
69
- '@CountryOfIssue': enum_mappings_1.countryCodeMapping[issuingCountry],
70
- '@PlaceOfIssue': enum_mappings_1.countryCodeMapping[issuingCountry]
49
+ '@DocumentType': DocumentTypeList.InternationalPassport,
50
+ '@CountryOfIssue': countryCodeMapping[issuingCountry],
51
+ '@PlaceOfIssue': countryCodeMapping[issuingCountry],
71
52
  }
72
- : { '@DocumentType': enum_mappings_2.proofOfIdentityMapping[idType] }));
53
+ : { '@DocumentType': proofOfIdentityMapping[idType] }));
73
54
  };
74
- exports.transformIdentification = transformIdentification;
75
55
  /**
76
56
  * Generates partial details for document used to verify identity
77
57
  *
78
58
  * @param requiredDocument RequiredDocumentCreated/RequiredDocumentUpdated event payload
79
- *
80
59
  * @returns Partial proof of identity document object
81
60
  */
82
- var generateProofOfIdentity = function (requiredDocument) {
83
- var id = requiredDocument.id, status = requiredDocument.status, expiryDate = requiredDocument.expiryDate, identification = requiredDocument.identification;
84
- return __assign(__assign(__assign({ '@UniqueID': id, '@CountryOfIssue': lixi_internal_request_1.CountryCodeList.Au, '@PlaceOfIssue': lixi_internal_request_1.CountryCodeList.Au }, (expiryDate && { '@ExpiryDate': (0, iso_date_1.isoDate)(expiryDate) })), (status && { '@PhotographVerified': verification_1.verificationMapping[status] })), (identification && (0, exports.transformIdentification)(identification)));
61
+ export const generateProofOfIdentity = (requiredDocument) => {
62
+ const { id, status, expiryDate, identification } = requiredDocument;
63
+ return Object.assign(Object.assign(Object.assign({ '@UniqueID': id, '@CountryOfIssue': CountryCodeList.Au, '@PlaceOfIssue': CountryCodeList.Au }, (expiryDate && { '@ExpiryDate': isoDate(expiryDate) })), (status && { '@PhotographVerified': verificationMapping[status] })), (identification && transformIdentification(identification)));
85
64
  };
86
- exports.generateProofOfIdentity = generateProofOfIdentity;
87
65
  /**
88
66
  * Generates an applicants disclosure details mapping for the partial application
89
67
  *
90
68
  * @param eConsent E-Consent detials from the RequiredDocumentCreated/RequqiredDocumentUpdated event payload
91
- *
92
69
  * @returns Applicant disclosure details for partial application
93
70
  */
94
- var generatePersonApplicantPrivacy = function (eConsent) {
95
- var hasConsented = eConsent.hasConsented, _a = eConsent.consentedAt, consentedAt = _a === void 0 ? new Date() : _a;
71
+ export const generatePersonApplicantPrivacy = (eConsent) => {
72
+ const { hasConsented, consentedAt = new Date() } = eConsent;
96
73
  return {
97
- '@CreditAuthoritySigned': (0, formatYesNo_1.formatYesNo)(hasConsented),
98
- '@DateSigned': (0, iso_date_1.isoDate)(consentedAt)
74
+ '@CreditAuthoritySigned': formatYesNo(hasConsented),
75
+ '@DateSigned': isoDate(consentedAt),
99
76
  };
100
77
  };
101
- exports.generatePersonApplicantPrivacy = generatePersonApplicantPrivacy;
102
78
  /**
103
79
  * Transforms a RequiredDocumentCreated or RequiredDocumentUpdated event payload into a partial application
104
80
  *
105
81
  * @param requiredDocument A RequiredDocumentCreated or RequiredDocumentUpdated event payload
106
- *
107
- * @return A partial application
82
+ * @returns A partial application
108
83
  */
109
- function transformRequiredDocument(requiredDocument) {
110
- var partialApplication = {};
111
- var applicantId = requiredDocument.applicantId, applicationId = requiredDocument.applicationId, identification = requiredDocument.identification, eConsent = requiredDocument.eConsent;
112
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@UniqueID"), applicantId);
113
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
84
+ export function transformRequiredDocument(requiredDocument) {
85
+ const partialApplication = {};
86
+ const { applicantId, applicationId, identification, eConsent } = requiredDocument;
87
+ set(partialApplication, `${paths.PersonApplicant}.@UniqueID`, applicantId);
88
+ set(partialApplication, paths.ApplicationId, applicationId);
114
89
  if (identification) {
115
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.PersonApplicant, ".@Gender"), (0, exports.getApplicantGenderFromIdentification)(identification));
116
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.ProofOfIdentity), (0, exports.generateProofOfIdentity)(requiredDocument));
90
+ set(partialApplication, `${paths.PersonApplicant}.@Gender`, getApplicantGenderFromIdentification(identification));
91
+ set(partialApplication, `${paths.ProofOfIdentity}`, generateProofOfIdentity(requiredDocument));
117
92
  }
118
93
  if (eConsent) {
119
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Privacy), (0, exports.generatePersonApplicantPrivacy)(eConsent));
94
+ set(partialApplication, `${paths.Privacy}`, generatePersonApplicantPrivacy(eConsent));
120
95
  }
121
96
  return partialApplication;
122
97
  }
123
- exports.transformRequiredDocument = transformRequiredDocument;
@@ -5,7 +5,8 @@ export declare const booleanMapping: (input?: boolean) => YesNoList;
5
5
  * Transforms a partial Applicant event to a partial LIXI application.
6
6
  *
7
7
  * @param applicant: A partial applicant.
8
- * @return partialApplication an incomplete application.
8
+ * @param applicant
9
+ * @returns partialApplication an incomplete application.
9
10
  */
10
11
  export declare function transformApplicant(applicant: ApplicantPayload): {};
11
12
  /**