@lendi/integrations-transform 1.5.3 → 1.5.6

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.js CHANGED
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
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);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];
@@ -1,8 +1,9 @@
1
- import { PayloadClass as ApplicationWorkflow } from '../types/events/application-workflow';
1
+ import { PayloadClass as ApplicationWorkflowEventPayload } from '../types/events/application-workflow';
2
2
  /**
3
- * Generates a partial internal request from a partial application workflow event.
3
+ * Generates a partial application from an ApplicationWorkflow event
4
4
  *
5
- * @return partialApplication: A partial internal request.
6
- * @param applicationWorkflow: ApplicationWorkflow object.
5
+ * @param applicationWorkflowEventPayload ApplicationWorkflow event payload
6
+ *
7
+ * @returns A partial application
7
8
  */
8
- export declare function transformApplicationWorkflow(applicationWorkflow: ApplicationWorkflow): {};
9
+ export declare function transformApplicationWorkflow(applicationWorkflowEventPayload: ApplicationWorkflowEventPayload): {};
@@ -4,29 +4,21 @@ exports.transformApplicationWorkflow = void 0;
4
4
  var application_paths_1 = require("@lendi/integrations-protocol/lib/utils/application-paths");
5
5
  var lodash_1 = require("lodash");
6
6
  /**
7
- * Generates a partial internal request from a partial application workflow event.
7
+ * Generates a partial application from an ApplicationWorkflow event
8
8
  *
9
- * @return partialApplication: A partial internal request.
10
- * @param applicationWorkflow: ApplicationWorkflow object.
9
+ * @param applicationWorkflowEventPayload ApplicationWorkflow event payload
10
+ *
11
+ * @returns A partial application
11
12
  */
12
- function transformApplicationWorkflow(applicationWorkflow) {
13
- var partialApplication = {};
14
- var opportunityMapping = {
15
- applicationId: application_paths_1.paths.ApplicationId,
16
- stage: application_paths_1.paths.Instructions
13
+ function transformApplicationWorkflow(applicationWorkflowEventPayload) {
14
+ var stage = applicationWorkflowEventPayload.stage, applicationStage = applicationWorkflowEventPayload.applicationStage, applicationId = applicationWorkflowEventPayload.applicationId, partialApplication = {};
15
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.ApplicationId, applicationId);
16
+ // The stage being defaulted to Unknown caters for LGSF application workflow events having stage as an optional attribute in the future
17
+ var instructionDetails = {
18
+ '@UniqueID': "".concat(applicationId, "-stage"),
19
+ '@Details': applicationStage || stage || 'Unknown'
17
20
  };
18
- for (var _i = 0, _a = Object.entries(applicationWorkflow); _i < _a.length; _i++) {
19
- var _b = _a[_i], key = _b[0], value = _b[1];
20
- if (opportunityMapping[key]) {
21
- if (key === 'stage') {
22
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Instructions, ".@UniqueID"), "".concat(applicationWorkflow.applicationId, "-stage"));
23
- (0, lodash_1.set)(partialApplication, "".concat(opportunityMapping[key], ".@Details"), value || 'Unknown');
24
- }
25
- else {
26
- (0, lodash_1.set)(partialApplication, opportunityMapping[key], value);
27
- }
28
- }
29
- }
21
+ (0, lodash_1.set)(partialApplication, application_paths_1.paths.Instructions, instructionDetails);
30
22
  return partialApplication;
31
23
  }
32
24
  exports.transformApplicationWorkflow = transformApplicationWorkflow;
@@ -1,8 +1,14 @@
1
1
  import { Payload as ApplicationPayload } from '../types/events/public-application';
2
+ interface transformApplicationOptions {
3
+ uniqueIdSuffix?: string;
4
+ enableRateLock?: boolean;
5
+ }
2
6
  /**
3
7
  * Transforms a partial opportunity event to a partial internal request.
4
8
  *
5
9
  * @param opportunity: Partial opportunity event.
10
+ * @param uniqueIdSuffix: Suffix for uniquerId
6
11
  * @return partialApplication: A partial internal request.
7
12
  */
8
- export declare function transformApplication(opportunity: ApplicationPayload): {};
13
+ export declare function transformApplication(opportunity: ApplicationPayload, options?: transformApplicationOptions): {};
14
+ export {};
@@ -11,9 +11,12 @@ var transform_applicant_1 = require("./transform-applicant");
11
11
  * Transforms a partial opportunity event to a partial internal request.
12
12
  *
13
13
  * @param opportunity: Partial opportunity event.
14
+ * @param uniqueIdSuffix: Suffix for uniquerId
14
15
  * @return partialApplication: A partial internal request.
15
16
  */
16
- function transformApplication(opportunity) {
17
+ function transformApplication(opportunity, options) {
18
+ if (options === void 0) { options = {}; }
19
+ var _a = options.uniqueIdSuffix, uniqueIdSuffix = _a === void 0 ? 'loanDetails' : _a, _b = options.enableRateLock, enableRateLock = _b === void 0 ? false : _b;
17
20
  var partialApplication = {};
18
21
  var opportunityMapping = {
19
22
  brand: application_paths_2.paths.BusinessName,
@@ -21,19 +24,21 @@ function transformApplication(opportunity) {
21
24
  paymentType: "".concat(application_paths_2.paths.LoanTerm, ".@PaymentType"),
22
25
  preliminary: 'preliminary',
23
26
  primaryPurpose: application_paths_2.paths.PurposeOfApplication,
24
- brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description',
25
- hasOptedInRateLock: "".concat(application_paths_1.paths.FeaturesSelected, ".@RateLock")
27
+ brokerPrimaryPurpose: 'Package.Content.NeedsAnalysis.PurposeOfApplication[0].@Description'
26
28
  };
27
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_2.paths.LoanDetail, ".@UniqueID"), "".concat(opportunity.id, "-loanDetails"));
29
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_2.paths.LoanDetail, ".@UniqueID"), "".concat(opportunity.id, "-").concat(uniqueIdSuffix));
28
30
  (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Instructions, ".@UniqueID"), "".concat(opportunity.id, "-stage"));
29
31
  (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.Instructions, ".@Name"), lixi_internal_request_1.EventNameApplicationInstructionsList.ApplicationReceived);
30
- (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.FeaturesSelected, ".@RateLock"), lixi_internal_request_1.YesNoList.No);
31
- for (var _i = 0, _a = Object.entries(opportunity); _i < _a.length; _i++) {
32
- var _b = _a[_i], opportunityKey = _b[0], opportunityValue = _b[1];
32
+ if (enableRateLock) {
33
+ var _c = opportunity.hasOptedInRateLock, hasOptedInRateLock = _c === void 0 ? false : _c;
34
+ (0, lodash_1.set)(partialApplication, "".concat(application_paths_1.paths.FeaturesSelected, ".@RateLock"), (0, transform_applicant_1.booleanMapping)(hasOptedInRateLock));
35
+ }
36
+ for (var _i = 0, _d = Object.entries(opportunity); _i < _d.length; _i++) {
37
+ var _e = _d[_i], opportunityKey = _e[0], opportunityValue = _e[1];
33
38
  if (opportunityMapping[opportunityKey]) {
34
39
  if (opportunityKey === 'preliminary') {
35
- for (var _c = 0, _d = Object.entries(opportunityValue); _c < _d.length; _c++) {
36
- var _e = _d[_c], key = _e[0], value = _e[1];
40
+ for (var _f = 0, _g = Object.entries(opportunityValue); _f < _g.length; _f++) {
41
+ var _h = _g[_f], key = _h[0], value = _h[1];
37
42
  if (opportunityMapping[key]) {
38
43
  switch (key) {
39
44
  case 'paymentType':
@@ -46,9 +51,6 @@ function transformApplication(opportunity) {
46
51
  }
47
52
  }
48
53
  }
49
- else if (opportunityKey === 'hasOptedInRateLock') {
50
- (0, lodash_1.set)(partialApplication, opportunityMapping[opportunityKey], (0, transform_applicant_1.booleanMapping)(opportunityValue));
51
- }
52
54
  else {
53
55
  (0, lodash_1.set)(partialApplication, opportunityMapping[opportunityKey], opportunityValue);
54
56
  }
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
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);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lendi/integrations-transform",
3
- "version": "1.5.3",
3
+ "version": "1.5.6",
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",