@contrail/flexplm 1.0.5 → 1.0.7

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.
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.ThumbnailUtil = void 0;
13
4
  const app_framework_1 = require("@contrail/app-framework");
@@ -21,109 +12,98 @@ class ThumbnailUtil {
21
12
  this.max_thumbnail_size = this.config['max_thumbnail_size'];
22
13
  }
23
14
  }
24
- setOutboundThumbnail(data, event) {
25
- var _a, _b, _c, _d, _e, _f, _g;
26
- return __awaiter(this, void 0, void 0, function* () {
27
- if (((_a = event === null || event === void 0 ? void 0 : event.newData) === null || _a === void 0 ? void 0 : _a.primaryViewableId) && ((_b = event === null || event === void 0 ? void 0 : event.newData) === null || _b === void 0 ? void 0 : _b.largeViewableDownloadUrl)) {
28
- const primaryViewableId = event.newData.primaryViewableId;
29
- const fileId = yield this.getFileId(primaryViewableId);
30
- if (fileId) {
31
- const key = ((_c = event === null || event === void 0 ? void 0 : event.propertyDiffs) === null || _c === void 0 ? void 0 : _c.largeViewableDownloadUrl)
32
- ? ThumbnailUtil.NEW_THUMBNAIL_ID
33
- : ThumbnailUtil.EXISTING_THUMBNAIL_ID;
34
- data[key] = fileId;
35
- }
36
- }
37
- else if (((_e = (_d = event === null || event === void 0 ? void 0 : event.propertyDiffs) === null || _d === void 0 ? void 0 : _d.largeViewableDownloadUrl) === null || _e === void 0 ? void 0 : _e.oldValue) && !((_g = (_f = event === null || event === void 0 ? void 0 : event.propertyDiffs) === null || _f === void 0 ? void 0 : _f.largeViewableDownloadUrl) === null || _g === void 0 ? void 0 : _g.newValue)) {
38
- data[ThumbnailUtil.NEW_THUMBNAIL_ID] = ThumbnailUtil.REMOVE_THUMBNAIL;
15
+ async setOutboundThumbnail(data, event) {
16
+ if (event?.newData?.primaryViewableId && event?.newData?.largeViewableDownloadUrl) {
17
+ const primaryViewableId = event.newData.primaryViewableId;
18
+ const fileId = await this.getFileId(primaryViewableId);
19
+ if (fileId) {
20
+ const key = (event?.propertyDiffs?.largeViewableDownloadUrl)
21
+ ? ThumbnailUtil.NEW_THUMBNAIL_ID
22
+ : ThumbnailUtil.EXISTING_THUMBNAIL_ID;
23
+ data[key] = fileId;
39
24
  }
40
- return data;
41
- });
25
+ }
26
+ else if (event?.propertyDiffs?.largeViewableDownloadUrl?.oldValue && !event?.propertyDiffs?.largeViewableDownloadUrl?.newValue) {
27
+ data[ThumbnailUtil.NEW_THUMBNAIL_ID] = ThumbnailUtil.REMOVE_THUMBNAIL;
28
+ }
29
+ return data;
42
30
  }
43
- getFileId(primaryViewableId) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- console.info('getFileId()-' + primaryViewableId);
46
- const sizes = yield this.getCustomSizes();
47
- const OOBSizes = [{ slug: 'largeViewable' }, { slug: 'mediumViewable' }, { slug: 'smallViewable' }, { slug: 'tinyViewable' }];
48
- sizes.push(...OOBSizes);
49
- console.info('sizes: ' + JSON.stringify(sizes));
50
- const content = yield this.getContentEntity(primaryViewableId);
51
- if (app_framework_1.Logger.isDebugOn()) {
52
- console.debug('content: ' + JSON.stringify(content));
53
- }
54
- if (!content) {
55
- return undefined;
56
- }
57
- const contentKeys = Object.getOwnPropertyNames(content);
58
- const fileEntityIds = [];
59
- for (const size of sizes) {
60
- const key = size.slug + 'Id';
61
- if (contentKeys.includes(key) && !fileEntityIds.includes(content[key])) {
62
- fileEntityIds.push(content[key]);
63
- size['fileId'] = content[key];
64
- }
31
+ async getFileId(primaryViewableId) {
32
+ console.info('getFileId()-' + primaryViewableId);
33
+ const sizes = await this.getCustomSizes();
34
+ const OOBSizes = [{ slug: 'largeViewable' }, { slug: 'mediumViewable' }, { slug: 'smallViewable' }, { slug: 'tinyViewable' }];
35
+ sizes.push(...OOBSizes);
36
+ console.info('sizes: ' + JSON.stringify(sizes));
37
+ const content = await this.getContentEntity(primaryViewableId);
38
+ if (app_framework_1.Logger.isDebugOn()) {
39
+ console.debug('content: ' + JSON.stringify(content));
40
+ }
41
+ if (!content) {
42
+ return undefined;
43
+ }
44
+ const contentKeys = Object.getOwnPropertyNames(content);
45
+ const fileEntityIds = [];
46
+ for (const size of sizes) {
47
+ const key = size.slug + 'Id';
48
+ if (contentKeys.includes(key) && !fileEntityIds.includes(content[key])) {
49
+ fileEntityIds.push(content[key]);
50
+ size['fileId'] = content[key];
65
51
  }
66
- const fileResults = yield this.getFileEntities(fileEntityIds);
67
- if (app_framework_1.Logger.isDebugOn()) {
68
- console.debug('fileResults: ' + JSON.stringify(fileResults));
52
+ }
53
+ const fileResults = await this.getFileEntities(fileEntityIds);
54
+ if (app_framework_1.Logger.isDebugOn()) {
55
+ console.debug('fileResults: ' + JSON.stringify(fileResults));
56
+ }
57
+ let fileId = undefined;
58
+ let tempFileSize = 0;
59
+ const isDebugOn = app_framework_1.Logger.isDebugOn();
60
+ for (const sizeObj of sizes) {
61
+ if (isDebugOn) {
62
+ console.debug('size: ' + JSON.stringify(sizeObj));
69
63
  }
70
- let fileId = undefined;
71
- let tempFileSize = 0;
72
- const isDebugOn = app_framework_1.Logger.isDebugOn();
73
- for (const sizeObj of sizes) {
74
- if (isDebugOn) {
75
- console.debug('size: ' + JSON.stringify(sizeObj));
76
- }
77
- if (sizeObj['fileId']) {
78
- const file = fileResults.find(f => f['id'] === sizeObj['fileId']);
79
- if (file['size'] > tempFileSize && file['size'] < this.max_thumbnail_size) {
80
- tempFileSize = file['size'];
81
- fileId = file['id'];
82
- if (isDebugOn) {
83
- console.debug('fileId: ' + fileId);
84
- }
64
+ if (sizeObj['fileId']) {
65
+ const file = fileResults.find(f => f['id'] === sizeObj['fileId']);
66
+ if (file['size'] > tempFileSize && file['size'] < this.max_thumbnail_size) {
67
+ tempFileSize = file['size'];
68
+ fileId = file['id'];
69
+ if (isDebugOn) {
70
+ console.debug('fileId: ' + fileId);
85
71
  }
86
72
  }
87
73
  }
88
- console.info('getFileId(): returning-' + fileId);
89
- return fileId;
90
- });
74
+ }
75
+ console.info('getFileId(): returning-' + fileId);
76
+ return fileId;
91
77
  }
92
- getCustomSizes() {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- const customSizes = yield this.entities.get({
95
- entityName: 'content-custom-size'
96
- });
97
- const sizes = [];
98
- sizes.push(...customSizes);
99
- return sizes;
78
+ async getCustomSizes() {
79
+ const customSizes = await this.entities.get({
80
+ entityName: 'content-custom-size'
100
81
  });
82
+ const sizes = [];
83
+ sizes.push(...customSizes);
84
+ return sizes;
101
85
  }
102
- getContentEntity(primaryViewableId) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- const criteria = {
105
- id: primaryViewableId
106
- };
107
- const contentResults = yield this.entities.get({
108
- entityName: 'content',
109
- criteria
110
- });
111
- console.info('contentResults: ' + JSON.stringify(contentResults));
112
- const content = (contentResults && contentResults[0]) ? contentResults[0] : undefined;
113
- return content;
86
+ async getContentEntity(primaryViewableId) {
87
+ const criteria = {
88
+ id: primaryViewableId
89
+ };
90
+ const contentResults = await this.entities.get({
91
+ entityName: 'content',
92
+ criteria
114
93
  });
94
+ console.info('contentResults: ' + JSON.stringify(contentResults));
95
+ const content = (contentResults && contentResults[0]) ? contentResults[0] : undefined;
96
+ return content;
115
97
  }
116
- getFileEntities(fileEntityIds) {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- const criteria = {
119
- ids: fileEntityIds
120
- };
121
- const fileResults = yield this.entities.get({
122
- entityName: 'file',
123
- criteria
124
- });
125
- return fileResults;
98
+ async getFileEntities(fileEntityIds) {
99
+ const criteria = {
100
+ ids: fileEntityIds
101
+ };
102
+ const fileResults = await this.entities.get({
103
+ entityName: 'file',
104
+ criteria
126
105
  });
106
+ return fileResults;
127
107
  }
128
108
  }
129
109
  exports.ThumbnailUtil = ThumbnailUtil;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.TypeUtils = void 0;
13
4
  const app_framework_1 = require("@contrail/app-framework");
@@ -16,20 +7,16 @@ class TypeUtils {
16
7
  constructor() {
17
8
  this.typesObj = new sdk_1.Types();
18
9
  }
19
- getTypeById(id) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const type = yield this.typesObj.getType({
22
- id,
23
- relations: ['typeProperties', 'typeInterfaces']
24
- });
25
- return type;
10
+ async getTypeById(id) {
11
+ const type = await this.typesObj.getType({
12
+ id,
13
+ relations: ['typeProperties', 'typeInterfaces']
26
14
  });
15
+ return type;
27
16
  }
28
- getByRootAndPath(options) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const type = yield this.typesObj.getByRootAndPath(options);
31
- return type;
32
- });
17
+ async getByRootAndPath(options) {
18
+ const type = await this.typesObj.getByRootAndPath(options);
19
+ return type;
33
20
  }
34
21
  static getFlexPLMTypePath(entity) {
35
22
  return entity['flexPLMTypePath'] || entity['flexTypePath'] || '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -40,6 +40,7 @@
40
40
  "@contrail/app-framework": "^1.2.0",
41
41
  "@contrail/sdk": "^1.2.11",
42
42
  "@contrail/transform-data": "^1.0.8",
43
- "axios": "^1.4.0"
43
+ "axios": "^1.4.0",
44
+ "p-limit": "^3.1.0"
44
45
  }
45
46
  }