@contrail/flexplm 1.2.1 → 1.3.0-alpha.3

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.
Files changed (57) hide show
  1. package/.claude/settings.local.json +1 -2
  2. package/.github/pull_request_template.md +31 -31
  3. package/.github/workflows/flexplm-lib.yml +27 -27
  4. package/lib/entity-processor/base-entity-processor.js +16 -2
  5. package/lib/entity-processor/base-entity-processor.spec.js +124 -0
  6. package/lib/util/flexplm-connect.d.ts +5 -1
  7. package/lib/util/flexplm-connect.js +8 -3
  8. package/lib/util/flexplm-connect.spec.d.ts +1 -0
  9. package/lib/util/flexplm-connect.spec.js +88 -0
  10. package/lib/util/thumbnail-util.d.ts +9 -0
  11. package/lib/util/thumbnail-util.js +88 -0
  12. package/lib/util/thumbnail-util.spec.js +156 -0
  13. package/lib/util/type-conversion-utils-spec-mockData.js +18 -0
  14. package/lib/util/type-conversion-utils.d.ts +2 -0
  15. package/lib/util/type-conversion-utils.js +43 -0
  16. package/lib/util/type-conversion-utils.spec.js +160 -0
  17. package/package.json +1 -1
  18. package/publish.bat +4 -4
  19. package/publish.sh +4 -4
  20. package/src/entity-processor/base-entity-processor.spec.ts +157 -0
  21. package/src/entity-processor/base-entity-processor.ts +21 -2
  22. package/src/flexplm-request.ts +28 -28
  23. package/src/flexplm-utils.spec.ts +27 -27
  24. package/src/flexplm-utils.ts +29 -29
  25. package/src/index.ts +21 -21
  26. package/src/interfaces/item-family-changes.ts +66 -66
  27. package/src/interfaces/publish-change-data.ts +42 -42
  28. package/src/publish/base-process-publish-assortment-callback.ts +50 -50
  29. package/src/transform/identifier-conversion-spec-mockData.ts +495 -495
  30. package/src/transform/identifier-conversion.spec.ts +353 -353
  31. package/src/transform/identifier-conversion.ts +281 -281
  32. package/src/util/config-defaults.spec.ts +350 -350
  33. package/src/util/config-defaults.ts +92 -92
  34. package/src/util/data-converter-spec-mockData.ts +230 -230
  35. package/src/util/error-response-object.spec.ts +115 -115
  36. package/src/util/error-response-object.ts +49 -49
  37. package/src/util/federation.ts +172 -172
  38. package/src/util/flexplm-connect.spec.ts +132 -0
  39. package/src/util/flexplm-connect.ts +14 -5
  40. package/src/util/logger-config.ts +19 -19
  41. package/src/util/map-util-spec-mockData.ts +230 -230
  42. package/src/util/map-utils.spec.ts +102 -102
  43. package/src/util/map-utils.ts +40 -40
  44. package/src/util/mockData.ts +97 -97
  45. package/src/util/thumbnail-util.spec.ts +190 -0
  46. package/src/util/thumbnail-util.ts +109 -1
  47. package/src/util/type-conversion-utils-spec-mockData.ts +18 -0
  48. package/src/util/type-conversion-utils.spec.ts +184 -0
  49. package/src/util/type-conversion-utils.ts +75 -0
  50. package/src/util/type-defaults.spec.ts +668 -668
  51. package/src/util/type-defaults.ts +280 -280
  52. package/src/util/type-utils.spec.ts +227 -227
  53. package/src/util/type-utils.ts +144 -144
  54. package/tsconfig.json +28 -26
  55. package/tslint.json +57 -57
  56. package/scripts/output.png +0 -0
  57. package/scripts/test-get-request.ts +0 -35
@@ -1,281 +1,281 @@
1
- export class TypeDefaults {
2
- static NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';
3
- static NO_OBJECT_CLASS = 'Please ensure that the flexPLMObjectClass property is provided.';
4
- static NO_TYPE_PATH = 'Please ensure that the flexPLMTypePath property is provided.';
5
- constructor() {
6
- }
7
- /**Takes in full entity and returs the default FlexPLM
8
- * object class.
9
- *
10
- * @param entity
11
- * @returns string
12
- */
13
- static getDefaultObjectClass(entity): string {
14
- const entityType = this.getEntityType(entity);
15
- let objectClass = '';
16
- if ('item' === entityType) {
17
- if (entity.roles.includes('family')) {
18
- objectClass = 'LCSProduct';
19
- } else if (entity.roles.includes('color')) {
20
- objectClass = 'LCSSKU';
21
- }
22
- } else if ('project-item' === entityType) {
23
- if (entity.roles.includes('family')) {
24
- objectClass = 'LCSProductSeasonLink';
25
- } else if (entity.roles.includes('color')) {
26
- objectClass = 'LCSSKUSeasonLink';
27
- }
28
- } else if ('color' === entityType) {
29
- objectClass = 'LCSColor';
30
- } else if ('custom-entity' === entityType) {
31
- objectClass = 'LCSRevisableEntity';
32
- } else if ('project' === entityType) {
33
- objectClass = 'LCSSeason';
34
- } else if ('assortment' === entityType) {
35
- if('LCSSeason' === entity.flex2vibeMapKeyRoot || entity.publishToFlexPLM){
36
- objectClass = 'LCSSeason';
37
- }else{
38
- objectClass = 'SeasonGroup';
39
- }
40
- }
41
- return objectClass;
42
-
43
- }
44
-
45
- /**Takes in full entity and returns the default FlexPLM type path
46
- * object class.
47
- *
48
- * @param entity
49
- * @returns string
50
- */
51
- static getDefaultObjectTypePath(entity): string {
52
- let typePath = '';
53
- const entityType = this.getEntityType(entity);
54
-
55
- switch (entityType) {
56
- case 'item':
57
- case 'project-item':
58
- typePath = 'Product';
59
- break;
60
- case 'color':
61
- typePath = 'Color';
62
- break;
63
- case 'custom-entity':
64
- typePath = 'Revisable Entity';
65
- break;
66
- case 'project':
67
- typePath = 'Season';
68
- break;
69
- case 'assortment':
70
- if('LCSSeason' === entity.flex2vibeMapKeyRoot || entity.publishToFlexPLM){
71
- typePath = 'Season';
72
- }else{
73
- typePath = 'Season Group';
74
- }
75
- break;
76
- }
77
-
78
- return typePath;
79
- }
80
-
81
- /**Takes in full entity and returns the slugs for the default identifier
82
- * properties. These properties are used when searching for an entity
83
- * object class.
84
- *
85
- * @param entity
86
- * @returns string[]
87
- */
88
-
89
- static getDefaultIdentifierProperties(entity): string[] {
90
- const identifierProps = [];
91
- const entityType = this.getEntityType(entity);
92
-
93
- switch (entityType) {
94
- case 'item':
95
- identifierProps.push('itemNumber');
96
- break;
97
- case 'project':
98
- identifierProps.push('flexPLMSeasonName');
99
- break;
100
- case 'assortment':
101
- if('LCSSeason' === entity.flex2vibeMapKeyRoot ||entity.publishToFlexPLM){
102
- identifierProps.push('flexPLMSeasonName');
103
- }else{
104
- identifierProps.push('seasonGroupName');
105
- }
106
- break;
107
- case 'color':
108
- case 'custom-entity':
109
- identifierProps.push('name');
110
- break;
111
- }
112
-
113
- return identifierProps;
114
- }
115
-
116
- /** Takes in full entity and returns the slugs for informational
117
- * properties. These properties are helpful when debugging issues
118
- * where the identifier properties don't find a match.
119
- *
120
- * @param entity
121
- * @returns string[]
122
- */
123
- static getDefaultInformationalProperties(entity): string[] {
124
- const entityType = this.getEntityType(entity);
125
- let properties:string[] = [];
126
- if ('item' === entityType) {
127
- if (entity.roles.includes('family')) {
128
- properties.push('name');
129
- } else if (entity.roles.includes('color')) {
130
- properties.push('optionName');
131
- }
132
- } else if (['project', 'assortment'].includes(entityType)) {
133
- properties.push('name');
134
- }
135
- return properties;
136
-
137
- }
138
-
139
- /** Returns the VibeIQ entity type from an entity.
140
- * Throws error if it can't determine the entity type
141
- *
142
- * @param entity
143
- * @returns string
144
- */
145
- static getEntityType(entity: any) {
146
- let entityType = entity['entityType'];
147
- if (!entityType) {
148
- const typePath: string = entity['typePath'];
149
- if (typePath) {
150
- const types = typePath.split(':');
151
- if (types && types[0]) {
152
- entityType = types[0];
153
- }
154
- }
155
- }
156
- if (!entityType) {
157
- throw Error(TypeDefaults.NO_ENTITY_TYPE);
158
- }
159
- return entityType;
160
- }
161
-
162
- /**Takes in full object and returns the default VibeIQ
163
- * entity class.
164
- *
165
- * @param entity
166
- * @returns string
167
- */
168
- static getDefaultEntityClass(object): string {
169
- let entityClass = '';
170
- let objectClass = TypeDefaults.getObjectClass(object);
171
- if(['LCSProduct', 'LCSSKU'].includes(objectClass)){
172
- entityClass = 'item';
173
- }else if(['LCSProductSeasonLink', 'LCSSKUSeasonLink'].includes(objectClass)){
174
- entityClass = 'project-item'
175
- } else if('LCSColor' === objectClass){
176
- entityClass = 'color';
177
- } else if(['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
178
- entityClass = 'assortment';
179
- } else if(['LCSRevisableEntity', 'LCSLifecycleManaged', 'LCSLast', 'LCSMaterial'].includes(objectClass)) {
180
- entityClass = 'custom-entity';
181
- }
182
-
183
- if(entityClass === '')
184
- throw Error(TypeDefaults.NO_OBJECT_CLASS);
185
-
186
- return entityClass;
187
- }
188
-
189
- /**Takes in full object and returns the default VibeIQ type path
190
- * object class.
191
- *
192
- * @param object
193
- * @returns string
194
- */
195
- static getDefaultEntityTypePath(object): string {
196
- let typePath = '';
197
- const objectClass = TypeDefaults.getObjectClass(object);
198
-
199
- switch (objectClass) {
200
- case 'LCSProduct':
201
- case 'LCSSKU':
202
- typePath = 'item';
203
- break;
204
- case 'LCSProductSeasonLink':
205
- case 'LCSSKUSeasonLink':
206
- typePath = 'project-item';
207
- break;
208
- case 'LCSColor':
209
- typePath = 'color';
210
- break;
211
- case 'LCSSeason':
212
- case 'SeasonGroup':
213
- typePath = 'assortment';
214
- break;
215
- }
216
-
217
- if(typePath === '')
218
- throw Error(TypeDefaults.NO_TYPE_PATH);
219
-
220
- return typePath;
221
- }
222
-
223
- /**Takes in full entity and returns the slugs for the default identifier
224
- * properties. These properties are used when searching for an entity
225
- * object class.
226
- *
227
- * @param entity
228
- * @returns string[]
229
- */
230
-
231
- static getDefaultIdentifierPropertiesFromObject(object): string[] {
232
- const identifierProps = [];
233
- const objectClass = TypeDefaults.getObjectClass(object);
234
-
235
- switch (objectClass) {
236
- case 'LCSProduct':
237
- case 'LCSSKU':
238
- identifierProps.push('itemNumber');
239
- break;
240
- case 'LCSSeason':
241
- identifierProps.push('flexPLMSeasonName');
242
- break;
243
- case 'SeasonGroup':
244
- identifierProps.push('seasonGroupName');
245
- break;
246
- case 'LCSColor':
247
- case 'LCSRevisableEntity':
248
- case 'LCSLifecycleManaged':
249
- case 'LCSLast':
250
- case 'LCSMaterial':
251
- identifierProps.push('name');
252
- break;
253
- }
254
-
255
- return identifierProps;
256
- }
257
-
258
- /** Takes in full object and returns the slugs for informational
259
- * properties. These properties are helpful when debugging issues
260
- * where the identifier properties don't find a match.
261
- *
262
- * @param object
263
- * @returns string[]
264
- */
265
- static getDefaultInformationalPropertiesFromObject(object): string[] {
266
- const objectClass = TypeDefaults.getObjectClass(object);
267
- let properties:string[] = [];
268
- if ('LCSProduct' === objectClass) {
269
- properties.push('name');
270
- } else if ('LCSSKU' === objectClass) {
271
- properties.push('optionName');
272
- } else if (['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
273
- properties.push('name');
274
- }
275
- return properties;
276
- }
277
-
278
- static getObjectClass(object: any): string {
279
- return (object)? object['flexPLMObjectClass']: '';
280
- }
1
+ export class TypeDefaults {
2
+ static NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';
3
+ static NO_OBJECT_CLASS = 'Please ensure that the flexPLMObjectClass property is provided.';
4
+ static NO_TYPE_PATH = 'Please ensure that the flexPLMTypePath property is provided.';
5
+ constructor() {
6
+ }
7
+ /**Takes in full entity and returs the default FlexPLM
8
+ * object class.
9
+ *
10
+ * @param entity
11
+ * @returns string
12
+ */
13
+ static getDefaultObjectClass(entity): string {
14
+ const entityType = this.getEntityType(entity);
15
+ let objectClass = '';
16
+ if ('item' === entityType) {
17
+ if (entity.roles.includes('family')) {
18
+ objectClass = 'LCSProduct';
19
+ } else if (entity.roles.includes('color')) {
20
+ objectClass = 'LCSSKU';
21
+ }
22
+ } else if ('project-item' === entityType) {
23
+ if (entity.roles.includes('family')) {
24
+ objectClass = 'LCSProductSeasonLink';
25
+ } else if (entity.roles.includes('color')) {
26
+ objectClass = 'LCSSKUSeasonLink';
27
+ }
28
+ } else if ('color' === entityType) {
29
+ objectClass = 'LCSColor';
30
+ } else if ('custom-entity' === entityType) {
31
+ objectClass = 'LCSRevisableEntity';
32
+ } else if ('project' === entityType) {
33
+ objectClass = 'LCSSeason';
34
+ } else if ('assortment' === entityType) {
35
+ if('LCSSeason' === entity.flex2vibeMapKeyRoot || entity.publishToFlexPLM){
36
+ objectClass = 'LCSSeason';
37
+ }else{
38
+ objectClass = 'SeasonGroup';
39
+ }
40
+ }
41
+ return objectClass;
42
+
43
+ }
44
+
45
+ /**Takes in full entity and returns the default FlexPLM type path
46
+ * object class.
47
+ *
48
+ * @param entity
49
+ * @returns string
50
+ */
51
+ static getDefaultObjectTypePath(entity): string {
52
+ let typePath = '';
53
+ const entityType = this.getEntityType(entity);
54
+
55
+ switch (entityType) {
56
+ case 'item':
57
+ case 'project-item':
58
+ typePath = 'Product';
59
+ break;
60
+ case 'color':
61
+ typePath = 'Color';
62
+ break;
63
+ case 'custom-entity':
64
+ typePath = 'Revisable Entity';
65
+ break;
66
+ case 'project':
67
+ typePath = 'Season';
68
+ break;
69
+ case 'assortment':
70
+ if('LCSSeason' === entity.flex2vibeMapKeyRoot || entity.publishToFlexPLM){
71
+ typePath = 'Season';
72
+ }else{
73
+ typePath = 'Season Group';
74
+ }
75
+ break;
76
+ }
77
+
78
+ return typePath;
79
+ }
80
+
81
+ /**Takes in full entity and returns the slugs for the default identifier
82
+ * properties. These properties are used when searching for an entity
83
+ * object class.
84
+ *
85
+ * @param entity
86
+ * @returns string[]
87
+ */
88
+
89
+ static getDefaultIdentifierProperties(entity): string[] {
90
+ const identifierProps = [];
91
+ const entityType = this.getEntityType(entity);
92
+
93
+ switch (entityType) {
94
+ case 'item':
95
+ identifierProps.push('itemNumber');
96
+ break;
97
+ case 'project':
98
+ identifierProps.push('flexPLMSeasonName');
99
+ break;
100
+ case 'assortment':
101
+ if('LCSSeason' === entity.flex2vibeMapKeyRoot ||entity.publishToFlexPLM){
102
+ identifierProps.push('flexPLMSeasonName');
103
+ }else{
104
+ identifierProps.push('seasonGroupName');
105
+ }
106
+ break;
107
+ case 'color':
108
+ case 'custom-entity':
109
+ identifierProps.push('name');
110
+ break;
111
+ }
112
+
113
+ return identifierProps;
114
+ }
115
+
116
+ /** Takes in full entity and returns the slugs for informational
117
+ * properties. These properties are helpful when debugging issues
118
+ * where the identifier properties don't find a match.
119
+ *
120
+ * @param entity
121
+ * @returns string[]
122
+ */
123
+ static getDefaultInformationalProperties(entity): string[] {
124
+ const entityType = this.getEntityType(entity);
125
+ let properties:string[] = [];
126
+ if ('item' === entityType) {
127
+ if (entity.roles.includes('family')) {
128
+ properties.push('name');
129
+ } else if (entity.roles.includes('color')) {
130
+ properties.push('optionName');
131
+ }
132
+ } else if (['project', 'assortment'].includes(entityType)) {
133
+ properties.push('name');
134
+ }
135
+ return properties;
136
+
137
+ }
138
+
139
+ /** Returns the VibeIQ entity type from an entity.
140
+ * Throws error if it can't determine the entity type
141
+ *
142
+ * @param entity
143
+ * @returns string
144
+ */
145
+ static getEntityType(entity: any) {
146
+ let entityType = entity['entityType'];
147
+ if (!entityType) {
148
+ const typePath: string = entity['typePath'];
149
+ if (typePath) {
150
+ const types = typePath.split(':');
151
+ if (types && types[0]) {
152
+ entityType = types[0];
153
+ }
154
+ }
155
+ }
156
+ if (!entityType) {
157
+ throw Error(TypeDefaults.NO_ENTITY_TYPE);
158
+ }
159
+ return entityType;
160
+ }
161
+
162
+ /**Takes in full object and returns the default VibeIQ
163
+ * entity class.
164
+ *
165
+ * @param entity
166
+ * @returns string
167
+ */
168
+ static getDefaultEntityClass(object): string {
169
+ let entityClass = '';
170
+ let objectClass = TypeDefaults.getObjectClass(object);
171
+ if(['LCSProduct', 'LCSSKU'].includes(objectClass)){
172
+ entityClass = 'item';
173
+ }else if(['LCSProductSeasonLink', 'LCSSKUSeasonLink'].includes(objectClass)){
174
+ entityClass = 'project-item'
175
+ } else if('LCSColor' === objectClass){
176
+ entityClass = 'color';
177
+ } else if(['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
178
+ entityClass = 'assortment';
179
+ } else if(['LCSRevisableEntity', 'LCSLifecycleManaged', 'LCSLast', 'LCSMaterial'].includes(objectClass)) {
180
+ entityClass = 'custom-entity';
181
+ }
182
+
183
+ if(entityClass === '')
184
+ throw Error(TypeDefaults.NO_OBJECT_CLASS);
185
+
186
+ return entityClass;
187
+ }
188
+
189
+ /**Takes in full object and returns the default VibeIQ type path
190
+ * object class.
191
+ *
192
+ * @param object
193
+ * @returns string
194
+ */
195
+ static getDefaultEntityTypePath(object): string {
196
+ let typePath = '';
197
+ const objectClass = TypeDefaults.getObjectClass(object);
198
+
199
+ switch (objectClass) {
200
+ case 'LCSProduct':
201
+ case 'LCSSKU':
202
+ typePath = 'item';
203
+ break;
204
+ case 'LCSProductSeasonLink':
205
+ case 'LCSSKUSeasonLink':
206
+ typePath = 'project-item';
207
+ break;
208
+ case 'LCSColor':
209
+ typePath = 'color';
210
+ break;
211
+ case 'LCSSeason':
212
+ case 'SeasonGroup':
213
+ typePath = 'assortment';
214
+ break;
215
+ }
216
+
217
+ if(typePath === '')
218
+ throw Error(TypeDefaults.NO_TYPE_PATH);
219
+
220
+ return typePath;
221
+ }
222
+
223
+ /**Takes in full entity and returns the slugs for the default identifier
224
+ * properties. These properties are used when searching for an entity
225
+ * object class.
226
+ *
227
+ * @param entity
228
+ * @returns string[]
229
+ */
230
+
231
+ static getDefaultIdentifierPropertiesFromObject(object): string[] {
232
+ const identifierProps = [];
233
+ const objectClass = TypeDefaults.getObjectClass(object);
234
+
235
+ switch (objectClass) {
236
+ case 'LCSProduct':
237
+ case 'LCSSKU':
238
+ identifierProps.push('itemNumber');
239
+ break;
240
+ case 'LCSSeason':
241
+ identifierProps.push('flexPLMSeasonName');
242
+ break;
243
+ case 'SeasonGroup':
244
+ identifierProps.push('seasonGroupName');
245
+ break;
246
+ case 'LCSColor':
247
+ case 'LCSRevisableEntity':
248
+ case 'LCSLifecycleManaged':
249
+ case 'LCSLast':
250
+ case 'LCSMaterial':
251
+ identifierProps.push('name');
252
+ break;
253
+ }
254
+
255
+ return identifierProps;
256
+ }
257
+
258
+ /** Takes in full object and returns the slugs for informational
259
+ * properties. These properties are helpful when debugging issues
260
+ * where the identifier properties don't find a match.
261
+ *
262
+ * @param object
263
+ * @returns string[]
264
+ */
265
+ static getDefaultInformationalPropertiesFromObject(object): string[] {
266
+ const objectClass = TypeDefaults.getObjectClass(object);
267
+ let properties:string[] = [];
268
+ if ('LCSProduct' === objectClass) {
269
+ properties.push('name');
270
+ } else if ('LCSSKU' === objectClass) {
271
+ properties.push('optionName');
272
+ } else if (['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
273
+ properties.push('name');
274
+ }
275
+ return properties;
276
+ }
277
+
278
+ static getObjectClass(object: any): string {
279
+ return (object)? object['flexPLMObjectClass']: '';
280
+ }
281
281
  }