@lendi/integrations-transform 1.6.4 → 1.6.5

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.
@@ -0,0 +1,21 @@
1
+ import { InternalRequest, PersonApplicant } from '@lendi/integrations-credit-protocol/types/lixi-internal-request';
2
+ import { Payload as RequiredDocEventPayload } from '../types/events/public-required-document';
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
+ /**
14
+ * Removes ProofOfIdentity ID document that is in status Not Required
15
+ *
16
+ * @param {RecursivePartial<InternalRequest>} application - Partial LIXI CAL application
17
+ * @param {RequiredDocEventPayload} eventPayload - Required Document event payload
18
+ *
19
+ * @returns {RecursivePartial<InternalRequest>} Updated application
20
+ */
21
+ export declare const removeIdsNotRequired: (application: RecursivePartial<InternalRequest>, eventPayload: RequiredDocEventPayload) => RecursivePartial<InternalRequest>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.removeIdsNotRequired = exports.removeIDDocumentFromApplicant = void 0;
15
+ const application_paths_1 = require("@lendi/integrations-credit-protocol/utils/application-paths");
16
+ const lodash_1 = require("lodash");
17
+ const public_required_document_1 = require("../types/events/public-required-document");
18
+ /**
19
+ * Remove proof of identity document from a person applicant
20
+ *
21
+ * @param {PersonApplicant} personApplicant Person applicant to remove the id document from
22
+ * @param {string} id Proof of identity document
23
+ *
24
+ * @returns {PersonApplicant} Updated person applicant
25
+ */
26
+ const removeIDDocumentFromApplicant = (personApplicant, id) => {
27
+ const { ProofOfIdentity = [] } = personApplicant, rest = __rest(personApplicant, ["ProofOfIdentity"]);
28
+ const updatedProofOfIdentity = ProofOfIdentity.filter((proofOfId) => proofOfId['@UniqueID'] !== id);
29
+ // If the updateProofOfIdentity is an empty array then we remove the ProofOfIdentity attribute from the person applicant
30
+ return Object.assign(Object.assign({}, rest), (updatedProofOfIdentity.length && { ProofOfIdentity: updatedProofOfIdentity }));
31
+ };
32
+ exports.removeIDDocumentFromApplicant = removeIDDocumentFromApplicant;
33
+ /**
34
+ * Removes ProofOfIdentity ID document that is in status Not Required
35
+ *
36
+ * @param {RecursivePartial<InternalRequest>} application - Partial LIXI CAL application
37
+ * @param {RequiredDocEventPayload} eventPayload - Required Document event payload
38
+ *
39
+ * @returns {RecursivePartial<InternalRequest>} Updated application
40
+ */
41
+ const removeIdsNotRequired = (application, eventPayload) => {
42
+ const { status: verificationStatus, id, applicantId } = eventPayload;
43
+ const personApplicants = (0, lodash_1.get)(application, application_paths_1.paths.PersonApplicants, []);
44
+ const updatedApplication = application;
45
+ if (verificationStatus === public_required_document_1.Status.NotRequired && personApplicants.length) {
46
+ const personApplicantIndex = personApplicants.findIndex((personApplicant) => personApplicant['@UniqueID'] === applicantId);
47
+ if (personApplicantIndex !== -1) {
48
+ const updatedPersonApplicant = (0, exports.removeIDDocumentFromApplicant)(personApplicants[personApplicantIndex], id);
49
+ (0, lodash_1.set)(updatedApplication, `${application_paths_1.paths.PersonApplicants}.[${personApplicantIndex}]`, updatedPersonApplicant);
50
+ }
51
+ }
52
+ return updatedApplication;
53
+ };
54
+ exports.removeIdsNotRequired = removeIdsNotRequired;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
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",