@lendi/integrations-transform 1.1.6 → 1.2.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 (39) hide show
  1. package/lib/index.d.ts +2 -1
  2. package/lib/index.js +2 -1
  3. package/lib/schemas/public-asset-event.json +86 -93
  4. package/lib/transform-events/generate-asset-liability-link.js +2 -2
  5. package/lib/transform-events/generate-credit-report-rebuilt.js +1 -1
  6. package/lib/transform-events/generate-employment.js +17 -17
  7. package/lib/transform-events/generate-funding-position.js +6 -6
  8. package/lib/transform-events/generate-liability.js +15 -15
  9. package/lib/transform-events/generate-opportunity.js +2 -2
  10. package/lib/transform-events/generate-required-document.js +7 -7
  11. package/lib/transform-events/transform-applicant.js +26 -29
  12. package/lib/transform-events/transform-application.js +7 -8
  13. package/lib/transform-events/transform-asset.d.ts +44 -0
  14. package/lib/transform-events/transform-asset.js +271 -0
  15. package/lib/transform-events/transform-expenses.js +6 -7
  16. package/lib/transform-events/{generate-income.d.ts → transform-income.d.ts} +1 -1
  17. package/lib/transform-events/{generate-income.js → transform-income.js} +35 -31
  18. package/lib/transform-events/{generate-lixi-percentowned.d.ts → transform-percent-owned.d.ts} +1 -1
  19. package/lib/transform-events/{generate-lixi-percentowned.js → transform-percent-owned.js} +3 -3
  20. package/lib/types/enum-mappings/asset-type.d.ts +3 -0
  21. package/lib/types/enum-mappings/asset-type.js +18 -0
  22. package/lib/types/enum-mappings/index.d.ts +26 -0
  23. package/lib/types/enum-mappings/index.js +38 -0
  24. package/lib/types/enum-mappings/to-be-purchased.d.ts +5 -0
  25. package/lib/types/enum-mappings/to-be-purchased.js +8 -0
  26. package/lib/types/enum-mappings/to-be-used-as-security.d.ts +5 -0
  27. package/lib/types/enum-mappings/to-be-used-as-security.js +8 -0
  28. package/lib/types/events/public-asset.d.ts +16 -17
  29. package/lib/types/events/public-asset.js +3 -0
  30. package/lib/utils/address-tools.d.ts +14 -1
  31. package/lib/utils/address-tools.js +35 -3
  32. package/lib/utils/generate-address.d.ts +3 -4
  33. package/lib/utils/generate-address.js +8 -9
  34. package/lib/utils/is-asset-type.d.ts +25 -0
  35. package/lib/utils/is-asset-type.js +46 -0
  36. package/lib/utils/normalise-date.js +1 -1
  37. package/package.json +4 -4
  38. package/lib/transform-events/generate-asset.d.ts +0 -17
  39. package/lib/transform-events/generate-asset.js +0 -178
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.isOtherAsset = exports.isMotorVehicle = exports.isRealEstateAsset = exports.isFinancialAsset = void 0;
4
+ var public_asset_1 = require("../types/events/public-asset");
5
+ /**
6
+ * @description Checks if the asset is of financial type.
7
+ * @param {Asset} asset asset payload.
8
+ * @returns {boolean} returns true if asset is a financial asset.
9
+ */
10
+ function isFinancialAsset(asset) {
11
+ return [
12
+ public_asset_1.AssetType.Shares,
13
+ public_asset_1.AssetType.Superannuation,
14
+ public_asset_1.AssetType.TermDeposit,
15
+ public_asset_1.AssetType.SavingCheckAccount,
16
+ public_asset_1.AssetType.ManagedFunds,
17
+ ].includes(asset.type);
18
+ }
19
+ exports.isFinancialAsset = isFinancialAsset;
20
+ /**
21
+ * @description Is Asset a Real Estate Asset.
22
+ * @param {Asset} asset An Asset.
23
+ * @returns {boolean} returns true if Asset is a Real Estate Asset.
24
+ */
25
+ function isRealEstateAsset(asset) {
26
+ return asset.type === public_asset_1.AssetType.Property;
27
+ }
28
+ exports.isRealEstateAsset = isRealEstateAsset;
29
+ /**
30
+ * @description Is Asset a Motor Vehicle.
31
+ * @param {Asset} asset An Asset.
32
+ * @returns {boolean} returns true if an Asset is a vehicle.
33
+ */
34
+ function isMotorVehicle(asset) {
35
+ return asset.type === public_asset_1.AssetType.Vehicle;
36
+ }
37
+ exports.isMotorVehicle = isMotorVehicle;
38
+ /**
39
+ * @description Is Asset of LIXI type `OtherAsset`.
40
+ * @param {Asset} asset An Asset.
41
+ * @returns {boolean} returns true if asset is `OtherAsset`.
42
+ */
43
+ function isOtherAsset(asset) {
44
+ return [public_asset_1.AssetType.HomeContents, public_asset_1.AssetType.Gifts, public_asset_1.AssetType.OtherAsset].includes(asset.type);
45
+ }
46
+ exports.isOtherAsset = isOtherAsset;
@@ -12,6 +12,6 @@ function normaliseDate(dateOfBirth) {
12
12
  var year = date.getFullYear();
13
13
  var month = ('0' + (date.getMonth() + 1)).slice(-2);
14
14
  var day = ('0' + date.getDate()).slice(-2);
15
- return "".concat(year, "-").concat(month, "-").concat(day);
15
+ return year + "-" + month + "-" + day;
16
16
  }
17
17
  exports.normaliseDate = normaliseDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.1.6",
3
+ "version": "1.2.1",
4
4
  "description": "Library for kafka event data transforming",
5
5
  "author": "Integrations <integrations@lendi.com.au>",
6
6
  "homepage": "https://bitbucket.org/lendi-dev/integrations-shared-packages#readme",
@@ -21,8 +21,8 @@
21
21
  "url": "git+ssh://git@bitbucket.org/lendi-dev/integrations-shared-packages.git"
22
22
  },
23
23
  "dependencies": {
24
- "@lendi/integrations-credit-protocol": "1.14.7",
25
- "@lendi/integrations-protocol": "2.4.9",
24
+ "@lendi/integrations-credit-protocol": "1.14.9",
25
+ "@lendi/integrations-protocol": "2.5.3",
26
26
  "clean-deep": "^3.4.0",
27
27
  "date-fns": "2.19.0",
28
28
  "dd-trace": "^0.28.1",
@@ -89,4 +89,4 @@
89
89
  "semver:major": "npm version major",
90
90
  "current:version": "echo $npm_package_version"
91
91
  }
92
- }
92
+ }
@@ -1,17 +0,0 @@
1
- import { Asset, AssetDefinition as Payload } from '../types/events/public-asset';
2
- export declare const residentialTypeList: string[];
3
- export declare const propertyTypeNameList: string[];
4
- /**
5
- * Generates a partial internal request from a partial public asset event.
6
- *
7
- * @param asset: A partial public asset.
8
- * @param applicationId: Id of application.
9
- * @param id: Id of asset entity.
10
- * @return A partial InternalRequest.
11
- */
12
- export declare function generateAsset({ asset, applicationId, id }: Payload): {};
13
- /**
14
- * Checks if the asset is of financial type.
15
- * @param asset asset payload
16
- */
17
- export declare function isFinancialAsset(asset: Asset): boolean;
@@ -1,178 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.isFinancialAsset = exports.generateAsset = exports.propertyTypeNameList = exports.residentialTypeList = 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 logger_1 = require("../logger");
8
- var public_financial_asset_1 = require("../types/enum-mappings/public-financial-asset");
9
- var public_primary_purpose_1 = require("../types/enum-mappings/public-primary-purpose");
10
- var public_property_status_1 = require("../types/enum-mappings/public-property-status");
11
- var public_property_type_1 = require("../types/enum-mappings/public-property-type");
12
- var public_asset_1 = require("../types/events/public-asset");
13
- var generate_address_1 = require("../utils/generate-address");
14
- var get_financial_institution_1 = require("../utils/get-financial-institution");
15
- var generate_lixi_percentowned_1 = require("./generate-lixi-percentowned");
16
- var toBeUsedAsSecurityMapping = {
17
- "true": lixi_internal_request_1.YesNoList.Yes,
18
- "false": lixi_internal_request_1.YesNoList.No
19
- };
20
- var toBePurchasedMapping = {
21
- "true": lixi_internal_request_1.AssetTransactionList.Purchasing,
22
- "false": lixi_internal_request_1.AssetTransactionList.Owns
23
- };
24
- var assetMapping = {
25
- make: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Make"),
26
- year: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Year"),
27
- model: "".concat(application_paths_1.paths.NonRealEstateAsset, ".MotorVehicle.@Model"),
28
- estimatedValue: "".concat(application_paths_1.paths.NonRealEstateAsset, ".EstimatedValue.@Value"),
29
- zoneType: "".concat(application_paths_1.paths.RealEstateAsset, ".Zoning.@Type"),
30
- toBeUsedAsSecurity: "".concat(application_paths_1.paths.RealEstateAsset, ".@ToBeUsedAsSecurity"),
31
- toBePurchased: "".concat(application_paths_1.paths.RealEstateAsset, ".@Transaction"),
32
- primaryPurpose: "".concat(application_paths_1.paths.RealEstateAsset, ".@PrimaryPurpose"),
33
- propertyStatus: "".concat(application_paths_1.paths.RealEstateAsset, ".@Status"),
34
- financialInstitution: "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.AccountNumber.@FinancialInstitution"),
35
- propertyType: "".concat(application_paths_1.paths.RealEstateAsset, ".Residential.@Type"),
36
- address: application_paths_1.paths.Address
37
- };
38
- exports.residentialTypeList = Object.values(lixi_internal_request_1.ResidentialTypeList);
39
- exports.propertyTypeNameList = Object.values(lixi_internal_request_1.Custom2PropertyTypeNameList);
40
- /**
41
- * Generates a partial internal request from a partial public asset event.
42
- *
43
- * @param asset: A partial public asset.
44
- * @param applicationId: Id of application.
45
- * @param id: Id of asset entity.
46
- * @return A partial InternalRequest.
47
- */
48
- function generateAsset(_a) {
49
- var asset = _a.asset, applicationId = _a.applicationId, id = _a.id;
50
- var partialApplication = {};
51
- (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
52
- var isPropertyAsset = asset.type === public_asset_1.AssetType.Property;
53
- switch (asset.type) {
54
- case public_asset_1.AssetType.Vehicle:
55
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.MotorVehicleAndTransport);
56
- break;
57
- case public_asset_1.AssetType.Property:
58
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@MultipleDwellings"), lixi_internal_request_1.YesNoList.No);
59
- break;
60
- case public_asset_1.AssetType.HomeContents:
61
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
62
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".OtherAsset.@Type"), lixi_internal_request_1.OtherAssetTypeList.HomeContents);
63
- break;
64
- case public_asset_1.AssetType.Gifts:
65
- case public_asset_1.AssetType.OtherAsset:
66
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.Other);
67
- if (asset.description)
68
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".OtherAsset.@Description"), asset.description);
69
- break;
70
- case public_asset_1.AssetType.Shares:
71
- case public_asset_1.AssetType.Superannuation:
72
- case public_asset_1.AssetType.TermDeposit:
73
- case public_asset_1.AssetType.SavingCheckAccount:
74
- case public_asset_1.AssetType.ManagedFunds:
75
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@Type"), lixi_internal_request_1.NonRealEstateAssetTypeList.FinancialAsset);
76
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".FinancialAsset.@Type"), public_financial_asset_1.financialAssetMapping[asset.type]);
77
- break;
78
- default:
79
- logger_1.logger.warn({ message: "Unhandled asset type: ".concat(asset.type), applicationId: applicationId });
80
- return;
81
- }
82
- if (isPropertyAsset) {
83
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@UniqueID"), id);
84
- assetMapping.percentOwned = "".concat(application_paths_1.paths.RealEstateAsset, ".PercentOwned");
85
- }
86
- else {
87
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.NonRealEstateAsset, ".@UniqueID"), id);
88
- assetMapping.percentOwned = "".concat(application_paths_1.paths.NonRealEstateAsset, ".PercentOwned");
89
- }
90
- for (var _i = 0, _b = Object.entries(asset); _i < _b.length; _i++) {
91
- var _c = _b[_i], key = _c[0], value = _c[1];
92
- if (assetMapping[key]) {
93
- switch (key) {
94
- case 'primaryPurpose':
95
- (0, lodash_1.set)(partialApplication, assetMapping[key], public_primary_purpose_1.primaryPurposeMapping[value]);
96
- break;
97
- case 'toBePurchased':
98
- (0, lodash_1.set)(partialApplication, assetMapping[key], toBePurchasedMapping[value]);
99
- break;
100
- case 'propertyStatus':
101
- (0, lodash_1.set)(partialApplication, assetMapping[key], public_property_status_1.propertyStatusMapping[value]);
102
- break;
103
- case 'toBeUsedAsSecurity':
104
- if (isPropertyAsset)
105
- (0, lodash_1.set)(partialApplication, assetMapping[key], toBeUsedAsSecurityMapping[value]);
106
- break;
107
- case 'estimatedValue':
108
- if (isPropertyAsset) {
109
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".EstimatedValue.@Value"), value);
110
- }
111
- else {
112
- (0, lodash_1.set)(partialApplication, assetMapping[key], value);
113
- }
114
- break;
115
- case 'propertyType':
116
- var mappedValue = public_property_type_1.propertyTypeMapping[value];
117
- if (exports.residentialTypeList.includes(mappedValue)) {
118
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".Residential.@Type"), mappedValue);
119
- }
120
- else if (exports.propertyTypeNameList.includes(mappedValue)) {
121
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType.@PropertyTypeName"), mappedValue);
122
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".PropertyType.@CategoryTypeName"), lixi_internal_request_1.Custom1CategoryTypeNameList.Residential);
123
- }
124
- else {
125
- logger_1.logger.warn({ message: "Unknown propertyType ".concat(value, " for asset ").concat(id), applicationId: applicationId });
126
- }
127
- break;
128
- case 'zoneType':
129
- if (asset.zoneType === public_asset_1.ZoneType.Commercial) {
130
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".Commercial.@Type"), lixi_internal_request_1.OtherAssetTypeList.Other);
131
- (0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom3TypeList.Commercial);
132
- }
133
- else {
134
- (0, lodash_1.set)(partialApplication, assetMapping[key], lixi_internal_request_1.Custom3TypeList.Residential);
135
- }
136
- break;
137
- case 'financialInstitution':
138
- if (isFinancialAsset(asset)) {
139
- var financialInstitution = (0, get_financial_institution_1.getFinancialInstitution)(value.toString());
140
- (0, lodash_1.set)(partialApplication, assetMapping[key], financialInstitution);
141
- }
142
- break;
143
- case 'year':
144
- (0, lodash_1.set)(partialApplication, assetMapping[key], value.toString());
145
- break;
146
- case 'address':
147
- var addressId = "".concat(id, "-address");
148
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.RealEstateAsset, ".@x_Address"), addressId);
149
- (0, lodash_1.set)(partialApplication, assetMapping[key], (0, generate_address_1.generateAddress)(value, addressId));
150
- break;
151
- case 'percentOwned':
152
- var percentOwned = (0, generate_lixi_percentowned_1.generateLIXIPercentOwned)(value);
153
- if (percentOwned) {
154
- (0, lodash_1.set)(partialApplication, assetMapping[key], percentOwned);
155
- }
156
- break;
157
- default:
158
- (0, lodash_1.set)(partialApplication, assetMapping[key], value);
159
- }
160
- }
161
- }
162
- return partialApplication;
163
- }
164
- exports.generateAsset = generateAsset;
165
- /**
166
- * Checks if the asset is of financial type.
167
- * @param asset asset payload
168
- */
169
- function isFinancialAsset(asset) {
170
- return [
171
- public_asset_1.AssetType.Shares,
172
- public_asset_1.AssetType.Superannuation,
173
- public_asset_1.AssetType.TermDeposit,
174
- public_asset_1.AssetType.SavingCheckAccount,
175
- public_asset_1.AssetType.ManagedFunds,
176
- ].includes(asset.type);
177
- }
178
- exports.isFinancialAsset = isFinancialAsset;