@contrail/flexplm 1.0.13 → 1.0.15

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.
@@ -2,7 +2,11 @@ import { FCConfig, EntityPayloadType } from '../util/interfaces';
2
2
  import { DataConverter } from '../util/data-converter';
3
3
  import { TypeUtils } from '../util/type-utils';
4
4
  import { MapFileUtil } from '@contrail/transform-data';
5
- export declare abstract class ProcessBaseEntity {
5
+ export declare class IncomingEntityResponse {
6
+ entity: any;
7
+ earlyReturn: any;
8
+ }
9
+ export declare abstract class BaseEntityProcessor {
6
10
  protected config: FCConfig;
7
11
  protected dc: DataConverter;
8
12
  protected mapFileUtil: MapFileUtil;
@@ -18,7 +22,7 @@ export declare abstract class ProcessBaseEntity {
18
22
  getUpdatesForEntity(entity: any, inboundData: any): Promise<object>;
19
23
  getVibeOwningKeys(entity: any): Promise<any[]>;
20
24
  updateEntity(entityName: any, entity: any, diffs: any): Promise<any>;
21
- protected abstract getIncomingEntity(event: any, inboundData: any): any;
25
+ protected abstract getIncomingEntity(event: any, inboundData: any): Promise<IncomingEntityResponse>;
22
26
  outbound(event: any): Promise<void | import("../util/interfaces").FlexPLMResponseData>;
23
27
  handleOutgoingUpsert(entityType: any, event: any): Promise<import("../util/interfaces").FlexPLMResponseData>;
24
28
  handleOutgoingDelete(entityType: any, event: any): Promise<void>;
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProcessBaseEntity = void 0;
3
+ exports.BaseEntityProcessor = exports.IncomingEntityResponse = void 0;
4
4
  const type_utils_1 = require("../util/type-utils");
5
5
  const flexplm_connect_1 = require("../util/flexplm-connect");
6
6
  const map_utils_1 = require("../util/map-utils");
7
7
  const sdk_1 = require("@contrail/sdk");
8
8
  const UNSUPPORTED_TYPE = 'Unsupported eventType.';
9
- class ProcessBaseEntity {
9
+ class IncomingEntityResponse {
10
+ }
11
+ exports.IncomingEntityResponse = IncomingEntityResponse;
12
+ class BaseEntityProcessor {
10
13
  constructor(config, dc, mapFileUtil, baseType) {
11
14
  this.config = config;
12
15
  this.dc = dc;
@@ -25,7 +28,7 @@ class ProcessBaseEntity {
25
28
  case 'DELETE':
26
29
  return await this.handleIncomingDelete(event);
27
30
  default:
28
- console.log(UNSUPPORTED_TYPE);
31
+ console.error(UNSUPPORTED_TYPE);
29
32
  return {
30
33
  status: 500,
31
34
  data: { UNSUPPORTED_TYPE }
@@ -34,7 +37,11 @@ class ProcessBaseEntity {
34
37
  }
35
38
  async handleIncomingUpdate(event) {
36
39
  const inboundData = await this.getTransformedData(event);
37
- const entity = await this.getIncomingEntity(event, inboundData);
40
+ const incomingEntityResponse = await this.getIncomingEntity(event, inboundData);
41
+ if (incomingEntityResponse.earlyReturn) {
42
+ return incomingEntityResponse.earlyReturn;
43
+ }
44
+ const entity = incomingEntityResponse.entity;
38
45
  if (!entity) {
39
46
  const message = 'No entity found';
40
47
  console.debug(message);
@@ -43,12 +50,9 @@ class ProcessBaseEntity {
43
50
  data: { message }
44
51
  };
45
52
  }
46
- else if (Object.keys(entity).length === 2 && entity?.status && entity?.data) {
47
- return entity;
48
- }
49
53
  const diffs = await this.getUpdatesForEntity(entity, inboundData);
50
54
  if (Object.getOwnPropertyNames(diffs).length == 0) {
51
- const message = 'No Changes to persist for entity: ' + entity['id'];
55
+ const message = 'No Changes to persist for entity: ' + entity.id;
52
56
  console.log(message);
53
57
  return {
54
58
  status: 200,
@@ -86,9 +90,7 @@ class ProcessBaseEntity {
86
90
  if (this.transformMapFile) {
87
91
  const wholeMap = await this.mapFileUtil.getMapFile(this.transformMapFile);
88
92
  const objClass = this.dc.getMappingClass(entity, wholeMap);
89
- if (objClass && wholeMap && wholeMap[objClass] && wholeMap[objClass]['vibeOwningKeys']) {
90
- vibeOwningKeys = wholeMap[objClass]['vibeOwningKeys'];
91
- }
93
+ vibeOwningKeys = wholeMap?.[objClass]?.vibeOwningKeys || [];
92
94
  }
93
95
  console.debug('vibeOwningKeys: ' + vibeOwningKeys);
94
96
  return vibeOwningKeys;
@@ -138,4 +140,4 @@ class ProcessBaseEntity {
138
140
  console.warn('delete is not configured', entityType, event.oldData);
139
141
  }
140
142
  }
141
- exports.ProcessBaseEntity = ProcessBaseEntity;
143
+ exports.BaseEntityProcessor = BaseEntityProcessor;
package/lib/index.d.ts CHANGED
@@ -9,4 +9,4 @@ export * from './util/logger-config';
9
9
  export * from './util/thumbnail-util';
10
10
  export * from './util/type-utils';
11
11
  export * from './util/map-utils';
12
- export * from './process-entity/process-entity';
12
+ export * from './entity-processor/base-entity-processor';
package/lib/index.js CHANGED
@@ -25,4 +25,4 @@ __exportStar(require("./util/logger-config"), exports);
25
25
  __exportStar(require("./util/thumbnail-util"), exports);
26
26
  __exportStar(require("./util/type-utils"), exports);
27
27
  __exportStar(require("./util/map-utils"), exports);
28
- __exportStar(require("./process-entity/process-entity"), exports);
28
+ __exportStar(require("./entity-processor/base-entity-processor"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",