@contrail/flexplm 1.3.0 → 1.3.1-alpha.3507ab6

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 (149) hide show
  1. package/lib/cli/commands/compile.d.ts +1 -0
  2. package/lib/cli/commands/compile.js +71 -0
  3. package/lib/cli/commands/compile.spec.d.ts +1 -0
  4. package/lib/cli/commands/compile.spec.js +80 -0
  5. package/lib/cli/commands/create.d.ts +1 -0
  6. package/lib/cli/commands/create.js +75 -0
  7. package/lib/cli/commands/create.spec.d.ts +1 -0
  8. package/lib/cli/commands/create.spec.js +78 -0
  9. package/lib/cli/commands/upload.d.ts +10 -0
  10. package/lib/cli/commands/upload.js +228 -0
  11. package/lib/cli/commands/upload.spec.d.ts +1 -0
  12. package/lib/cli/commands/upload.spec.js +88 -0
  13. package/lib/cli/index.d.ts +2 -0
  14. package/lib/cli/index.js +64 -0
  15. package/lib/cli/index.spec.d.ts +1 -0
  16. package/lib/cli/index.spec.js +79 -0
  17. package/lib/cli/template/mapping-template.ts.template +62 -0
  18. package/lib/entity-processor/base-entity-processor.d.ts +89 -42
  19. package/lib/entity-processor/base-entity-processor.js +438 -385
  20. package/lib/entity-processor/base-entity-processor.spec.d.ts +1 -1
  21. package/lib/entity-processor/base-entity-processor.spec.js +398 -397
  22. package/lib/flexplm-request.d.ts +3 -3
  23. package/lib/flexplm-request.js +34 -34
  24. package/lib/flexplm-utils.d.ts +5 -5
  25. package/lib/flexplm-utils.js +33 -33
  26. package/lib/flexplm-utils.spec.d.ts +1 -1
  27. package/lib/flexplm-utils.spec.js +26 -26
  28. package/lib/index.d.ts +23 -22
  29. package/lib/index.js +39 -38
  30. package/lib/interfaces/interfaces.d.ts +105 -105
  31. package/lib/interfaces/interfaces.js +2 -2
  32. package/lib/interfaces/item-family-changes.d.ts +20 -20
  33. package/lib/interfaces/item-family-changes.js +56 -56
  34. package/lib/interfaces/mapping-file.d.ts +460 -0
  35. package/lib/interfaces/mapping-file.js +2 -0
  36. package/lib/interfaces/publish-change-data.d.ts +19 -19
  37. package/lib/interfaces/publish-change-data.js +32 -32
  38. package/lib/publish/base-process-publish-assortment-callback.d.ts +9 -9
  39. package/lib/publish/base-process-publish-assortment-callback.js +38 -38
  40. package/lib/publish/base-process-publish-assortment.d.ts +118 -93
  41. package/lib/publish/base-process-publish-assortment.js +998 -944
  42. package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -1
  43. package/lib/publish/base-process-publish-assortment.spec.js +1688 -1670
  44. package/lib/publish/mockData.d.ts +1389 -1389
  45. package/lib/publish/mockData.js +4524 -4519
  46. package/lib/transform/identifier-conversion-spec-mockData.js +472 -444
  47. package/lib/transform/identifier-conversion.d.ts +51 -15
  48. package/lib/transform/identifier-conversion.js +248 -212
  49. package/lib/transform/identifier-conversion.spec.d.ts +1 -1
  50. package/lib/transform/identifier-conversion.spec.js +343 -339
  51. package/lib/util/config-defaults.d.ts +8 -8
  52. package/lib/util/config-defaults.js +88 -85
  53. package/lib/util/config-defaults.spec.d.ts +1 -1
  54. package/lib/util/config-defaults.spec.js +302 -293
  55. package/lib/util/data-converter-spec-mockData.js +219 -205
  56. package/lib/util/data-converter.d.ts +136 -39
  57. package/lib/util/data-converter.js +718 -592
  58. package/lib/util/data-converter.spec.d.ts +1 -1
  59. package/lib/util/data-converter.spec.js +906 -904
  60. package/lib/util/error-response-object.d.ts +9 -4
  61. package/lib/util/error-response-object.js +54 -47
  62. package/lib/util/error-response-object.spec.d.ts +1 -1
  63. package/lib/util/error-response-object.spec.js +99 -99
  64. package/lib/util/event-short-message-status.d.ts +19 -19
  65. package/lib/util/event-short-message-status.js +24 -23
  66. package/lib/util/federation.d.ts +15 -15
  67. package/lib/util/federation.js +157 -149
  68. package/lib/util/flexplm-connect.d.ts +29 -22
  69. package/lib/util/flexplm-connect.js +190 -176
  70. package/lib/util/flexplm-connect.spec.d.ts +1 -1
  71. package/lib/util/flexplm-connect.spec.js +88 -88
  72. package/lib/util/logger-config.d.ts +1 -1
  73. package/lib/util/logger-config.js +27 -26
  74. package/lib/util/map-util-spec-mockData.js +219 -205
  75. package/lib/util/map-utils.d.ts +33 -6
  76. package/lib/util/map-utils.js +42 -15
  77. package/lib/util/map-utils.spec.d.ts +1 -1
  78. package/lib/util/map-utils.spec.js +89 -89
  79. package/lib/util/mockData.d.ts +80 -80
  80. package/lib/util/mockData.js +103 -103
  81. package/lib/util/thumbnail-util.d.ts +55 -34
  82. package/lib/util/thumbnail-util.js +242 -215
  83. package/lib/util/thumbnail-util.spec.d.ts +1 -1
  84. package/lib/util/thumbnail-util.spec.js +440 -434
  85. package/lib/util/type-conversion-utils-spec-mockData.js +259 -259
  86. package/lib/util/type-conversion-utils.d.ts +163 -23
  87. package/lib/util/type-conversion-utils.js +408 -265
  88. package/lib/util/type-conversion-utils.spec.d.ts +1 -1
  89. package/lib/util/type-conversion-utils.spec.js +868 -868
  90. package/lib/util/type-defaults.d.ts +74 -16
  91. package/lib/util/type-defaults.js +279 -221
  92. package/lib/util/type-defaults.spec.d.ts +1 -1
  93. package/lib/util/type-defaults.spec.js +516 -516
  94. package/lib/util/type-utils.d.ts +34 -13
  95. package/lib/util/type-utils.js +137 -114
  96. package/lib/util/type-utils.spec.d.ts +1 -1
  97. package/lib/util/type-utils.spec.js +192 -190
  98. package/package.json +21 -6
  99. package/scripts/copy-template.js +10 -0
  100. package/.claude/settings.local.json +0 -8
  101. package/.github/pull_request_template.md +0 -31
  102. package/.github/workflows/flexplm-lib.yml +0 -27
  103. package/.github/workflows/publish-to-npm.yml +0 -124
  104. package/CHANGELOG.md +0 -32
  105. package/publish.bat +0 -5
  106. package/publish.sh +0 -5
  107. package/src/entity-processor/base-entity-processor.spec.ts +0 -460
  108. package/src/entity-processor/base-entity-processor.ts +0 -515
  109. package/src/flexplm-request.ts +0 -28
  110. package/src/flexplm-utils.spec.ts +0 -27
  111. package/src/flexplm-utils.ts +0 -29
  112. package/src/index.ts +0 -22
  113. package/src/interfaces/interfaces.ts +0 -122
  114. package/src/interfaces/item-family-changes.ts +0 -67
  115. package/src/interfaces/publish-change-data.ts +0 -43
  116. package/src/publish/base-process-publish-assortment-callback.ts +0 -50
  117. package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
  118. package/src/publish/base-process-publish-assortment.ts +0 -1134
  119. package/src/publish/mockData.ts +0 -4561
  120. package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
  121. package/src/transform/identifier-conversion.spec.ts +0 -354
  122. package/src/transform/identifier-conversion.ts +0 -282
  123. package/src/util/config-defaults.spec.ts +0 -350
  124. package/src/util/config-defaults.ts +0 -93
  125. package/src/util/data-converter-spec-mockData.ts +0 -231
  126. package/src/util/data-converter.spec.ts +0 -1041
  127. package/src/util/data-converter.ts +0 -762
  128. package/src/util/error-response-object.spec.ts +0 -116
  129. package/src/util/error-response-object.ts +0 -50
  130. package/src/util/event-short-message-status.ts +0 -22
  131. package/src/util/federation.ts +0 -172
  132. package/src/util/flexplm-connect.spec.ts +0 -132
  133. package/src/util/flexplm-connect.ts +0 -208
  134. package/src/util/logger-config.ts +0 -20
  135. package/src/util/map-util-spec-mockData.ts +0 -231
  136. package/src/util/map-utils.spec.ts +0 -103
  137. package/src/util/map-utils.ts +0 -41
  138. package/src/util/mockData.ts +0 -101
  139. package/src/util/thumbnail-util.spec.ts +0 -508
  140. package/src/util/thumbnail-util.ts +0 -272
  141. package/src/util/type-conversion-utils-spec-mockData.ts +0 -271
  142. package/src/util/type-conversion-utils.spec.ts +0 -968
  143. package/src/util/type-conversion-utils.ts +0 -460
  144. package/src/util/type-defaults.spec.ts +0 -669
  145. package/src/util/type-defaults.ts +0 -281
  146. package/src/util/type-utils.spec.ts +0 -227
  147. package/src/util/type-utils.ts +0 -144
  148. package/tsconfig.json +0 -29
  149. package/tslint.json +0 -57
@@ -1,281 +0,0 @@
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
- }
@@ -1,227 +0,0 @@
1
- import { TypeUtils } from './type-utils';
2
-
3
- describe('TypeUtils.getEventObjectClass() tests', () =>{
4
-
5
- const tu = new TypeUtils();
6
-
7
- it('LCSProduct', () =>{
8
- const entityType = 'item';
9
- const newData = {
10
- roles: ['family']
11
- };
12
-
13
- const objectClass = tu.getEventObjectClass(entityType, newData);
14
-
15
- expect(objectClass).toEqual('LCSProduct');
16
- });
17
-
18
- it('LCSSKU', () =>{
19
- const entityType = 'item';
20
- const newData = {
21
- roles: ['color']
22
- };
23
-
24
- const objectClass = tu.getEventObjectClass(entityType, newData);
25
-
26
- expect(objectClass).toEqual('LCSSKU');
27
- });
28
-
29
- it('LCSProductSeasonLink', () =>{
30
- const entityType = 'project-item';
31
- const newData = {
32
- roles: ['family']
33
- };
34
-
35
- const objectClass = tu.getEventObjectClass(entityType, newData);
36
-
37
- expect(objectClass).toEqual('LCSProductSeasonLink');
38
- });
39
-
40
- it('LCSSKUSeasonLink', () =>{
41
- const entityType = 'project-item';
42
- const newData = {
43
- roles: ['color']
44
- };
45
-
46
- const objectClass = tu.getEventObjectClass(entityType, newData);
47
-
48
- expect(objectClass).toEqual('LCSSKUSeasonLink');
49
- });
50
- it('LCSColor', () =>{
51
- const entityType = 'color';
52
- const newData = {};
53
-
54
- const objectClass = tu.getEventObjectClass(entityType, newData);
55
-
56
- expect(objectClass).toEqual('LCSColor');
57
- });
58
-
59
- it('LCSRevisableEntity', () =>{
60
- const entityType = 'custom-entity';
61
- const newData = {};
62
-
63
- const objectClass = tu.getEventObjectClass(entityType, newData);
64
-
65
- expect(objectClass).toEqual('LCSRevisableEntity');
66
- });
67
-
68
- });
69
- describe('filterProperties-item', () => {
70
-
71
- const itemType = {
72
- typePath: 'item'
73
- };
74
- itemType['typeProperties'] = [
75
- {
76
- id: 'H4NazLloHdUVhc71',
77
- slug: 'null',
78
- propertyLevel: null
79
- },
80
- {
81
- id: 'H4NazLloHdUVhc71',
82
- slug: 'family',
83
- propertyLevel: 'family'
84
- },
85
- {
86
- id: 'H4NazLloHdUVhc71',
87
- slug: 'option',
88
- propertyLevel: 'option'
89
- },
90
- {
91
- id: 'H4NazLloHdUVhc71',
92
- slug: 'overridable',
93
- propertyLevel: 'overridable'
94
- },
95
- {
96
- id: 'H4NazLloHdUVhc71',
97
- slug: 'all',
98
- propertyLevel: 'all'
99
- },
100
- ];
101
- const tu = new TypeUtils();
102
-
103
- it('item-family', () =>{
104
- const len = 4;
105
- const newData = {
106
- roles: ['family']
107
- };
108
-
109
- const filteredProps = tu.filterTypeProperties(itemType, newData);
110
- expect(filteredProps.length).toEqual(len);
111
- });
112
-
113
- it('item-option', () =>{
114
- const len = 4;
115
- const newData = {
116
- roles: ['option']
117
- };
118
-
119
- const filteredProps = tu.filterTypeProperties(itemType, newData);
120
- expect(filteredProps.length).toEqual(len);
121
- });
122
-
123
- it('item-no-roles', () =>{
124
- const len = 5;
125
- const newData = {
126
- };
127
-
128
- const filteredProps = tu.filterTypeProperties(itemType, newData);
129
- expect(filteredProps.length).toEqual(len);
130
- });
131
- });
132
-
133
- //project-item
134
- describe('filterProperties-project-item', () => {
135
-
136
- const projectItemType = {
137
- typePath: 'project-item'
138
- };
139
- projectItemType['typeProperties'] = [
140
- {
141
- id: 'H4NazLloHdUVhc71',
142
- slug: 'null',
143
- propertyLevel: null
144
- },
145
- {
146
- id: 'H4NazLloHdUVhc71',
147
- slug: 'family',
148
- propertyLevel: 'family'
149
- },
150
- {
151
- id: 'H4NazLloHdUVhc71',
152
- slug: 'option',
153
- propertyLevel: 'option'
154
- },
155
- {
156
- id: 'H4NazLloHdUVhc71',
157
- slug: 'overridable',
158
- propertyLevel: 'overridable'
159
- },
160
- {
161
- id: 'H4NazLloHdUVhc71',
162
- slug: 'all',
163
- propertyLevel: 'all'
164
- },
165
- ];
166
- const tu = new TypeUtils();
167
-
168
- it('item-family', () =>{
169
- const len = 4;
170
- const newData = {
171
- roles: ['family']
172
- };
173
-
174
- const filteredProps = tu.filterTypeProperties(projectItemType, newData);
175
- expect(filteredProps.length).toEqual(len);
176
- });
177
-
178
- it('item-option', () =>{
179
- const len = 4;
180
- const newData = {
181
- roles: ['option']
182
- };
183
-
184
- const filteredProps = tu.filterTypeProperties(projectItemType, newData);
185
- expect(filteredProps.length).toEqual(len);
186
- });
187
- });
188
-
189
- //color
190
- describe('filterProperties-color', () => {
191
- const colorType = {
192
- typePath: 'color'
193
- };
194
- colorType['typeProperties'] = [
195
- {
196
- id: 'H4NazLloHdUVhc71',
197
- slug: 'null',
198
- },
199
- {
200
- id: 'H4NazLloHdUVhc71',
201
- slug: 'family',
202
- },
203
- {
204
- id: 'H4NazLloHdUVhc71',
205
- slug: 'option',
206
- },
207
- {
208
- id: 'H4NazLloHdUVhc71',
209
- slug: 'overridable',
210
- },
211
- {
212
- id: 'H4NazLloHdUVhc71',
213
- slug: 'all',
214
- },
215
- ];
216
- const tu = new TypeUtils();
217
-
218
- it('color', () =>{
219
- const len = 5;
220
- const newData = {
221
- roles: ['family']
222
- };
223
-
224
- const filteredProps = tu.filterTypeProperties(colorType, newData);
225
- expect(filteredProps.length).toEqual(len);
226
- });
227
- });
@@ -1,144 +0,0 @@
1
- import { Logger } from '@contrail/app-framework';
2
- import { TypeClientOptions, Types } from '@contrail/sdk';
3
- import { TypeProperty } from '@contrail/types';
4
- import { TypeConversionUtils } from './type-conversion-utils';
5
-
6
- export class TypeUtils {
7
- private typesObj: Types;
8
- constructor() {
9
- this.typesObj = new Types();
10
- }
11
-
12
- async getTypeById(id) {
13
- // this.logger.log('!-getTypeById: ' + id);
14
- const type = await this.typesObj.getType({
15
- id,
16
- relations: ['typeProperties', 'typeInterfaces']
17
- });
18
- return type;
19
- }
20
-
21
- async getByRootAndPath(options: TypeClientOptions) {
22
- const type = await this.typesObj.getByRootAndPath(options);
23
- return type;
24
- }
25
-
26
- /** Deprecated: use TypeConversionUtils.getObjectTypePath() */
27
- static getFlexPLMTypePath(entity) {
28
- return entity['flexPLMTypePath'] || entity['flexTypePath'] || '';
29
- }
30
-
31
- /** Deprecated: use TypeConversionUtils.getObjectClass()
32
- *
33
- * @param entityType
34
- * @param newData
35
- * @returns
36
- */
37
- getEventObjectClass(entityType: string, newData): string {
38
- let objectClass = '';
39
- if ('item' === entityType) {
40
- if (newData.roles.includes('family')) {
41
- objectClass = 'LCSProduct';
42
- } else if (newData.roles.includes('color')) {
43
- objectClass = 'LCSSKU';
44
- }
45
- } else if ('project-item' === entityType) {
46
- if (newData.roles.includes('family')) {
47
- objectClass = 'LCSProductSeasonLink';
48
- } else if (newData.roles.includes('color')) {
49
- objectClass = 'LCSSKUSeasonLink';
50
- }
51
- } else if ('color' === entityType) {
52
- objectClass = 'LCSColor';
53
- } else if ('custom-entity' === entityType) {
54
- objectClass = 'LCSRevisableEntity';
55
-
56
- }
57
- return objectClass;
58
- }
59
-
60
- /** Gets the VibeIQ entity type for the object data
61
- * @param data: object data
62
- */
63
- async getEntityTypeClientOptionsUsingMapping(transformMapFile, mapFileUtil, data): Promise<TypeClientOptions> {
64
- const root = await TypeConversionUtils.getEntityClassFromObject(transformMapFile, mapFileUtil, data);
65
- const path = await TypeConversionUtils.getEntityTypePathFromOjbect(transformMapFile, mapFileUtil, data);
66
-
67
- let tco: TypeClientOptions = {
68
- root,
69
- path
70
- };
71
-
72
-
73
-
74
- return tco;
75
- }
76
-
77
- /** Gets the VibeIQ entity type for the object data
78
- * @param objectClass: string object class
79
- * @param data: object data
80
- */
81
- getEntityTypeClientOptions(objectClass: string, data): TypeClientOptions {
82
- let tco: TypeClientOptions;
83
- if (['LCSProduct', 'LCSSKU'].includes(objectClass)) {
84
- tco = {
85
- root: 'item'
86
- };
87
- } else if ('LCSSeason' === objectClass) {
88
- tco = {
89
- root: 'assortment'
90
- };
91
- } else if ('LCSColor' === objectClass) {
92
- tco = {
93
- root: 'color'
94
- };
95
- } else if (['LCSBusinessObject', 'LCSRevisableEntity', 'LCSLast'].includes(objectClass)) {
96
- //TODO need to write logic using mapping file
97
- tco = {
98
- root: 'custom-entity'
99
- };
100
- console.log('data: ' + data);
101
- }
102
-
103
- return tco;
104
- }
105
- /** This will filter the properties based the newData entity.
106
- * It is assumed the type is correct for the entity
107
- *
108
- * @param type entire type object
109
- * @param newData the entity being processed
110
- * @returns TypeProperty[] of applicable properties
111
- */
112
- filterTypeProperties(type, newData): TypeProperty[] {
113
- let filteredProps: TypeProperty[] = type['typeProperties'];
114
- const typePath = type['typePath'];
115
- const roles = newData['roles'];
116
- if (typePath && (typePath.startsWith('item') || typePath.startsWith('project-item'))) {
117
- if (Logger.isDebugOn()) {
118
- console.debug('filterTypeProperties():id: ' +newData?.id
119
- + ', typePath: ' + typePath
120
- + ', newData.roles: ' + newData?.roles);
121
- }
122
- if (roles) {
123
- const isFamily = roles.includes('family');
124
- if (Logger.isDebugOn()) {
125
- console.debug('isFamily: ' + isFamily);
126
- }
127
-
128
- filteredProps = filteredProps.filter(prop => {
129
- const propertyLevel = prop.propertyLevel;
130
- const applies =
131
- (isFamily && 'option' != propertyLevel) ||
132
- (!isFamily && 'family' != propertyLevel);
133
- return applies;
134
- });
135
-
136
- } else {
137
- console.error('filterTypeProperties():Entity missing role-id: ' + newData['id']);
138
- }
139
- }
140
-
141
- return filteredProps;
142
- }
143
-
144
- }
package/tsconfig.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2020",
4
- "module": "commonjs",
5
- "declaration": true,
6
- "rootDir": "./src",
7
- "outDir": "./lib",
8
- "types": ["jest", "node"],
9
- "experimentalDecorators": true,
10
- "esModuleInterop": true,
11
- "strictPropertyInitialization": false,
12
- "noImplicitAny": false,
13
- "allowSyntheticDefaultImports": true,
14
- "emitDecoratorMetadata": true,
15
- "removeComments": true,
16
- "skipLibCheck": true,
17
- "lib": [
18
- "es5",
19
- "ES2015",
20
- "ES2016",
21
- "ES2017",
22
- "ES2020",
23
- "dom",
24
- "esnext.asynciterable"
25
- ],
26
- },
27
- "include": ["src"],
28
- "exclude": ["node_modules", "**/__tests__/*"]
29
- }