@contrail/flexplm 1.3.0 → 1.3.1-alpha.56221f6

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.
Files changed (149) hide show
  1. package/lib/cli/commands/compile.d.ts +1 -0
  2. package/lib/cli/commands/compile.js +71 -0
  3. package/lib/cli/commands/compile.spec.d.ts +1 -0
  4. package/lib/cli/commands/compile.spec.js +80 -0
  5. package/lib/cli/commands/create.d.ts +1 -0
  6. package/lib/cli/commands/create.js +75 -0
  7. package/lib/cli/commands/create.spec.d.ts +1 -0
  8. package/lib/cli/commands/create.spec.js +78 -0
  9. package/lib/cli/commands/upload.d.ts +10 -0
  10. package/lib/cli/commands/upload.js +219 -0
  11. package/lib/cli/commands/upload.spec.d.ts +1 -0
  12. package/lib/cli/commands/upload.spec.js +88 -0
  13. package/lib/cli/index.d.ts +2 -0
  14. package/lib/cli/index.js +64 -0
  15. package/lib/cli/index.spec.d.ts +1 -0
  16. package/lib/cli/index.spec.js +79 -0
  17. package/lib/cli/template/mapping-template.ts.template +18 -0
  18. package/lib/entity-processor/base-entity-processor.d.ts +89 -42
  19. package/lib/entity-processor/base-entity-processor.js +438 -385
  20. package/lib/entity-processor/base-entity-processor.spec.d.ts +1 -1
  21. package/lib/entity-processor/base-entity-processor.spec.js +398 -397
  22. package/lib/flexplm-request.d.ts +3 -3
  23. package/lib/flexplm-request.js +34 -34
  24. package/lib/flexplm-utils.d.ts +5 -5
  25. package/lib/flexplm-utils.js +33 -33
  26. package/lib/flexplm-utils.spec.d.ts +1 -1
  27. package/lib/flexplm-utils.spec.js +26 -26
  28. package/lib/index.d.ts +23 -22
  29. package/lib/index.js +39 -38
  30. package/lib/interfaces/interfaces.d.ts +105 -105
  31. package/lib/interfaces/interfaces.js +2 -2
  32. package/lib/interfaces/item-family-changes.d.ts +20 -20
  33. package/lib/interfaces/item-family-changes.js +56 -56
  34. package/lib/interfaces/mapping-file.d.ts +429 -0
  35. package/lib/interfaces/mapping-file.js +2 -0
  36. package/lib/interfaces/publish-change-data.d.ts +19 -19
  37. package/lib/interfaces/publish-change-data.js +32 -32
  38. package/lib/publish/base-process-publish-assortment-callback.d.ts +9 -9
  39. package/lib/publish/base-process-publish-assortment-callback.js +38 -38
  40. package/lib/publish/base-process-publish-assortment.d.ts +118 -93
  41. package/lib/publish/base-process-publish-assortment.js +998 -944
  42. package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -1
  43. package/lib/publish/base-process-publish-assortment.spec.js +1688 -1670
  44. package/lib/publish/mockData.d.ts +1389 -1389
  45. package/lib/publish/mockData.js +4524 -4519
  46. package/lib/transform/identifier-conversion-spec-mockData.js +472 -444
  47. package/lib/transform/identifier-conversion.d.ts +51 -15
  48. package/lib/transform/identifier-conversion.js +248 -212
  49. package/lib/transform/identifier-conversion.spec.d.ts +1 -1
  50. package/lib/transform/identifier-conversion.spec.js +343 -339
  51. package/lib/util/config-defaults.d.ts +8 -8
  52. package/lib/util/config-defaults.js +88 -85
  53. package/lib/util/config-defaults.spec.d.ts +1 -1
  54. package/lib/util/config-defaults.spec.js +302 -293
  55. package/lib/util/data-converter-spec-mockData.js +219 -205
  56. package/lib/util/data-converter.d.ts +136 -39
  57. package/lib/util/data-converter.js +718 -592
  58. package/lib/util/data-converter.spec.d.ts +1 -1
  59. package/lib/util/data-converter.spec.js +906 -904
  60. package/lib/util/error-response-object.d.ts +9 -4
  61. package/lib/util/error-response-object.js +54 -47
  62. package/lib/util/error-response-object.spec.d.ts +1 -1
  63. package/lib/util/error-response-object.spec.js +99 -99
  64. package/lib/util/event-short-message-status.d.ts +19 -19
  65. package/lib/util/event-short-message-status.js +24 -23
  66. package/lib/util/federation.d.ts +15 -15
  67. package/lib/util/federation.js +157 -149
  68. package/lib/util/flexplm-connect.d.ts +29 -22
  69. package/lib/util/flexplm-connect.js +190 -176
  70. package/lib/util/flexplm-connect.spec.d.ts +1 -1
  71. package/lib/util/flexplm-connect.spec.js +88 -88
  72. package/lib/util/logger-config.d.ts +1 -1
  73. package/lib/util/logger-config.js +27 -26
  74. package/lib/util/map-util-spec-mockData.js +219 -205
  75. package/lib/util/map-utils.d.ts +33 -6
  76. package/lib/util/map-utils.js +42 -15
  77. package/lib/util/map-utils.spec.d.ts +1 -1
  78. package/lib/util/map-utils.spec.js +89 -89
  79. package/lib/util/mockData.d.ts +80 -80
  80. package/lib/util/mockData.js +103 -103
  81. package/lib/util/thumbnail-util.d.ts +55 -34
  82. package/lib/util/thumbnail-util.js +242 -215
  83. package/lib/util/thumbnail-util.spec.d.ts +1 -1
  84. package/lib/util/thumbnail-util.spec.js +440 -434
  85. package/lib/util/type-conversion-utils-spec-mockData.js +259 -259
  86. package/lib/util/type-conversion-utils.d.ts +163 -23
  87. package/lib/util/type-conversion-utils.js +408 -265
  88. package/lib/util/type-conversion-utils.spec.d.ts +1 -1
  89. package/lib/util/type-conversion-utils.spec.js +868 -868
  90. package/lib/util/type-defaults.d.ts +74 -16
  91. package/lib/util/type-defaults.js +279 -221
  92. package/lib/util/type-defaults.spec.d.ts +1 -1
  93. package/lib/util/type-defaults.spec.js +516 -516
  94. package/lib/util/type-utils.d.ts +34 -13
  95. package/lib/util/type-utils.js +137 -114
  96. package/lib/util/type-utils.spec.d.ts +1 -1
  97. package/lib/util/type-utils.spec.js +192 -190
  98. package/package.json +21 -6
  99. package/scripts/copy-template.js +10 -0
  100. package/.claude/settings.local.json +0 -8
  101. package/.github/pull_request_template.md +0 -31
  102. package/.github/workflows/flexplm-lib.yml +0 -27
  103. package/.github/workflows/publish-to-npm.yml +0 -124
  104. package/CHANGELOG.md +0 -32
  105. package/publish.bat +0 -5
  106. package/publish.sh +0 -5
  107. package/src/entity-processor/base-entity-processor.spec.ts +0 -460
  108. package/src/entity-processor/base-entity-processor.ts +0 -515
  109. package/src/flexplm-request.ts +0 -28
  110. package/src/flexplm-utils.spec.ts +0 -27
  111. package/src/flexplm-utils.ts +0 -29
  112. package/src/index.ts +0 -22
  113. package/src/interfaces/interfaces.ts +0 -122
  114. package/src/interfaces/item-family-changes.ts +0 -67
  115. package/src/interfaces/publish-change-data.ts +0 -43
  116. package/src/publish/base-process-publish-assortment-callback.ts +0 -50
  117. package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
  118. package/src/publish/base-process-publish-assortment.ts +0 -1134
  119. package/src/publish/mockData.ts +0 -4561
  120. package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
  121. package/src/transform/identifier-conversion.spec.ts +0 -354
  122. package/src/transform/identifier-conversion.ts +0 -282
  123. package/src/util/config-defaults.spec.ts +0 -350
  124. package/src/util/config-defaults.ts +0 -93
  125. package/src/util/data-converter-spec-mockData.ts +0 -231
  126. package/src/util/data-converter.spec.ts +0 -1041
  127. package/src/util/data-converter.ts +0 -762
  128. package/src/util/error-response-object.spec.ts +0 -116
  129. package/src/util/error-response-object.ts +0 -50
  130. package/src/util/event-short-message-status.ts +0 -22
  131. package/src/util/federation.ts +0 -172
  132. package/src/util/flexplm-connect.spec.ts +0 -132
  133. package/src/util/flexplm-connect.ts +0 -208
  134. package/src/util/logger-config.ts +0 -20
  135. package/src/util/map-util-spec-mockData.ts +0 -231
  136. package/src/util/map-utils.spec.ts +0 -103
  137. package/src/util/map-utils.ts +0 -41
  138. package/src/util/mockData.ts +0 -101
  139. package/src/util/thumbnail-util.spec.ts +0 -508
  140. package/src/util/thumbnail-util.ts +0 -272
  141. package/src/util/type-conversion-utils-spec-mockData.ts +0 -271
  142. package/src/util/type-conversion-utils.spec.ts +0 -968
  143. package/src/util/type-conversion-utils.ts +0 -460
  144. package/src/util/type-defaults.spec.ts +0 -669
  145. package/src/util/type-defaults.ts +0 -281
  146. package/src/util/type-utils.spec.ts +0 -227
  147. package/src/util/type-utils.ts +0 -144
  148. package/tsconfig.json +0 -29
  149. 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
- 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
+ /** 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
- 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
+ /** 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 {};