@contrail/flexplm 1.3.0-alpha.5 → 1.3.0-alpha.7cd23d9
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/.github/workflows/flexplm-lib.yml +1 -1
- package/.github/workflows/publish-to-npm.yml +118 -0
- package/CHANGELOG.md +1 -1
- package/lib/entity-processor/base-entity-processor.d.ts +42 -42
- package/lib/entity-processor/base-entity-processor.js +385 -385
- package/lib/entity-processor/base-entity-processor.spec.d.ts +1 -1
- package/lib/entity-processor/base-entity-processor.spec.js +397 -397
- package/lib/flexplm-request.d.ts +3 -3
- package/lib/flexplm-request.js +34 -34
- package/lib/flexplm-utils.d.ts +5 -5
- package/lib/flexplm-utils.js +33 -33
- package/lib/flexplm-utils.spec.d.ts +1 -1
- package/lib/flexplm-utils.spec.js +26 -26
- package/lib/index.d.ts +22 -22
- package/lib/index.js +38 -38
- package/lib/interfaces/interfaces.d.ts +105 -105
- package/lib/interfaces/interfaces.js +2 -2
- package/lib/interfaces/item-family-changes.d.ts +20 -20
- package/lib/interfaces/item-family-changes.js +56 -56
- package/lib/interfaces/publish-change-data.d.ts +19 -19
- package/lib/interfaces/publish-change-data.js +32 -32
- package/lib/publish/base-process-publish-assortment-callback.d.ts +9 -9
- package/lib/publish/base-process-publish-assortment-callback.js +38 -38
- package/lib/publish/base-process-publish-assortment.d.ts +93 -93
- package/lib/publish/base-process-publish-assortment.js +944 -944
- package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -1
- package/lib/publish/base-process-publish-assortment.spec.js +1670 -1670
- package/lib/publish/mockData.d.ts +1389 -1389
- package/lib/publish/mockData.js +4519 -4519
- package/lib/transform/identifier-conversion-spec-mockData.js +444 -444
- package/lib/transform/identifier-conversion.d.ts +15 -15
- package/lib/transform/identifier-conversion.js +212 -212
- package/lib/transform/identifier-conversion.spec.d.ts +1 -1
- package/lib/transform/identifier-conversion.spec.js +339 -339
- package/lib/util/config-defaults.d.ts +8 -8
- package/lib/util/config-defaults.js +85 -85
- package/lib/util/config-defaults.spec.d.ts +1 -1
- package/lib/util/config-defaults.spec.js +293 -293
- package/lib/util/data-converter-spec-mockData.js +205 -205
- package/lib/util/data-converter.d.ts +39 -39
- package/lib/util/data-converter.js +592 -592
- package/lib/util/data-converter.spec.d.ts +1 -1
- package/lib/util/data-converter.spec.js +904 -904
- package/lib/util/error-response-object.d.ts +4 -4
- package/lib/util/error-response-object.js +47 -47
- package/lib/util/error-response-object.spec.d.ts +1 -1
- package/lib/util/error-response-object.spec.js +99 -99
- package/lib/util/event-short-message-status.d.ts +19 -19
- package/lib/util/event-short-message-status.js +23 -23
- package/lib/util/federation.d.ts +15 -15
- package/lib/util/federation.js +149 -149
- package/lib/util/flexplm-connect.d.ts +22 -22
- package/lib/util/flexplm-connect.js +176 -176
- package/lib/util/flexplm-connect.spec.d.ts +1 -1
- package/lib/util/flexplm-connect.spec.js +88 -88
- package/lib/util/logger-config.d.ts +1 -1
- package/lib/util/logger-config.js +26 -26
- package/lib/util/map-util-spec-mockData.js +205 -205
- package/lib/util/map-utils.d.ts +6 -6
- package/lib/util/map-utils.js +15 -15
- package/lib/util/map-utils.spec.d.ts +1 -1
- package/lib/util/map-utils.spec.js +89 -89
- package/lib/util/mockData.d.ts +80 -80
- package/lib/util/mockData.js +103 -103
- package/lib/util/thumbnail-util.d.ts +34 -34
- package/lib/util/thumbnail-util.js +215 -214
- package/lib/util/thumbnail-util.spec.d.ts +1 -1
- package/lib/util/thumbnail-util.spec.js +434 -394
- package/lib/util/type-conversion-utils-spec-mockData.js +259 -259
- package/lib/util/type-conversion-utils.d.ts +23 -23
- package/lib/util/type-conversion-utils.js +265 -265
- package/lib/util/type-conversion-utils.spec.d.ts +1 -1
- package/lib/util/type-conversion-utils.spec.js +868 -868
- package/lib/util/type-defaults.d.ts +16 -16
- package/lib/util/type-defaults.js +221 -221
- package/lib/util/type-defaults.spec.d.ts +1 -1
- package/lib/util/type-defaults.spec.js +516 -516
- package/lib/util/type-utils.d.ts +13 -13
- package/lib/util/type-utils.js +114 -114
- package/lib/util/type-utils.spec.d.ts +1 -1
- package/lib/util/type-utils.spec.js +190 -190
- package/package.json +1 -1
- package/publish.sh +0 -0
- package/src/util/thumbnail-util.spec.ts +50 -0
- package/src/util/thumbnail-util.ts +5 -4
- package/tsconfig.json +1 -6
- package/.claude/settings.local.json +0 -8
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { MapFileUtil } from "@contrail/transform-data";
|
|
2
|
-
import { ProductFederation, SeasonFederation, SeasonGroupFederation, SkuFederation } from "../interfaces/interfaces";
|
|
3
|
-
import { DataConverter } from "../util/data-converter";
|
|
4
|
-
export declare class IdentifierConversion {
|
|
5
|
-
static readonly INBOUND_ENTITY_MISSING_IDENIFIER_PROPS = "IdentifierConversion.getEntityCriteriaFromObject(): missing identifier properties: ";
|
|
6
|
-
static readonly MISSING_OBJECT = "IdentifierConversion.getEntityCriteriaFromObject(): missing: object";
|
|
7
|
-
static readonly MISSING_FLEXPLM_OBJECT_CLASS = "IdentifierConversion.getEntityCriteriaFromObject(): missing: flexPLMObjectClass";
|
|
8
|
-
static getSeasonIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment: any, includeInformationKeys?: boolean): Promise<SeasonFederation>;
|
|
9
|
-
static getSeasonGroupIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment: any, includeInformationKeys?: boolean): Promise<SeasonGroupFederation>;
|
|
10
|
-
static getProductIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemFamilyObject: any, includeInformationKeys?: boolean): Promise<ProductFederation>;
|
|
11
|
-
static getSKUIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemObject: any, includeInformationKeys?: boolean): Promise<SkuFederation>;
|
|
12
|
-
static getEntityCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
|
|
13
|
-
static getAssortmentCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
|
|
14
|
-
static getItemCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
|
|
15
|
-
}
|
|
1
|
+
import { MapFileUtil } from "@contrail/transform-data";
|
|
2
|
+
import { ProductFederation, SeasonFederation, SeasonGroupFederation, SkuFederation } from "../interfaces/interfaces";
|
|
3
|
+
import { DataConverter } from "../util/data-converter";
|
|
4
|
+
export declare class IdentifierConversion {
|
|
5
|
+
static readonly INBOUND_ENTITY_MISSING_IDENIFIER_PROPS = "IdentifierConversion.getEntityCriteriaFromObject(): missing identifier properties: ";
|
|
6
|
+
static readonly MISSING_OBJECT = "IdentifierConversion.getEntityCriteriaFromObject(): missing: object";
|
|
7
|
+
static readonly MISSING_FLEXPLM_OBJECT_CLASS = "IdentifierConversion.getEntityCriteriaFromObject(): missing: flexPLMObjectClass";
|
|
8
|
+
static getSeasonIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment: any, includeInformationKeys?: boolean): Promise<SeasonFederation>;
|
|
9
|
+
static getSeasonGroupIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment: any, includeInformationKeys?: boolean): Promise<SeasonGroupFederation>;
|
|
10
|
+
static getProductIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemFamilyObject: any, includeInformationKeys?: boolean): Promise<ProductFederation>;
|
|
11
|
+
static getSKUIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemObject: any, includeInformationKeys?: boolean): Promise<SkuFederation>;
|
|
12
|
+
static getEntityCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
|
|
13
|
+
static getAssortmentCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
|
|
14
|
+
static getItemCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
|
|
15
|
+
}
|
|
@@ -1,212 +1,212 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IdentifierConversion = void 0;
|
|
4
|
-
const map_utils_1 = require("../util/map-utils");
|
|
5
|
-
const type_conversion_utils_1 = require("../util/type-conversion-utils");
|
|
6
|
-
const event_short_message_status_1 = require("../util/event-short-message-status");
|
|
7
|
-
class IdentifierConversion {
|
|
8
|
-
static async getSeasonIdentityObject(transformMapFile, mapFileUtil, dc, assortment, includeInformationKeys = true) {
|
|
9
|
-
if (!assortment) {
|
|
10
|
-
throw new Error('IdentifierConversion.getSeasonIdentityObject(): assortment must be provided.');
|
|
11
|
-
}
|
|
12
|
-
assortment['flex2vibeMapKeyRoot'] = 'LCSSeason';
|
|
13
|
-
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
14
|
-
let seasonObj = {
|
|
15
|
-
entityReference: 'assortment:' + assortment?.id,
|
|
16
|
-
objectClass: 'LCSSeason',
|
|
17
|
-
flexPLMTypePath
|
|
18
|
-
};
|
|
19
|
-
try {
|
|
20
|
-
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
21
|
-
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
22
|
-
for (const key of identifierKeys) {
|
|
23
|
-
if (assortmentObj[key]) {
|
|
24
|
-
seasonObj[key] = assortmentObj[key];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (includeInformationKeys) {
|
|
28
|
-
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
29
|
-
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
30
|
-
for (const key of informationKeys) {
|
|
31
|
-
if (assortmentObj[key]) {
|
|
32
|
-
seasonObj[key] = assortmentObj[key];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const objectKeys = Object.keys(seasonObj);
|
|
37
|
-
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
38
|
-
if (!hasAllIdentifiers) {
|
|
39
|
-
console.error('IdentifierConversion.getSeasonIdentityObject(): doesnt have all identifier properties - ' + identifierKeys);
|
|
40
|
-
console.error('assortment: ' + JSON.stringify(assortment));
|
|
41
|
-
}
|
|
42
|
-
const mapKey = await type_conversion_utils_1.TypeConversionUtils
|
|
43
|
-
.getMapKey(transformMapFile, mapFileUtil, assortment, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
44
|
-
seasonObj = await map_utils_1.MapUtil
|
|
45
|
-
.applyTransformMap(transformMapFile, mapFileUtil, seasonObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
delete assortment['flex2vibeMapKeyRoot'];
|
|
49
|
-
}
|
|
50
|
-
return seasonObj;
|
|
51
|
-
}
|
|
52
|
-
static async getSeasonGroupIdentityObject(transformMapFile, mapFileUtil, dc, assortment, includeInformationKeys = true) {
|
|
53
|
-
if (!assortment) {
|
|
54
|
-
throw new Error('IdentifierConversion.getSeasonGroupIdentityObject(): assortment must be provided.');
|
|
55
|
-
}
|
|
56
|
-
assortment['flex2vibeMapKeyRoot'] = 'SeasonGroup';
|
|
57
|
-
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
58
|
-
let seasonGroupObj = {
|
|
59
|
-
entityReference: 'assortment:' + assortment?.id,
|
|
60
|
-
objectClass: 'SeasonGroup',
|
|
61
|
-
flexPLMTypePath
|
|
62
|
-
};
|
|
63
|
-
try {
|
|
64
|
-
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
65
|
-
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
66
|
-
.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
67
|
-
for (const key of identifierKeys) {
|
|
68
|
-
if (assortmentObj[key]) {
|
|
69
|
-
seasonGroupObj[key] = assortmentObj[key];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (includeInformationKeys) {
|
|
73
|
-
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
74
|
-
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
75
|
-
for (const key of informationKeys) {
|
|
76
|
-
if (assortmentObj[key]) {
|
|
77
|
-
seasonGroupObj[key] = assortmentObj[key];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const objectKeys = Object.keys(seasonGroupObj);
|
|
82
|
-
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
83
|
-
if (!hasAllIdentifiers) {
|
|
84
|
-
console.error('IdentifierConversion.getSeasonGroupIdentityObject(): doesnt have all identifier properties - ' + identifierKeys);
|
|
85
|
-
console.error('assortment: ' + JSON.stringify(assortment));
|
|
86
|
-
}
|
|
87
|
-
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, assortment, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
88
|
-
seasonGroupObj = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, seasonGroupObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
89
|
-
}
|
|
90
|
-
finally {
|
|
91
|
-
delete assortment['flex2vibeMapKeyRoot'];
|
|
92
|
-
}
|
|
93
|
-
return seasonGroupObj;
|
|
94
|
-
}
|
|
95
|
-
static async getProductIdentityObject(transformMapFile, mapFileUtil, dc, itemFamilyObject, includeInformationKeys = true) {
|
|
96
|
-
if (!itemFamilyObject) {
|
|
97
|
-
throw new Error('IdentifierConversion.getProductIdentityObject(): itemFamilyObject must be provided.');
|
|
98
|
-
}
|
|
99
|
-
const itemObj = await dc.getFlexPLMObjectData(itemFamilyObject, [], true);
|
|
100
|
-
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
101
|
-
let prodObj = {
|
|
102
|
-
entityReference: 'item:' + itemFamilyObject?.id,
|
|
103
|
-
objectClass: 'LCSProduct',
|
|
104
|
-
flexPLMTypePath
|
|
105
|
-
};
|
|
106
|
-
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
107
|
-
.getIdentifierProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
108
|
-
for (const key of identifierKeys) {
|
|
109
|
-
if (itemObj[key]) {
|
|
110
|
-
prodObj[key] = itemObj[key];
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (includeInformationKeys) {
|
|
114
|
-
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
115
|
-
.getInformationalProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
116
|
-
for (const key of informationKeys) {
|
|
117
|
-
if (itemObj[key]) {
|
|
118
|
-
prodObj[key] = itemObj[key];
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
123
|
-
if (!prodObj[vibeIQIdentifier]) {
|
|
124
|
-
prodObj['vibeIQIdentifier'] = itemFamilyObject['identifier'] || itemFamilyObject['itemNumber'];
|
|
125
|
-
}
|
|
126
|
-
const mapKey = await type_conversion_utils_1.TypeConversionUtils
|
|
127
|
-
.getMapKey(transformMapFile, mapFileUtil, itemFamilyObject, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
128
|
-
prodObj = await map_utils_1.MapUtil
|
|
129
|
-
.applyTransformMap(transformMapFile, mapFileUtil, prodObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
130
|
-
return prodObj;
|
|
131
|
-
}
|
|
132
|
-
static async getSKUIdentityObject(transformMapFile, mapFileUtil, dc, itemObject, includeInformationKeys = true) {
|
|
133
|
-
if (!itemObject) {
|
|
134
|
-
throw new Error('IdentifierConversion.getSKUIdentityObject(): itemObject must be provided.');
|
|
135
|
-
}
|
|
136
|
-
const itemObj = await dc.getFlexPLMObjectData(itemObject, [], true);
|
|
137
|
-
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemObject);
|
|
138
|
-
let skuObj = {
|
|
139
|
-
entityReference: 'item:' + itemObject?.id,
|
|
140
|
-
objectClass: 'LCSSKU',
|
|
141
|
-
flexPLMTypePath
|
|
142
|
-
};
|
|
143
|
-
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, itemObject);
|
|
144
|
-
for (const key of identifierKeys) {
|
|
145
|
-
if (itemObj[key]) {
|
|
146
|
-
skuObj[key] = itemObj[key];
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (includeInformationKeys) {
|
|
150
|
-
const informationKeys = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(transformMapFile, mapFileUtil, itemObject);
|
|
151
|
-
for (const key of informationKeys) {
|
|
152
|
-
if (itemObj[key]) {
|
|
153
|
-
skuObj[key] = itemObj[key];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
158
|
-
if (!skuObj[vibeIQIdentifier]) {
|
|
159
|
-
skuObj['vibeIQIdentifier'] = itemObject['identifier'] || itemObject['itemNumber'];
|
|
160
|
-
}
|
|
161
|
-
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, itemObject, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
162
|
-
skuObj = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, skuObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
163
|
-
return skuObj;
|
|
164
|
-
}
|
|
165
|
-
static async getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object) {
|
|
166
|
-
if (!object) {
|
|
167
|
-
const e = new Error(IdentifierConversion.MISSING_OBJECT);
|
|
168
|
-
e['shortStatusMessage'] = event_short_message_status_1.EventShortMessageStatus.MISSING_INPUT;
|
|
169
|
-
throw e;
|
|
170
|
-
}
|
|
171
|
-
else if (!object.flexPLMObjectClass) {
|
|
172
|
-
const e = new Error(IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS);
|
|
173
|
-
e['shortStatusMessage'] = event_short_message_status_1.EventShortMessageStatus.MISSING_INPUT;
|
|
174
|
-
throw e;
|
|
175
|
-
}
|
|
176
|
-
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(transformMapFile, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
177
|
-
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(transformMapFile, mapFileUtil, object);
|
|
178
|
-
const objectData = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, object, mapKey, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
179
|
-
let identifierValues = identifierKeys.reduce((acc, key) => {
|
|
180
|
-
acc[key] = objectData[key];
|
|
181
|
-
return acc;
|
|
182
|
-
}, {});
|
|
183
|
-
identifierValues['flexPLMObjectClass'] = objectData?.flexPLMObjectClass;
|
|
184
|
-
identifierValues['flexPLMTypePath'] = objectData?.flexPLMTypePath;
|
|
185
|
-
identifierValues = await dc.getEntityValues(objectData?.flexPLMObjectClass, identifierValues, []);
|
|
186
|
-
const entityKeys = Object.keys(identifierValues);
|
|
187
|
-
const hasAllIdentifiers = identifierKeys.every(key => entityKeys.includes(key));
|
|
188
|
-
if (!hasAllIdentifiers) {
|
|
189
|
-
const e = new Error(IdentifierConversion.INBOUND_ENTITY_MISSING_IDENIFIER_PROPS + identifierKeys);
|
|
190
|
-
e['shortStatusMessage'] = event_short_message_status_1.EventShortMessageStatus.MISSING_IDENTIFIER_PROPERTIES;
|
|
191
|
-
throw e;
|
|
192
|
-
}
|
|
193
|
-
const criteria = {};
|
|
194
|
-
for (const key of identifierKeys) {
|
|
195
|
-
criteria[key] = identifierValues[key];
|
|
196
|
-
}
|
|
197
|
-
return criteria;
|
|
198
|
-
}
|
|
199
|
-
static async getAssortmentCriteriaFromObject(transformMapFile, mapFileUtil, dc, object) {
|
|
200
|
-
return IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
|
|
201
|
-
}
|
|
202
|
-
static async getItemCriteriaFromObject(transformMapFile, mapFileUtil, dc, object) {
|
|
203
|
-
const criteria = await IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
|
|
204
|
-
const roles = (object.flexPLMObjectClass === 'LCSProduct') ? 'family' : 'color';
|
|
205
|
-
criteria['roles'] = roles;
|
|
206
|
-
return criteria;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
exports.IdentifierConversion = IdentifierConversion;
|
|
210
|
-
IdentifierConversion.INBOUND_ENTITY_MISSING_IDENIFIER_PROPS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing identifier properties: ';
|
|
211
|
-
IdentifierConversion.MISSING_OBJECT = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: object';
|
|
212
|
-
IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: flexPLMObjectClass';
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdentifierConversion = void 0;
|
|
4
|
+
const map_utils_1 = require("../util/map-utils");
|
|
5
|
+
const type_conversion_utils_1 = require("../util/type-conversion-utils");
|
|
6
|
+
const event_short_message_status_1 = require("../util/event-short-message-status");
|
|
7
|
+
class IdentifierConversion {
|
|
8
|
+
static async getSeasonIdentityObject(transformMapFile, mapFileUtil, dc, assortment, includeInformationKeys = true) {
|
|
9
|
+
if (!assortment) {
|
|
10
|
+
throw new Error('IdentifierConversion.getSeasonIdentityObject(): assortment must be provided.');
|
|
11
|
+
}
|
|
12
|
+
assortment['flex2vibeMapKeyRoot'] = 'LCSSeason';
|
|
13
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
14
|
+
let seasonObj = {
|
|
15
|
+
entityReference: 'assortment:' + assortment?.id,
|
|
16
|
+
objectClass: 'LCSSeason',
|
|
17
|
+
flexPLMTypePath
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
21
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
22
|
+
for (const key of identifierKeys) {
|
|
23
|
+
if (assortmentObj[key]) {
|
|
24
|
+
seasonObj[key] = assortmentObj[key];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (includeInformationKeys) {
|
|
28
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
29
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
30
|
+
for (const key of informationKeys) {
|
|
31
|
+
if (assortmentObj[key]) {
|
|
32
|
+
seasonObj[key] = assortmentObj[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const objectKeys = Object.keys(seasonObj);
|
|
37
|
+
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
38
|
+
if (!hasAllIdentifiers) {
|
|
39
|
+
console.error('IdentifierConversion.getSeasonIdentityObject(): doesnt have all identifier properties - ' + identifierKeys);
|
|
40
|
+
console.error('assortment: ' + JSON.stringify(assortment));
|
|
41
|
+
}
|
|
42
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils
|
|
43
|
+
.getMapKey(transformMapFile, mapFileUtil, assortment, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
44
|
+
seasonObj = await map_utils_1.MapUtil
|
|
45
|
+
.applyTransformMap(transformMapFile, mapFileUtil, seasonObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
delete assortment['flex2vibeMapKeyRoot'];
|
|
49
|
+
}
|
|
50
|
+
return seasonObj;
|
|
51
|
+
}
|
|
52
|
+
static async getSeasonGroupIdentityObject(transformMapFile, mapFileUtil, dc, assortment, includeInformationKeys = true) {
|
|
53
|
+
if (!assortment) {
|
|
54
|
+
throw new Error('IdentifierConversion.getSeasonGroupIdentityObject(): assortment must be provided.');
|
|
55
|
+
}
|
|
56
|
+
assortment['flex2vibeMapKeyRoot'] = 'SeasonGroup';
|
|
57
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
58
|
+
let seasonGroupObj = {
|
|
59
|
+
entityReference: 'assortment:' + assortment?.id,
|
|
60
|
+
objectClass: 'SeasonGroup',
|
|
61
|
+
flexPLMTypePath
|
|
62
|
+
};
|
|
63
|
+
try {
|
|
64
|
+
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
65
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
66
|
+
.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
67
|
+
for (const key of identifierKeys) {
|
|
68
|
+
if (assortmentObj[key]) {
|
|
69
|
+
seasonGroupObj[key] = assortmentObj[key];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (includeInformationKeys) {
|
|
73
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
74
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
75
|
+
for (const key of informationKeys) {
|
|
76
|
+
if (assortmentObj[key]) {
|
|
77
|
+
seasonGroupObj[key] = assortmentObj[key];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const objectKeys = Object.keys(seasonGroupObj);
|
|
82
|
+
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
83
|
+
if (!hasAllIdentifiers) {
|
|
84
|
+
console.error('IdentifierConversion.getSeasonGroupIdentityObject(): doesnt have all identifier properties - ' + identifierKeys);
|
|
85
|
+
console.error('assortment: ' + JSON.stringify(assortment));
|
|
86
|
+
}
|
|
87
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, assortment, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
88
|
+
seasonGroupObj = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, seasonGroupObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
delete assortment['flex2vibeMapKeyRoot'];
|
|
92
|
+
}
|
|
93
|
+
return seasonGroupObj;
|
|
94
|
+
}
|
|
95
|
+
static async getProductIdentityObject(transformMapFile, mapFileUtil, dc, itemFamilyObject, includeInformationKeys = true) {
|
|
96
|
+
if (!itemFamilyObject) {
|
|
97
|
+
throw new Error('IdentifierConversion.getProductIdentityObject(): itemFamilyObject must be provided.');
|
|
98
|
+
}
|
|
99
|
+
const itemObj = await dc.getFlexPLMObjectData(itemFamilyObject, [], true);
|
|
100
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
101
|
+
let prodObj = {
|
|
102
|
+
entityReference: 'item:' + itemFamilyObject?.id,
|
|
103
|
+
objectClass: 'LCSProduct',
|
|
104
|
+
flexPLMTypePath
|
|
105
|
+
};
|
|
106
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
107
|
+
.getIdentifierProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
108
|
+
for (const key of identifierKeys) {
|
|
109
|
+
if (itemObj[key]) {
|
|
110
|
+
prodObj[key] = itemObj[key];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (includeInformationKeys) {
|
|
114
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
115
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
116
|
+
for (const key of informationKeys) {
|
|
117
|
+
if (itemObj[key]) {
|
|
118
|
+
prodObj[key] = itemObj[key];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
123
|
+
if (!prodObj[vibeIQIdentifier]) {
|
|
124
|
+
prodObj['vibeIQIdentifier'] = itemFamilyObject['identifier'] || itemFamilyObject['itemNumber'];
|
|
125
|
+
}
|
|
126
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils
|
|
127
|
+
.getMapKey(transformMapFile, mapFileUtil, itemFamilyObject, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
128
|
+
prodObj = await map_utils_1.MapUtil
|
|
129
|
+
.applyTransformMap(transformMapFile, mapFileUtil, prodObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
130
|
+
return prodObj;
|
|
131
|
+
}
|
|
132
|
+
static async getSKUIdentityObject(transformMapFile, mapFileUtil, dc, itemObject, includeInformationKeys = true) {
|
|
133
|
+
if (!itemObject) {
|
|
134
|
+
throw new Error('IdentifierConversion.getSKUIdentityObject(): itemObject must be provided.');
|
|
135
|
+
}
|
|
136
|
+
const itemObj = await dc.getFlexPLMObjectData(itemObject, [], true);
|
|
137
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemObject);
|
|
138
|
+
let skuObj = {
|
|
139
|
+
entityReference: 'item:' + itemObject?.id,
|
|
140
|
+
objectClass: 'LCSSKU',
|
|
141
|
+
flexPLMTypePath
|
|
142
|
+
};
|
|
143
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, itemObject);
|
|
144
|
+
for (const key of identifierKeys) {
|
|
145
|
+
if (itemObj[key]) {
|
|
146
|
+
skuObj[key] = itemObj[key];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (includeInformationKeys) {
|
|
150
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(transformMapFile, mapFileUtil, itemObject);
|
|
151
|
+
for (const key of informationKeys) {
|
|
152
|
+
if (itemObj[key]) {
|
|
153
|
+
skuObj[key] = itemObj[key];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
158
|
+
if (!skuObj[vibeIQIdentifier]) {
|
|
159
|
+
skuObj['vibeIQIdentifier'] = itemObject['identifier'] || itemObject['itemNumber'];
|
|
160
|
+
}
|
|
161
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, itemObject, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
162
|
+
skuObj = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, skuObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
163
|
+
return skuObj;
|
|
164
|
+
}
|
|
165
|
+
static async getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object) {
|
|
166
|
+
if (!object) {
|
|
167
|
+
const e = new Error(IdentifierConversion.MISSING_OBJECT);
|
|
168
|
+
e['shortStatusMessage'] = event_short_message_status_1.EventShortMessageStatus.MISSING_INPUT;
|
|
169
|
+
throw e;
|
|
170
|
+
}
|
|
171
|
+
else if (!object.flexPLMObjectClass) {
|
|
172
|
+
const e = new Error(IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS);
|
|
173
|
+
e['shortStatusMessage'] = event_short_message_status_1.EventShortMessageStatus.MISSING_INPUT;
|
|
174
|
+
throw e;
|
|
175
|
+
}
|
|
176
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(transformMapFile, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
177
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(transformMapFile, mapFileUtil, object);
|
|
178
|
+
const objectData = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, object, mapKey, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
179
|
+
let identifierValues = identifierKeys.reduce((acc, key) => {
|
|
180
|
+
acc[key] = objectData[key];
|
|
181
|
+
return acc;
|
|
182
|
+
}, {});
|
|
183
|
+
identifierValues['flexPLMObjectClass'] = objectData?.flexPLMObjectClass;
|
|
184
|
+
identifierValues['flexPLMTypePath'] = objectData?.flexPLMTypePath;
|
|
185
|
+
identifierValues = await dc.getEntityValues(objectData?.flexPLMObjectClass, identifierValues, []);
|
|
186
|
+
const entityKeys = Object.keys(identifierValues);
|
|
187
|
+
const hasAllIdentifiers = identifierKeys.every(key => entityKeys.includes(key));
|
|
188
|
+
if (!hasAllIdentifiers) {
|
|
189
|
+
const e = new Error(IdentifierConversion.INBOUND_ENTITY_MISSING_IDENIFIER_PROPS + identifierKeys);
|
|
190
|
+
e['shortStatusMessage'] = event_short_message_status_1.EventShortMessageStatus.MISSING_IDENTIFIER_PROPERTIES;
|
|
191
|
+
throw e;
|
|
192
|
+
}
|
|
193
|
+
const criteria = {};
|
|
194
|
+
for (const key of identifierKeys) {
|
|
195
|
+
criteria[key] = identifierValues[key];
|
|
196
|
+
}
|
|
197
|
+
return criteria;
|
|
198
|
+
}
|
|
199
|
+
static async getAssortmentCriteriaFromObject(transformMapFile, mapFileUtil, dc, object) {
|
|
200
|
+
return IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
|
|
201
|
+
}
|
|
202
|
+
static async getItemCriteriaFromObject(transformMapFile, mapFileUtil, dc, object) {
|
|
203
|
+
const criteria = await IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
|
|
204
|
+
const roles = (object.flexPLMObjectClass === 'LCSProduct') ? 'family' : 'color';
|
|
205
|
+
criteria['roles'] = roles;
|
|
206
|
+
return criteria;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.IdentifierConversion = IdentifierConversion;
|
|
210
|
+
IdentifierConversion.INBOUND_ENTITY_MISSING_IDENIFIER_PROPS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing identifier properties: ';
|
|
211
|
+
IdentifierConversion.MISSING_OBJECT = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: object';
|
|
212
|
+
IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: flexPLMObjectClass';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|