@lendi/integrations-transform 1.1.8 → 1.2.2
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.
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -1
- package/lib/schemas/public-asset-event.json +86 -93
- package/lib/transform-events/generate-liability.js +2 -2
- package/lib/transform-events/transform-applicant.js +5 -8
- package/lib/transform-events/transform-application.js +3 -4
- package/lib/transform-events/transform-asset-address.d.ts +19 -0
- package/lib/transform-events/transform-asset-address.js +83 -0
- package/lib/transform-events/transform-asset.d.ts +28 -0
- package/lib/transform-events/transform-asset.js +203 -0
- package/lib/transform-events/transform-expenses.js +3 -4
- package/lib/transform-events/{generate-income.d.ts → transform-income.d.ts} +1 -1
- package/lib/transform-events/{generate-income.js → transform-income.js} +14 -13
- package/lib/transform-events/{generate-lixi-percentowned.d.ts → transform-percent-owned.d.ts} +1 -1
- package/lib/transform-events/{generate-lixi-percentowned.js → transform-percent-owned.js} +5 -4
- package/lib/types/enum-mappings/asset-type.d.ts +3 -0
- package/lib/types/enum-mappings/asset-type.js +18 -0
- package/lib/types/enum-mappings/index.d.ts +26 -0
- package/lib/types/enum-mappings/index.js +38 -0
- package/lib/types/enum-mappings/to-be-purchased.d.ts +5 -0
- package/lib/types/enum-mappings/to-be-purchased.js +8 -0
- package/lib/types/enum-mappings/to-be-used-as-security.d.ts +5 -0
- package/lib/types/enum-mappings/to-be-used-as-security.js +8 -0
- package/lib/types/events/public-asset.d.ts +16 -17
- package/lib/types/events/public-asset.js +3 -0
- package/lib/update-application/merge-application.d.ts +8 -0
- package/lib/update-application/merge-application.js +132 -0
- package/lib/utils/address-tools.d.ts +14 -1
- package/lib/utils/address-tools.js +35 -3
- package/lib/utils/generate-address.d.ts +3 -4
- package/lib/utils/generate-address.js +8 -9
- package/lib/utils/is-asset-type.d.ts +25 -0
- package/lib/utils/is-asset-type.js +46 -0
- package/package.json +3 -3
- package/lib/transform-events/generate-asset.d.ts +0 -17
- package/lib/transform-events/generate-asset.js +0 -178
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './transform-events/transform-applicant';
|
|
2
2
|
export * from './transform-events/transform-application';
|
|
3
|
-
export * from './transform-events/
|
|
3
|
+
export * from './transform-events/transform-income';
|
|
4
|
+
export * from './transform-events/transform-asset';
|
|
4
5
|
export * from './transform-events/transform-expenses';
|
|
5
6
|
export * from './transform-events/generate-liability';
|
|
6
7
|
export * from './transform-events/generate-required-document';
|
|
7
8
|
export * from './transform-events/generate-funding-position';
|
|
9
|
+
export * from './update-application/merge-application';
|
package/lib/index.js
CHANGED
|
@@ -13,8 +13,10 @@ exports.__esModule = true;
|
|
|
13
13
|
/* istanbul ignore file */
|
|
14
14
|
__exportStar(require("./transform-events/transform-applicant"), exports);
|
|
15
15
|
__exportStar(require("./transform-events/transform-application"), exports);
|
|
16
|
-
__exportStar(require("./transform-events/
|
|
16
|
+
__exportStar(require("./transform-events/transform-income"), exports);
|
|
17
|
+
__exportStar(require("./transform-events/transform-asset"), exports);
|
|
17
18
|
__exportStar(require("./transform-events/transform-expenses"), exports);
|
|
18
19
|
__exportStar(require("./transform-events/generate-liability"), exports);
|
|
19
20
|
__exportStar(require("./transform-events/generate-required-document"), exports);
|
|
20
21
|
__exportStar(require("./transform-events/generate-funding-position"), exports);
|
|
22
|
+
__exportStar(require("./update-application/merge-application"), exports);
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"definitions": {
|
|
3
|
+
"payload": {
|
|
4
|
+
"type": "object",
|
|
5
|
+
"$ref": "#/definitions/createAssetDefinition"
|
|
6
|
+
},
|
|
7
|
+
"id": {
|
|
8
|
+
"type": "string"
|
|
9
|
+
},
|
|
3
10
|
"meta": {
|
|
4
11
|
"type": "object",
|
|
5
12
|
"additionalProperties": false,
|
|
@@ -16,22 +23,9 @@
|
|
|
16
23
|
},
|
|
17
24
|
"required": ["actionedBy", "actionedByRole"]
|
|
18
25
|
},
|
|
19
|
-
"Ownership": {
|
|
20
|
-
"type": "object",
|
|
21
|
-
"properties": {
|
|
22
|
-
"applicantId": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"format": "uuid"
|
|
25
|
-
},
|
|
26
|
-
"percent": {
|
|
27
|
-
"type": "number",
|
|
28
|
-
"description": "how much percent for the corresponding applicant",
|
|
29
|
-
"examples": [0.5]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
26
|
"applicantOwnership": {
|
|
34
27
|
"type": "object",
|
|
28
|
+
"required": ["applicantId", "percent"],
|
|
35
29
|
"properties": {
|
|
36
30
|
"applicantId": {
|
|
37
31
|
"type": "string",
|
|
@@ -45,11 +39,11 @@
|
|
|
45
39
|
"description": "how much percent for the corresponding applicant",
|
|
46
40
|
"examples": [0.5]
|
|
47
41
|
}
|
|
48
|
-
}
|
|
49
|
-
"required": ["percent", "applicantId"]
|
|
42
|
+
}
|
|
50
43
|
},
|
|
51
44
|
"percentOwned": {
|
|
52
45
|
"type": "object",
|
|
46
|
+
"required": ["owners"],
|
|
53
47
|
"properties": {
|
|
54
48
|
"proportions": {
|
|
55
49
|
"enum": ["EQUAL", "SPECIFIED", "NOT_SPECIFIED"],
|
|
@@ -93,6 +87,33 @@
|
|
|
93
87
|
"type": "string",
|
|
94
88
|
"description": "Description of the entity."
|
|
95
89
|
},
|
|
90
|
+
"address": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"properties": {
|
|
93
|
+
"postcode": {
|
|
94
|
+
"description": "A 4 digit postcode",
|
|
95
|
+
"type": "string"
|
|
96
|
+
},
|
|
97
|
+
"state": {
|
|
98
|
+
"description": "One our great nation's states",
|
|
99
|
+
"type": "string"
|
|
100
|
+
},
|
|
101
|
+
"city": {
|
|
102
|
+
"description": "The suburb name",
|
|
103
|
+
"type": "string"
|
|
104
|
+
},
|
|
105
|
+
"country": {
|
|
106
|
+
"$ref": "#/definitions/countries"
|
|
107
|
+
},
|
|
108
|
+
"formatted": {
|
|
109
|
+
"description": "A formatted version of the address",
|
|
110
|
+
"type": "string"
|
|
111
|
+
},
|
|
112
|
+
"standard": {
|
|
113
|
+
"$ref": "#/definitions/addressStandard"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
96
117
|
"countries": {
|
|
97
118
|
"type": "string",
|
|
98
119
|
"example": "Australia",
|
|
@@ -338,84 +359,36 @@
|
|
|
338
359
|
"Zimbabwe"
|
|
339
360
|
]
|
|
340
361
|
},
|
|
341
|
-
"address": {
|
|
342
|
-
"type": "object",
|
|
343
|
-
"additionalProperties": false,
|
|
344
|
-
"properties": {
|
|
345
|
-
"city": {
|
|
346
|
-
"description": "The city / suburb name",
|
|
347
|
-
"type": "string",
|
|
348
|
-
"example": "Sydney"
|
|
349
|
-
},
|
|
350
|
-
"country": {
|
|
351
|
-
"$ref": "#/definitions/countries"
|
|
352
|
-
},
|
|
353
|
-
"formatted": {
|
|
354
|
-
"description": "A formatted version of the address",
|
|
355
|
-
"type": "string",
|
|
356
|
-
"example": "L 9, 50 Pitt St, Sydney, NSW 2000, Australia"
|
|
357
|
-
},
|
|
358
|
-
"postcode": {
|
|
359
|
-
"description": "N digit postcode (for AU addresses, usually 4)",
|
|
360
|
-
"type": "string",
|
|
361
|
-
"example": "2000"
|
|
362
|
-
},
|
|
363
|
-
"standard": {
|
|
364
|
-
"$ref": "#/definitions/addressStandard"
|
|
365
|
-
},
|
|
366
|
-
"state": {
|
|
367
|
-
"description": "The state name",
|
|
368
|
-
"type": "string"
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
362
|
"addressStandard": {
|
|
373
363
|
"type": "object",
|
|
374
364
|
"properties": {
|
|
375
365
|
"buildingName": {
|
|
376
366
|
"description": "The building name",
|
|
377
|
-
"type": "string"
|
|
378
|
-
"example": "Opera House"
|
|
379
|
-
},
|
|
380
|
-
"deliveryAddress": {
|
|
381
|
-
"description": "Postal address, usually a PO Box or Locked Bag",
|
|
382
|
-
"type": "string",
|
|
383
|
-
"example": "PO Box 1"
|
|
367
|
+
"type": "string"
|
|
384
368
|
},
|
|
385
369
|
"level": {
|
|
386
370
|
"description": "The level of the unit/apartment",
|
|
387
|
-
"type": "string"
|
|
388
|
-
"example": "L 9"
|
|
371
|
+
"type": "string"
|
|
389
372
|
},
|
|
390
373
|
"lotSection": {
|
|
391
374
|
"description": "The lot number",
|
|
392
|
-
"type": "string"
|
|
393
|
-
"example": "Lot 1"
|
|
375
|
+
"type": "string"
|
|
394
376
|
},
|
|
395
377
|
"streetName": {
|
|
396
378
|
"description": "The street name",
|
|
397
|
-
"type": "string"
|
|
398
|
-
"example": "Pitt"
|
|
379
|
+
"type": "string"
|
|
399
380
|
},
|
|
400
381
|
"streetNumber": {
|
|
401
382
|
"description": "The street number",
|
|
402
|
-
"type": "string"
|
|
403
|
-
"example": "50"
|
|
404
|
-
},
|
|
405
|
-
"streetSuffix": {
|
|
406
|
-
"description": "The street suffix",
|
|
407
|
-
"type": "string",
|
|
408
|
-
"example": "North"
|
|
383
|
+
"type": "string"
|
|
409
384
|
},
|
|
410
385
|
"streetType": {
|
|
411
386
|
"description": "The type of the street i.e. road",
|
|
412
|
-
"type": "string"
|
|
413
|
-
"example": "St"
|
|
387
|
+
"type": "string"
|
|
414
388
|
},
|
|
415
389
|
"unit": {
|
|
416
390
|
"description": "The unit number",
|
|
417
|
-
"type": "string"
|
|
418
|
-
"example": "U 1"
|
|
391
|
+
"type": "string"
|
|
419
392
|
}
|
|
420
393
|
}
|
|
421
394
|
},
|
|
@@ -494,6 +467,25 @@
|
|
|
494
467
|
"financialInstitutionShortName": {
|
|
495
468
|
"type": "string"
|
|
496
469
|
},
|
|
470
|
+
"FinancialInstitutionBsb": {
|
|
471
|
+
"type": "string",
|
|
472
|
+
"pattern": "^\\d{6}$",
|
|
473
|
+
"description": "The BSB number identifying where the account is held within the Financial Institution",
|
|
474
|
+
"example": "123456"
|
|
475
|
+
},
|
|
476
|
+
"FinancialInstitutionAccountNumber": {
|
|
477
|
+
"type": "string",
|
|
478
|
+
"pattern": "^\\d{0,10}$",
|
|
479
|
+
"description": "The unique number assigned to the Financial Institution account",
|
|
480
|
+
"example": "999994"
|
|
481
|
+
},
|
|
482
|
+
"dataType": {
|
|
483
|
+
"type": "string"
|
|
484
|
+
},
|
|
485
|
+
"relationId": {
|
|
486
|
+
"$ref": "#/definitions/id",
|
|
487
|
+
"description": "uuid of relation"
|
|
488
|
+
},
|
|
497
489
|
"assetType": {
|
|
498
490
|
"enum": [
|
|
499
491
|
"GIFTS",
|
|
@@ -520,6 +512,9 @@
|
|
|
520
512
|
"description": {
|
|
521
513
|
"type": "string"
|
|
522
514
|
},
|
|
515
|
+
"dataType": {
|
|
516
|
+
"$ref": "#/definitions/dataType"
|
|
517
|
+
},
|
|
523
518
|
"type": {
|
|
524
519
|
"$ref": "#/definitions/assetType"
|
|
525
520
|
},
|
|
@@ -532,6 +527,12 @@
|
|
|
532
527
|
"financialInstitutionShortName": {
|
|
533
528
|
"$ref": "#/definitions/financialInstitutionShortName"
|
|
534
529
|
},
|
|
530
|
+
"financialInstitutionBsb": {
|
|
531
|
+
"$ref": "#/definitions/FinancialInstitutionBsb"
|
|
532
|
+
},
|
|
533
|
+
"financialInstitutionAccountNumber": {
|
|
534
|
+
"$ref": "#/definitions/FinancialInstitutionAccountNumber"
|
|
535
|
+
},
|
|
535
536
|
"toBeSold": {
|
|
536
537
|
"$ref": "#/definitions/toBeSold"
|
|
537
538
|
},
|
|
@@ -562,6 +563,9 @@
|
|
|
562
563
|
"propertyType": {
|
|
563
564
|
"$ref": "#/definitions/propertyType"
|
|
564
565
|
},
|
|
566
|
+
"relationId": {
|
|
567
|
+
"$ref": "#/definitions/relationId"
|
|
568
|
+
},
|
|
565
569
|
"contractDetails": {
|
|
566
570
|
"$ref": "#/definitions/contractDetails"
|
|
567
571
|
},
|
|
@@ -578,21 +582,14 @@
|
|
|
578
582
|
"$ref": "#/definitions/year"
|
|
579
583
|
}
|
|
580
584
|
},
|
|
585
|
+
"additionalProperties": true,
|
|
581
586
|
"required": ["type"]
|
|
582
587
|
},
|
|
583
|
-
"
|
|
584
|
-
"type": "string",
|
|
585
|
-
"enum": ["QLD", "NSW", "VIC", "WA", "SA", "TAS", "ACT", "NT"]
|
|
586
|
-
},
|
|
587
|
-
"otherState": {
|
|
588
|
-
"type": "string",
|
|
589
|
-
"example": "Ohio"
|
|
590
|
-
},
|
|
591
|
-
"AssetDefinition": {
|
|
588
|
+
"createAssetDefinition": {
|
|
592
589
|
"type": "object",
|
|
593
590
|
"properties": {
|
|
594
591
|
"id": {
|
|
595
|
-
"
|
|
592
|
+
"$ref": "#/definitions/id",
|
|
596
593
|
"description": "uuid of asset"
|
|
597
594
|
},
|
|
598
595
|
"meta": {
|
|
@@ -606,27 +603,23 @@
|
|
|
606
603
|
}
|
|
607
604
|
},
|
|
608
605
|
"required": ["id", "applicationId", "asset"],
|
|
609
|
-
"description": "create
|
|
610
|
-
},
|
|
611
|
-
"Amount": {
|
|
612
|
-
"type": "number",
|
|
613
|
-
"example": 100000
|
|
606
|
+
"description": "create Asset payload"
|
|
614
607
|
}
|
|
615
608
|
},
|
|
616
609
|
"type": "object",
|
|
617
|
-
"title": "The
|
|
618
|
-
"description": "Create
|
|
610
|
+
"title": "The asset event schema",
|
|
611
|
+
"description": "Create or update",
|
|
619
612
|
"properties": {
|
|
620
|
-
"
|
|
613
|
+
"type": {
|
|
621
614
|
"type": "string",
|
|
615
|
+
"enum": ["AssetUpdated", "AssetCreated"],
|
|
622
616
|
"description": "schema version"
|
|
623
617
|
},
|
|
624
|
-
"
|
|
625
|
-
"type": "string"
|
|
626
|
-
"enum": ["AssetCreated", "AssetUpdated"]
|
|
618
|
+
"version": {
|
|
619
|
+
"type": "string"
|
|
627
620
|
},
|
|
628
621
|
"payload": {
|
|
629
|
-
"$ref": "#/definitions/
|
|
622
|
+
"$ref": "#/definitions/payload"
|
|
630
623
|
}
|
|
631
624
|
},
|
|
632
625
|
"required": ["version", "payload", "type"]
|
|
@@ -8,7 +8,7 @@ var liability_payment_type_1 = require("../types/enum-mappings/liability-payment
|
|
|
8
8
|
var liability_type_1 = require("../types/enum-mappings/liability-type");
|
|
9
9
|
var get_financial_institution_1 = require("../utils/get-financial-institution");
|
|
10
10
|
var round_decimal_1 = require("../utils/round-decimal");
|
|
11
|
-
var
|
|
11
|
+
var transform_percent_owned_1 = require("./transform-percent-owned");
|
|
12
12
|
var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/lixi-internal-request");
|
|
13
13
|
/**
|
|
14
14
|
* Generates a partial internal request from a liability event payload.
|
|
@@ -71,7 +71,7 @@ function generateLiability(_a) {
|
|
|
71
71
|
(0, lodash_1.set)(partialApplication, liabilityMapping[key], financialInstitution);
|
|
72
72
|
break;
|
|
73
73
|
case 'percentOwned':
|
|
74
|
-
var percentOwned = (0,
|
|
74
|
+
var percentOwned = (0, transform_percent_owned_1.transformPercentOwned)(value);
|
|
75
75
|
if (percentOwned) {
|
|
76
76
|
(0, lodash_1.set)(partialApplication, liabilityMapping[key], percentOwned);
|
|
77
77
|
}
|
|
@@ -5,10 +5,7 @@ var lixi_internal_request_1 = require("@lendi/integrations-protocol/lib/types/li
|
|
|
5
5
|
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
6
|
var lodash_1 = require("lodash");
|
|
7
7
|
var address_tools_1 = require("../utils/address-tools");
|
|
8
|
-
var
|
|
9
|
-
var marital_status_1 = require("../types/enum-mappings/marital-status");
|
|
10
|
-
var residency_status_1 = require("../types/enum-mappings/residency-status");
|
|
11
|
-
var title_1 = require("../types/enum-mappings/title");
|
|
8
|
+
var enum_mappings_1 = require("../types/enum-mappings");
|
|
12
9
|
var public_applicant_1 = require("../types/events/public-applicant");
|
|
13
10
|
var normalise_date_1 = require("../utils/normalise-date");
|
|
14
11
|
var booleanMapping = function (input) {
|
|
@@ -44,7 +41,7 @@ function transformApplicant(applicant) {
|
|
|
44
41
|
var applicantId = applicant.id, applicationId = applicant.applicationId;
|
|
45
42
|
(0, lodash_1.set)(partialApplication, applicantMapping['isFirstHomeBuyer'], (0, exports.booleanMapping)(applicant.isFirstHomeBuyer));
|
|
46
43
|
(0, lodash_1.set)(partialApplication, applicantMapping['isPrimaryApplicant'], (0, exports.booleanMapping)(applicant.isPrimaryApplicant));
|
|
47
|
-
(0, lodash_1.set)(partialApplication, applicantMapping['title'],
|
|
44
|
+
(0, lodash_1.set)(partialApplication, applicantMapping['title'], enum_mappings_1.titleMapping[applicant.title || public_applicant_1.Title.Unknown]);
|
|
48
45
|
var applicantUpdated = (0, lodash_1.omit)(applicant, ['isFirstHomeBuyer', 'isPrimaryApplicant', 'title']);
|
|
49
46
|
for (var _i = 0, _a = Object.entries(applicantUpdated); _i < _a.length; _i++) {
|
|
50
47
|
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
@@ -54,13 +51,13 @@ function transformApplicant(applicant) {
|
|
|
54
51
|
(0, lodash_1.set)(partialApplication, applicantMapping[key], (0, normalise_date_1.normaliseDate)(value));
|
|
55
52
|
break;
|
|
56
53
|
case 'maritalStatus':
|
|
57
|
-
(0, lodash_1.set)(partialApplication, applicantMapping[key],
|
|
54
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], enum_mappings_1.maritalStatusMapping[value]);
|
|
58
55
|
break;
|
|
59
56
|
case 'citizenship':
|
|
60
|
-
(0, lodash_1.set)(partialApplication, applicantMapping[key],
|
|
57
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], enum_mappings_1.countryCodeMapping[value]);
|
|
61
58
|
break;
|
|
62
59
|
case 'residencyStatus':
|
|
63
|
-
(0, lodash_1.set)(partialApplication, applicantMapping[key],
|
|
60
|
+
(0, lodash_1.set)(partialApplication, applicantMapping[key], enum_mappings_1.residencyStatusMapping[value]);
|
|
64
61
|
// Certain bank integrations require the ability to differentiate between permanentResident and Citizen
|
|
65
62
|
// As lixi does not have a citizen enum for residencyStatus citizen is mapped to permanentResident
|
|
66
63
|
// Adding a @Citizenship attribute to person applicant gives us the ability to determine citizenship status
|
|
@@ -5,8 +5,7 @@ var lixi_internal_request_1 = require("@lendi/integrations-credit-protocol/types
|
|
|
5
5
|
var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
|
|
6
6
|
var application_paths_2 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
7
7
|
var lodash_1 = require("lodash");
|
|
8
|
-
var
|
|
9
|
-
var transaction_type_1 = require("../types/enum-mappings/transaction-type");
|
|
8
|
+
var enum_mappings_1 = require("../types/enum-mappings/");
|
|
10
9
|
/**
|
|
11
10
|
* Transforms a partial opportunity event to a partial internal request.
|
|
12
11
|
*
|
|
@@ -35,10 +34,10 @@ function transformApplication(opportunity) {
|
|
|
35
34
|
if (opportunityMapping[key]) {
|
|
36
35
|
switch (key) {
|
|
37
36
|
case 'paymentType':
|
|
38
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[key],
|
|
37
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[key], enum_mappings_1.preferredRepaymentMapping[value]);
|
|
39
38
|
break;
|
|
40
39
|
case 'primaryPurpose':
|
|
41
|
-
(0, lodash_1.set)(partialApplication, opportunityMapping[key],
|
|
40
|
+
(0, lodash_1.set)(partialApplication, opportunityMapping[key], enum_mappings_1.transactionTypeMapping[value]);
|
|
42
41
|
break;
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AddressType, Standard } from "@lendi/integrations-protocol/lib/types/lixi-internal-request";
|
|
2
|
+
import { Address, AddressStandard } from "../types/events/public-asset";
|
|
3
|
+
export declare function getAddressMapping(address: Address): Record<string, string>;
|
|
4
|
+
export declare const standardMapping: Record<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
* Generates an address for an asset.
|
|
7
|
+
*
|
|
8
|
+
* @param address: An address object.
|
|
9
|
+
* @param id: address event id.
|
|
10
|
+
* @param toBeUsedAsSecurity
|
|
11
|
+
* @return A transformed address object.
|
|
12
|
+
*/
|
|
13
|
+
export declare function transformAddress(address: Address, id: string): Partial<AddressType>;
|
|
14
|
+
/**
|
|
15
|
+
* @description Generates an address standard.
|
|
16
|
+
* @param {AddressStandard} addressStandard An address standard object.
|
|
17
|
+
* @return {Partial<Standard>} A transformed standard object.
|
|
18
|
+
*/
|
|
19
|
+
export declare function transformStandard(addressStandard: AddressStandard): Partial<Standard>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
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");
|
|
8
|
+
function getAddressMapping(address) {
|
|
9
|
+
return {
|
|
10
|
+
city: '@Suburb',
|
|
11
|
+
country: '@Country',
|
|
12
|
+
postcode: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasPostCode' : '@AustralianPostCode',
|
|
13
|
+
state: (0, address_tools_1.isOverseasAddress)(address) ? '@OverseasState' : '@AustralianState',
|
|
14
|
+
standard: 'Standard',
|
|
15
|
+
formatted: '@Country'
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.getAddressMapping = getAddressMapping;
|
|
19
|
+
exports.standardMapping = {
|
|
20
|
+
streetName: '@StreetName',
|
|
21
|
+
streetType: '@StreetType',
|
|
22
|
+
streetNumber: '@StreetNumber',
|
|
23
|
+
level: '@Level',
|
|
24
|
+
unit: '@Unit'
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Generates an address for an asset.
|
|
28
|
+
*
|
|
29
|
+
* @param address: An address object.
|
|
30
|
+
* @param id: address event id.
|
|
31
|
+
* @param toBeUsedAsSecurity
|
|
32
|
+
* @return A transformed address object.
|
|
33
|
+
*/
|
|
34
|
+
function transformAddress(address, id) {
|
|
35
|
+
var transformedAddress = {
|
|
36
|
+
'@UniqueID': id
|
|
37
|
+
};
|
|
38
|
+
var addressMapping = getAddressMapping(address);
|
|
39
|
+
// for an Australian address: if no postcode is provided, infer one from the state:
|
|
40
|
+
if (!(0, address_tools_1.isOverseasAddress)(address) && address.state && !address.postcode) {
|
|
41
|
+
address.postcode = enum_mappings_1.postcodeMapping[address.state];
|
|
42
|
+
}
|
|
43
|
+
for (var _i = 0, _a = Object.entries(address); _i < _a.length; _i++) {
|
|
44
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
45
|
+
if (addressMapping[key]) {
|
|
46
|
+
switch (key) {
|
|
47
|
+
case 'standard':
|
|
48
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], transformStandard(value));
|
|
49
|
+
break;
|
|
50
|
+
case 'country':
|
|
51
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], (0, address_tools_1.isOverseasAddress)(address) ? enum_mappings_1.countryCodeMapping[value] : lixi_internal_request_1.CountryCodeList.Au);
|
|
52
|
+
break;
|
|
53
|
+
case 'formatted':
|
|
54
|
+
if (!address.country) {
|
|
55
|
+
var country = (0, address_tools_1.extractCountryFromFormatted)(value);
|
|
56
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], enum_mappings_1.countryCodeMapping[country]);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
(0, lodash_1.set)(transformedAddress, addressMapping[key], value);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return transformedAddress;
|
|
66
|
+
}
|
|
67
|
+
exports.transformAddress = transformAddress;
|
|
68
|
+
/**
|
|
69
|
+
* @description Generates an address standard.
|
|
70
|
+
* @param {AddressStandard} addressStandard An address standard object.
|
|
71
|
+
* @return {Partial<Standard>} A transformed standard object.
|
|
72
|
+
*/
|
|
73
|
+
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];
|
|
77
|
+
if (exports.standardMapping[key]) {
|
|
78
|
+
(0, lodash_1.set)(transformedStandard, exports.standardMapping[key], value);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return transformedStandard;
|
|
82
|
+
}
|
|
83
|
+
exports.transformStandard = transformStandard;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PropertyType as LixiPropertyType, Residential } from '@lendi/integrations-protocol/lib/types/lixi-internal-request';
|
|
2
|
+
import { Asset, Payload, PropertyType } from '../types/events/public-asset';
|
|
3
|
+
import { PartialApplication } from '../types/partial-application';
|
|
4
|
+
export interface PropertyTypeMapping {
|
|
5
|
+
path: string;
|
|
6
|
+
value: Residential | LixiPropertyType;
|
|
7
|
+
}
|
|
8
|
+
export declare const propertyTypeNameList: string[];
|
|
9
|
+
export declare const residentialTypeList: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Generates a partial internal request from a partial public asset event.
|
|
12
|
+
*
|
|
13
|
+
* @param {Payload} asset - A partial public asset.
|
|
14
|
+
* @return {PartialApplication} A partial InternalRequest.
|
|
15
|
+
*/
|
|
16
|
+
export declare function transformAsset({ asset, applicationId, id }: Payload): PartialApplication;
|
|
17
|
+
/**
|
|
18
|
+
* @description Map the propertyType to a RealEstateAsset path and the value.
|
|
19
|
+
* @param {PropertyType} propertyType - A propertyType.
|
|
20
|
+
* @returns {PropertyTypeMapping | null} A path and value to be used for property type mapping.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getPropertyType(propertyType: PropertyType): PropertyTypeMapping | null;
|
|
23
|
+
/**
|
|
24
|
+
* @description Get the asset transform mapping for various asset types.
|
|
25
|
+
* @param {Asset} asset An Asset
|
|
26
|
+
* @returns {Record<string, string>} Asset Transform Mapping.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getAssetMapping(asset: Asset): Record<string, string>;
|