@contrail/flexplm 1.3.0-alpha.ccc03be → 1.3.1-alpha.3e8dbdd
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/cli/commands/compile.d.ts +1 -0
- package/lib/cli/commands/compile.js +71 -0
- package/lib/cli/commands/compile.spec.d.ts +1 -0
- package/lib/cli/commands/compile.spec.js +80 -0
- package/lib/cli/commands/create.d.ts +1 -0
- package/lib/cli/commands/create.js +75 -0
- package/lib/cli/commands/create.spec.d.ts +1 -0
- package/lib/cli/commands/create.spec.js +78 -0
- package/lib/cli/commands/upload.d.ts +10 -0
- package/lib/cli/commands/upload.js +226 -0
- package/lib/cli/commands/upload.spec.d.ts +1 -0
- package/lib/cli/commands/upload.spec.js +88 -0
- package/lib/cli/index.d.ts +2 -0
- package/lib/cli/index.js +64 -0
- package/lib/cli/index.spec.d.ts +1 -0
- package/lib/cli/index.spec.js +79 -0
- package/lib/cli/template/mapping-template.ts.template +62 -0
- package/lib/entity-processor/base-entity-processor.d.ts +47 -0
- package/lib/entity-processor/base-entity-processor.js +53 -0
- package/lib/entity-processor/base-entity-processor.spec.js +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/interfaces/mapping-file.d.ts +460 -0
- package/lib/interfaces/mapping-file.js +2 -0
- package/lib/publish/base-process-publish-assortment.d.ts +25 -0
- package/lib/publish/base-process-publish-assortment.js +60 -6
- package/lib/publish/base-process-publish-assortment.spec.js +22 -4
- package/lib/publish/mockData.js +5 -0
- package/lib/transform/identifier-conversion-spec-mockData.js +34 -6
- package/lib/transform/identifier-conversion.d.ts +36 -0
- package/lib/transform/identifier-conversion.js +36 -0
- package/lib/transform/identifier-conversion.spec.js +4 -0
- package/lib/util/config-defaults.js +3 -0
- package/lib/util/config-defaults.spec.js +9 -0
- package/lib/util/data-converter-spec-mockData.js +17 -3
- package/lib/util/data-converter.d.ts +97 -0
- package/lib/util/data-converter.js +127 -1
- package/lib/util/data-converter.spec.js +2 -0
- package/lib/util/error-response-object.d.ts +5 -0
- package/lib/util/error-response-object.js +7 -0
- package/lib/util/event-short-message-status.js +1 -0
- package/lib/util/federation.js +8 -0
- package/lib/util/flexplm-connect.d.ts +7 -0
- package/lib/util/flexplm-connect.js +14 -0
- package/lib/util/logger-config.js +1 -0
- package/lib/util/map-util-spec-mockData.js +17 -3
- package/lib/util/map-utils.d.ts +27 -0
- package/lib/util/map-utils.js +27 -0
- package/lib/util/thumbnail-util.d.ts +21 -0
- package/lib/util/thumbnail-util.js +28 -1
- package/lib/util/thumbnail-util.spec.js +6 -0
- package/lib/util/type-conversion-utils-spec-mockData.js +3 -3
- package/lib/util/type-conversion-utils.d.ts +140 -0
- package/lib/util/type-conversion-utils.js +143 -0
- package/lib/util/type-defaults.d.ts +58 -0
- package/lib/util/type-defaults.js +58 -0
- package/lib/util/type-defaults.spec.js +5 -5
- package/lib/util/type-utils.d.ts +21 -0
- package/lib/util/type-utils.js +23 -0
- package/lib/util/type-utils.spec.js +2 -0
- package/package.json +21 -6
- package/scripts/copy-template.js +10 -0
- package/.github/pull_request_template.md +0 -31
- package/.github/workflows/flexplm-lib.yml +0 -27
- package/.github/workflows/publish-to-npm.yml +0 -121
- package/CHANGELOG.md +0 -32
- package/publish.bat +0 -5
- package/publish.sh +0 -5
- package/src/entity-processor/base-entity-processor.spec.ts +0 -460
- package/src/entity-processor/base-entity-processor.ts +0 -515
- package/src/flexplm-request.ts +0 -28
- package/src/flexplm-utils.spec.ts +0 -27
- package/src/flexplm-utils.ts +0 -29
- package/src/index.ts +0 -22
- package/src/interfaces/interfaces.ts +0 -122
- package/src/interfaces/item-family-changes.ts +0 -67
- package/src/interfaces/publish-change-data.ts +0 -43
- package/src/publish/base-process-publish-assortment-callback.ts +0 -50
- package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
- package/src/publish/base-process-publish-assortment.ts +0 -1134
- package/src/publish/mockData.ts +0 -4561
- package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
- package/src/transform/identifier-conversion.spec.ts +0 -354
- package/src/transform/identifier-conversion.ts +0 -282
- package/src/util/config-defaults.spec.ts +0 -350
- package/src/util/config-defaults.ts +0 -93
- package/src/util/data-converter-spec-mockData.ts +0 -231
- package/src/util/data-converter.spec.ts +0 -1041
- package/src/util/data-converter.ts +0 -762
- package/src/util/error-response-object.spec.ts +0 -116
- package/src/util/error-response-object.ts +0 -50
- package/src/util/event-short-message-status.ts +0 -22
- package/src/util/federation.ts +0 -172
- package/src/util/flexplm-connect.spec.ts +0 -132
- package/src/util/flexplm-connect.ts +0 -208
- package/src/util/logger-config.ts +0 -20
- package/src/util/map-util-spec-mockData.ts +0 -231
- package/src/util/map-utils.spec.ts +0 -103
- package/src/util/map-utils.ts +0 -41
- package/src/util/mockData.ts +0 -101
- package/src/util/thumbnail-util.spec.ts +0 -508
- package/src/util/thumbnail-util.ts +0 -272
- package/src/util/type-conversion-utils-spec-mockData.ts +0 -271
- package/src/util/type-conversion-utils.spec.ts +0 -968
- package/src/util/type-conversion-utils.ts +0 -460
- package/src/util/type-defaults.spec.ts +0 -669
- package/src/util/type-defaults.ts +0 -281
- package/src/util/type-utils.spec.ts +0 -227
- package/src/util/type-utils.ts +0 -144
- package/tsconfig.json +0 -24
- 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
|
-
});
|
package/src/util/type-utils.ts
DELETED
|
@@ -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,24 +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
|
-
"ES2020",
|
|
19
|
-
"dom",
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
"include": ["src"],
|
|
23
|
-
"exclude": ["node_modules", "**/__tests__/*"]
|
|
24
|
-
}
|