@contrail/flexplm 1.1.32 → 1.1.34
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/entity-processor/base-entity-processor.d.ts +1 -0
- package/lib/entity-processor/base-entity-processor.js +11 -4
- package/lib/publish/base-process-publish-assortment.js +22 -26
- package/lib/publish/base-process-publish-assortment.spec.js +8 -8
- package/lib/util/mockData.d.ts +45 -5
- package/lib/util/mockData.js +36 -37
- package/lib/util/thumbnail-util.d.ts +6 -2
- package/lib/util/thumbnail-util.js +45 -40
- package/lib/util/thumbnail-util.spec.js +10 -7
- package/package.json +1 -1
- package/src/entity-processor/base-entity-processor.ts +12 -4
- package/src/publish/base-process-publish-assortment.spec.ts +8 -8
- package/src/publish/base-process-publish-assortment.ts +25 -37
- package/src/util/mockData.ts +35 -36
- package/src/util/thumbnail-util.spec.ts +12 -11
- package/src/util/thumbnail-util.ts +63 -47
|
@@ -28,6 +28,7 @@ export declare abstract class BaseEntityProcessor {
|
|
|
28
28
|
protected abstract getCreateEntity(inboundData: any): Promise<IncomingEntityResponse>;
|
|
29
29
|
outbound(event: any): Promise<any>;
|
|
30
30
|
handleOutgoingUpsert(entityType: any, event: any): Promise<any>;
|
|
31
|
+
getOutboundEntityUpdates(event: any, flexResponse: any): Promise<any>;
|
|
31
32
|
handleOutgoingDelete(entityType: any, event: any): Promise<void>;
|
|
32
33
|
protected abstract getOutgoingUpsertPayload(entityType: any, event: any): Promise<EntityPayloadType>;
|
|
33
34
|
}
|
|
@@ -153,14 +153,21 @@ class BaseEntityProcessor {
|
|
|
153
153
|
}
|
|
154
154
|
const payload = await this.getOutgoingUpsertPayload(entityType, event);
|
|
155
155
|
const flexResponse = await new flexplm_connect_1.FlexPLMConnect(this.config).sendToFlexPLM(payload);
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
const inboundData = await this.getTransformedData(flexPayload);
|
|
159
|
-
const outboundEntityUpdates = await this.getUpdatesForEntity(event.newData, inboundData);
|
|
156
|
+
const outboundEntityUpdates = await this.getOutboundEntityUpdates(event, flexResponse);
|
|
157
|
+
if (outboundEntityUpdates) {
|
|
160
158
|
flexResponse['outboundEntityUpdates'] = outboundEntityUpdates;
|
|
161
159
|
}
|
|
162
160
|
return flexResponse;
|
|
163
161
|
}
|
|
162
|
+
async getOutboundEntityUpdates(event, flexResponse) {
|
|
163
|
+
const flexPayload = flexResponse?.data?.payload[0];
|
|
164
|
+
let outboundEntityUpdates = undefined;
|
|
165
|
+
if (flexPayload && 'OK' === flexPayload.status) {
|
|
166
|
+
const inboundData = await this.getTransformedData(flexPayload);
|
|
167
|
+
outboundEntityUpdates = await this.getUpdatesForEntity(event.newData, inboundData);
|
|
168
|
+
}
|
|
169
|
+
return outboundEntityUpdates;
|
|
170
|
+
}
|
|
164
171
|
async handleOutgoingDelete(entityType, event) {
|
|
165
172
|
console.warn('delete is not configured', entityType, event.oldData);
|
|
166
173
|
}
|
|
@@ -148,50 +148,46 @@ class BaseProcessPublishAssortment {
|
|
|
148
148
|
getSinceDateFromAPCSpecificDate(apcHistory, assortmentPublishChangeId, specificDate) {
|
|
149
149
|
const apc = apcHistory.find(apc => apc['id'] === assortmentPublishChangeId);
|
|
150
150
|
const apcDate = new Date(apc['createdOn']);
|
|
151
|
-
|
|
151
|
+
let afterDate = apcDate;
|
|
152
|
+
let beforeDate = new Date(0);
|
|
153
|
+
const sinceDate = specificDate;
|
|
152
154
|
for (const tempapc of apcHistory) {
|
|
153
155
|
if (assortmentPublishChangeId !== tempapc['id']) {
|
|
154
156
|
const tempDate = new Date(tempapc['createdOn']);
|
|
155
157
|
if (tempDate < apcDate) {
|
|
156
|
-
|
|
158
|
+
if (tempDate > sinceDate && tempDate < afterDate) {
|
|
159
|
+
afterDate = tempDate;
|
|
160
|
+
}
|
|
161
|
+
else if (tempDate < sinceDate && tempDate > beforeDate) {
|
|
162
|
+
beforeDate = tempDate;
|
|
163
|
+
}
|
|
157
164
|
}
|
|
158
165
|
}
|
|
159
166
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const sinceDateMilliseconds = sinceDate.getTime();
|
|
163
|
-
for (const d of dateArray) {
|
|
164
|
-
const milli = Date.parse(d);
|
|
165
|
-
if (milli >= sinceDateMilliseconds) {
|
|
166
|
-
sinceDate = d;
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return sinceDate;
|
|
167
|
+
const selectedDate = (beforeDate.getTime() !== 0) ? beforeDate : afterDate;
|
|
168
|
+
return selectedDate;
|
|
171
169
|
}
|
|
172
170
|
getSinceDateDaysPrevious(apcHistory, assortmentPublishChangeId, daysBack) {
|
|
173
171
|
const apc = apcHistory.find(apc => apc['id'] === assortmentPublishChangeId);
|
|
174
172
|
const apcDate = new Date(apc['createdOn']);
|
|
175
|
-
|
|
173
|
+
let afterDate = apcDate;
|
|
174
|
+
let beforeDate = new Date(0);
|
|
175
|
+
const sinceDate = new Date(apcDate.getUTCFullYear(), apcDate.getUTCMonth(), apcDate.getUTCDate() - daysBack, 0, (0 - apcDate.getTimezoneOffset()), 0);
|
|
176
176
|
for (const tempapc of apcHistory) {
|
|
177
177
|
if (assortmentPublishChangeId !== tempapc['id']) {
|
|
178
178
|
const tempDate = new Date(tempapc['createdOn']);
|
|
179
179
|
if (tempDate < apcDate) {
|
|
180
|
-
|
|
180
|
+
if (tempDate > sinceDate && tempDate < afterDate) {
|
|
181
|
+
afterDate = tempDate;
|
|
182
|
+
}
|
|
183
|
+
else if (tempDate < sinceDate && tempDate > beforeDate) {
|
|
184
|
+
beforeDate = tempDate;
|
|
185
|
+
}
|
|
181
186
|
}
|
|
182
187
|
}
|
|
183
188
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const sinceDateMilliseconds = sinceDate.getTime();
|
|
187
|
-
for (const d of dateArray) {
|
|
188
|
-
const milli = Date.parse(d);
|
|
189
|
-
if (milli >= sinceDateMilliseconds) {
|
|
190
|
-
sinceDate = d;
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return sinceDate;
|
|
189
|
+
const selectedDate = (beforeDate.getTime() !== 0) ? beforeDate : afterDate;
|
|
190
|
+
return selectedDate;
|
|
195
191
|
}
|
|
196
192
|
getSinceDateFromAPCs(apcHistory, assortmentPublishChangeId, pastPublishCount = 1) {
|
|
197
193
|
if (apcHistory.length === 1) {
|
|
@@ -96,7 +96,7 @@ describe('Test getSinceDate', () => {
|
|
|
96
96
|
it('getSinceDate date from config as year', async () => {
|
|
97
97
|
const history = new Array(...mockData_1.plan1_history);
|
|
98
98
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
99
|
-
const matchDate = new Date('2023-01-
|
|
99
|
+
const matchDate = new Date('2023-01-16T21:50:42.742Z');
|
|
100
100
|
const config = { sinceDate: '2023-01-17' };
|
|
101
101
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
102
102
|
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
@@ -120,7 +120,7 @@ describe('Test getSinceDate', () => {
|
|
|
120
120
|
expect(sinceDate).toEqual(matchDate);
|
|
121
121
|
});
|
|
122
122
|
it('getSinceDate date from config numberofdays-cross DST', async () => {
|
|
123
|
-
const count =
|
|
123
|
+
const count = 11;
|
|
124
124
|
const history = new Array(...mockData_1.plan1_across_month_DST);
|
|
125
125
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
126
126
|
const matchDate = new Date('2023-03-06T21:50:42.742Z');
|
|
@@ -163,7 +163,7 @@ describe('getSinceDateFromAPCSpecificDate', () => {
|
|
|
163
163
|
it('last apc - one day', () => {
|
|
164
164
|
const history = new Array(...mockData_1.plan1_history);
|
|
165
165
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
166
|
-
const matchDate = new Date('2023-01-
|
|
166
|
+
const matchDate = new Date('2023-01-16T21:50:42.742Z');
|
|
167
167
|
const config = {};
|
|
168
168
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
169
169
|
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
@@ -174,7 +174,7 @@ describe('getSinceDateFromAPCSpecificDate', () => {
|
|
|
174
174
|
it('apc in the middle - one day', () => {
|
|
175
175
|
const history = new Array(...mockData_1.plan1_history);
|
|
176
176
|
const lastAPCId = 'GiT9CZXZGVljoYMR';
|
|
177
|
-
const matchDate = new Date('2023-01-
|
|
177
|
+
const matchDate = new Date('2023-01-15T19:13:58.902Z');
|
|
178
178
|
const config = {};
|
|
179
179
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
180
180
|
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
@@ -196,7 +196,7 @@ describe('getSinceDateFromAPCSpecificDate', () => {
|
|
|
196
196
|
it('numberofdays at 2 ', () => {
|
|
197
197
|
const history = new Array(...mockData_1.plan1_history);
|
|
198
198
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
199
|
-
const matchDate = new Date('2023-01-
|
|
199
|
+
const matchDate = new Date('2023-01-15T19:13:58.902Z');
|
|
200
200
|
const config = {};
|
|
201
201
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
202
202
|
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
@@ -209,7 +209,7 @@ describe('getSinceDateDaysPrevious', () => {
|
|
|
209
209
|
it('last apc - one day', () => {
|
|
210
210
|
const history = new Array(...mockData_1.plan1_history);
|
|
211
211
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
212
|
-
const matchDate = new Date('2023-01-
|
|
212
|
+
const matchDate = new Date('2023-01-16T21:50:42.742Z');
|
|
213
213
|
const config = {};
|
|
214
214
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
215
215
|
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
@@ -220,7 +220,7 @@ describe('getSinceDateDaysPrevious', () => {
|
|
|
220
220
|
it('apc in the middle - one day', () => {
|
|
221
221
|
const history = new Array(...mockData_1.plan1_history);
|
|
222
222
|
const lastAPCId = 'GiT9CZXZGVljoYMR';
|
|
223
|
-
const matchDate = new Date('2023-01-
|
|
223
|
+
const matchDate = new Date('2023-01-15T19:13:58.902Z');
|
|
224
224
|
const config = {};
|
|
225
225
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
226
226
|
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
@@ -242,7 +242,7 @@ describe('getSinceDateDaysPrevious', () => {
|
|
|
242
242
|
it('numberofdays at 2 ', () => {
|
|
243
243
|
const history = new Array(...mockData_1.plan1_history);
|
|
244
244
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
245
|
-
const matchDate = new Date('2023-01-
|
|
245
|
+
const matchDate = new Date('2023-01-15T19:13:58.902Z');
|
|
246
246
|
const config = {};
|
|
247
247
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
248
248
|
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
package/lib/util/mockData.d.ts
CHANGED
|
@@ -8,22 +8,67 @@ export declare const thumbnail_content_entity: {
|
|
|
8
8
|
fileName: string;
|
|
9
9
|
primaryFileId: string;
|
|
10
10
|
primaryFileUrl: string;
|
|
11
|
+
primaryFile: {
|
|
12
|
+
fileName: string;
|
|
13
|
+
id: string;
|
|
14
|
+
size: number;
|
|
15
|
+
};
|
|
11
16
|
tinyViewableId: string;
|
|
12
17
|
tinyViewableUrl: string;
|
|
18
|
+
tinyViewable: {
|
|
19
|
+
fileName: string;
|
|
20
|
+
id: string;
|
|
21
|
+
size: number;
|
|
22
|
+
};
|
|
13
23
|
smallViewableId: string;
|
|
14
24
|
smallViewableUrl: string;
|
|
25
|
+
smallViewable: {
|
|
26
|
+
fileName: string;
|
|
27
|
+
id: string;
|
|
28
|
+
size: number;
|
|
29
|
+
};
|
|
15
30
|
mediumViewableId: string;
|
|
16
31
|
mediumViewableUrl: string;
|
|
32
|
+
mediumViewable: {
|
|
33
|
+
fileName: string;
|
|
34
|
+
id: string;
|
|
35
|
+
size: number;
|
|
36
|
+
};
|
|
17
37
|
largeViewableId: string;
|
|
18
38
|
largeViewableUrl: string;
|
|
39
|
+
largeViewable: {
|
|
40
|
+
fileName: string;
|
|
41
|
+
id: string;
|
|
42
|
+
size: number;
|
|
43
|
+
};
|
|
19
44
|
CS_300Id: string;
|
|
20
45
|
CS_300Url: string;
|
|
46
|
+
CS_300: {
|
|
47
|
+
fileName: string;
|
|
48
|
+
id: string;
|
|
49
|
+
size: number;
|
|
50
|
+
};
|
|
21
51
|
CS_500Id: string;
|
|
22
52
|
CS_500Url: string;
|
|
53
|
+
CS_500: {
|
|
54
|
+
fileName: string;
|
|
55
|
+
id: string;
|
|
56
|
+
size: number;
|
|
57
|
+
};
|
|
23
58
|
CS_800Id: string;
|
|
24
59
|
CS_800Url: string;
|
|
60
|
+
CS_800: {
|
|
61
|
+
fileName: string;
|
|
62
|
+
id: string;
|
|
63
|
+
size: number;
|
|
64
|
+
};
|
|
25
65
|
CS_1000Id: string;
|
|
26
66
|
CS_1000Url: string;
|
|
67
|
+
CS_1000: {
|
|
68
|
+
fileName: string;
|
|
69
|
+
id: string;
|
|
70
|
+
size: number;
|
|
71
|
+
};
|
|
27
72
|
createdOn: string;
|
|
28
73
|
orgId: string;
|
|
29
74
|
id: string;
|
|
@@ -32,8 +77,3 @@ export declare const thumbnail_content_entity: {
|
|
|
32
77
|
updatedById: string;
|
|
33
78
|
fileSize: number;
|
|
34
79
|
};
|
|
35
|
-
export declare const cuRficeyoStwTF_f_fileEntities: {
|
|
36
|
-
fileName: string;
|
|
37
|
-
id: string;
|
|
38
|
-
size: number;
|
|
39
|
-
}[];
|
package/lib/util/mockData.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.thumbnail_content_entity = exports.four_custom_sizes = exports.empty_custom_sizes = void 0;
|
|
4
4
|
exports.empty_custom_sizes = [];
|
|
5
5
|
exports.four_custom_sizes = [
|
|
6
6
|
{
|
|
@@ -28,73 +28,72 @@ exports.thumbnail_content_entity = {
|
|
|
28
28
|
fileName: 'JACKET 300_SOLDIER OLIVE.png',
|
|
29
29
|
primaryFileId: 'yn2d5oHD4rXHRzyB',
|
|
30
30
|
primaryFileUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Ff646d3cd-e23a-4689-bd16-0301d2036720.png',
|
|
31
|
-
|
|
32
|
-
tinyViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb68f8652-f33f-452f-ae34-25397b4521eb.png',
|
|
33
|
-
smallViewableId: 'D3WRW4iRmjLzp5VX',
|
|
34
|
-
smallViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F541c53f8-fd85-418e-ae28-ad7410658b90.png',
|
|
35
|
-
mediumViewableId: 'AsRvJenpeqxksUNW',
|
|
36
|
-
mediumViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fe803c2d3-3e1b-4d9c-9bb9-2c488f1f295b.png',
|
|
37
|
-
largeViewableId: 'vo4N4mCd-tFrw101',
|
|
38
|
-
largeViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb1b7a55c-b8ba-4857-be4e-e1c3f11d8e9a.png',
|
|
39
|
-
CS_300Id: '6A5AG33nVu3Z6ogO',
|
|
40
|
-
CS_300Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F3f2ea306-a77f-4cc3-a49a-75fb5d8b113c.png',
|
|
41
|
-
CS_500Id: 'rBaHc1J2xdOWdbhI',
|
|
42
|
-
CS_500Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F979c8c65-b63f-4220-aa2e-11520f2f68bf.png',
|
|
43
|
-
CS_800Id: 'ZPAeYI3JiqjQ7unY',
|
|
44
|
-
CS_800Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fc58eeffa-2592-4698-a058-19281cda447c.png',
|
|
45
|
-
CS_1000Id: 'Hg_CthwsD4ozopCb',
|
|
46
|
-
CS_1000Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F2c827c7b-361b-4e05-b77d-4280294f9d9c.png',
|
|
47
|
-
createdOn: '2023-07-05T15:02:13.950Z',
|
|
48
|
-
orgId: '5LZnKVTNxvwMqufy',
|
|
49
|
-
id: 'cuRficeyoStwTF-f',
|
|
50
|
-
contentType: 'image/png',
|
|
51
|
-
createdById: 'SWIFPZeZzkBvrSLD',
|
|
52
|
-
updatedById: 'SWIFPZeZzkBvrSLD',
|
|
53
|
-
fileSize: 1757973
|
|
54
|
-
};
|
|
55
|
-
exports.cuRficeyoStwTF_f_fileEntities = [
|
|
56
|
-
{
|
|
31
|
+
primaryFile: {
|
|
57
32
|
fileName: 'JACKET 300_SOLDIER OLIVE.png',
|
|
58
33
|
id: 'yn2d5oHD4rXHRzyB',
|
|
59
34
|
size: 1757973
|
|
60
35
|
},
|
|
61
|
-
|
|
36
|
+
tinyViewableId: '6HWzJrQ-Jx1iefmj',
|
|
37
|
+
tinyViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb68f8652-f33f-452f-ae34-25397b4521eb.png',
|
|
38
|
+
tinyViewable: {
|
|
62
39
|
fileName: 'JACKET 300_SOLDIER OLIVE_tiny.png',
|
|
63
40
|
id: '6HWzJrQ-Jx1iefmj',
|
|
64
41
|
size: 1784
|
|
65
42
|
},
|
|
66
|
-
|
|
43
|
+
smallViewableId: 'D3WRW4iRmjLzp5VX',
|
|
44
|
+
smallViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F541c53f8-fd85-418e-ae28-ad7410658b90.png',
|
|
45
|
+
smallViewable: {
|
|
67
46
|
fileName: 'JACKET 300_SOLDIER OLIVE_small.png',
|
|
68
47
|
id: 'D3WRW4iRmjLzp5VX',
|
|
69
48
|
size: 8699
|
|
70
49
|
},
|
|
71
|
-
|
|
50
|
+
mediumViewableId: 'AsRvJenpeqxksUNW',
|
|
51
|
+
mediumViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fe803c2d3-3e1b-4d9c-9bb9-2c488f1f295b.png',
|
|
52
|
+
mediumViewable: {
|
|
72
53
|
fileName: 'JACKET 300_SOLDIER OLIVE_medium.png',
|
|
73
54
|
id: 'AsRvJenpeqxksUNW',
|
|
74
55
|
size: 77558
|
|
75
56
|
},
|
|
76
|
-
|
|
57
|
+
largeViewableId: 'vo4N4mCd-tFrw101',
|
|
58
|
+
largeViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb1b7a55c-b8ba-4857-be4e-e1c3f11d8e9a.png',
|
|
59
|
+
largeViewable: {
|
|
77
60
|
fileName: 'JACKET 300_SOLDIER OLIVE_large.png',
|
|
78
61
|
id: 'vo4N4mCd-tFrw101',
|
|
79
62
|
size: 1781538
|
|
80
63
|
},
|
|
81
|
-
|
|
64
|
+
CS_300Id: '6A5AG33nVu3Z6ogO',
|
|
65
|
+
CS_300Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F3f2ea306-a77f-4cc3-a49a-75fb5d8b113c.png',
|
|
66
|
+
CS_300: {
|
|
82
67
|
fileName: 'JACKET 300_SOLDIER OLIVE_CS_300.png',
|
|
83
68
|
id: '6A5AG33nVu3Z6ogO',
|
|
84
69
|
size: 141153
|
|
85
70
|
},
|
|
86
|
-
|
|
71
|
+
CS_500Id: 'rBaHc1J2xdOWdbhI',
|
|
72
|
+
CS_500Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F979c8c65-b63f-4220-aa2e-11520f2f68bf.png',
|
|
73
|
+
CS_500: {
|
|
87
74
|
fileName: 'JACKET 300_SOLDIER OLIVE_CS_500.png',
|
|
88
75
|
id: 'rBaHc1J2xdOWdbhI',
|
|
89
76
|
size: 382057
|
|
90
77
|
},
|
|
91
|
-
|
|
78
|
+
CS_800Id: 'ZPAeYI3JiqjQ7unY',
|
|
79
|
+
CS_800Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fc58eeffa-2592-4698-a058-19281cda447c.png',
|
|
80
|
+
CS_800: {
|
|
92
81
|
fileName: 'JACKET 300_SOLDIER OLIVE_CS_800.png',
|
|
93
82
|
id: 'ZPAeYI3JiqjQ7unY',
|
|
94
83
|
size: 1008702
|
|
95
|
-
},
|
|
84
|
+
},
|
|
85
|
+
CS_1000Id: 'Hg_CthwsD4ozopCb',
|
|
86
|
+
CS_1000Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F2c827c7b-361b-4e05-b77d-4280294f9d9c.png',
|
|
87
|
+
CS_1000: {
|
|
96
88
|
fileName: 'JACKET 300_SOLDIER OLIVE_CS_1000.png',
|
|
97
89
|
id: 'Hg_CthwsD4ozopCb',
|
|
98
90
|
size: 1605889
|
|
99
|
-
}
|
|
100
|
-
|
|
91
|
+
},
|
|
92
|
+
createdOn: '2023-07-05T15:02:13.950Z',
|
|
93
|
+
orgId: '5LZnKVTNxvwMqufy',
|
|
94
|
+
id: 'cuRficeyoStwTF-f',
|
|
95
|
+
contentType: 'image/png',
|
|
96
|
+
createdById: 'SWIFPZeZzkBvrSLD',
|
|
97
|
+
updatedById: 'SWIFPZeZzkBvrSLD',
|
|
98
|
+
fileSize: 1757973
|
|
99
|
+
};
|
|
@@ -6,10 +6,14 @@ export declare class ThumbnailUtil {
|
|
|
6
6
|
static NEW_THUMBNAIL_ID: string;
|
|
7
7
|
static EXISTING_THUMBNAIL_ID: string;
|
|
8
8
|
static REMOVE_THUMBNAIL: string;
|
|
9
|
+
static OOB_SIZES: {
|
|
10
|
+
slug: string;
|
|
11
|
+
}[];
|
|
9
12
|
constructor(config: FCConfig);
|
|
10
13
|
setOutboundThumbnail(data: any, event: any): Promise<any>;
|
|
14
|
+
isThumbnailNew(event: any, customSizes: any[]): boolean;
|
|
11
15
|
getFileId(primaryViewableId: string): Promise<string>;
|
|
12
16
|
getCustomSizes(): Promise<any[]>;
|
|
13
|
-
getContentEntity(primaryViewableId: any): Promise<any>;
|
|
14
|
-
|
|
17
|
+
getContentEntity(primaryViewableId: any, sizes: any[]): Promise<any>;
|
|
18
|
+
logContentResults(content: any, relations: string[]): void;
|
|
15
19
|
}
|
|
@@ -17,7 +17,8 @@ class ThumbnailUtil {
|
|
|
17
17
|
const primaryViewableId = event.newData.primaryViewableId;
|
|
18
18
|
const fileId = await this.getFileId(primaryViewableId);
|
|
19
19
|
if (fileId) {
|
|
20
|
-
const
|
|
20
|
+
const customSizes = await this.getCustomSizes();
|
|
21
|
+
const key = (this.isThumbnailNew(event, customSizes))
|
|
21
22
|
? ThumbnailUtil.NEW_THUMBNAIL_ID
|
|
22
23
|
: ThumbnailUtil.EXISTING_THUMBNAIL_ID;
|
|
23
24
|
data[key] = fileId;
|
|
@@ -28,42 +29,43 @@ class ThumbnailUtil {
|
|
|
28
29
|
}
|
|
29
30
|
return data;
|
|
30
31
|
}
|
|
32
|
+
isThumbnailNew(event, customSizes) {
|
|
33
|
+
const propertyDiffs = event?.propertyDiffs;
|
|
34
|
+
if (propertyDiffs) {
|
|
35
|
+
const diffKeys = Object.keys(propertyDiffs);
|
|
36
|
+
const sizeKeys = ThumbnailUtil.OOB_SIZES.map(s => s.slug);
|
|
37
|
+
if (customSizes) {
|
|
38
|
+
sizeKeys.push(...customSizes.map(s => s.slug));
|
|
39
|
+
}
|
|
40
|
+
console.info('diffKeys: ' + JSON.stringify(diffKeys));
|
|
41
|
+
console.info('sizeKeys: ' + JSON.stringify(sizeKeys));
|
|
42
|
+
return diffKeys.some(s => sizeKeys.includes(s));
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
31
46
|
async getFileId(primaryViewableId) {
|
|
32
|
-
console.info('getFileId()-' + primaryViewableId);
|
|
47
|
+
console.info('ThumbnailUtil.getFileId()-' + primaryViewableId);
|
|
33
48
|
const sizes = await this.getCustomSizes();
|
|
34
|
-
const OOBSizes =
|
|
49
|
+
const OOBSizes = JSON.parse(JSON.stringify(ThumbnailUtil.OOB_SIZES));
|
|
35
50
|
sizes.push(...OOBSizes);
|
|
36
51
|
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
|
-
}
|
|
52
|
+
const content = await this.getContentEntity(primaryViewableId, sizes);
|
|
41
53
|
if (!content) {
|
|
42
54
|
return undefined;
|
|
43
55
|
}
|
|
44
56
|
const contentKeys = Object.getOwnPropertyNames(content);
|
|
45
|
-
const
|
|
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];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const fileResults = await this.getFileEntities(fileEntityIds);
|
|
54
|
-
if (app_framework_1.Logger.isDebugOn()) {
|
|
55
|
-
console.debug('fileResults: ' + JSON.stringify(fileResults));
|
|
56
|
-
}
|
|
57
|
+
const isDebugOn = app_framework_1.Logger.isDebugOn();
|
|
57
58
|
let fileId = undefined;
|
|
58
59
|
let tempFileSize = 0;
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
for (const size of sizes) {
|
|
61
|
+
const slug = size?.slug;
|
|
62
|
+
if (contentKeys.includes(slug)) {
|
|
63
|
+
const file = content[slug];
|
|
64
|
+
if (isDebugOn) {
|
|
65
|
+
console.debug('size: ' + slug);
|
|
66
|
+
console.debug('fileId: ' + file['id']);
|
|
67
|
+
}
|
|
68
|
+
if (file && file['size'] > tempFileSize && file['size'] < this.max_thumbnail_size) {
|
|
67
69
|
tempFileSize = file['size'];
|
|
68
70
|
fileId = file['id'];
|
|
69
71
|
if (isDebugOn) {
|
|
@@ -72,7 +74,7 @@ class ThumbnailUtil {
|
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
console.info('getFileId(): returning-' + fileId);
|
|
77
|
+
console.info('ThumbnailUtil.getFileId(): returning-' + fileId);
|
|
76
78
|
return fileId;
|
|
77
79
|
}
|
|
78
80
|
async getCustomSizes() {
|
|
@@ -83,30 +85,33 @@ class ThumbnailUtil {
|
|
|
83
85
|
sizes.push(...customSizes);
|
|
84
86
|
return sizes;
|
|
85
87
|
}
|
|
86
|
-
async getContentEntity(primaryViewableId) {
|
|
88
|
+
async getContentEntity(primaryViewableId, sizes) {
|
|
87
89
|
const criteria = {
|
|
88
90
|
id: primaryViewableId
|
|
89
91
|
};
|
|
92
|
+
const relations = sizes.map(s => s.slug);
|
|
93
|
+
relations.push('primaryFile');
|
|
90
94
|
const contentResults = await this.entities.get({
|
|
91
95
|
entityName: 'content',
|
|
92
|
-
criteria
|
|
96
|
+
criteria,
|
|
97
|
+
relations
|
|
93
98
|
});
|
|
94
|
-
console.info('contentResults: ' + JSON.stringify(contentResults));
|
|
95
99
|
const content = (contentResults && contentResults[0]) ? contentResults[0] : undefined;
|
|
100
|
+
this.logContentResults(content, relations);
|
|
96
101
|
return content;
|
|
97
102
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
return fileResults;
|
|
103
|
+
logContentResults(content, relations) {
|
|
104
|
+
if (app_framework_1.Logger.isDebugOn()) {
|
|
105
|
+
const contentCopy = JSON.parse(JSON.stringify(content));
|
|
106
|
+
relations.forEach(r => {
|
|
107
|
+
delete contentCopy[r];
|
|
108
|
+
});
|
|
109
|
+
console.debug('content: ' + JSON.stringify(contentCopy));
|
|
110
|
+
}
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
exports.ThumbnailUtil = ThumbnailUtil;
|
|
110
114
|
ThumbnailUtil.NEW_THUMBNAIL_ID = 'NEW_THUMBNAIL_ID';
|
|
111
115
|
ThumbnailUtil.EXISTING_THUMBNAIL_ID = 'EXISTING_THUMBNAIL_ID';
|
|
112
116
|
ThumbnailUtil.REMOVE_THUMBNAIL = 'REMOVE_THUMBNAIL';
|
|
117
|
+
ThumbnailUtil.OOB_SIZES = [{ slug: 'largeViewable' }, { slug: 'mediumLargeViewable' }, { slug: 'mediumViewable' }, { slug: 'smallViewable' }, { slug: 'tinyViewable' }];
|
|
@@ -47,9 +47,16 @@ describe('ThumbnailUtil Tests', () => {
|
|
|
47
47
|
largeViewableDownloadUrl: {
|
|
48
48
|
newValue: newDownloadUrl,
|
|
49
49
|
oldValue: oldDownloadUrl
|
|
50
|
+
},
|
|
51
|
+
largeViewable: {
|
|
52
|
+
propertyName: 'largeViewable',
|
|
53
|
+
oldValue: '',
|
|
54
|
+
newValue: 'Test1'
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
};
|
|
58
|
+
const spyCustomSizes = jest.spyOn(tu, 'getCustomSizes');
|
|
59
|
+
spyCustomSizes.mockReturnValue(Promise.resolve(mockData_1.empty_custom_sizes));
|
|
53
60
|
const spyGetFileId = jest.spyOn(tu, 'getFileId');
|
|
54
61
|
spyGetFileId.mockReturnValue(Promise.resolve(thumbnailId));
|
|
55
62
|
const results = await tu.setOutboundThumbnail(data, event);
|
|
@@ -70,6 +77,8 @@ describe('ThumbnailUtil Tests', () => {
|
|
|
70
77
|
},
|
|
71
78
|
propertyDiffs: {}
|
|
72
79
|
};
|
|
80
|
+
const spyCustomSizes = jest.spyOn(tu, 'getCustomSizes');
|
|
81
|
+
spyCustomSizes.mockReturnValue(Promise.resolve(mockData_1.empty_custom_sizes));
|
|
73
82
|
const spyGetFileId = jest.spyOn(tu, 'getFileId');
|
|
74
83
|
spyGetFileId.mockReturnValue(Promise.resolve(thumbnailId));
|
|
75
84
|
const results = await tu.setOutboundThumbnail(data, event);
|
|
@@ -90,10 +99,8 @@ describe('ThumbnailUtil Tests', () => {
|
|
|
90
99
|
const spyCustomSizes = jest.spyOn(tu, 'getCustomSizes');
|
|
91
100
|
spyCustomSizes.mockReturnValue(Promise.resolve(mockData_1.empty_custom_sizes));
|
|
92
101
|
const spyContentEntity = jest.spyOn(tu, 'getContentEntity');
|
|
93
|
-
const content = mockData_1.thumbnail_content_entity;
|
|
102
|
+
const content = JSON.parse(JSON.stringify(mockData_1.thumbnail_content_entity));
|
|
94
103
|
spyContentEntity.mockReturnValue(Promise.resolve(content));
|
|
95
|
-
const spyGetFileEntities = jest.spyOn(tu, 'getFileEntities');
|
|
96
|
-
spyGetFileEntities.mockReturnValue(Promise.resolve(mockData_1.cuRficeyoStwTF_f_fileEntities));
|
|
97
104
|
const results = await tu.getFileId(primaryFileId);
|
|
98
105
|
expect(results).toEqual('vo4N4mCd-tFrw101');
|
|
99
106
|
});
|
|
@@ -107,8 +114,6 @@ describe('ThumbnailUtil Tests', () => {
|
|
|
107
114
|
const spyContentEntity = jest.spyOn(tu, 'getContentEntity');
|
|
108
115
|
const content = mockData_1.thumbnail_content_entity;
|
|
109
116
|
spyContentEntity.mockReturnValue(Promise.resolve(content));
|
|
110
|
-
const spyGetFileEntities = jest.spyOn(tu, 'getFileEntities');
|
|
111
|
-
spyGetFileEntities.mockReturnValue(Promise.resolve(mockData_1.cuRficeyoStwTF_f_fileEntities));
|
|
112
117
|
const results = await tu.getFileId(primaryFileId);
|
|
113
118
|
expect(results).toEqual('AsRvJenpeqxksUNW');
|
|
114
119
|
});
|
|
@@ -123,8 +128,6 @@ describe('ThumbnailUtil Tests', () => {
|
|
|
123
128
|
const spyContentEntity = jest.spyOn(tu, 'getContentEntity');
|
|
124
129
|
const content = mockData_1.thumbnail_content_entity;
|
|
125
130
|
spyContentEntity.mockReturnValue(Promise.resolve(content));
|
|
126
|
-
const spyGetFileEntities = jest.spyOn(tu, 'getFileEntities');
|
|
127
|
-
spyGetFileEntities.mockReturnValue(Promise.resolve(mockData_1.cuRficeyoStwTF_f_fileEntities));
|
|
128
131
|
const results = await tu.getFileId(primaryFileId);
|
|
129
132
|
expect(results).toEqual('rBaHc1J2xdOWdbhI');
|
|
130
133
|
});
|
package/package.json
CHANGED
|
@@ -199,16 +199,24 @@ export abstract class BaseEntityProcessor {
|
|
|
199
199
|
const payload = await this.getOutgoingUpsertPayload(entityType, event);
|
|
200
200
|
const flexResponse: any = await new FlexPLMConnect(this.config).sendToFlexPLM(payload);
|
|
201
201
|
|
|
202
|
-
const
|
|
203
|
-
if(
|
|
204
|
-
const inboundData = await this.getTransformedData(flexPayload);
|
|
205
|
-
const outboundEntityUpdates = await this.getUpdatesForEntity(event.newData, inboundData)
|
|
202
|
+
const outboundEntityUpdates = await this.getOutboundEntityUpdates(event, flexResponse);
|
|
203
|
+
if(outboundEntityUpdates){
|
|
206
204
|
flexResponse['outboundEntityUpdates'] = outboundEntityUpdates;
|
|
207
205
|
}
|
|
208
206
|
|
|
209
207
|
return flexResponse;
|
|
210
208
|
}
|
|
211
209
|
|
|
210
|
+
async getOutboundEntityUpdates(event, flexResponse): Promise<any> {
|
|
211
|
+
const flexPayload = flexResponse?.data?.payload[0];
|
|
212
|
+
let outboundEntityUpdates = undefined;
|
|
213
|
+
if(flexPayload && 'OK' === flexPayload.status) {
|
|
214
|
+
const inboundData = await this.getTransformedData(flexPayload);
|
|
215
|
+
outboundEntityUpdates = await this.getUpdatesForEntity(event.newData, inboundData)
|
|
216
|
+
}
|
|
217
|
+
return outboundEntityUpdates;
|
|
218
|
+
}
|
|
219
|
+
|
|
212
220
|
async handleOutgoingDelete(entityType, event) {
|
|
213
221
|
console.warn('delete is not configured', entityType, event.oldData);
|
|
214
222
|
}
|
|
@@ -105,7 +105,7 @@ describe('Test getSinceDate', () =>{
|
|
|
105
105
|
it('getSinceDate date from config as year', async () =>{
|
|
106
106
|
const history = new Array(...plan1_history);
|
|
107
107
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
108
|
-
const matchDate = new Date('2023-01-
|
|
108
|
+
const matchDate = new Date('2023-01-16T21:50:42.742Z');
|
|
109
109
|
|
|
110
110
|
const config = {sinceDate: '2023-01-17' } as any as FCConfig;
|
|
111
111
|
|
|
@@ -133,7 +133,7 @@ describe('Test getSinceDate', () =>{
|
|
|
133
133
|
expect(sinceDate).toEqual(matchDate);
|
|
134
134
|
});
|
|
135
135
|
it('getSinceDate date from config numberofdays-cross DST', async () =>{
|
|
136
|
-
const count =
|
|
136
|
+
const count = 11;
|
|
137
137
|
const history = new Array(...plan1_across_month_DST);
|
|
138
138
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
139
139
|
const matchDate = new Date('2023-03-06T21:50:42.742Z');
|
|
@@ -178,7 +178,7 @@ describe('getSinceDateFromAPCSpecificDate', () =>{
|
|
|
178
178
|
it('last apc - one day', () =>{
|
|
179
179
|
const history = new Array(...plan1_history);
|
|
180
180
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
181
|
-
const matchDate = new Date('2023-01-
|
|
181
|
+
const matchDate = new Date('2023-01-16T21:50:42.742Z');
|
|
182
182
|
|
|
183
183
|
const config = {} as FCConfig;
|
|
184
184
|
const mapFileUtil = new MapFileUtil(new Entities());
|
|
@@ -192,7 +192,7 @@ describe('getSinceDateFromAPCSpecificDate', () =>{
|
|
|
192
192
|
it('apc in the middle - one day', () =>{
|
|
193
193
|
const history = new Array(...plan1_history);
|
|
194
194
|
const lastAPCId = 'GiT9CZXZGVljoYMR';
|
|
195
|
-
const matchDate = new Date('2023-01-
|
|
195
|
+
const matchDate = new Date('2023-01-15T19:13:58.902Z');
|
|
196
196
|
|
|
197
197
|
const config = {} as FCConfig;
|
|
198
198
|
const mapFileUtil = new MapFileUtil(new Entities());
|
|
@@ -216,7 +216,7 @@ describe('getSinceDateFromAPCSpecificDate', () =>{
|
|
|
216
216
|
it('numberofdays at 2 ', () => {
|
|
217
217
|
const history = new Array(...plan1_history);
|
|
218
218
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
219
|
-
const matchDate = new Date('2023-01-
|
|
219
|
+
const matchDate = new Date('2023-01-15T19:13:58.902Z');
|
|
220
220
|
const config = {} as FCConfig;
|
|
221
221
|
const mapFileUtil = new MapFileUtil(new Entities());
|
|
222
222
|
const dc = new DataConverter(config, mapFileUtil);
|
|
@@ -231,7 +231,7 @@ describe('getSinceDateDaysPrevious', () =>{
|
|
|
231
231
|
it('last apc - one day', () =>{
|
|
232
232
|
const history = new Array(...plan1_history);
|
|
233
233
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
234
|
-
const matchDate = new Date('2023-01-
|
|
234
|
+
const matchDate = new Date('2023-01-16T21:50:42.742Z');
|
|
235
235
|
|
|
236
236
|
const config = {} as FCConfig;
|
|
237
237
|
const mapFileUtil = new MapFileUtil(new Entities());
|
|
@@ -245,7 +245,7 @@ describe('getSinceDateDaysPrevious', () =>{
|
|
|
245
245
|
it('apc in the middle - one day', () =>{
|
|
246
246
|
const history = new Array(...plan1_history);
|
|
247
247
|
const lastAPCId = 'GiT9CZXZGVljoYMR';
|
|
248
|
-
const matchDate = new Date('2023-01-
|
|
248
|
+
const matchDate = new Date('2023-01-15T19:13:58.902Z');
|
|
249
249
|
|
|
250
250
|
const config = {} as FCConfig;
|
|
251
251
|
const mapFileUtil = new MapFileUtil(new Entities());
|
|
@@ -269,7 +269,7 @@ describe('getSinceDateDaysPrevious', () =>{
|
|
|
269
269
|
it('numberofdays at 2 ', () => {
|
|
270
270
|
const history = new Array(...plan1_history);
|
|
271
271
|
const lastAPCId = 'sJbGx1Fpq1v2MmcI';
|
|
272
|
-
const matchDate = new Date('2023-01-
|
|
272
|
+
const matchDate = new Date('2023-01-15T19:13:58.902Z');
|
|
273
273
|
const config = {} as FCConfig;
|
|
274
274
|
const mapFileUtil = new MapFileUtil(new Entities());
|
|
275
275
|
const dc = new DataConverter(config, mapFileUtil);
|
|
@@ -178,47 +178,30 @@ export class BaseProcessPublishAssortment {
|
|
|
178
178
|
getSinceDateFromAPCSpecificDate(apcHistory: object[], assortmentPublishChangeId: string, specificDate: Date):Date {
|
|
179
179
|
const apc = apcHistory.find(apc => apc['id'] === assortmentPublishChangeId);
|
|
180
180
|
const apcDate = new Date(apc['createdOn']);
|
|
181
|
-
|
|
181
|
+
let afterDate = apcDate;
|
|
182
|
+
let beforeDate = new Date(0);
|
|
183
|
+
const sinceDate = specificDate;
|
|
182
184
|
for (const tempapc of apcHistory) {
|
|
183
185
|
if (assortmentPublishChangeId !== tempapc['id']) {
|
|
184
186
|
const tempDate = new Date(tempapc['createdOn']);
|
|
185
187
|
if (tempDate < apcDate) {
|
|
186
|
-
|
|
188
|
+
if(tempDate > sinceDate && tempDate < afterDate){
|
|
189
|
+
afterDate = tempDate;
|
|
190
|
+
} else if(tempDate < sinceDate && tempDate > beforeDate){
|
|
191
|
+
beforeDate = tempDate;
|
|
192
|
+
}
|
|
187
193
|
}
|
|
188
194
|
}
|
|
189
195
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
let sinceDate = specificDate;
|
|
194
|
-
|
|
195
|
-
const sinceDateMilliseconds = sinceDate.getTime();
|
|
196
|
-
for(const d of dateArray){
|
|
197
|
-
const milli = Date.parse(d);
|
|
198
|
-
if(milli >= sinceDateMilliseconds){
|
|
199
|
-
sinceDate = d;
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return sinceDate;
|
|
204
|
-
|
|
196
|
+
const selectedDate = (beforeDate.getTime() !== 0)?beforeDate : afterDate;
|
|
197
|
+
return selectedDate;
|
|
205
198
|
}
|
|
206
199
|
getSinceDateDaysPrevious(apcHistory: object[], assortmentPublishChangeId: string, daysBack):Date {
|
|
207
200
|
const apc = apcHistory.find(apc => apc['id'] === assortmentPublishChangeId);
|
|
208
201
|
const apcDate = new Date(apc['createdOn']);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const tempDate = new Date(tempapc['createdOn']);
|
|
213
|
-
if (tempDate < apcDate) {
|
|
214
|
-
dateArray.push(tempDate);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
dateArray.sort((a,b) => { return Date.parse(a) - Date.parse(b);});
|
|
220
|
-
|
|
221
|
-
let sinceDate = new Date(
|
|
202
|
+
let afterDate = apcDate;
|
|
203
|
+
let beforeDate = new Date(0);
|
|
204
|
+
const sinceDate = new Date(
|
|
222
205
|
apcDate.getUTCFullYear(),
|
|
223
206
|
apcDate.getUTCMonth(),
|
|
224
207
|
apcDate.getUTCDate()-daysBack,
|
|
@@ -226,15 +209,20 @@ export class BaseProcessPublishAssortment {
|
|
|
226
209
|
(0 - apcDate.getTimezoneOffset()),
|
|
227
210
|
0);
|
|
228
211
|
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
212
|
+
for (const tempapc of apcHistory) {
|
|
213
|
+
if (assortmentPublishChangeId !== tempapc['id']) {
|
|
214
|
+
const tempDate = new Date(tempapc['createdOn']);
|
|
215
|
+
if (tempDate < apcDate) {
|
|
216
|
+
if(tempDate > sinceDate && tempDate < afterDate){
|
|
217
|
+
afterDate = tempDate;
|
|
218
|
+
} else if(tempDate < sinceDate && tempDate > beforeDate){
|
|
219
|
+
beforeDate = tempDate;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
235
222
|
}
|
|
236
223
|
}
|
|
237
|
-
|
|
224
|
+
const selectedDate = (beforeDate.getTime() !== 0)?beforeDate : afterDate;
|
|
225
|
+
return selectedDate;
|
|
238
226
|
}
|
|
239
227
|
|
|
240
228
|
getSinceDateFromAPCs(apcHistory: any[], assortmentPublishChangeId: string, pastPublishCount = 1): Date {
|
package/src/util/mockData.ts
CHANGED
|
@@ -26,73 +26,72 @@ export const thumbnail_content_entity = {
|
|
|
26
26
|
fileName: 'JACKET 300_SOLDIER OLIVE.png',
|
|
27
27
|
primaryFileId: 'yn2d5oHD4rXHRzyB',
|
|
28
28
|
primaryFileUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Ff646d3cd-e23a-4689-bd16-0301d2036720.png',
|
|
29
|
-
|
|
30
|
-
tinyViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb68f8652-f33f-452f-ae34-25397b4521eb.png',
|
|
31
|
-
smallViewableId: 'D3WRW4iRmjLzp5VX',
|
|
32
|
-
smallViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F541c53f8-fd85-418e-ae28-ad7410658b90.png',
|
|
33
|
-
mediumViewableId: 'AsRvJenpeqxksUNW',
|
|
34
|
-
mediumViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fe803c2d3-3e1b-4d9c-9bb9-2c488f1f295b.png',
|
|
35
|
-
largeViewableId: 'vo4N4mCd-tFrw101',
|
|
36
|
-
largeViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb1b7a55c-b8ba-4857-be4e-e1c3f11d8e9a.png',
|
|
37
|
-
CS_300Id: '6A5AG33nVu3Z6ogO',
|
|
38
|
-
CS_300Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F3f2ea306-a77f-4cc3-a49a-75fb5d8b113c.png',
|
|
39
|
-
CS_500Id: 'rBaHc1J2xdOWdbhI',
|
|
40
|
-
CS_500Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F979c8c65-b63f-4220-aa2e-11520f2f68bf.png',
|
|
41
|
-
CS_800Id: 'ZPAeYI3JiqjQ7unY',
|
|
42
|
-
CS_800Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fc58eeffa-2592-4698-a058-19281cda447c.png',
|
|
43
|
-
CS_1000Id: 'Hg_CthwsD4ozopCb',
|
|
44
|
-
CS_1000Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F2c827c7b-361b-4e05-b77d-4280294f9d9c.png',
|
|
45
|
-
createdOn: '2023-07-05T15:02:13.950Z',
|
|
46
|
-
orgId: '5LZnKVTNxvwMqufy',
|
|
47
|
-
id: 'cuRficeyoStwTF-f',
|
|
48
|
-
contentType: 'image/png',
|
|
49
|
-
createdById: 'SWIFPZeZzkBvrSLD',
|
|
50
|
-
updatedById: 'SWIFPZeZzkBvrSLD',
|
|
51
|
-
fileSize: 1757973
|
|
52
|
-
};
|
|
53
|
-
export const cuRficeyoStwTF_f_fileEntities = [
|
|
54
|
-
{
|
|
29
|
+
primaryFile: {
|
|
55
30
|
fileName: 'JACKET 300_SOLDIER OLIVE.png',
|
|
56
31
|
id: 'yn2d5oHD4rXHRzyB',
|
|
57
32
|
size: 1757973
|
|
58
33
|
},
|
|
59
|
-
|
|
34
|
+
tinyViewableId: '6HWzJrQ-Jx1iefmj',
|
|
35
|
+
tinyViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb68f8652-f33f-452f-ae34-25397b4521eb.png',
|
|
36
|
+
tinyViewable: {
|
|
60
37
|
fileName: 'JACKET 300_SOLDIER OLIVE_tiny.png',
|
|
61
38
|
id: '6HWzJrQ-Jx1iefmj',
|
|
62
39
|
size: 1784
|
|
63
40
|
},
|
|
64
|
-
|
|
41
|
+
smallViewableId: 'D3WRW4iRmjLzp5VX',
|
|
42
|
+
smallViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F541c53f8-fd85-418e-ae28-ad7410658b90.png',
|
|
43
|
+
smallViewable: {
|
|
65
44
|
fileName: 'JACKET 300_SOLDIER OLIVE_small.png',
|
|
66
45
|
id: 'D3WRW4iRmjLzp5VX',
|
|
67
46
|
size: 8699
|
|
68
47
|
},
|
|
69
|
-
|
|
48
|
+
mediumViewableId: 'AsRvJenpeqxksUNW',
|
|
49
|
+
mediumViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fe803c2d3-3e1b-4d9c-9bb9-2c488f1f295b.png',
|
|
50
|
+
mediumViewable: {
|
|
70
51
|
fileName: 'JACKET 300_SOLDIER OLIVE_medium.png',
|
|
71
52
|
id: 'AsRvJenpeqxksUNW',
|
|
72
53
|
size: 77558
|
|
73
54
|
},
|
|
74
|
-
|
|
55
|
+
largeViewableId: 'vo4N4mCd-tFrw101',
|
|
56
|
+
largeViewableUrl: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fb1b7a55c-b8ba-4857-be4e-e1c3f11d8e9a.png',
|
|
57
|
+
largeViewable: {
|
|
75
58
|
fileName: 'JACKET 300_SOLDIER OLIVE_large.png',
|
|
76
59
|
id: 'vo4N4mCd-tFrw101',
|
|
77
60
|
size: 1781538
|
|
78
61
|
},
|
|
79
|
-
|
|
62
|
+
CS_300Id: '6A5AG33nVu3Z6ogO',
|
|
63
|
+
CS_300Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F3f2ea306-a77f-4cc3-a49a-75fb5d8b113c.png',
|
|
64
|
+
CS_300: {
|
|
80
65
|
fileName: 'JACKET 300_SOLDIER OLIVE_CS_300.png',
|
|
81
66
|
id: '6A5AG33nVu3Z6ogO',
|
|
82
67
|
size: 141153
|
|
83
68
|
},
|
|
84
|
-
|
|
69
|
+
CS_500Id: 'rBaHc1J2xdOWdbhI',
|
|
70
|
+
CS_500Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F979c8c65-b63f-4220-aa2e-11520f2f68bf.png',
|
|
71
|
+
CS_500: {
|
|
85
72
|
fileName: 'JACKET 300_SOLDIER OLIVE_CS_500.png',
|
|
86
73
|
id: 'rBaHc1J2xdOWdbhI',
|
|
87
74
|
size: 382057
|
|
88
75
|
},
|
|
89
|
-
|
|
76
|
+
CS_800Id: 'ZPAeYI3JiqjQ7unY',
|
|
77
|
+
CS_800Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2Fc58eeffa-2592-4698-a058-19281cda447c.png',
|
|
78
|
+
CS_800:{
|
|
90
79
|
fileName: 'JACKET 300_SOLDIER OLIVE_CS_800.png',
|
|
91
80
|
id: 'ZPAeYI3JiqjQ7unY',
|
|
92
81
|
size: 1008702
|
|
93
|
-
},
|
|
82
|
+
},
|
|
83
|
+
CS_1000Id: 'Hg_CthwsD4ozopCb',
|
|
84
|
+
CS_1000Url: 'https://api.vibeiq.com/prod/api/files/downloadUrl/5LZnKVTNxvwMqufy%2Fcontent:cuRficeyoStwTF-f%2F2c827c7b-361b-4e05-b77d-4280294f9d9c.png',
|
|
85
|
+
CS_1000: {
|
|
94
86
|
fileName: 'JACKET 300_SOLDIER OLIVE_CS_1000.png',
|
|
95
87
|
id: 'Hg_CthwsD4ozopCb',
|
|
96
88
|
size: 1605889
|
|
97
|
-
}
|
|
98
|
-
|
|
89
|
+
},
|
|
90
|
+
createdOn: '2023-07-05T15:02:13.950Z',
|
|
91
|
+
orgId: '5LZnKVTNxvwMqufy',
|
|
92
|
+
id: 'cuRficeyoStwTF-f',
|
|
93
|
+
contentType: 'image/png',
|
|
94
|
+
createdById: 'SWIFPZeZzkBvrSLD',
|
|
95
|
+
updatedById: 'SWIFPZeZzkBvrSLD',
|
|
96
|
+
fileSize: 1757973
|
|
97
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FCConfig } from '../interfaces/interfaces';
|
|
2
2
|
import { ThumbnailUtil } from './thumbnail-util';
|
|
3
3
|
|
|
4
|
-
import { empty_custom_sizes, four_custom_sizes, thumbnail_content_entity
|
|
4
|
+
import { empty_custom_sizes, four_custom_sizes, thumbnail_content_entity } from './mockData';
|
|
5
5
|
|
|
6
6
|
describe('ThumbnailUtil Tests', () =>{
|
|
7
7
|
const config = {} as FCConfig;
|
|
@@ -54,10 +54,17 @@ describe('ThumbnailUtil Tests', () =>{
|
|
|
54
54
|
largeViewableDownloadUrl :{
|
|
55
55
|
newValue: newDownloadUrl,
|
|
56
56
|
oldValue: oldDownloadUrl
|
|
57
|
+
},
|
|
58
|
+
largeViewable: {
|
|
59
|
+
propertyName: 'largeViewable',
|
|
60
|
+
oldValue: '',
|
|
61
|
+
newValue: 'Test1'
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
};
|
|
60
65
|
|
|
66
|
+
const spyCustomSizes = jest.spyOn(tu, 'getCustomSizes');
|
|
67
|
+
spyCustomSizes.mockReturnValue(Promise.resolve(empty_custom_sizes));
|
|
61
68
|
const spyGetFileId = jest.spyOn(tu, 'getFileId');
|
|
62
69
|
spyGetFileId.mockReturnValue(Promise.resolve(thumbnailId));
|
|
63
70
|
const results = await tu.setOutboundThumbnail(data, event);
|
|
@@ -80,6 +87,8 @@ describe('ThumbnailUtil Tests', () =>{
|
|
|
80
87
|
propertyDiffs: {}
|
|
81
88
|
};
|
|
82
89
|
|
|
90
|
+
const spyCustomSizes = jest.spyOn(tu, 'getCustomSizes');
|
|
91
|
+
spyCustomSizes.mockReturnValue(Promise.resolve(empty_custom_sizes));
|
|
83
92
|
const spyGetFileId = jest.spyOn(tu, 'getFileId');
|
|
84
93
|
spyGetFileId.mockReturnValue(Promise.resolve(thumbnailId));
|
|
85
94
|
const results = await tu.setOutboundThumbnail(data, event);
|
|
@@ -101,11 +110,9 @@ describe('ThumbnailUtil Tests', () =>{
|
|
|
101
110
|
const spyCustomSizes = jest.spyOn(tu, 'getCustomSizes');
|
|
102
111
|
spyCustomSizes.mockReturnValue(Promise.resolve(empty_custom_sizes));
|
|
103
112
|
const spyContentEntity = jest.spyOn(tu, 'getContentEntity');
|
|
104
|
-
const content = thumbnail_content_entity;
|
|
105
|
-
spyContentEntity.mockReturnValue(Promise.resolve(content));
|
|
113
|
+
const content = JSON.parse(JSON.stringify(thumbnail_content_entity));
|
|
106
114
|
|
|
107
|
-
|
|
108
|
-
spyGetFileEntities.mockReturnValue(Promise.resolve(cuRficeyoStwTF_f_fileEntities));
|
|
115
|
+
spyContentEntity.mockReturnValue(Promise.resolve(content));
|
|
109
116
|
|
|
110
117
|
const results = await tu.getFileId(primaryFileId);
|
|
111
118
|
expect(results).toEqual('vo4N4mCd-tFrw101');
|
|
@@ -122,9 +129,6 @@ describe('ThumbnailUtil Tests', () =>{
|
|
|
122
129
|
const content = thumbnail_content_entity;
|
|
123
130
|
spyContentEntity.mockReturnValue(Promise.resolve(content));
|
|
124
131
|
|
|
125
|
-
const spyGetFileEntities = jest.spyOn(tu, 'getFileEntities');
|
|
126
|
-
spyGetFileEntities.mockReturnValue(Promise.resolve(cuRficeyoStwTF_f_fileEntities));
|
|
127
|
-
|
|
128
132
|
const results = await tu.getFileId(primaryFileId);
|
|
129
133
|
expect(results).toEqual('AsRvJenpeqxksUNW');
|
|
130
134
|
});
|
|
@@ -141,9 +145,6 @@ describe('ThumbnailUtil Tests', () =>{
|
|
|
141
145
|
const content = thumbnail_content_entity;
|
|
142
146
|
spyContentEntity.mockReturnValue(Promise.resolve(content));
|
|
143
147
|
|
|
144
|
-
const spyGetFileEntities = jest.spyOn(tu, 'getFileEntities');
|
|
145
|
-
spyGetFileEntities.mockReturnValue(Promise.resolve(cuRficeyoStwTF_f_fileEntities));
|
|
146
|
-
|
|
147
148
|
const results = await tu.getFileId(primaryFileId);
|
|
148
149
|
expect(results).toEqual('rBaHc1J2xdOWdbhI');
|
|
149
150
|
});
|
|
@@ -8,6 +8,7 @@ export class ThumbnailUtil {
|
|
|
8
8
|
static NEW_THUMBNAIL_ID = 'NEW_THUMBNAIL_ID';
|
|
9
9
|
static EXISTING_THUMBNAIL_ID = 'EXISTING_THUMBNAIL_ID';
|
|
10
10
|
static REMOVE_THUMBNAIL = 'REMOVE_THUMBNAIL';
|
|
11
|
+
static OOB_SIZES = [{ slug: 'largeViewable' }, { slug: 'mediumLargeViewable' }, { slug: 'mediumViewable' }, { slug: 'smallViewable' }, { slug: 'tinyViewable' }]
|
|
11
12
|
constructor(private config: FCConfig){
|
|
12
13
|
this.entities = new Entities();
|
|
13
14
|
if(this.config['max_thumbnail_size']){
|
|
@@ -22,7 +23,8 @@ export class ThumbnailUtil {
|
|
|
22
23
|
const fileId = await this.getFileId(primaryViewableId);
|
|
23
24
|
|
|
24
25
|
if(fileId){
|
|
25
|
-
const
|
|
26
|
+
const customSizes = await this.getCustomSizes();
|
|
27
|
+
const key = (this.isThumbnailNew(event, customSizes))
|
|
26
28
|
? ThumbnailUtil.NEW_THUMBNAIL_ID
|
|
27
29
|
: ThumbnailUtil.EXISTING_THUMBNAIL_ID;
|
|
28
30
|
data[key] = fileId;
|
|
@@ -33,52 +35,57 @@ export class ThumbnailUtil {
|
|
|
33
35
|
}
|
|
34
36
|
return data;
|
|
35
37
|
}
|
|
38
|
+
/** Determines if a new image has been generated. If any viewable is new, there might be a better
|
|
39
|
+
* sized image. So send the fileId as new.
|
|
40
|
+
*
|
|
41
|
+
* @param event
|
|
42
|
+
* @param customSizes
|
|
43
|
+
* @returns boolean
|
|
44
|
+
*/
|
|
45
|
+
public isThumbnailNew(event, customSizes: any[]): boolean {
|
|
46
|
+
const propertyDiffs = event?.propertyDiffs;
|
|
47
|
+
if(propertyDiffs){
|
|
48
|
+
const diffKeys = Object.keys(propertyDiffs);
|
|
49
|
+
const sizeKeys = ThumbnailUtil.OOB_SIZES.map( s => s.slug);
|
|
50
|
+
if(customSizes){
|
|
51
|
+
sizeKeys.push(...customSizes.map(s => s.slug));
|
|
52
|
+
}
|
|
53
|
+
console.info('diffKeys: ' + JSON.stringify(diffKeys));
|
|
54
|
+
console.info('sizeKeys: ' + JSON.stringify(sizeKeys));
|
|
55
|
+
return diffKeys.some(s => sizeKeys.includes(s));
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
36
59
|
|
|
37
60
|
public async getFileId(primaryViewableId: string): Promise<string> {
|
|
38
|
-
console.info('getFileId()-' + primaryViewableId);
|
|
61
|
+
console.info('ThumbnailUtil.getFileId()-' + primaryViewableId);
|
|
39
62
|
const sizes = await this.getCustomSizes();
|
|
40
63
|
|
|
41
|
-
const OOBSizes =
|
|
64
|
+
const OOBSizes = JSON.parse(JSON.stringify(ThumbnailUtil.OOB_SIZES));
|
|
42
65
|
sizes.push(...OOBSizes);
|
|
43
66
|
console.info('sizes: ' + JSON.stringify(sizes));
|
|
44
67
|
|
|
45
68
|
//get Content
|
|
46
|
-
const content = await this.getContentEntity(primaryViewableId);
|
|
47
|
-
if(Logger.isDebugOn()){
|
|
48
|
-
console.debug('content: ' + JSON.stringify(content));
|
|
49
|
-
|
|
50
|
-
}
|
|
69
|
+
const content = await this.getContentEntity(primaryViewableId, sizes);
|
|
51
70
|
if (!content) {
|
|
52
71
|
return undefined;
|
|
53
72
|
}
|
|
54
|
-
//get file entities
|
|
55
|
-
const contentKeys = Object.getOwnPropertyNames(content);
|
|
56
|
-
const fileEntityIds = [];
|
|
57
|
-
for (const size of sizes) {
|
|
58
|
-
const key = size.slug + 'Id';
|
|
59
|
-
if (contentKeys.includes(key) && !fileEntityIds.includes(content[key])) {
|
|
60
|
-
fileEntityIds.push(content[key]);
|
|
61
|
-
size['fileId'] = content[key];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const fileResults = await this.getFileEntities(fileEntityIds);
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
74
|
+
const contentKeys = Object.getOwnPropertyNames(content);
|
|
75
|
+
const isDebugOn = Logger.isDebugOn();
|
|
70
76
|
|
|
71
|
-
// Finding largest image that is under the max limit
|
|
72
77
|
let fileId = undefined;
|
|
73
78
|
let tempFileSize = 0;
|
|
74
|
-
|
|
75
|
-
for
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
|
|
80
|
+
for(const size of sizes){
|
|
81
|
+
const slug = size?.slug;
|
|
82
|
+
if(contentKeys.includes(slug)){
|
|
83
|
+
const file = content[slug];
|
|
84
|
+
if(isDebugOn){
|
|
85
|
+
console.debug('size: ' + slug);
|
|
86
|
+
console.debug('fileId: ' + file['id']);
|
|
87
|
+
}
|
|
88
|
+
if(file && file['size'] > tempFileSize && file['size'] < this.max_thumbnail_size){
|
|
82
89
|
tempFileSize = file['size'];
|
|
83
90
|
fileId = file['id'];
|
|
84
91
|
if(isDebugOn){
|
|
@@ -87,7 +94,7 @@ export class ThumbnailUtil {
|
|
|
87
94
|
}
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
|
-
console.info('getFileId(): returning-' + fileId);
|
|
97
|
+
console.info('ThumbnailUtil.getFileId(): returning-' + fileId);
|
|
91
98
|
return fileId;
|
|
92
99
|
}
|
|
93
100
|
|
|
@@ -100,29 +107,38 @@ export class ThumbnailUtil {
|
|
|
100
107
|
return sizes;
|
|
101
108
|
}
|
|
102
109
|
|
|
103
|
-
async getContentEntity(primaryViewableId: any) {
|
|
110
|
+
async getContentEntity(primaryViewableId: any, sizes: any[]) {
|
|
104
111
|
const criteria = {
|
|
105
112
|
id: primaryViewableId
|
|
106
113
|
};
|
|
114
|
+
const relations = sizes.map(s => s.slug);
|
|
115
|
+
relations.push('primaryFile');
|
|
107
116
|
const contentResults = await this.entities.get({
|
|
108
117
|
entityName: 'content',
|
|
109
|
-
criteria
|
|
118
|
+
criteria,
|
|
119
|
+
relations
|
|
110
120
|
});
|
|
111
|
-
console.info('contentResults: ' + JSON.stringify(contentResults));
|
|
112
121
|
const content = (contentResults && contentResults[0]) ? contentResults[0] : undefined;
|
|
122
|
+
this.logContentResults(content, relations);
|
|
113
123
|
return content;
|
|
114
124
|
}
|
|
115
125
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
/** This outputs the content entity, without the inflated file entities.
|
|
127
|
+
* To help debugging issues with sending the thumbnail info.
|
|
128
|
+
* The inflated entities are removed, because are large and cause
|
|
129
|
+
* problems with log file size limits.
|
|
130
|
+
*
|
|
131
|
+
* @param content: the content with inflated objects
|
|
132
|
+
* @param relations: string[] of the slugs for inflated objects
|
|
133
|
+
*/
|
|
134
|
+
logContentResults(content: any, relations: string[]) {
|
|
135
|
+
if(Logger.isDebugOn()){
|
|
136
|
+
const contentCopy = JSON.parse(JSON.stringify(content));
|
|
137
|
+
relations.forEach(r => {
|
|
138
|
+
delete contentCopy[r];
|
|
139
|
+
});
|
|
140
|
+
console.debug('content: ' + JSON.stringify(contentCopy));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
127
143
|
|
|
128
144
|
}
|