@contrail/flexplm 1.3.0-alpha.3 → 1.3.0-alpha.4
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/.claude/settings.local.json +2 -1
- package/lib/util/mockData.d.ts +1 -0
- package/lib/util/mockData.js +8 -4
- package/lib/util/thumbnail-util.d.ts +9 -3
- package/lib/util/thumbnail-util.js +11 -2
- package/package.json +1 -1
- package/src/util/mockData.ts +8 -4
- package/src/util/thumbnail-util.ts +19 -6
package/lib/util/mockData.d.ts
CHANGED
package/lib/util/mockData.js
CHANGED
|
@@ -6,22 +6,26 @@ exports.four_custom_sizes = [
|
|
|
6
6
|
{
|
|
7
7
|
size: 1000,
|
|
8
8
|
id: '-QwFOWnCs0Gb5jkA',
|
|
9
|
-
slug: 'CS_1000'
|
|
9
|
+
slug: 'CS_1000',
|
|
10
|
+
name: 'CS_1000'
|
|
10
11
|
},
|
|
11
12
|
{
|
|
12
13
|
size: 300,
|
|
13
14
|
id: 'AKXOowvhJRnkerG8',
|
|
14
|
-
slug: 'CS_300'
|
|
15
|
+
slug: 'CS_300',
|
|
16
|
+
name: 'CS_300'
|
|
15
17
|
},
|
|
16
18
|
{
|
|
17
19
|
size: 500,
|
|
18
20
|
id: '9asQ65N188RIYgnh',
|
|
19
|
-
slug: 'CS_500'
|
|
21
|
+
slug: 'CS_500',
|
|
22
|
+
name: 'CS_500'
|
|
20
23
|
},
|
|
21
24
|
{
|
|
22
25
|
size: 800,
|
|
23
26
|
id: 'xkzhwE4nJ6iRwfvP',
|
|
24
|
-
slug: 'CS_800'
|
|
27
|
+
slug: 'CS_800',
|
|
28
|
+
name: 'CS_800'
|
|
25
29
|
}
|
|
26
30
|
];
|
|
27
31
|
exports.thumbnail_content_entity = {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { FCConfig } from '../interfaces/interfaces';
|
|
2
|
+
interface ContentCustomSize {
|
|
3
|
+
id: string;
|
|
4
|
+
slug: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
2
7
|
export declare class ThumbnailUtil {
|
|
3
8
|
private config;
|
|
4
9
|
private max_thumbnail_size;
|
|
@@ -12,9 +17,9 @@ export declare class ThumbnailUtil {
|
|
|
12
17
|
constructor(config: FCConfig);
|
|
13
18
|
setOutboundThumbnail(data: any, event: any): Promise<any>;
|
|
14
19
|
isThumbnailNew(event: any, customSizes: any[]): boolean;
|
|
15
|
-
getFileId(primaryViewableId: string): Promise<string>;
|
|
16
|
-
getCustomSizes(): Promise<
|
|
17
|
-
getContentEntity(primaryViewableId: any, sizes:
|
|
20
|
+
getFileId(primaryViewableId: string): Promise<string | undefined>;
|
|
21
|
+
getCustomSizes(): Promise<ContentCustomSize[]>;
|
|
22
|
+
getContentEntity(primaryViewableId: any, sizes: ContentCustomSize[]): Promise<any>;
|
|
18
23
|
logContentResults(content: any, relations: string[]): void;
|
|
19
24
|
syncThumbnailToVibeIQ({ entityId, primaryViewableId, event, entityName }: {
|
|
20
25
|
entityId: string;
|
|
@@ -26,3 +31,4 @@ export declare class ThumbnailUtil {
|
|
|
26
31
|
private getPrimaryViewableUpdates;
|
|
27
32
|
private getClearPrimaryViewableUpdates;
|
|
28
33
|
}
|
|
34
|
+
export {};
|
|
@@ -4,6 +4,7 @@ exports.ThumbnailUtil = void 0;
|
|
|
4
4
|
const app_framework_1 = require("@contrail/app-framework");
|
|
5
5
|
const sdk_1 = require("@contrail/sdk");
|
|
6
6
|
const flexplm_connect_1 = require("./flexplm-connect");
|
|
7
|
+
;
|
|
7
8
|
class ThumbnailUtil {
|
|
8
9
|
constructor(config) {
|
|
9
10
|
this.config = config;
|
|
@@ -108,6 +109,7 @@ class ThumbnailUtil {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
async syncThumbnailToVibeIQ({ entityId, primaryViewableId, event, entityName }) {
|
|
112
|
+
console.debug(`syncThumbnailToVibeIQ: entityId=${entityId}, primaryViewableId=${primaryViewableId}, entityName=${entityName}`);
|
|
111
113
|
const eventData = event.data || {};
|
|
112
114
|
const newThumbnailId = eventData[ThumbnailUtil.NEW_THUMBNAIL_ID];
|
|
113
115
|
const existingThumbnailId = eventData[ThumbnailUtil.EXISTING_THUMBNAIL_ID];
|
|
@@ -116,24 +118,31 @@ class ThumbnailUtil {
|
|
|
116
118
|
if (primaryViewableId) {
|
|
117
119
|
await this.entities.delete({ entityName: 'content', id: primaryViewableId });
|
|
118
120
|
}
|
|
119
|
-
|
|
121
|
+
const clearUpdates = await this.getClearPrimaryViewableUpdates();
|
|
122
|
+
console.debug(`syncThumbnailToVibeIQ: returning clear updates for entityId=${entityId}`);
|
|
123
|
+
return clearUpdates;
|
|
120
124
|
}
|
|
121
125
|
if (!thumbnailUrl) {
|
|
126
|
+
console.debug(`syncThumbnailToVibeIQ: no thumbnail URL for entityId=${entityId}`);
|
|
122
127
|
return undefined;
|
|
123
128
|
}
|
|
124
129
|
if (!primaryViewableId) {
|
|
125
130
|
const content = await this.createContentFromFlexPLM(thumbnailUrl, entityId, entityName);
|
|
126
131
|
await this.entities.update({ entityName: 'content', id: content.id, object: { flexplmThumbnailUrl: thumbnailUrl } });
|
|
127
|
-
|
|
132
|
+
const primaryUpdates = await this.getPrimaryViewableUpdates(content);
|
|
133
|
+
console.debug(`syncThumbnailToVibeIQ: created new content ${content.id} for entityId=${entityId}`);
|
|
134
|
+
return primaryUpdates;
|
|
128
135
|
}
|
|
129
136
|
const primaryViewable = await this.entities.get({ entityName: 'content', id: primaryViewableId });
|
|
130
137
|
if (primaryViewable?.flexplmThumbnailUrl === thumbnailUrl) {
|
|
138
|
+
console.debug(`syncThumbnailToVibeIQ: thumbnail already synced for entityId=${entityId}`);
|
|
131
139
|
return undefined;
|
|
132
140
|
}
|
|
133
141
|
const content = await this.createContentFromFlexPLM(thumbnailUrl, entityId, entityName);
|
|
134
142
|
await this.entities.update({ entityName: 'content', id: content.id, object: { flexplmThumbnailUrl: thumbnailUrl } });
|
|
135
143
|
const primaryUpdates = await this.getPrimaryViewableUpdates(content);
|
|
136
144
|
await this.entities.delete({ entityName: 'content', id: primaryViewableId });
|
|
145
|
+
console.debug(`syncThumbnailToVibeIQ: replaced content ${primaryViewableId} with ${content.id} for entityId=${entityId}`);
|
|
137
146
|
return primaryUpdates;
|
|
138
147
|
}
|
|
139
148
|
async createContentFromFlexPLM(thumbnailUrl, entityId, entityName) {
|
package/package.json
CHANGED
package/src/util/mockData.ts
CHANGED
|
@@ -3,22 +3,26 @@ export const four_custom_sizes = [
|
|
|
3
3
|
{
|
|
4
4
|
size: 1000,
|
|
5
5
|
id: '-QwFOWnCs0Gb5jkA',
|
|
6
|
-
slug: 'CS_1000'
|
|
6
|
+
slug: 'CS_1000',
|
|
7
|
+
name: 'CS_1000'
|
|
7
8
|
},
|
|
8
9
|
{
|
|
9
10
|
size: 300,
|
|
10
11
|
id: 'AKXOowvhJRnkerG8',
|
|
11
|
-
slug: 'CS_300'
|
|
12
|
+
slug: 'CS_300',
|
|
13
|
+
name: 'CS_300'
|
|
12
14
|
},
|
|
13
15
|
{
|
|
14
16
|
size: 500,
|
|
15
17
|
id: '9asQ65N188RIYgnh',
|
|
16
|
-
slug: 'CS_500'
|
|
18
|
+
slug: 'CS_500',
|
|
19
|
+
name: 'CS_500'
|
|
17
20
|
},
|
|
18
21
|
{
|
|
19
22
|
size: 800,
|
|
20
23
|
id: 'xkzhwE4nJ6iRwfvP',
|
|
21
|
-
slug: 'CS_800'
|
|
24
|
+
slug: 'CS_800',
|
|
25
|
+
name: 'CS_800'
|
|
22
26
|
}
|
|
23
27
|
];
|
|
24
28
|
|
|
@@ -3,6 +3,11 @@ import { Content, Entities } from '@contrail/sdk';
|
|
|
3
3
|
import { FCConfig } from '../interfaces/interfaces';
|
|
4
4
|
import { FlexPLMConnect } from './flexplm-connect';
|
|
5
5
|
|
|
6
|
+
interface ContentCustomSize {
|
|
7
|
+
id: string;
|
|
8
|
+
slug: string;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
6
11
|
export class ThumbnailUtil {
|
|
7
12
|
private max_thumbnail_size = 5 * 1_024 * 1_024;
|
|
8
13
|
private entities: Entities;
|
|
@@ -55,7 +60,7 @@ export class ThumbnailUtil {
|
|
|
55
60
|
return false;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
|
-
public async getFileId(primaryViewableId: string): Promise<string> {
|
|
63
|
+
public async getFileId(primaryViewableId: string): Promise<string | undefined> {
|
|
59
64
|
console.info('ThumbnailUtil.getFileId()-' + primaryViewableId);
|
|
60
65
|
const sizes = await this.getCustomSizes();
|
|
61
66
|
|
|
@@ -96,16 +101,16 @@ export class ThumbnailUtil {
|
|
|
96
101
|
return fileId;
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
async getCustomSizes() {
|
|
104
|
+
async getCustomSizes(): Promise<ContentCustomSize[]> {
|
|
100
105
|
const customSizes = await this.entities.get({
|
|
101
106
|
entityName: 'content-custom-size'
|
|
102
107
|
});
|
|
103
|
-
const sizes = [];
|
|
108
|
+
const sizes: ContentCustomSize[] = [];
|
|
104
109
|
sizes.push(...customSizes);
|
|
105
110
|
return sizes;
|
|
106
111
|
}
|
|
107
112
|
|
|
108
|
-
async getContentEntity(primaryViewableId: any, sizes:
|
|
113
|
+
async getContentEntity(primaryViewableId: any, sizes: ContentCustomSize[]) {
|
|
109
114
|
const relations = sizes.map(s => s.slug);
|
|
110
115
|
relations.push('primaryFile');
|
|
111
116
|
const content = await this.entities.get({
|
|
@@ -136,6 +141,7 @@ export class ThumbnailUtil {
|
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
async syncThumbnailToVibeIQ({ entityId, primaryViewableId, event, entityName }: { entityId: string; primaryViewableId?: string; event: any; entityName: string }): Promise<any> {
|
|
144
|
+
console.debug(`syncThumbnailToVibeIQ: entityId=${entityId}, primaryViewableId=${primaryViewableId}, entityName=${entityName}`);
|
|
139
145
|
const eventData = event.data || {};
|
|
140
146
|
const newThumbnailId = eventData[ThumbnailUtil.NEW_THUMBNAIL_ID];
|
|
141
147
|
const existingThumbnailId = eventData[ThumbnailUtil.EXISTING_THUMBNAIL_ID];
|
|
@@ -146,11 +152,14 @@ export class ThumbnailUtil {
|
|
|
146
152
|
if (primaryViewableId) {
|
|
147
153
|
await this.entities.delete({ entityName: 'content', id: primaryViewableId });
|
|
148
154
|
}
|
|
149
|
-
|
|
155
|
+
const clearUpdates = await this.getClearPrimaryViewableUpdates();
|
|
156
|
+
console.debug(`syncThumbnailToVibeIQ: returning clear updates for entityId=${entityId}`);
|
|
157
|
+
return clearUpdates;
|
|
150
158
|
}
|
|
151
159
|
|
|
152
160
|
// Early return if no thumbnail URL
|
|
153
161
|
if (!thumbnailUrl) {
|
|
162
|
+
console.debug(`syncThumbnailToVibeIQ: no thumbnail URL for entityId=${entityId}`);
|
|
154
163
|
return undefined;
|
|
155
164
|
}
|
|
156
165
|
|
|
@@ -158,12 +167,15 @@ export class ThumbnailUtil {
|
|
|
158
167
|
if (!primaryViewableId) {
|
|
159
168
|
const content = await this.createContentFromFlexPLM(thumbnailUrl, entityId, entityName);
|
|
160
169
|
await this.entities.update({ entityName: 'content', id: content.id, object: { flexplmThumbnailUrl: thumbnailUrl } });
|
|
161
|
-
|
|
170
|
+
const primaryUpdates = await this.getPrimaryViewableUpdates(content);
|
|
171
|
+
console.debug(`syncThumbnailToVibeIQ: created new content ${content.id} for entityId=${entityId}`);
|
|
172
|
+
return primaryUpdates;
|
|
162
173
|
}
|
|
163
174
|
|
|
164
175
|
// Case 3: Has primaryViewableId — check if thumbnail changed
|
|
165
176
|
const primaryViewable = await this.entities.get({ entityName: 'content', id: primaryViewableId });
|
|
166
177
|
if (primaryViewable?.flexplmThumbnailUrl === thumbnailUrl) {
|
|
178
|
+
console.debug(`syncThumbnailToVibeIQ: thumbnail already synced for entityId=${entityId}`);
|
|
167
179
|
return undefined; // Already synced
|
|
168
180
|
}
|
|
169
181
|
|
|
@@ -171,6 +183,7 @@ export class ThumbnailUtil {
|
|
|
171
183
|
await this.entities.update({ entityName: 'content', id: content.id, object: { flexplmThumbnailUrl: thumbnailUrl } });
|
|
172
184
|
const primaryUpdates = await this.getPrimaryViewableUpdates(content);
|
|
173
185
|
await this.entities.delete({ entityName: 'content', id: primaryViewableId });
|
|
186
|
+
console.debug(`syncThumbnailToVibeIQ: replaced content ${primaryViewableId} with ${content.id} for entityId=${entityId}`);
|
|
174
187
|
return primaryUpdates;
|
|
175
188
|
}
|
|
176
189
|
|