@lendi/integrations-transform 1.6.6 → 1.6.7-beta.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.
- package/lib/schemas/public-applicant-event.json +416 -70
- package/lib/schemas/public-application-event.json +1 -1
- package/lib/transform-events/transform-applicant.d.ts +2 -32
- package/lib/transform-events/transform-applicant.js +84 -132
- package/lib/transform-events/transform-application.d.ts +6 -0
- package/lib/transform-events/transform-application.js +6 -0
- package/lib/types/enum-mappings/applicant-gender.d.ts +6 -0
- package/lib/types/enum-mappings/applicant-gender.js +11 -0
- package/lib/types/enum-mappings/applicant-type.d.ts +6 -0
- package/lib/types/enum-mappings/applicant-type.js +10 -0
- package/lib/types/events/public-applicant.d.ts +144 -5
- package/lib/types/events/public-applicant.js +60 -2
- package/lib/types/events/public-application.d.ts +1 -0
- package/lib/types/events/public-application.js +1 -0
- package/lib/update-application/remove-ids-not-required.d.ts +1 -11
- package/lib/update-application/remove-ids-not-required.js +18 -9
- package/lib/utils/errors.d.ts +28 -0
- package/lib/utils/errors.js +43 -0
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.Type = exports.YearsOfTrading = exports.TrustType = exports.Title = exports.ResidencyStatus = exports.AustralianStates = exports.ActionedByRole = exports.MaritalStatus = exports.YesNoIntend = exports.InvitationStatus = exports.GuarantorRelationshipToBorrowerType = exports.Gender = exports.Entity = exports.EmploymentType = exports.CreditStatus = exports.HousingStatusList = exports.CompanyType = exports.CompanyStructure = exports.Countries = exports.ApplicantType = void 0;
|
|
4
4
|
var ApplicantType;
|
|
5
5
|
(function (ApplicantType) {
|
|
6
6
|
ApplicantType["Borrower"] = "BORROWER";
|
|
@@ -249,6 +249,20 @@ var Countries;
|
|
|
249
249
|
Countries["Zambia"] = "Zambia";
|
|
250
250
|
Countries["Zimbabwe"] = "Zimbabwe";
|
|
251
251
|
})(Countries = exports.Countries || (exports.Countries = {}));
|
|
252
|
+
var CompanyStructure;
|
|
253
|
+
(function (CompanyStructure) {
|
|
254
|
+
CompanyStructure["Corporation"] = "CORPORATION";
|
|
255
|
+
CompanyStructure["Partnership"] = "PARTNERSHIP";
|
|
256
|
+
CompanyStructure["SoleTrader"] = "SOLE_TRADER";
|
|
257
|
+
CompanyStructure["Trust"] = "TRUST";
|
|
258
|
+
})(CompanyStructure = exports.CompanyStructure || (exports.CompanyStructure = {}));
|
|
259
|
+
var CompanyType;
|
|
260
|
+
(function (CompanyType) {
|
|
261
|
+
CompanyType["Incorporated"] = "INCORPORATED";
|
|
262
|
+
CompanyType["Ltd"] = "LTD";
|
|
263
|
+
CompanyType["Nl"] = "NL";
|
|
264
|
+
CompanyType["PtyLtd"] = "PTY_LTD";
|
|
265
|
+
})(CompanyType = exports.CompanyType || (exports.CompanyType = {}));
|
|
252
266
|
var HousingStatusList;
|
|
253
267
|
(function (HousingStatusList) {
|
|
254
268
|
HousingStatusList["Boarding"] = "Boarding";
|
|
@@ -271,7 +285,8 @@ var CreditStatus;
|
|
|
271
285
|
CreditStatus["Unknown"] = "UNKNOWN";
|
|
272
286
|
})(CreditStatus = exports.CreditStatus || (exports.CreditStatus = {}));
|
|
273
287
|
/**
|
|
274
|
-
* applicant's employment type
|
|
288
|
+
* LEGACY. DO NOT USE. Historic events only - applicant's employment type. Use the
|
|
289
|
+
* employment events instead!
|
|
275
290
|
*/
|
|
276
291
|
var EmploymentType;
|
|
277
292
|
(function (EmploymentType) {
|
|
@@ -280,12 +295,17 @@ var EmploymentType;
|
|
|
280
295
|
EmploymentType["Unknown"] = "UNKNOWN";
|
|
281
296
|
})(EmploymentType = exports.EmploymentType || (exports.EmploymentType = {}));
|
|
282
297
|
/**
|
|
298
|
+
* applicant's entity. For a trust applicant this is 'TRUST'
|
|
299
|
+
*
|
|
300
|
+
* applicant's entity. For a company applicant this is 'COMPANY'
|
|
301
|
+
*
|
|
283
302
|
* applicant's entity. For a person applicant this is 'PERSON'
|
|
284
303
|
*/
|
|
285
304
|
var Entity;
|
|
286
305
|
(function (Entity) {
|
|
287
306
|
Entity["Company"] = "COMPANY";
|
|
288
307
|
Entity["Person"] = "PERSON";
|
|
308
|
+
Entity["Trust"] = "TRUST";
|
|
289
309
|
})(Entity = exports.Entity || (exports.Entity = {}));
|
|
290
310
|
var Gender;
|
|
291
311
|
(function (Gender) {
|
|
@@ -319,6 +339,12 @@ var InvitationStatus;
|
|
|
319
339
|
InvitationStatus["Expired"] = "EXPIRED";
|
|
320
340
|
InvitationStatus["Pending"] = "PENDING";
|
|
321
341
|
})(InvitationStatus = exports.InvitationStatus || (exports.InvitationStatus = {}));
|
|
342
|
+
var YesNoIntend;
|
|
343
|
+
(function (YesNoIntend) {
|
|
344
|
+
YesNoIntend["Intend"] = "Intend";
|
|
345
|
+
YesNoIntend["No"] = "No";
|
|
346
|
+
YesNoIntend["Yes"] = "Yes";
|
|
347
|
+
})(YesNoIntend = exports.YesNoIntend || (exports.YesNoIntend = {}));
|
|
322
348
|
var MaritalStatus;
|
|
323
349
|
(function (MaritalStatus) {
|
|
324
350
|
MaritalStatus["DeFacto"] = "DE_FACTO";
|
|
@@ -335,6 +361,17 @@ var ActionedByRole;
|
|
|
335
361
|
ActionedByRole["Customer"] = "customer";
|
|
336
362
|
ActionedByRole["Team"] = "team";
|
|
337
363
|
})(ActionedByRole = exports.ActionedByRole || (exports.ActionedByRole = {}));
|
|
364
|
+
var AustralianStates;
|
|
365
|
+
(function (AustralianStates) {
|
|
366
|
+
AustralianStates["Act"] = "ACT";
|
|
367
|
+
AustralianStates["NT"] = "NT";
|
|
368
|
+
AustralianStates["Nsw"] = "NSW";
|
|
369
|
+
AustralianStates["Qld"] = "QLD";
|
|
370
|
+
AustralianStates["Sa"] = "SA";
|
|
371
|
+
AustralianStates["Tas"] = "TAS";
|
|
372
|
+
AustralianStates["Vic"] = "VIC";
|
|
373
|
+
AustralianStates["Wa"] = "WA";
|
|
374
|
+
})(AustralianStates = exports.AustralianStates || (exports.AustralianStates = {}));
|
|
338
375
|
var ResidencyStatus;
|
|
339
376
|
(function (ResidencyStatus) {
|
|
340
377
|
ResidencyStatus["AustralianCitizen"] = "AUSTRALIAN_CITIZEN";
|
|
@@ -351,8 +388,29 @@ var Title;
|
|
|
351
388
|
Title["Mrs"] = "MRS";
|
|
352
389
|
Title["Unknown"] = "UNKNOWN";
|
|
353
390
|
})(Title = exports.Title || (exports.Title = {}));
|
|
391
|
+
var TrustType;
|
|
392
|
+
(function (TrustType) {
|
|
393
|
+
TrustType["CashManagementTrust"] = "CASH_MANAGEMENT_TRUST";
|
|
394
|
+
TrustType["DiscretionaryTrust"] = "DISCRETIONARY_TRUST";
|
|
395
|
+
TrustType["Fixed"] = "FIXED";
|
|
396
|
+
TrustType["Hybrid"] = "HYBRID";
|
|
397
|
+
TrustType["Other"] = "OTHER";
|
|
398
|
+
TrustType["SuperannuationTrusts"] = "SUPERANNUATION_TRUSTS";
|
|
399
|
+
TrustType["Unit"] = "UNIT";
|
|
400
|
+
})(TrustType = exports.TrustType || (exports.TrustType = {}));
|
|
401
|
+
var YearsOfTrading;
|
|
402
|
+
(function (YearsOfTrading) {
|
|
403
|
+
YearsOfTrading["The1"] = "1";
|
|
404
|
+
YearsOfTrading["The10"] = ">10";
|
|
405
|
+
YearsOfTrading["The2"] = "2";
|
|
406
|
+
YearsOfTrading["The3"] = "3";
|
|
407
|
+
YearsOfTrading["The4"] = "4";
|
|
408
|
+
YearsOfTrading["The5"] = "5";
|
|
409
|
+
YearsOfTrading["The510"] = "5-10";
|
|
410
|
+
})(YearsOfTrading = exports.YearsOfTrading || (exports.YearsOfTrading = {}));
|
|
354
411
|
var Type;
|
|
355
412
|
(function (Type) {
|
|
356
413
|
Type["CreateApplicant"] = "CreateApplicant";
|
|
414
|
+
Type["DeleteApplicant"] = "DeleteApplicant";
|
|
357
415
|
Type["UpdateApplicant"] = "UpdateApplicant";
|
|
358
416
|
})(Type = exports.Type || (exports.Type = {}));
|
|
@@ -3,6 +3,7 @@ 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) {
|
|
6
|
+
Brand["Aussie"] = "aussie";
|
|
6
7
|
Brand["Domain"] = "domain";
|
|
7
8
|
Brand["DomainVariation"] = "domain variation";
|
|
8
9
|
Brand["Lendi"] = "lendi";
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import { InternalRequest
|
|
1
|
+
import { InternalRequest } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
|
|
2
2
|
import { Payload as RequiredDocEventPayload } from '../types/events/public-required-document';
|
|
3
3
|
import { RecursivePartial } from '../types/recursive-partial';
|
|
4
|
-
/**
|
|
5
|
-
* Remove proof of identity document from a person applicant
|
|
6
|
-
*
|
|
7
|
-
* @param {PersonApplicant} personApplicant Person applicant to remove the id document from
|
|
8
|
-
* @param {string} id Proof of identity document
|
|
9
|
-
*
|
|
10
|
-
* @returns {PersonApplicant} Updated person applicant
|
|
11
|
-
*/
|
|
12
|
-
export declare const removeIDDocumentFromApplicant: (personApplicant: PersonApplicant, id: string) => PersonApplicant;
|
|
13
4
|
/**
|
|
14
5
|
* Removes ProofOfIdentity ID document that is in status Not Required
|
|
15
6
|
*
|
|
16
7
|
* @param {RecursivePartial<InternalRequest>} application - Partial LIXI CAL application
|
|
17
8
|
* @param {RequiredDocEventPayload} eventPayload - Required Document event payload
|
|
18
|
-
*
|
|
19
9
|
* @returns {RecursivePartial<InternalRequest>} Updated application
|
|
20
10
|
*/
|
|
21
11
|
export declare const removeIdsNotRequired: (application: RecursivePartial<InternalRequest>, eventPayload: RequiredDocEventPayload) => RecursivePartial<InternalRequest>;
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.removeIdsNotRequired =
|
|
14
|
+
exports.removeIdsNotRequired = void 0;
|
|
15
15
|
const application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
|
|
16
16
|
const lodash_1 = require("lodash");
|
|
17
17
|
const public_required_document_1 = require("../types/events/public-required-document");
|
|
@@ -20,32 +20,41 @@ const public_required_document_1 = require("../types/events/public-required-docu
|
|
|
20
20
|
*
|
|
21
21
|
* @param {PersonApplicant} personApplicant Person applicant to remove the id document from
|
|
22
22
|
* @param {string} id Proof of identity document
|
|
23
|
-
*
|
|
23
|
+
* @param {identification} identification Identification data in RequiredDocument event
|
|
24
24
|
* @returns {PersonApplicant} Updated person applicant
|
|
25
25
|
*/
|
|
26
|
-
const removeIDDocumentFromApplicant = (personApplicant, id) => {
|
|
26
|
+
const removeIDDocumentFromApplicant = (personApplicant, id, identification) => {
|
|
27
27
|
const { ProofOfIdentity = [] } = personApplicant, rest = __rest(personApplicant, ["ProofOfIdentity"]);
|
|
28
|
-
const updatedProofOfIdentity = ProofOfIdentity.filter((proofOfId) =>
|
|
28
|
+
const updatedProofOfIdentity = ProofOfIdentity.filter((proofOfId) => {
|
|
29
|
+
let shouldKeepProofOfId = true;
|
|
30
|
+
if (proofOfId['@UniqueID']) {
|
|
31
|
+
shouldKeepProofOfId = proofOfId['@UniqueID'] !== id;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (identification === null || identification === void 0 ? void 0 : identification.idNumber) {
|
|
35
|
+
shouldKeepProofOfId = proofOfId['@DocumentNumber'] !== identification.idNumber;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return shouldKeepProofOfId;
|
|
39
|
+
});
|
|
29
40
|
// If the updateProofOfIdentity is an empty array then we remove the ProofOfIdentity attribute from the person applicant
|
|
30
41
|
return Object.assign(Object.assign({}, rest), (updatedProofOfIdentity.length && { ProofOfIdentity: updatedProofOfIdentity }));
|
|
31
42
|
};
|
|
32
|
-
exports.removeIDDocumentFromApplicant = removeIDDocumentFromApplicant;
|
|
33
43
|
/**
|
|
34
44
|
* Removes ProofOfIdentity ID document that is in status Not Required
|
|
35
45
|
*
|
|
36
46
|
* @param {RecursivePartial<InternalRequest>} application - Partial LIXI CAL application
|
|
37
47
|
* @param {RequiredDocEventPayload} eventPayload - Required Document event payload
|
|
38
|
-
*
|
|
39
48
|
* @returns {RecursivePartial<InternalRequest>} Updated application
|
|
40
49
|
*/
|
|
41
50
|
const removeIdsNotRequired = (application, eventPayload) => {
|
|
42
|
-
const { status: verificationStatus,
|
|
51
|
+
const { status: verificationStatus, identification, applicantId, id } = eventPayload;
|
|
43
52
|
const personApplicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
|
|
44
|
-
const updatedApplication = application;
|
|
53
|
+
const updatedApplication = (0, lodash_1.cloneDeep)(application);
|
|
45
54
|
if (verificationStatus === public_required_document_1.Status.NotRequired && personApplicants.length) {
|
|
46
55
|
const personApplicantIndex = personApplicants.findIndex((personApplicant) => personApplicant['@UniqueID'] === applicantId);
|
|
47
56
|
if (personApplicantIndex !== -1) {
|
|
48
|
-
const updatedPersonApplicant =
|
|
57
|
+
const updatedPersonApplicant = removeIDDocumentFromApplicant(personApplicants[personApplicantIndex], id, identification);
|
|
49
58
|
(0, lodash_1.set)(updatedApplication, `${application_paths_1.paths.PersonApplicants}.[${personApplicantIndex}]`, updatedPersonApplicant);
|
|
50
59
|
}
|
|
51
60
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum ErrorType {
|
|
2
|
+
ApplicationNotFound = "ApplicationNotFound",
|
|
3
|
+
BaseError = "BaseError",
|
|
4
|
+
DatabaseConditionalWriteError = "DatabaseConditionalWriteError",
|
|
5
|
+
DatabaseError = "DatabaseError",
|
|
6
|
+
Errors = "Errors",
|
|
7
|
+
InternalError = "InternalError",
|
|
8
|
+
InvalidApplication = "InvalidApplication",
|
|
9
|
+
InvalidEvent = "InvalidEvent",
|
|
10
|
+
InvalidEventNoApplicationId = "InvalidEventNoApplicationId",
|
|
11
|
+
InvalidEventNotCritical = "InvalidEventNotCritical",
|
|
12
|
+
OwnershipOutOfBounds = "OwnershipOutOfBounds",
|
|
13
|
+
ResourceNotFound = "ResourceNotFound"
|
|
14
|
+
}
|
|
15
|
+
export declare class BaseError extends Error {
|
|
16
|
+
origin: string;
|
|
17
|
+
path: string[];
|
|
18
|
+
type: ErrorType;
|
|
19
|
+
context: object;
|
|
20
|
+
constructor(message: string, path: string[], origin: string, context?: object);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* InvalidEvent occurs when an incorrect/damaged event has been consumed and
|
|
24
|
+
* found to be invalid against its related schema.
|
|
25
|
+
*/
|
|
26
|
+
export declare class InvalidEvent extends BaseError {
|
|
27
|
+
constructor(message: string, path?: string[], origin?: string, context?: object);
|
|
28
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidEvent = exports.BaseError = exports.ErrorType = void 0;
|
|
4
|
+
var ErrorType;
|
|
5
|
+
(function (ErrorType) {
|
|
6
|
+
ErrorType["ApplicationNotFound"] = "ApplicationNotFound";
|
|
7
|
+
ErrorType["BaseError"] = "BaseError";
|
|
8
|
+
ErrorType["DatabaseConditionalWriteError"] = "DatabaseConditionalWriteError";
|
|
9
|
+
ErrorType["DatabaseError"] = "DatabaseError";
|
|
10
|
+
ErrorType["Errors"] = "Errors";
|
|
11
|
+
ErrorType["InternalError"] = "InternalError";
|
|
12
|
+
ErrorType["InvalidApplication"] = "InvalidApplication";
|
|
13
|
+
ErrorType["InvalidEvent"] = "InvalidEvent";
|
|
14
|
+
ErrorType["InvalidEventNoApplicationId"] = "InvalidEventNoApplicationId";
|
|
15
|
+
ErrorType["InvalidEventNotCritical"] = "InvalidEventNotCritical";
|
|
16
|
+
ErrorType["OwnershipOutOfBounds"] = "OwnershipOutOfBounds";
|
|
17
|
+
ErrorType["ResourceNotFound"] = "ResourceNotFound";
|
|
18
|
+
})(ErrorType = exports.ErrorType || (exports.ErrorType = {}));
|
|
19
|
+
class BaseError extends Error {
|
|
20
|
+
/* istanbul ignore next */
|
|
21
|
+
constructor(message, path = [], origin, context = {}) {
|
|
22
|
+
super(message);
|
|
23
|
+
Object.setPrototypeOf(this, BaseError.prototype);
|
|
24
|
+
this.type = ErrorType.BaseError;
|
|
25
|
+
this.path = path;
|
|
26
|
+
this.origin = origin;
|
|
27
|
+
this.context = context;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.BaseError = BaseError;
|
|
31
|
+
/**
|
|
32
|
+
* InvalidEvent occurs when an incorrect/damaged event has been consumed and
|
|
33
|
+
* found to be invalid against its related schema.
|
|
34
|
+
*/
|
|
35
|
+
class InvalidEvent extends BaseError {
|
|
36
|
+
/* istanbul ignore next */
|
|
37
|
+
constructor(message, path, origin, context) {
|
|
38
|
+
super(message, path, origin, context);
|
|
39
|
+
Object.setPrototypeOf(this, InvalidEvent.prototype);
|
|
40
|
+
this.type = ErrorType.InvalidEvent;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.InvalidEvent = InvalidEvent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lendi/integrations-transform",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.7-beta.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.
|
|
25
|
-
"@lendi/integrations-protocol": "^2.6.
|
|
24
|
+
"@lendi/integrations-credit-protocol": "^1.18.0",
|
|
25
|
+
"@lendi/integrations-protocol": "^2.6.7",
|
|
26
26
|
"@lendi/logging": "^1.0.0",
|
|
27
27
|
"clean-deep": "^3.4.0",
|
|
28
28
|
"date-fns": "2.19.0",
|