@contrail/flexplm 1.3.0 → 1.3.1-alpha.3507ab6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +228 -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 +89 -42
- package/lib/entity-processor/base-entity-processor.js +438 -385
- package/lib/entity-processor/base-entity-processor.spec.d.ts +1 -1
- package/lib/entity-processor/base-entity-processor.spec.js +398 -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 +23 -22
- package/lib/index.js +39 -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/mapping-file.d.ts +460 -0
- package/lib/interfaces/mapping-file.js +2 -0
- 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 +118 -93
- package/lib/publish/base-process-publish-assortment.js +998 -944
- package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -1
- package/lib/publish/base-process-publish-assortment.spec.js +1688 -1670
- package/lib/publish/mockData.d.ts +1389 -1389
- package/lib/publish/mockData.js +4524 -4519
- package/lib/transform/identifier-conversion-spec-mockData.js +472 -444
- package/lib/transform/identifier-conversion.d.ts +51 -15
- package/lib/transform/identifier-conversion.js +248 -212
- package/lib/transform/identifier-conversion.spec.d.ts +1 -1
- package/lib/transform/identifier-conversion.spec.js +343 -339
- package/lib/util/config-defaults.d.ts +8 -8
- package/lib/util/config-defaults.js +88 -85
- package/lib/util/config-defaults.spec.d.ts +1 -1
- package/lib/util/config-defaults.spec.js +302 -293
- package/lib/util/data-converter-spec-mockData.js +219 -205
- package/lib/util/data-converter.d.ts +136 -39
- package/lib/util/data-converter.js +718 -592
- package/lib/util/data-converter.spec.d.ts +1 -1
- package/lib/util/data-converter.spec.js +906 -904
- package/lib/util/error-response-object.d.ts +9 -4
- package/lib/util/error-response-object.js +54 -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 +24 -23
- package/lib/util/federation.d.ts +15 -15
- package/lib/util/federation.js +157 -149
- package/lib/util/flexplm-connect.d.ts +29 -22
- package/lib/util/flexplm-connect.js +190 -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 +27 -26
- package/lib/util/map-util-spec-mockData.js +219 -205
- package/lib/util/map-utils.d.ts +33 -6
- package/lib/util/map-utils.js +42 -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 +55 -34
- package/lib/util/thumbnail-util.js +242 -215
- package/lib/util/thumbnail-util.spec.d.ts +1 -1
- package/lib/util/thumbnail-util.spec.js +440 -434
- package/lib/util/type-conversion-utils-spec-mockData.js +259 -259
- package/lib/util/type-conversion-utils.d.ts +163 -23
- package/lib/util/type-conversion-utils.js +408 -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 +74 -16
- package/lib/util/type-defaults.js +279 -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 +34 -13
- package/lib/util/type-utils.js +137 -114
- package/lib/util/type-utils.spec.d.ts +1 -1
- package/lib/util/type-utils.spec.js +192 -190
- package/package.json +21 -6
- package/scripts/copy-template.js +10 -0
- package/.claude/settings.local.json +0 -8
- package/.github/pull_request_template.md +0 -31
- package/.github/workflows/flexplm-lib.yml +0 -27
- package/.github/workflows/publish-to-npm.yml +0 -124
- 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 -29
- package/tslint.json +0 -57
|
@@ -1,15 +1,51 @@
|
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
/** Takes in an assortment and returns an object to query for an LCSSeason
|
|
9
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
10
|
+
* @param transformMapFile
|
|
11
|
+
* @param mapFileUtil
|
|
12
|
+
* @param dc
|
|
13
|
+
* @param assortment
|
|
14
|
+
* @param includeInformationKeys defaults true
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
static getSeasonIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment: any, includeInformationKeys?: boolean): Promise<SeasonFederation>;
|
|
18
|
+
/** Takes in an assortment and returns an object to query for an SeasonGroup
|
|
19
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
20
|
+
* @param transformMapFile
|
|
21
|
+
* @param mapFileUtil
|
|
22
|
+
* @param dc
|
|
23
|
+
* @param assortment
|
|
24
|
+
* @param includeInformationKeys defaults true
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
static getSeasonGroupIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, assortment: any, includeInformationKeys?: boolean): Promise<SeasonGroupFederation>;
|
|
28
|
+
/** Takes in an item and returns an object to query for an LCSProduct
|
|
29
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
30
|
+
* @param transformMapFile
|
|
31
|
+
* @param mapFileUtil
|
|
32
|
+
* @param dc
|
|
33
|
+
* @param assortment
|
|
34
|
+
* @param includeInformationKeys defaults true
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
static getProductIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemFamilyObject: any, includeInformationKeys?: boolean): Promise<ProductFederation>;
|
|
38
|
+
/** Takes in an item and returns an object to query for an LCSSKU
|
|
39
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
40
|
+
* @param transformMapFile
|
|
41
|
+
* @param mapFileUtil
|
|
42
|
+
* @param dc
|
|
43
|
+
* @param assortment
|
|
44
|
+
* @param includeInformationKeys defaults true
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
static getSKUIdentityObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, itemObject: any, includeInformationKeys?: boolean): Promise<SkuFederation>;
|
|
48
|
+
static getEntityCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
|
|
49
|
+
static getAssortmentCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
|
|
50
|
+
static getItemCriteriaFromObject(transformMapFile: string, mapFileUtil: MapFileUtil, dc: DataConverter, object: any): Promise<any>;
|
|
51
|
+
}
|
|
@@ -1,212 +1,248 @@
|
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (!
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
prodObj =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
+
/** Takes in an assortment and returns an object to query for an LCSSeason
|
|
9
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
10
|
+
* @param transformMapFile
|
|
11
|
+
* @param mapFileUtil
|
|
12
|
+
* @param dc
|
|
13
|
+
* @param assortment
|
|
14
|
+
* @param includeInformationKeys defaults true
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
static async getSeasonIdentityObject(transformMapFile, mapFileUtil, dc, assortment, includeInformationKeys = true) {
|
|
18
|
+
if (!assortment) {
|
|
19
|
+
throw new Error('IdentifierConversion.getSeasonIdentityObject(): assortment must be provided.');
|
|
20
|
+
}
|
|
21
|
+
assortment['flex2vibeMapKeyRoot'] = 'LCSSeason';
|
|
22
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
23
|
+
let seasonObj = {
|
|
24
|
+
entityReference: 'assortment:' + assortment?.id,
|
|
25
|
+
objectClass: 'LCSSeason',
|
|
26
|
+
flexPLMTypePath
|
|
27
|
+
};
|
|
28
|
+
try {
|
|
29
|
+
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
30
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
31
|
+
for (const key of identifierKeys) {
|
|
32
|
+
if (assortmentObj[key]) {
|
|
33
|
+
seasonObj[key] = assortmentObj[key];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (includeInformationKeys) {
|
|
37
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
38
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
39
|
+
for (const key of informationKeys) {
|
|
40
|
+
if (assortmentObj[key]) {
|
|
41
|
+
seasonObj[key] = assortmentObj[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const objectKeys = Object.keys(seasonObj);
|
|
46
|
+
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
47
|
+
if (!hasAllIdentifiers) {
|
|
48
|
+
console.error('IdentifierConversion.getSeasonIdentityObject(): doesnt have all identifier properties - ' + identifierKeys);
|
|
49
|
+
console.error('assortment: ' + JSON.stringify(assortment));
|
|
50
|
+
}
|
|
51
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils
|
|
52
|
+
.getMapKey(transformMapFile, mapFileUtil, assortment, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
53
|
+
seasonObj = await map_utils_1.MapUtil
|
|
54
|
+
.applyTransformMap(transformMapFile, mapFileUtil, seasonObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
delete assortment['flex2vibeMapKeyRoot'];
|
|
58
|
+
}
|
|
59
|
+
return seasonObj;
|
|
60
|
+
}
|
|
61
|
+
/** Takes in an assortment and returns an object to query for an SeasonGroup
|
|
62
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
63
|
+
* @param transformMapFile
|
|
64
|
+
* @param mapFileUtil
|
|
65
|
+
* @param dc
|
|
66
|
+
* @param assortment
|
|
67
|
+
* @param includeInformationKeys defaults true
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
static async getSeasonGroupIdentityObject(transformMapFile, mapFileUtil, dc, assortment, includeInformationKeys = true) {
|
|
71
|
+
if (!assortment) {
|
|
72
|
+
throw new Error('IdentifierConversion.getSeasonGroupIdentityObject(): assortment must be provided.');
|
|
73
|
+
}
|
|
74
|
+
assortment['flex2vibeMapKeyRoot'] = 'SeasonGroup';
|
|
75
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, assortment);
|
|
76
|
+
let seasonGroupObj = {
|
|
77
|
+
entityReference: 'assortment:' + assortment?.id,
|
|
78
|
+
objectClass: 'SeasonGroup',
|
|
79
|
+
flexPLMTypePath
|
|
80
|
+
};
|
|
81
|
+
try {
|
|
82
|
+
const assortmentObj = await dc.getFlexPLMObjectData(assortment, [], true);
|
|
83
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
84
|
+
.getIdentifierProperties(transformMapFile, mapFileUtil, assortment);
|
|
85
|
+
for (const key of identifierKeys) {
|
|
86
|
+
if (assortmentObj[key]) {
|
|
87
|
+
seasonGroupObj[key] = assortmentObj[key];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (includeInformationKeys) {
|
|
91
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
92
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, assortment);
|
|
93
|
+
for (const key of informationKeys) {
|
|
94
|
+
if (assortmentObj[key]) {
|
|
95
|
+
seasonGroupObj[key] = assortmentObj[key];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const objectKeys = Object.keys(seasonGroupObj);
|
|
100
|
+
const hasAllIdentifiers = identifierKeys.every(key => objectKeys.includes(key));
|
|
101
|
+
if (!hasAllIdentifiers) {
|
|
102
|
+
console.error('IdentifierConversion.getSeasonGroupIdentityObject(): doesnt have all identifier properties - ' + identifierKeys);
|
|
103
|
+
console.error('assortment: ' + JSON.stringify(assortment));
|
|
104
|
+
}
|
|
105
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, assortment, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
106
|
+
seasonGroupObj = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, seasonGroupObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
delete assortment['flex2vibeMapKeyRoot'];
|
|
110
|
+
}
|
|
111
|
+
return seasonGroupObj;
|
|
112
|
+
}
|
|
113
|
+
/** Takes in an item and returns an object to query for an LCSProduct
|
|
114
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
115
|
+
* @param transformMapFile
|
|
116
|
+
* @param mapFileUtil
|
|
117
|
+
* @param dc
|
|
118
|
+
* @param assortment
|
|
119
|
+
* @param includeInformationKeys defaults true
|
|
120
|
+
* @returns
|
|
121
|
+
*/
|
|
122
|
+
static async getProductIdentityObject(transformMapFile, mapFileUtil, dc, itemFamilyObject, includeInformationKeys = true) {
|
|
123
|
+
if (!itemFamilyObject) {
|
|
124
|
+
throw new Error('IdentifierConversion.getProductIdentityObject(): itemFamilyObject must be provided.');
|
|
125
|
+
}
|
|
126
|
+
const itemObj = await dc.getFlexPLMObjectData(itemFamilyObject, [], true);
|
|
127
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
128
|
+
let prodObj = {
|
|
129
|
+
entityReference: 'item:' + itemFamilyObject?.id,
|
|
130
|
+
objectClass: 'LCSProduct',
|
|
131
|
+
flexPLMTypePath
|
|
132
|
+
};
|
|
133
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
134
|
+
.getIdentifierProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
135
|
+
for (const key of identifierKeys) {
|
|
136
|
+
if (itemObj[key]) {
|
|
137
|
+
prodObj[key] = itemObj[key];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (includeInformationKeys) {
|
|
141
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils
|
|
142
|
+
.getInformationalProperties(transformMapFile, mapFileUtil, itemFamilyObject);
|
|
143
|
+
for (const key of informationKeys) {
|
|
144
|
+
if (itemObj[key]) {
|
|
145
|
+
prodObj[key] = itemObj[key];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
150
|
+
if (!prodObj[vibeIQIdentifier]) {
|
|
151
|
+
prodObj['vibeIQIdentifier'] = itemFamilyObject['identifier'] || itemFamilyObject['itemNumber'];
|
|
152
|
+
}
|
|
153
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils
|
|
154
|
+
.getMapKey(transformMapFile, mapFileUtil, itemFamilyObject, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
155
|
+
prodObj = await map_utils_1.MapUtil
|
|
156
|
+
.applyTransformMap(transformMapFile, mapFileUtil, prodObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
157
|
+
return prodObj;
|
|
158
|
+
}
|
|
159
|
+
/** Takes in an item and returns an object to query for an LCSSKU
|
|
160
|
+
* This will only return the identifier properties, and information properties if specified.
|
|
161
|
+
* @param transformMapFile
|
|
162
|
+
* @param mapFileUtil
|
|
163
|
+
* @param dc
|
|
164
|
+
* @param assortment
|
|
165
|
+
* @param includeInformationKeys defaults true
|
|
166
|
+
* @returns
|
|
167
|
+
*/
|
|
168
|
+
static async getSKUIdentityObject(transformMapFile, mapFileUtil, dc, itemObject, includeInformationKeys = true) {
|
|
169
|
+
if (!itemObject) {
|
|
170
|
+
throw new Error('IdentifierConversion.getSKUIdentityObject(): itemObject must be provided.');
|
|
171
|
+
}
|
|
172
|
+
const itemObj = await dc.getFlexPLMObjectData(itemObject, [], true);
|
|
173
|
+
const flexPLMTypePath = await type_conversion_utils_1.TypeConversionUtils.getObjectTypePath(transformMapFile, mapFileUtil, itemObject);
|
|
174
|
+
let skuObj = {
|
|
175
|
+
entityReference: 'item:' + itemObject?.id,
|
|
176
|
+
objectClass: 'LCSSKU',
|
|
177
|
+
flexPLMTypePath
|
|
178
|
+
};
|
|
179
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierProperties(transformMapFile, mapFileUtil, itemObject);
|
|
180
|
+
for (const key of identifierKeys) {
|
|
181
|
+
if (itemObj[key]) {
|
|
182
|
+
skuObj[key] = itemObj[key];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (includeInformationKeys) {
|
|
186
|
+
const informationKeys = await type_conversion_utils_1.TypeConversionUtils.getInformationalProperties(transformMapFile, mapFileUtil, itemObject);
|
|
187
|
+
for (const key of informationKeys) {
|
|
188
|
+
if (itemObj[key]) {
|
|
189
|
+
skuObj[key] = itemObj[key];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const vibeIQIdentifier = 'vibeIQIdentifier';
|
|
194
|
+
if (!skuObj[vibeIQIdentifier]) {
|
|
195
|
+
skuObj['vibeIQIdentifier'] = itemObject['identifier'] || itemObject['itemNumber'];
|
|
196
|
+
}
|
|
197
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKey(transformMapFile, mapFileUtil, itemObject, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
198
|
+
skuObj = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, skuObj, mapKey, type_conversion_utils_1.TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
199
|
+
return skuObj;
|
|
200
|
+
}
|
|
201
|
+
static async getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object) {
|
|
202
|
+
if (!object) {
|
|
203
|
+
const e = new Error(IdentifierConversion.MISSING_OBJECT);
|
|
204
|
+
e['shortStatusMessage'] = event_short_message_status_1.EventShortMessageStatus.MISSING_INPUT;
|
|
205
|
+
throw e;
|
|
206
|
+
}
|
|
207
|
+
else if (!object.flexPLMObjectClass) {
|
|
208
|
+
const e = new Error(IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS);
|
|
209
|
+
e['shortStatusMessage'] = event_short_message_status_1.EventShortMessageStatus.MISSING_INPUT;
|
|
210
|
+
throw e;
|
|
211
|
+
}
|
|
212
|
+
const mapKey = await type_conversion_utils_1.TypeConversionUtils.getMapKeyFromObject(transformMapFile, mapFileUtil, object, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
213
|
+
const identifierKeys = await type_conversion_utils_1.TypeConversionUtils.getIdentifierPropertiesFromObject(transformMapFile, mapFileUtil, object);
|
|
214
|
+
const objectData = await map_utils_1.MapUtil.applyTransformMap(transformMapFile, mapFileUtil, object, mapKey, type_conversion_utils_1.TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
215
|
+
let identifierValues = identifierKeys.reduce((acc, key) => {
|
|
216
|
+
acc[key] = objectData[key];
|
|
217
|
+
return acc;
|
|
218
|
+
}, {});
|
|
219
|
+
identifierValues['flexPLMObjectClass'] = objectData?.flexPLMObjectClass;
|
|
220
|
+
identifierValues['flexPLMTypePath'] = objectData?.flexPLMTypePath;
|
|
221
|
+
identifierValues = await dc.getEntityValues(objectData?.flexPLMObjectClass, identifierValues, []);
|
|
222
|
+
const entityKeys = Object.keys(identifierValues);
|
|
223
|
+
const hasAllIdentifiers = identifierKeys.every(key => entityKeys.includes(key));
|
|
224
|
+
if (!hasAllIdentifiers) {
|
|
225
|
+
const e = new Error(IdentifierConversion.INBOUND_ENTITY_MISSING_IDENIFIER_PROPS + identifierKeys);
|
|
226
|
+
e['shortStatusMessage'] = event_short_message_status_1.EventShortMessageStatus.MISSING_IDENTIFIER_PROPERTIES;
|
|
227
|
+
throw e;
|
|
228
|
+
}
|
|
229
|
+
const criteria = {};
|
|
230
|
+
for (const key of identifierKeys) {
|
|
231
|
+
criteria[key] = identifierValues[key];
|
|
232
|
+
}
|
|
233
|
+
return criteria;
|
|
234
|
+
}
|
|
235
|
+
static async getAssortmentCriteriaFromObject(transformMapFile, mapFileUtil, dc, object) {
|
|
236
|
+
return IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
|
|
237
|
+
}
|
|
238
|
+
static async getItemCriteriaFromObject(transformMapFile, mapFileUtil, dc, object) {
|
|
239
|
+
const criteria = await IdentifierConversion.getEntityCriteriaFromObject(transformMapFile, mapFileUtil, dc, object);
|
|
240
|
+
const roles = (object.flexPLMObjectClass === 'LCSProduct') ? 'family' : 'color';
|
|
241
|
+
criteria['roles'] = roles;
|
|
242
|
+
return criteria;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
exports.IdentifierConversion = IdentifierConversion;
|
|
246
|
+
IdentifierConversion.INBOUND_ENTITY_MISSING_IDENIFIER_PROPS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing identifier properties: ';
|
|
247
|
+
IdentifierConversion.MISSING_OBJECT = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: object';
|
|
248
|
+
IdentifierConversion.MISSING_FLEXPLM_OBJECT_CLASS = 'IdentifierConversion.getEntityCriteriaFromObject(): missing: flexPLMObjectClass';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|