@contrail/flexplm 1.1.34 → 1.1.35

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.
@@ -33,10 +33,11 @@ class ThumbnailUtil {
33
33
  const propertyDiffs = event?.propertyDiffs;
34
34
  if (propertyDiffs) {
35
35
  const diffKeys = Object.keys(propertyDiffs);
36
- const sizeKeys = ThumbnailUtil.OOB_SIZES.map(s => s.slug);
36
+ const sizeKeys = ThumbnailUtil.OOB_SIZES.map(s => s.slug + 'DownloadUrl');
37
37
  if (customSizes) {
38
- sizeKeys.push(...customSizes.map(s => s.slug));
38
+ sizeKeys.push(...customSizes.map(s => s.slug + 'Url'));
39
39
  }
40
+ sizeKeys.push('primaryFileUrl');
40
41
  console.info('diffKeys: ' + JSON.stringify(diffKeys));
41
42
  console.info('sizeKeys: ' + JSON.stringify(sizeKeys));
42
43
  return diffKeys.some(s => sizeKeys.includes(s));
@@ -47,11 +47,6 @@ 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'
55
50
  }
56
51
  }
57
52
  };
@@ -118,7 +113,6 @@ describe('ThumbnailUtil Tests', () => {
118
113
  expect(results).toEqual('AsRvJenpeqxksUNW');
119
114
  });
120
115
  it('custom sizes, 750 * 1_024 max_thumbnail_size - result CS_500Id', async () => {
121
- console.log('custom sizes, 750 * 1_024 max_thumbnail_size - result CS_500Id');
122
116
  const config1 = {
123
117
  max_thumbnail_size: 750 * 1024
124
118
  };
@@ -132,4 +126,89 @@ describe('ThumbnailUtil Tests', () => {
132
126
  expect(results).toEqual('rBaHc1J2xdOWdbhI');
133
127
  });
134
128
  });
129
+ describe('Test isThumbnailNew', () => {
130
+ const tu = new thumbnail_util_1.ThumbnailUtil(config);
131
+ it('no propertyDiffs', () => {
132
+ const event = {
133
+ newData: {
134
+ name: 'Test'
135
+ },
136
+ oldData: {
137
+ name: 'Test'
138
+ }
139
+ };
140
+ const results = tu.isThumbnailNew(event, undefined);
141
+ expect(results).toBeFalsy();
142
+ });
143
+ it('empty propertyDiffs', () => {
144
+ const event = {
145
+ newData: {
146
+ name: 'Test'
147
+ },
148
+ oldData: {
149
+ name: 'Test'
150
+ },
151
+ propertyDiffs: {}
152
+ };
153
+ const results = tu.isThumbnailNew(event, undefined);
154
+ expect(results).toBeFalsy();
155
+ });
156
+ it('propertyDiffs diff property', () => {
157
+ const event = {
158
+ newData: {
159
+ name: 'Test1'
160
+ },
161
+ oldData: {
162
+ name: 'Test'
163
+ },
164
+ propertyDiffs: {
165
+ name: {
166
+ propertyName: 'name',
167
+ oldValue: 'Test',
168
+ newValue: 'Test1'
169
+ }
170
+ }
171
+ };
172
+ const results = tu.isThumbnailNew(event, undefined);
173
+ expect(results).toBeFalsy();
174
+ });
175
+ it('propertyDiffs OOB property', () => {
176
+ const event = {
177
+ newData: {
178
+ name: 'Test1'
179
+ },
180
+ oldData: {
181
+ name: 'Test'
182
+ },
183
+ propertyDiffs: {
184
+ mediumLargeViewableDownloadUrl: {
185
+ propertyName: 'mediumLargeViewableDownloadUrl',
186
+ oldValue: '',
187
+ newValue: 'Test1'
188
+ }
189
+ }
190
+ };
191
+ const results = tu.isThumbnailNew(event, undefined);
192
+ expect(results).toBeTruthy();
193
+ });
194
+ it('propertyDiffs custom property', () => {
195
+ const event = {
196
+ newData: {
197
+ name: 'Test1'
198
+ },
199
+ oldData: {
200
+ name: 'Test'
201
+ },
202
+ propertyDiffs: {
203
+ RL_1000Url: {
204
+ propertyName: 'RL_1000Url',
205
+ oldValue: '',
206
+ newValue: 'Test1'
207
+ }
208
+ }
209
+ };
210
+ const results = tu.isThumbnailNew(event, [{ slug: 'RL_1000' }]);
211
+ expect(results).toBeTruthy();
212
+ });
213
+ });
135
214
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.1.34",
3
+ "version": "1.1.35",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -54,11 +54,6 @@ 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'
62
57
  }
63
58
  }
64
59
  };
@@ -134,7 +129,6 @@ describe('ThumbnailUtil Tests', () =>{
134
129
  });
135
130
 
136
131
  it('custom sizes, 750 * 1_024 max_thumbnail_size - result CS_500Id', async () =>{
137
- console.log('custom sizes, 750 * 1_024 max_thumbnail_size - result CS_500Id');
138
132
  const config1 = {
139
133
  max_thumbnail_size: 750 * 1_024
140
134
  } as any as FCConfig;
@@ -150,4 +144,94 @@ describe('ThumbnailUtil Tests', () =>{
150
144
  });
151
145
 
152
146
  });
147
+
148
+ describe('Test isThumbnailNew', () =>{
149
+ const tu = new ThumbnailUtil(config);
150
+ it('no propertyDiffs', () =>{
151
+ const event = {
152
+ newData: {
153
+ name: 'Test'
154
+ },
155
+ oldData:{
156
+ name: 'Test'
157
+ }
158
+ };
159
+ const results = tu.isThumbnailNew(event, undefined);
160
+ expect(results).toBeFalsy();
161
+ });
162
+
163
+ it('empty propertyDiffs', () =>{
164
+ const event = {
165
+ newData: {
166
+ name: 'Test'
167
+ },
168
+ oldData:{
169
+ name: 'Test'
170
+ },
171
+ propertyDiffs: {}
172
+ };
173
+ const results = tu.isThumbnailNew(event, undefined);
174
+ expect(results).toBeFalsy();
175
+ });
176
+
177
+ it('propertyDiffs diff property', () =>{
178
+ const event = {
179
+ newData: {
180
+ name: 'Test1'
181
+ },
182
+ oldData:{
183
+ name: 'Test'
184
+ },
185
+ propertyDiffs: {
186
+ name: {
187
+ propertyName: 'name',
188
+ oldValue: 'Test',
189
+ newValue: 'Test1'
190
+ }
191
+ }
192
+ };
193
+ const results = tu.isThumbnailNew(event, undefined);
194
+ expect(results).toBeFalsy();
195
+ });
196
+
197
+ it('propertyDiffs OOB property', () =>{
198
+ const event = {
199
+ newData: {
200
+ name: 'Test1'
201
+ },
202
+ oldData:{
203
+ name: 'Test'
204
+ },
205
+ propertyDiffs: {
206
+ mediumLargeViewableDownloadUrl: {
207
+ propertyName: 'mediumLargeViewableDownloadUrl',
208
+ oldValue: '',
209
+ newValue: 'Test1'
210
+ }
211
+ }
212
+ };
213
+ const results = tu.isThumbnailNew(event, undefined);
214
+ expect(results).toBeTruthy();
215
+ });
216
+
217
+ it('propertyDiffs custom property', () =>{
218
+ const event = {
219
+ newData: {
220
+ name: 'Test1'
221
+ },
222
+ oldData:{
223
+ name: 'Test'
224
+ },
225
+ propertyDiffs: {
226
+ RL_1000Url: {
227
+ propertyName: 'RL_1000Url',
228
+ oldValue: '',
229
+ newValue: 'Test1'
230
+ }
231
+ }
232
+ };
233
+ const results = tu.isThumbnailNew(event, [{slug: 'RL_1000'}]);
234
+ expect(results).toBeTruthy();
235
+ });
236
+ });
153
237
  });
@@ -46,10 +46,11 @@ export class ThumbnailUtil {
46
46
  const propertyDiffs = event?.propertyDiffs;
47
47
  if(propertyDiffs){
48
48
  const diffKeys = Object.keys(propertyDiffs);
49
- const sizeKeys = ThumbnailUtil.OOB_SIZES.map( s => s.slug);
49
+ const sizeKeys = ThumbnailUtil.OOB_SIZES.map( s => s.slug + 'DownloadUrl');
50
50
  if(customSizes){
51
- sizeKeys.push(...customSizes.map(s => s.slug));
51
+ sizeKeys.push(...customSizes.map(s => s.slug+ 'Url'));
52
52
  }
53
+ sizeKeys.push('primaryFileUrl');
53
54
  console.info('diffKeys: ' + JSON.stringify(diffKeys));
54
55
  console.info('sizeKeys: ' + JSON.stringify(sizeKeys));
55
56
  return diffKeys.some(s => sizeKeys.includes(s));