@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.
- package/lib/flexplm-request.js +12 -23
- package/lib/util/config-defaults.js +57 -70
- package/lib/util/data-converter.js +178 -201
- package/lib/util/federation.js +93 -114
- package/lib/util/flexplm-connect.js +92 -113
- package/lib/util/logger-config.js +20 -31
- package/lib/util/thumbnail-util.js +79 -99
- package/lib/util/type-utils.js +8 -21
- package/package.json +3 -2
|
@@ -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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
74
|
+
}
|
|
75
|
+
console.info('getFileId(): returning-' + fileId);
|
|
76
|
+
return fileId;
|
|
91
77
|
}
|
|
92
|
-
getCustomSizes() {
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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;
|
package/lib/util/type-utils.js
CHANGED
|
@@ -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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
30
|
-
|
|
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.
|
|
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
|
}
|