@contrail/flexplm 1.1.6 → 1.1.7
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/index.d.ts
CHANGED
|
@@ -17,3 +17,4 @@ export * from './interfaces/publish-change-data';
|
|
|
17
17
|
export * from './publish/base-process-publish-assortment';
|
|
18
18
|
export * from './publish/base-process-publish-assortment-callback';
|
|
19
19
|
export * from './entity-processor/base-entity-processor';
|
|
20
|
+
export * from './transform/identifier-conversion';
|
package/lib/index.js
CHANGED
|
@@ -33,3 +33,4 @@ __exportStar(require("./interfaces/publish-change-data"), exports);
|
|
|
33
33
|
__exportStar(require("./publish/base-process-publish-assortment"), exports);
|
|
34
34
|
__exportStar(require("./publish/base-process-publish-assortment-callback"), exports);
|
|
35
35
|
__exportStar(require("./entity-processor/base-entity-processor"), exports);
|
|
36
|
+
__exportStar(require("./transform/identifier-conversion"), exports);
|
|
@@ -23,6 +23,7 @@ export interface ProductFederation {
|
|
|
23
23
|
entityReference: string;
|
|
24
24
|
objectClass: 'LCSProduct';
|
|
25
25
|
federatedId?: string;
|
|
26
|
+
flexPLMTypePath?: string;
|
|
26
27
|
vibeIQIdentifier?: string;
|
|
27
28
|
}
|
|
28
29
|
export interface ProductData extends ProductFederation {
|
|
@@ -36,12 +37,21 @@ export interface SeasonFederation {
|
|
|
36
37
|
objectClass: 'LCSSeason';
|
|
37
38
|
flexPLMSeasonName?: string;
|
|
38
39
|
federationId?: string;
|
|
40
|
+
flexPLMTypePath?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface SeasonGroupFederation {
|
|
43
|
+
entityReference: string;
|
|
44
|
+
objectClass: 'SeasonGroup';
|
|
45
|
+
seasonGroupName?: string;
|
|
46
|
+
federationId?: string;
|
|
47
|
+
flexPLMTypePath?: string;
|
|
39
48
|
}
|
|
40
49
|
export interface SkuFederation {
|
|
41
50
|
entityReference: string;
|
|
42
51
|
objectClass: 'LCSSKU';
|
|
43
52
|
LCSProduct?: ProductFederation;
|
|
44
53
|
federatedId?: string;
|
|
54
|
+
flexPLMTypePath?: string;
|
|
45
55
|
vibeIQIdentifier?: string;
|
|
46
56
|
}
|
|
47
57
|
export interface SkuData extends SkuFederation {
|
|
@@ -453,7 +453,7 @@ class BaseProcessPublishAssortment {
|
|
|
453
453
|
data: seasonalData
|
|
454
454
|
};
|
|
455
455
|
if ('ASSORTMENT' === projectItem.addedFromSource && projectItem.addedFromAssortment) {
|
|
456
|
-
const carriedFromSeason =
|
|
456
|
+
const carriedFromSeason = this.getCarriedFromSeason(projectItem);
|
|
457
457
|
if (carriedFromSeason) {
|
|
458
458
|
psUpsert['carriedFromSeason'] = carriedFromSeason;
|
|
459
459
|
}
|
|
@@ -482,7 +482,7 @@ class BaseProcessPublishAssortment {
|
|
|
482
482
|
data: seasonalData
|
|
483
483
|
};
|
|
484
484
|
if ('ASSORTMENT' === projectItem.addedFromSource && projectItem.addedFromAssortment) {
|
|
485
|
-
const carriedFromSeason =
|
|
485
|
+
const carriedFromSeason = this.getCarriedFromSeason(projectItem);
|
|
486
486
|
if (carriedFromSeason) {
|
|
487
487
|
csUpsert['carriedFromSeason'] = carriedFromSeason;
|
|
488
488
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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 getSeasonIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment: any, includeInformationKeys?: boolean): Promise<SeasonFederation>;
|
|
6
|
+
static getSeasonGroupIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment: any, includeInformationKeys?: boolean): Promise<SeasonGroupFederation>;
|
|
7
|
+
static getProductIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemFamilyObject: any, includeInformationKeys?: boolean): Promise<ProductFederation>;
|
|
8
|
+
static getSKUIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemObject: any, includeInformationKeys?: boolean): Promise<SkuFederation>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
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
|
+
class IdentifierConversion {
|
|
7
|
+
static async getSeasonIdentityObject(transformMapFile, mapFileUtil, dc, assortment, includeInformationKeys = true) {
|
|
8
|
+
if (!assortment) {
|
|
9
|
+
throw new Error('IdentifierConversion.getSeasonIdentityObject(): assortment must be provided.');
|
|
10
|
+
}
|
|
11
|
+
assortment['flex2vibeMapKeyRoot'] = 'LCSSeason';
|
|
12
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
13
|
+
let seasonObj = {
|
|
14
|
+
entityReference: 'assortment:' + assortment?.id,
|
|
15
|
+
objectClass: 'LCSSeason',
|
|
16
|
+
flexPLMTypePath
|
|
17
|
+
};
|
|
18
|
+
try {
|
|
19
|
+
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
20
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
21
|
+
for (const key of identifierKeys) {
|
|
22
|
+
if (assortmentObj[key]) {
|
|
23
|
+
seasonObj[key] = assortmentObj[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (includeInformationKeys) {
|
|
27
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
28
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
29
|
+
for (const key of informationKeys) {
|
|
30
|
+
if (assortmentObj[key]) {
|
|
31
|
+
seasonObj[key] = assortmentObj[key];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const objectKeys = Object.keys(seasonObj);
|
|
36
|
+
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
37
|
+
if (!hasAllIdentifiers) {
|
|
38
|
+
console.error('IdentifierConversion.getSeasonIdentityObject(): doesnt have all identifier properties - ' + identifierKeys);
|
|
39
|
+
console.error('assortment: ' + JSON.stringify(assortment));
|
|
40
|
+
}
|
|
41
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils
|
|
42
|
+
.getMapKey(transformMapFile, mapFileUtil, assortment, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
43
|
+
seasonObj = await map_utils_1.MapUtil
|
|
44
|
+
.applyTransformMap(transformMapFile, mapFileUtil, seasonObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
delete assortment['flex2vibeMapKeyRoot'];
|
|
48
|
+
}
|
|
49
|
+
return seasonObj;
|
|
50
|
+
}
|
|
51
|
+
static async getSeasonGroupIdentityObject(transformMapFile, mapFileUtil, dc, assortment, includeInformationKeys = true) {
|
|
52
|
+
if (!assortment) {
|
|
53
|
+
throw new Error('IdentifierConversion.getSeasonGroupIdentityObject(): assortment must be provided.');
|
|
54
|
+
}
|
|
55
|
+
assortment['flex2vibeMapKeyRoot'] = 'SeasonGroup';
|
|
56
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
57
|
+
let seasonGroupObj = {
|
|
58
|
+
entityReference: 'assortment:' + assortment?.id,
|
|
59
|
+
objectClass: 'SeasonGroup',
|
|
60
|
+
flexPLMTypePath
|
|
61
|
+
};
|
|
62
|
+
try {
|
|
63
|
+
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
64
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
65
|
+
.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
66
|
+
for (const key of identifierKeys) {
|
|
67
|
+
if (assortmentObj[key]) {
|
|
68
|
+
seasonGroupObj[key] = assortmentObj[key];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (includeInformationKeys) {
|
|
72
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
73
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
74
|
+
for (const key of informationKeys) {
|
|
75
|
+
if (assortmentObj[key]) {
|
|
76
|
+
seasonGroupObj[key] = assortmentObj[key];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const objectKeys = Object.keys(seasonGroupObj);
|
|
81
|
+
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
82
|
+
if (!hasAllIdentifiers) {
|
|
83
|
+
console.error('IdentifierConversion.getSeasonGroupIdentityObject(): doesnt have all identifier properties - ' + identifierKeys);
|
|
84
|
+
console.error('assortment: ' + JSON.stringify(assortment));
|
|
85
|
+
}
|
|
86
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, assortment, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
87
|
+
seasonGroupObj = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, seasonGroupObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
delete assortment['flex2vibeMapKeyRoot'];
|
|
91
|
+
}
|
|
92
|
+
return seasonGroupObj;
|
|
93
|
+
}
|
|
94
|
+
static async getProductIdentityObject(transformMapFile, mapFileUtil, dc, itemFamilyObject, includeInformationKeys = true) {
|
|
95
|
+
if (!itemFamilyObject) {
|
|
96
|
+
throw new Error('IdentifierConversion.getProductIdentityObject(): itemFamilyObject must be provided.');
|
|
97
|
+
}
|
|
98
|
+
const itemObj = await dc.getFlexPLMObjectData(itemFamilyObject, [], true);
|
|
99
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
100
|
+
let prodObj = {
|
|
101
|
+
entityReference: 'item:' + itemFamilyObject?.id,
|
|
102
|
+
objectClass: 'LCSProduct',
|
|
103
|
+
flexPLMTypePath
|
|
104
|
+
};
|
|
105
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
106
|
+
.getIdentifierProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
107
|
+
for (const key of identifierKeys) {
|
|
108
|
+
if (itemObj[key]) {
|
|
109
|
+
prodObj[key] = itemObj[key];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (includeInformationKeys) {
|
|
113
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
114
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
115
|
+
for (const key of informationKeys) {
|
|
116
|
+
if (itemObj[key]) {
|
|
117
|
+
prodObj[key] = itemObj[key];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
122
|
+
if (!prodObj[vibeIQIdentifier]) {
|
|
123
|
+
prodObj['vibeIQIdentifier'] = itemFamilyObject['identifier'] || itemFamilyObject['itemNumber'];
|
|
124
|
+
}
|
|
125
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils
|
|
126
|
+
.getMapKey(transformMapFile, mapFileUtil, itemFamilyObject, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
127
|
+
prodObj = await map_utils_1.MapUtil
|
|
128
|
+
.applyTransformMap(transformMapFile, mapFileUtil, prodObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
129
|
+
return prodObj;
|
|
130
|
+
}
|
|
131
|
+
static async getSKUIdentityObject(transformMapFile, mapFileUtil, dc, itemObject, includeInformationKeys = true) {
|
|
132
|
+
if (!itemObject) {
|
|
133
|
+
throw new Error('IdentifierConversion.getSKUIdentityObject(): itemObject must be provided.');
|
|
134
|
+
}
|
|
135
|
+
const itemObj = await dc.getFlexPLMObjectData(itemObject, [], true);
|
|
136
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemObject);
|
|
137
|
+
let skuObj = {
|
|
138
|
+
entityReference: 'item:' + itemObject?.id,
|
|
139
|
+
objectClass: 'LCSSKU',
|
|
140
|
+
flexPLMTypePath
|
|
141
|
+
};
|
|
142
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, itemObject);
|
|
143
|
+
for (const key of identifierKeys) {
|
|
144
|
+
if (itemObj[key]) {
|
|
145
|
+
skuObj[key] = itemObj[key];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (includeInformationKeys) {
|
|
149
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(transformMapFile, mapFileUtil, itemObject);
|
|
150
|
+
for (const key of informationKeys) {
|
|
151
|
+
if (itemObj[key]) {
|
|
152
|
+
skuObj[key] = itemObj[key];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
157
|
+
if (!skuObj[vibeIQIdentifier]) {
|
|
158
|
+
skuObj['vibeIQIdentifier'] = itemObject['identifier'] || itemObject['itemNumber'];
|
|
159
|
+
}
|
|
160
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, itemObject, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
161
|
+
skuObj = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, skuObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
162
|
+
return skuObj;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.IdentifierConversion = IdentifierConversion;
|