@contrail/flexplm 1.1.9 → 1.1.10

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.
@@ -5,6 +5,7 @@ export interface FCConfig {
5
5
  configFile?: string;
6
6
  eventObjectClassParam?: string;
7
7
  eventFlexTypePathParam?: string;
8
+ flexplmConnect?: any;
8
9
  taskId?: string;
9
10
  apiHost: string;
10
11
  userName(): string;
@@ -130,14 +130,18 @@ class DataConverter {
130
130
  }
131
131
  async getObjectReferenceValue(prop, newData, inflateObjRef = false) {
132
132
  const slug = prop['slug'];
133
- console.debug('getObjectReferenceValue-prop: ' + slug);
133
+ if (app_framework_1.Logger.isDebugOn()) {
134
+ console.debug('getObjectReferenceValue-prop: ' + slug);
135
+ }
134
136
  let value = newData[slug];
135
137
  const entityType = prop['referencedTypeRootSlug'];
136
138
  const entityId = newData[slug + 'Id'];
137
139
  if ((!value || typeof value === 'string') && inflateObjRef) {
138
140
  if (entityId) {
139
141
  if (this.objRefCache[entityId]) {
140
- console.log('cache hit: ' + entityId);
142
+ if (app_framework_1.Logger.isDebugOn()) {
143
+ console.debug('cache hit: ' + entityId);
144
+ }
141
145
  return this.objRefCache[entityId];
142
146
  }
143
147
  const criteria = {
@@ -251,13 +255,10 @@ class DataConverter {
251
255
  else if ('object_reference' === propertyType) {
252
256
  }
253
257
  else if ('image' === propertyType) {
254
- console.log('TODO');
255
258
  }
256
259
  else if ('formula' === propertyType) {
257
- console.log('TODO');
258
260
  }
259
261
  else if ('json' === propertyType) {
260
- console.log('TODO');
261
262
  }
262
263
  return value;
263
264
  }
@@ -2,6 +2,7 @@ import { FCConfig, FlexPLMResponseData, PayloadType } from '../interfaces/interf
2
2
  export declare class FlexPLMConnect {
3
3
  private config;
4
4
  private vibeEventEndpoint;
5
+ private staticHeaders;
5
6
  payloadSendAsArray: boolean;
6
7
  constructor(_config: FCConfig, endPoint?: any, payloadAsArray?: any);
7
8
  private getRequestOptions;
@@ -5,6 +5,7 @@ const app_framework_1 = require("@contrail/app-framework");
5
5
  class FlexPLMConnect {
6
6
  constructor(_config, endPoint = undefined, payloadAsArray = undefined) {
7
7
  this.vibeEventEndpoint = '';
8
+ this.staticHeaders = undefined;
8
9
  this.payloadSendAsArray = true;
9
10
  this.config = _config;
10
11
  this.vibeEventEndpoint = (endPoint)
@@ -13,6 +14,9 @@ class FlexPLMConnect {
13
14
  this.payloadSendAsArray = (payloadAsArray != undefined)
14
15
  ? payloadAsArray
15
16
  : this.config['payloadDefaultAsArray'];
17
+ if (this.config?.flexplmConnect?.staticHeaders) {
18
+ this.staticHeaders = this.config?.flexplmConnect?.staticHeaders;
19
+ }
16
20
  }
17
21
  getRequestOptions(method) {
18
22
  const csrfOptions = {
@@ -23,6 +27,9 @@ class FlexPLMConnect {
23
27
  Authorization: 'Basic ' + Buffer.from(`${this.config.userName()}:${this.config.password()}`, 'binary').toString('base64')
24
28
  }
25
29
  };
30
+ if (this.staticHeaders) {
31
+ Object.assign(csrfOptions.headers, this.staticHeaders);
32
+ }
26
33
  if (app_framework_1.Logger.isInfoOn()) {
27
34
  const logOptions = JSON.parse(JSON.stringify(csrfOptions));
28
35
  logOptions['headers']['Authorization'] = logOptions?.headers?.Authorization.substring(0, 9);
@@ -105,11 +112,19 @@ class FlexPLMConnect {
105
112
  throw new Error(message);
106
113
  }
107
114
  try {
108
- const data = await response.json();
109
115
  const res = {
110
116
  status,
111
- data
112
117
  };
118
+ if (![204, 205].includes(status)) {
119
+ try {
120
+ const data = await response.json();
121
+ res.data = data;
122
+ }
123
+ catch (e) {
124
+ console.error('Error getting response body. Setting {} body: ' + e);
125
+ res.data = {};
126
+ }
127
+ }
113
128
  console.log('eventResponse.status: ' + status);
114
129
  return res;
115
130
  }
@@ -83,7 +83,9 @@ class TypeUtils {
83
83
  const roles = newData['roles'];
84
84
  if (roles) {
85
85
  const isFamily = roles.includes('family');
86
- console.debug('isFamily: ' + isFamily);
86
+ if (app_framework_1.Logger.isDebugOn()) {
87
+ console.debug('isFamily: ' + isFamily);
88
+ }
87
89
  filteredProps = filteredProps.filter(prop => {
88
90
  const propertyLevel = prop.propertyLevel;
89
91
  const applies = (isFamily && 'option' != propertyLevel) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",