@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.
- package/.claude/settings.local.json +1 -2
- package/.github/pull_request_template.md +31 -31
- package/.github/workflows/flexplm-lib.yml +27 -27
- package/lib/entity-processor/base-entity-processor.js +16 -2
- package/lib/entity-processor/base-entity-processor.spec.js +124 -0
- package/lib/util/flexplm-connect.d.ts +5 -1
- package/lib/util/flexplm-connect.js +8 -3
- package/lib/util/flexplm-connect.spec.d.ts +1 -0
- package/lib/util/flexplm-connect.spec.js +88 -0
- package/lib/util/thumbnail-util.d.ts +9 -0
- package/lib/util/thumbnail-util.js +88 -0
- package/lib/util/thumbnail-util.spec.js +156 -0
- package/lib/util/type-conversion-utils-spec-mockData.js +18 -0
- package/lib/util/type-conversion-utils.d.ts +2 -0
- package/lib/util/type-conversion-utils.js +43 -0
- package/lib/util/type-conversion-utils.spec.js +160 -0
- package/package.json +1 -1
- package/publish.bat +4 -4
- package/publish.sh +4 -4
- package/src/entity-processor/base-entity-processor.spec.ts +157 -0
- package/src/entity-processor/base-entity-processor.ts +21 -2
- package/src/flexplm-request.ts +28 -28
- package/src/flexplm-utils.spec.ts +27 -27
- package/src/flexplm-utils.ts +29 -29
- package/src/index.ts +21 -21
- package/src/interfaces/item-family-changes.ts +66 -66
- package/src/interfaces/publish-change-data.ts +42 -42
- package/src/publish/base-process-publish-assortment-callback.ts +50 -50
- package/src/transform/identifier-conversion-spec-mockData.ts +495 -495
- package/src/transform/identifier-conversion.spec.ts +353 -353
- package/src/transform/identifier-conversion.ts +281 -281
- package/src/util/config-defaults.spec.ts +350 -350
- package/src/util/config-defaults.ts +92 -92
- package/src/util/data-converter-spec-mockData.ts +230 -230
- package/src/util/error-response-object.spec.ts +115 -115
- package/src/util/error-response-object.ts +49 -49
- package/src/util/federation.ts +172 -172
- package/src/util/flexplm-connect.spec.ts +132 -0
- package/src/util/flexplm-connect.ts +14 -5
- package/src/util/logger-config.ts +19 -19
- package/src/util/map-util-spec-mockData.ts +230 -230
- package/src/util/map-utils.spec.ts +102 -102
- package/src/util/map-utils.ts +40 -40
- package/src/util/mockData.ts +97 -97
- package/src/util/thumbnail-util.spec.ts +190 -0
- package/src/util/thumbnail-util.ts +109 -1
- package/src/util/type-conversion-utils-spec-mockData.ts +18 -0
- package/src/util/type-conversion-utils.spec.ts +184 -0
- package/src/util/type-conversion-utils.ts +75 -0
- package/src/util/type-defaults.spec.ts +668 -668
- package/src/util/type-defaults.ts +280 -280
- package/src/util/type-utils.spec.ts +227 -227
- package/src/util/type-utils.ts +144 -144
- package/tsconfig.json +28 -26
- package/tslint.json +57 -57
- package/scripts/output.png +0 -0
- package/scripts/test-get-request.ts +0 -35
|
@@ -1,282 +1,282 @@
|
|
|
1
|
-
import { MapFileUtil } from "@contrail/transform-data";
|
|
2
|
-
import { ProductFederation, SeasonFederation, SeasonGroupFederation, SkuFederation } from "../interfaces/interfaces";
|
|
3
|
-
import { MapUtil } from "../util/map-utils";
|
|
4
|
-
import { TypeConversionUtils } from "../util/type-conversion-utils";
|
|
5
|
-
import { DataConverter } from "../util/data-converter";
|
|
6
|
-
import { EventShortMessageStatus } from "../util/event-short-message-status";
|
|
7
|
-
|
|
8
|
-
export class IdentifierConversion {
|
|
9
|
-
static readonly INBOUND_ENTITY_MISSING_IDENIFIER_PROPS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing identifier properties: ';
|
|
10
|
-
|
|
11
|
-
static readonly MISSING_OBJECT = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: object';
|
|
12
|
-
|
|
13
|
-
static readonly MISSING_FLEXPLM_OBJECT_CLASS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: flexPLMObjectClass';
|
|
14
|
-
|
|
15
|
-
/** Takes in an assortment and returns an object to query for an LCSSeason
|
|
16
|
-
* This will only return the identifier properties, and information properties if specified.
|
|
17
|
-
* @param transformMapFile
|
|
18
|
-
* @param mapFileUtil
|
|
19
|
-
* @param dc
|
|
20
|
-
* @param assortment
|
|
21
|
-
* @param includeInformationKeys defaults true
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
static async getSeasonIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment, includeInformationKeys = true): Promise<SeasonFederation>{
|
|
25
|
-
if(!assortment){
|
|
26
|
-
throw new Error('IdentifierConversion.getSeasonIdentityObject(): assortment must be provided.');
|
|
27
|
-
}
|
|
28
|
-
assortment['flex2vibeMapKeyRoot'] = 'LCSSeason';
|
|
29
|
-
const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
30
|
-
|
|
31
|
-
let seasonObj: any = {
|
|
32
|
-
entityReference: 'assortment:' + assortment?.id,
|
|
33
|
-
objectClass: 'LCSSeason' as const,
|
|
34
|
-
flexPLMTypePath
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
try{
|
|
38
|
-
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
39
|
-
const identifierKeys: string[] = await TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
40
|
-
for(const key of identifierKeys){
|
|
41
|
-
if(assortmentObj[key]){
|
|
42
|
-
seasonObj[key] = assortmentObj[key];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if(includeInformationKeys){
|
|
46
|
-
const informationKeys: string[] = await TypeConversionUtils
|
|
47
|
-
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
48
|
-
for(const key of informationKeys){
|
|
49
|
-
if(assortmentObj[key]){
|
|
50
|
-
seasonObj[key] = assortmentObj[key];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const objectKeys = Object.keys(seasonObj);
|
|
56
|
-
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
57
|
-
if(!hasAllIdentifiers){
|
|
58
|
-
console.error('IdentifierConversion.getSeasonIdentityObject(): doesnt have all identifier properties - '+ identifierKeys);
|
|
59
|
-
console.error('assortment: ' + JSON.stringify(assortment));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const mapKey:string = await TypeConversionUtils
|
|
63
|
-
.getMapKey(transformMapFile, mapFileUtil, assortment, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
64
|
-
seasonObj = await MapUtil
|
|
65
|
-
.applyTransformMap(transformMapFile, mapFileUtil, seasonObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
66
|
-
} finally {
|
|
67
|
-
delete assortment['flex2vibeMapKeyRoot'];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return seasonObj as SeasonFederation;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** Takes in an assortment and returns an object to query for an SeasonGroup
|
|
74
|
-
* This will only return the identifier properties, and information properties if specified.
|
|
75
|
-
* @param transformMapFile
|
|
76
|
-
* @param mapFileUtil
|
|
77
|
-
* @param dc
|
|
78
|
-
* @param assortment
|
|
79
|
-
* @param includeInformationKeys defaults true
|
|
80
|
-
* @returns
|
|
81
|
-
*/
|
|
82
|
-
static async getSeasonGroupIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment, includeInformationKeys = true): Promise<SeasonGroupFederation> {
|
|
83
|
-
if(!assortment){
|
|
84
|
-
throw new Error('IdentifierConversion.getSeasonGroupIdentityObject(): assortment must be provided.');
|
|
85
|
-
}
|
|
86
|
-
assortment['flex2vibeMapKeyRoot'] = 'SeasonGroup';
|
|
87
|
-
const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
88
|
-
|
|
89
|
-
let seasonGroupObj = {
|
|
90
|
-
entityReference: 'assortment:' + assortment?.id,
|
|
91
|
-
objectClass: 'SeasonGroup' as const,
|
|
92
|
-
flexPLMTypePath
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
97
|
-
|
|
98
|
-
const identifierKeys: string[] = await TypeConversionUtils
|
|
99
|
-
.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
100
|
-
for (const key of identifierKeys) {
|
|
101
|
-
if (assortmentObj[key]) {
|
|
102
|
-
seasonGroupObj[key] = assortmentObj[key];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if(includeInformationKeys){
|
|
107
|
-
const informationKeys: string[] = await TypeConversionUtils
|
|
108
|
-
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
109
|
-
for (const key of informationKeys) {
|
|
110
|
-
if (assortmentObj[key]) {
|
|
111
|
-
seasonGroupObj[key] = assortmentObj[key];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
const objectKeys = Object.keys(seasonGroupObj);
|
|
117
|
-
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
118
|
-
|
|
119
|
-
if (!hasAllIdentifiers) {
|
|
120
|
-
console.error('IdentifierConversion.getSeasonGroupIdentityObject(): doesnt have all identifier properties - '+ identifierKeys);
|
|
121
|
-
console.error('assortment: ' + JSON.stringify(assortment));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const mapKey: string = await TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, assortment, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
125
|
-
seasonGroupObj = await MapUtil.applyTransformMap(transformMapFile, mapFileUtil, seasonGroupObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
126
|
-
|
|
127
|
-
} finally {
|
|
128
|
-
delete assortment['flex2vibeMapKeyRoot'];
|
|
129
|
-
}
|
|
130
|
-
return seasonGroupObj;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** Takes in an item and returns an object to query for an LCSProduct
|
|
134
|
-
* This will only return the identifier properties, and information properties if specified.
|
|
135
|
-
* @param transformMapFile
|
|
136
|
-
* @param mapFileUtil
|
|
137
|
-
* @param dc
|
|
138
|
-
* @param assortment
|
|
139
|
-
* @param includeInformationKeys defaults true
|
|
140
|
-
* @returns
|
|
141
|
-
*/
|
|
142
|
-
static async getProductIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemFamilyObject, includeInformationKeys = true): Promise<ProductFederation> {
|
|
143
|
-
if(!itemFamilyObject){
|
|
144
|
-
throw new Error('IdentifierConversion.getProductIdentityObject(): itemFamilyObject must be provided.');
|
|
145
|
-
}
|
|
146
|
-
const itemObj = await dc.getFlexPLMObjectData(itemFamilyObject, [], true);
|
|
147
|
-
const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
148
|
-
let prodObj: ProductFederation = {
|
|
149
|
-
entityReference: 'item:' + itemFamilyObject?.id,
|
|
150
|
-
objectClass: 'LCSProduct' as const,
|
|
151
|
-
flexPLMTypePath
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const identifierKeys: string[] = await TypeConversionUtils
|
|
155
|
-
.getIdentifierProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
156
|
-
for (const key of identifierKeys) {
|
|
157
|
-
if (itemObj[key]) {
|
|
158
|
-
prodObj[key] = itemObj[key];
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if(includeInformationKeys){
|
|
163
|
-
const informationKeys: string[] = await TypeConversionUtils
|
|
164
|
-
.getInformationalProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
165
|
-
for (const key of informationKeys) {
|
|
166
|
-
if (itemObj[key]) {
|
|
167
|
-
prodObj[key] = itemObj[key];
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
173
|
-
if (!prodObj[vibeIQIdentifier]) {
|
|
174
|
-
prodObj['vibeIQIdentifier'] = itemFamilyObject['identifier'] || itemFamilyObject['itemNumber'];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const mapKey: string = await TypeConversionUtils
|
|
178
|
-
.getMapKey(transformMapFile, mapFileUtil, itemFamilyObject, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
179
|
-
prodObj = await MapUtil
|
|
180
|
-
.applyTransformMap(transformMapFile, mapFileUtil, prodObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
181
|
-
|
|
182
|
-
return prodObj as ProductFederation;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/** Takes in an item and returns an object to query for an LCSSKU
|
|
186
|
-
* This will only return the identifier properties, and information properties if specified.
|
|
187
|
-
* @param transformMapFile
|
|
188
|
-
* @param mapFileUtil
|
|
189
|
-
* @param dc
|
|
190
|
-
* @param assortment
|
|
191
|
-
* @param includeInformationKeys defaults true
|
|
192
|
-
* @returns
|
|
193
|
-
*/
|
|
194
|
-
static async getSKUIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemObject, includeInformationKeys = true): Promise<SkuFederation> {
|
|
195
|
-
if(!itemObject){
|
|
196
|
-
throw new Error('IdentifierConversion.getSKUIdentityObject(): itemObject must be provided.');
|
|
197
|
-
}
|
|
198
|
-
const itemObj = await dc.getFlexPLMObjectData(itemObject, [], true);
|
|
199
|
-
const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemObject);
|
|
200
|
-
let skuObj: SkuFederation = {
|
|
201
|
-
entityReference: 'item:' + itemObject?.id,
|
|
202
|
-
objectClass: 'LCSSKU' as const,
|
|
203
|
-
flexPLMTypePath
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const identifierKeys: string[] = await TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, itemObject);
|
|
207
|
-
for (const key of identifierKeys) {
|
|
208
|
-
if (itemObj[key]) {
|
|
209
|
-
skuObj[key] = itemObj[key];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if(includeInformationKeys){
|
|
214
|
-
const informationKeys: string[] = await TypeConversionUtils.getInformationalProperties(transformMapFile, mapFileUtil, itemObject);
|
|
215
|
-
for (const key of informationKeys) {
|
|
216
|
-
if (itemObj[key]) {
|
|
217
|
-
skuObj[key] = itemObj[key];
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
223
|
-
if (!skuObj[vibeIQIdentifier]) {
|
|
224
|
-
skuObj['vibeIQIdentifier'] = itemObject['identifier'] || itemObject['itemNumber'];
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const mapKey: string = await TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, itemObject, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
228
|
-
skuObj = await MapUtil.applyTransformMap(transformMapFile, mapFileUtil, skuObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
229
|
-
|
|
230
|
-
return skuObj as SkuFederation;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
static async getEntityCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any> {
|
|
234
|
-
if(!object){
|
|
235
|
-
const e =new Error(IdentifierConversion.MISSING_OBJECT)
|
|
236
|
-
e['shortStatusMessage'] = EventShortMessageStatus.MISSING_INPUT;
|
|
237
|
-
throw e;
|
|
238
|
-
} else if(!object.flexPLMObjectClass){
|
|
239
|
-
const e = new Error(IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS);
|
|
240
|
-
e['shortStatusMessage'] = EventShortMessageStatus.MISSING_INPUT;
|
|
241
|
-
throw e;
|
|
242
|
-
}
|
|
243
|
-
const mapKey: string = await TypeConversionUtils.getMapKeyFromObject(transformMapFile, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
244
|
-
|
|
245
|
-
const identifierKeys: string[] = await TypeConversionUtils.getIdentifierPropertiesFromObject(transformMapFile, mapFileUtil, object);
|
|
246
|
-
const objectData = await MapUtil.applyTransformMap(transformMapFile, mapFileUtil, object, mapKey, TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
247
|
-
|
|
248
|
-
let identifierValues = identifierKeys.reduce((acc, key) => {
|
|
249
|
-
acc[key] = objectData[key];
|
|
250
|
-
return acc;
|
|
251
|
-
}, {});
|
|
252
|
-
identifierValues['flexPLMObjectClass']= objectData?.flexPLMObjectClass;
|
|
253
|
-
identifierValues['flexPLMTypePath']= objectData?.flexPLMTypePath;
|
|
254
|
-
|
|
255
|
-
identifierValues = await dc.getEntityValues(objectData?.flexPLMObjectClass, identifierValues, []);
|
|
256
|
-
|
|
257
|
-
const entityKeys = Object.keys(identifierValues);
|
|
258
|
-
const hasAllIdentifiers = identifierKeys.every(key => entityKeys.includes(key));
|
|
259
|
-
if (!hasAllIdentifiers) {
|
|
260
|
-
const e = new Error(IdentifierConversion.INBOUND_ENTITY_MISSING_IDENIFIER_PROPS + identifierKeys);
|
|
261
|
-
e['shortStatusMessage'] = EventShortMessageStatus.MISSING_IDENTIFIER_PROPERTIES;
|
|
262
|
-
|
|
263
|
-
throw e;
|
|
264
|
-
}
|
|
265
|
-
const criteria = {};
|
|
266
|
-
for (const key of identifierKeys) {
|
|
267
|
-
criteria[key] = identifierValues[key];
|
|
268
|
-
}
|
|
269
|
-
return criteria;
|
|
270
|
-
}
|
|
271
|
-
static async getAssortmentCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any> {
|
|
272
|
-
return IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
static async getItemCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any> {
|
|
276
|
-
const criteria = await IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
|
|
277
|
-
const roles = (object.flexPLMObjectClass === 'LCSProduct') ? 'family' : 'color';
|
|
278
|
-
criteria['roles'] = roles;
|
|
279
|
-
|
|
280
|
-
return criteria;
|
|
281
|
-
}
|
|
1
|
+
import { MapFileUtil } from "@contrail/transform-data";
|
|
2
|
+
import { ProductFederation, SeasonFederation, SeasonGroupFederation, SkuFederation } from "../interfaces/interfaces";
|
|
3
|
+
import { MapUtil } from "../util/map-utils";
|
|
4
|
+
import { TypeConversionUtils } from "../util/type-conversion-utils";
|
|
5
|
+
import { DataConverter } from "../util/data-converter";
|
|
6
|
+
import { EventShortMessageStatus } from "../util/event-short-message-status";
|
|
7
|
+
|
|
8
|
+
export class IdentifierConversion {
|
|
9
|
+
static readonly INBOUND_ENTITY_MISSING_IDENIFIER_PROPS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing identifier properties: ';
|
|
10
|
+
|
|
11
|
+
static readonly MISSING_OBJECT = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: object';
|
|
12
|
+
|
|
13
|
+
static readonly MISSING_FLEXPLM_OBJECT_CLASS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: flexPLMObjectClass';
|
|
14
|
+
|
|
15
|
+
/** Takes in an assortment and returns an object to query for an LCSSeason
|
|
16
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
17
|
+
* @param transformMapFile
|
|
18
|
+
* @param mapFileUtil
|
|
19
|
+
* @param dc
|
|
20
|
+
* @param assortment
|
|
21
|
+
* @param includeInformationKeys defaults true
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
static async getSeasonIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment, includeInformationKeys = true): Promise<SeasonFederation>{
|
|
25
|
+
if(!assortment){
|
|
26
|
+
throw new Error('IdentifierConversion.getSeasonIdentityObject(): assortment must be provided.');
|
|
27
|
+
}
|
|
28
|
+
assortment['flex2vibeMapKeyRoot'] = 'LCSSeason';
|
|
29
|
+
const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
30
|
+
|
|
31
|
+
let seasonObj: any = {
|
|
32
|
+
entityReference: 'assortment:' + assortment?.id,
|
|
33
|
+
objectClass: 'LCSSeason' as const,
|
|
34
|
+
flexPLMTypePath
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
try{
|
|
38
|
+
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
39
|
+
const identifierKeys: string[] = await TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
40
|
+
for(const key of identifierKeys){
|
|
41
|
+
if(assortmentObj[key]){
|
|
42
|
+
seasonObj[key] = assortmentObj[key];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if(includeInformationKeys){
|
|
46
|
+
const informationKeys: string[] = await TypeConversionUtils
|
|
47
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
48
|
+
for(const key of informationKeys){
|
|
49
|
+
if(assortmentObj[key]){
|
|
50
|
+
seasonObj[key] = assortmentObj[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const objectKeys = Object.keys(seasonObj);
|
|
56
|
+
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
57
|
+
if(!hasAllIdentifiers){
|
|
58
|
+
console.error('IdentifierConversion.getSeasonIdentityObject(): doesnt have all identifier properties - '+ identifierKeys);
|
|
59
|
+
console.error('assortment: ' + JSON.stringify(assortment));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const mapKey:string = await TypeConversionUtils
|
|
63
|
+
.getMapKey(transformMapFile, mapFileUtil, assortment, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
64
|
+
seasonObj = await MapUtil
|
|
65
|
+
.applyTransformMap(transformMapFile, mapFileUtil, seasonObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
66
|
+
} finally {
|
|
67
|
+
delete assortment['flex2vibeMapKeyRoot'];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return seasonObj as SeasonFederation;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Takes in an assortment and returns an object to query for an SeasonGroup
|
|
74
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
75
|
+
* @param transformMapFile
|
|
76
|
+
* @param mapFileUtil
|
|
77
|
+
* @param dc
|
|
78
|
+
* @param assortment
|
|
79
|
+
* @param includeInformationKeys defaults true
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
static async getSeasonGroupIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment, includeInformationKeys = true): Promise<SeasonGroupFederation> {
|
|
83
|
+
if(!assortment){
|
|
84
|
+
throw new Error('IdentifierConversion.getSeasonGroupIdentityObject(): assortment must be provided.');
|
|
85
|
+
}
|
|
86
|
+
assortment['flex2vibeMapKeyRoot'] = 'SeasonGroup';
|
|
87
|
+
const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
88
|
+
|
|
89
|
+
let seasonGroupObj = {
|
|
90
|
+
entityReference: 'assortment:' + assortment?.id,
|
|
91
|
+
objectClass: 'SeasonGroup' as const,
|
|
92
|
+
flexPLMTypePath
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
97
|
+
|
|
98
|
+
const identifierKeys: string[] = await TypeConversionUtils
|
|
99
|
+
.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
100
|
+
for (const key of identifierKeys) {
|
|
101
|
+
if (assortmentObj[key]) {
|
|
102
|
+
seasonGroupObj[key] = assortmentObj[key];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if(includeInformationKeys){
|
|
107
|
+
const informationKeys: string[] = await TypeConversionUtils
|
|
108
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
109
|
+
for (const key of informationKeys) {
|
|
110
|
+
if (assortmentObj[key]) {
|
|
111
|
+
seasonGroupObj[key] = assortmentObj[key];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
const objectKeys = Object.keys(seasonGroupObj);
|
|
117
|
+
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
118
|
+
|
|
119
|
+
if (!hasAllIdentifiers) {
|
|
120
|
+
console.error('IdentifierConversion.getSeasonGroupIdentityObject(): doesnt have all identifier properties - '+ identifierKeys);
|
|
121
|
+
console.error('assortment: ' + JSON.stringify(assortment));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const mapKey: string = await TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, assortment, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
125
|
+
seasonGroupObj = await MapUtil.applyTransformMap(transformMapFile, mapFileUtil, seasonGroupObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
126
|
+
|
|
127
|
+
} finally {
|
|
128
|
+
delete assortment['flex2vibeMapKeyRoot'];
|
|
129
|
+
}
|
|
130
|
+
return seasonGroupObj;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Takes in an item and returns an object to query for an LCSProduct
|
|
134
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
135
|
+
* @param transformMapFile
|
|
136
|
+
* @param mapFileUtil
|
|
137
|
+
* @param dc
|
|
138
|
+
* @param assortment
|
|
139
|
+
* @param includeInformationKeys defaults true
|
|
140
|
+
* @returns
|
|
141
|
+
*/
|
|
142
|
+
static async getProductIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemFamilyObject, includeInformationKeys = true): Promise<ProductFederation> {
|
|
143
|
+
if(!itemFamilyObject){
|
|
144
|
+
throw new Error('IdentifierConversion.getProductIdentityObject(): itemFamilyObject must be provided.');
|
|
145
|
+
}
|
|
146
|
+
const itemObj = await dc.getFlexPLMObjectData(itemFamilyObject, [], true);
|
|
147
|
+
const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
148
|
+
let prodObj: ProductFederation = {
|
|
149
|
+
entityReference: 'item:' + itemFamilyObject?.id,
|
|
150
|
+
objectClass: 'LCSProduct' as const,
|
|
151
|
+
flexPLMTypePath
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const identifierKeys: string[] = await TypeConversionUtils
|
|
155
|
+
.getIdentifierProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
156
|
+
for (const key of identifierKeys) {
|
|
157
|
+
if (itemObj[key]) {
|
|
158
|
+
prodObj[key] = itemObj[key];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if(includeInformationKeys){
|
|
163
|
+
const informationKeys: string[] = await TypeConversionUtils
|
|
164
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
165
|
+
for (const key of informationKeys) {
|
|
166
|
+
if (itemObj[key]) {
|
|
167
|
+
prodObj[key] = itemObj[key];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
173
|
+
if (!prodObj[vibeIQIdentifier]) {
|
|
174
|
+
prodObj['vibeIQIdentifier'] = itemFamilyObject['identifier'] || itemFamilyObject['itemNumber'];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const mapKey: string = await TypeConversionUtils
|
|
178
|
+
.getMapKey(transformMapFile, mapFileUtil, itemFamilyObject, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
179
|
+
prodObj = await MapUtil
|
|
180
|
+
.applyTransformMap(transformMapFile, mapFileUtil, prodObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
181
|
+
|
|
182
|
+
return prodObj as ProductFederation;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Takes in an item and returns an object to query for an LCSSKU
|
|
186
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
187
|
+
* @param transformMapFile
|
|
188
|
+
* @param mapFileUtil
|
|
189
|
+
* @param dc
|
|
190
|
+
* @param assortment
|
|
191
|
+
* @param includeInformationKeys defaults true
|
|
192
|
+
* @returns
|
|
193
|
+
*/
|
|
194
|
+
static async getSKUIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemObject, includeInformationKeys = true): Promise<SkuFederation> {
|
|
195
|
+
if(!itemObject){
|
|
196
|
+
throw new Error('IdentifierConversion.getSKUIdentityObject(): itemObject must be provided.');
|
|
197
|
+
}
|
|
198
|
+
const itemObj = await dc.getFlexPLMObjectData(itemObject, [], true);
|
|
199
|
+
const flexPLMTypePath = await TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemObject);
|
|
200
|
+
let skuObj: SkuFederation = {
|
|
201
|
+
entityReference: 'item:' + itemObject?.id,
|
|
202
|
+
objectClass: 'LCSSKU' as const,
|
|
203
|
+
flexPLMTypePath
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const identifierKeys: string[] = await TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, itemObject);
|
|
207
|
+
for (const key of identifierKeys) {
|
|
208
|
+
if (itemObj[key]) {
|
|
209
|
+
skuObj[key] = itemObj[key];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if(includeInformationKeys){
|
|
214
|
+
const informationKeys: string[] = await TypeConversionUtils.getInformationalProperties(transformMapFile, mapFileUtil, itemObject);
|
|
215
|
+
for (const key of informationKeys) {
|
|
216
|
+
if (itemObj[key]) {
|
|
217
|
+
skuObj[key] = itemObj[key];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
223
|
+
if (!skuObj[vibeIQIdentifier]) {
|
|
224
|
+
skuObj['vibeIQIdentifier'] = itemObject['identifier'] || itemObject['itemNumber'];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const mapKey: string = await TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, itemObject, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
228
|
+
skuObj = await MapUtil.applyTransformMap(transformMapFile, mapFileUtil, skuObj, mapKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
229
|
+
|
|
230
|
+
return skuObj as SkuFederation;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
static async getEntityCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any> {
|
|
234
|
+
if(!object){
|
|
235
|
+
const e =new Error(IdentifierConversion.MISSING_OBJECT)
|
|
236
|
+
e['shortStatusMessage'] = EventShortMessageStatus.MISSING_INPUT;
|
|
237
|
+
throw e;
|
|
238
|
+
} else if(!object.flexPLMObjectClass){
|
|
239
|
+
const e = new Error(IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS);
|
|
240
|
+
e['shortStatusMessage'] = EventShortMessageStatus.MISSING_INPUT;
|
|
241
|
+
throw e;
|
|
242
|
+
}
|
|
243
|
+
const mapKey: string = await TypeConversionUtils.getMapKeyFromObject(transformMapFile, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
244
|
+
|
|
245
|
+
const identifierKeys: string[] = await TypeConversionUtils.getIdentifierPropertiesFromObject(transformMapFile, mapFileUtil, object);
|
|
246
|
+
const objectData = await MapUtil.applyTransformMap(transformMapFile, mapFileUtil, object, mapKey, TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
247
|
+
|
|
248
|
+
let identifierValues = identifierKeys.reduce((acc, key) => {
|
|
249
|
+
acc[key] = objectData[key];
|
|
250
|
+
return acc;
|
|
251
|
+
}, {});
|
|
252
|
+
identifierValues['flexPLMObjectClass']= objectData?.flexPLMObjectClass;
|
|
253
|
+
identifierValues['flexPLMTypePath']= objectData?.flexPLMTypePath;
|
|
254
|
+
|
|
255
|
+
identifierValues = await dc.getEntityValues(objectData?.flexPLMObjectClass, identifierValues, []);
|
|
256
|
+
|
|
257
|
+
const entityKeys = Object.keys(identifierValues);
|
|
258
|
+
const hasAllIdentifiers = identifierKeys.every(key => entityKeys.includes(key));
|
|
259
|
+
if (!hasAllIdentifiers) {
|
|
260
|
+
const e = new Error(IdentifierConversion.INBOUND_ENTITY_MISSING_IDENIFIER_PROPS + identifierKeys);
|
|
261
|
+
e['shortStatusMessage'] = EventShortMessageStatus.MISSING_IDENTIFIER_PROPERTIES;
|
|
262
|
+
|
|
263
|
+
throw e;
|
|
264
|
+
}
|
|
265
|
+
const criteria = {};
|
|
266
|
+
for (const key of identifierKeys) {
|
|
267
|
+
criteria[key] = identifierValues[key];
|
|
268
|
+
}
|
|
269
|
+
return criteria;
|
|
270
|
+
}
|
|
271
|
+
static async getAssortmentCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any> {
|
|
272
|
+
return IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
static async getItemCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any> {
|
|
276
|
+
const criteria = await IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
|
|
277
|
+
const roles = (object.flexPLMObjectClass === 'LCSProduct') ? 'family' : 'color';
|
|
278
|
+
criteria['roles'] = roles;
|
|
279
|
+
|
|
280
|
+
return criteria;
|
|
281
|
+
}
|
|
282
282
|
}
|