@contrail/flexplm 1.3.0 → 1.3.1-alpha.585afc1

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,16 +1,74 @@
1
- export declare class TypeDefaults {
2
- static NO_ENTITY_TYPE: string;
3
- static NO_OBJECT_CLASS: string;
4
- static NO_TYPE_PATH: string;
5
- constructor();
6
- static getDefaultObjectClass(entity: any): string;
7
- static getDefaultObjectTypePath(entity: any): string;
8
- static getDefaultIdentifierProperties(entity: any): string[];
9
- static getDefaultInformationalProperties(entity: any): string[];
10
- static getEntityType(entity: any): any;
11
- static getDefaultEntityClass(object: any): string;
12
- static getDefaultEntityTypePath(object: any): string;
13
- static getDefaultIdentifierPropertiesFromObject(object: any): string[];
14
- static getDefaultInformationalPropertiesFromObject(object: any): string[];
15
- static getObjectClass(object: any): string;
16
- }
1
+ export declare class TypeDefaults {
2
+ static NO_ENTITY_TYPE: string;
3
+ static NO_OBJECT_CLASS: string;
4
+ static NO_TYPE_PATH: string;
5
+ constructor();
6
+ /**Takes in full entity and returs the default FlexPLM
7
+ * object class.
8
+ *
9
+ * @param entity
10
+ * @returns string
11
+ */
12
+ static getDefaultObjectClass(entity: any): string;
13
+ /**Takes in full entity and returns the default FlexPLM type path
14
+ * object class.
15
+ *
16
+ * @param entity
17
+ * @returns string
18
+ */
19
+ static getDefaultObjectTypePath(entity: any): string;
20
+ /**Takes in full entity and returns the slugs for the default identifier
21
+ * properties. These properties are used when searching for an entity
22
+ * object class.
23
+ *
24
+ * @param entity
25
+ * @returns string[]
26
+ */
27
+ static getDefaultIdentifierProperties(entity: any): string[];
28
+ /** Takes in full entity and returns the slugs for informational
29
+ * properties. These properties are helpful when debugging issues
30
+ * where the identifier properties don't find a match.
31
+ *
32
+ * @param entity
33
+ * @returns string[]
34
+ */
35
+ static getDefaultInformationalProperties(entity: any): string[];
36
+ /** Returns the VibeIQ entity type from an entity.
37
+ * Throws error if it can't determine the entity type
38
+ *
39
+ * @param entity
40
+ * @returns string
41
+ */
42
+ static getEntityType(entity: any): any;
43
+ /**Takes in full object and returns the default VibeIQ
44
+ * entity class.
45
+ *
46
+ * @param entity
47
+ * @returns string
48
+ */
49
+ static getDefaultEntityClass(object: any): string;
50
+ /**Takes in full object and returns the default VibeIQ type path
51
+ * object class.
52
+ *
53
+ * @param object
54
+ * @returns string
55
+ */
56
+ static getDefaultEntityTypePath(object: any): string;
57
+ /**Takes in full entity and returns the slugs for the default identifier
58
+ * properties. These properties are used when searching for an entity
59
+ * object class.
60
+ *
61
+ * @param entity
62
+ * @returns string[]
63
+ */
64
+ static getDefaultIdentifierPropertiesFromObject(object: any): string[];
65
+ /** Takes in full object and returns the slugs for informational
66
+ * properties. These properties are helpful when debugging issues
67
+ * where the identifier properties don't find a match.
68
+ *
69
+ * @param object
70
+ * @returns string[]
71
+ */
72
+ static getDefaultInformationalPropertiesFromObject(object: any): string[];
73
+ static getObjectClass(object: any): string;
74
+ }
@@ -1,221 +1,279 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeDefaults = void 0;
4
- class TypeDefaults {
5
- constructor() {
6
- }
7
- static getDefaultObjectClass(entity) {
8
- const entityType = this.getEntityType(entity);
9
- let objectClass = '';
10
- if ('item' === entityType) {
11
- if (entity.roles.includes('family')) {
12
- objectClass = 'LCSProduct';
13
- }
14
- else if (entity.roles.includes('color')) {
15
- objectClass = 'LCSSKU';
16
- }
17
- }
18
- else if ('project-item' === entityType) {
19
- if (entity.roles.includes('family')) {
20
- objectClass = 'LCSProductSeasonLink';
21
- }
22
- else if (entity.roles.includes('color')) {
23
- objectClass = 'LCSSKUSeasonLink';
24
- }
25
- }
26
- else if ('color' === entityType) {
27
- objectClass = 'LCSColor';
28
- }
29
- else if ('custom-entity' === entityType) {
30
- objectClass = 'LCSRevisableEntity';
31
- }
32
- else if ('project' === entityType) {
33
- objectClass = 'LCSSeason';
34
- }
35
- else if ('assortment' === entityType) {
36
- if ('LCSSeason' === entity.flex2vibeMapKeyRoot || entity.publishToFlexPLM) {
37
- objectClass = 'LCSSeason';
38
- }
39
- else {
40
- objectClass = 'SeasonGroup';
41
- }
42
- }
43
- return objectClass;
44
- }
45
- static getDefaultObjectTypePath(entity) {
46
- let typePath = '';
47
- const entityType = this.getEntityType(entity);
48
- switch (entityType) {
49
- case 'item':
50
- case 'project-item':
51
- typePath = 'Product';
52
- break;
53
- case 'color':
54
- typePath = 'Color';
55
- break;
56
- case 'custom-entity':
57
- typePath = 'Revisable Entity';
58
- break;
59
- case 'project':
60
- typePath = 'Season';
61
- break;
62
- case 'assortment':
63
- if ('LCSSeason' === entity.flex2vibeMapKeyRoot || entity.publishToFlexPLM) {
64
- typePath = 'Season';
65
- }
66
- else {
67
- typePath = 'Season Group';
68
- }
69
- break;
70
- }
71
- return typePath;
72
- }
73
- static getDefaultIdentifierProperties(entity) {
74
- const identifierProps = [];
75
- const entityType = this.getEntityType(entity);
76
- switch (entityType) {
77
- case 'item':
78
- identifierProps.push('itemNumber');
79
- break;
80
- case 'project':
81
- identifierProps.push('flexPLMSeasonName');
82
- break;
83
- case 'assortment':
84
- if ('LCSSeason' === entity.flex2vibeMapKeyRoot || entity.publishToFlexPLM) {
85
- identifierProps.push('flexPLMSeasonName');
86
- }
87
- else {
88
- identifierProps.push('seasonGroupName');
89
- }
90
- break;
91
- case 'color':
92
- case 'custom-entity':
93
- identifierProps.push('name');
94
- break;
95
- }
96
- return identifierProps;
97
- }
98
- static getDefaultInformationalProperties(entity) {
99
- const entityType = this.getEntityType(entity);
100
- let properties = [];
101
- if ('item' === entityType) {
102
- if (entity.roles.includes('family')) {
103
- properties.push('name');
104
- }
105
- else if (entity.roles.includes('color')) {
106
- properties.push('optionName');
107
- }
108
- }
109
- else if (['project', 'assortment'].includes(entityType)) {
110
- properties.push('name');
111
- }
112
- return properties;
113
- }
114
- static getEntityType(entity) {
115
- let entityType = entity['entityType'];
116
- if (!entityType) {
117
- const typePath = entity['typePath'];
118
- if (typePath) {
119
- const types = typePath.split(':');
120
- if (types && types[0]) {
121
- entityType = types[0];
122
- }
123
- }
124
- }
125
- if (!entityType) {
126
- throw Error(TypeDefaults.NO_ENTITY_TYPE);
127
- }
128
- return entityType;
129
- }
130
- static getDefaultEntityClass(object) {
131
- let entityClass = '';
132
- let objectClass = TypeDefaults.getObjectClass(object);
133
- if (['LCSProduct', 'LCSSKU'].includes(objectClass)) {
134
- entityClass = 'item';
135
- }
136
- else if (['LCSProductSeasonLink', 'LCSSKUSeasonLink'].includes(objectClass)) {
137
- entityClass = 'project-item';
138
- }
139
- else if ('LCSColor' === objectClass) {
140
- entityClass = 'color';
141
- }
142
- else if (['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
143
- entityClass = 'assortment';
144
- }
145
- else if (['LCSRevisableEntity', 'LCSLifecycleManaged', 'LCSLast', 'LCSMaterial'].includes(objectClass)) {
146
- entityClass = 'custom-entity';
147
- }
148
- if (entityClass === '')
149
- throw Error(TypeDefaults.NO_OBJECT_CLASS);
150
- return entityClass;
151
- }
152
- static getDefaultEntityTypePath(object) {
153
- let typePath = '';
154
- const objectClass = TypeDefaults.getObjectClass(object);
155
- switch (objectClass) {
156
- case 'LCSProduct':
157
- case 'LCSSKU':
158
- typePath = 'item';
159
- break;
160
- case 'LCSProductSeasonLink':
161
- case 'LCSSKUSeasonLink':
162
- typePath = 'project-item';
163
- break;
164
- case 'LCSColor':
165
- typePath = 'color';
166
- break;
167
- case 'LCSSeason':
168
- case 'SeasonGroup':
169
- typePath = 'assortment';
170
- break;
171
- }
172
- if (typePath === '')
173
- throw Error(TypeDefaults.NO_TYPE_PATH);
174
- return typePath;
175
- }
176
- static getDefaultIdentifierPropertiesFromObject(object) {
177
- const identifierProps = [];
178
- const objectClass = TypeDefaults.getObjectClass(object);
179
- switch (objectClass) {
180
- case 'LCSProduct':
181
- case 'LCSSKU':
182
- identifierProps.push('itemNumber');
183
- break;
184
- case 'LCSSeason':
185
- identifierProps.push('flexPLMSeasonName');
186
- break;
187
- case 'SeasonGroup':
188
- identifierProps.push('seasonGroupName');
189
- break;
190
- case 'LCSColor':
191
- case 'LCSRevisableEntity':
192
- case 'LCSLifecycleManaged':
193
- case 'LCSLast':
194
- case 'LCSMaterial':
195
- identifierProps.push('name');
196
- break;
197
- }
198
- return identifierProps;
199
- }
200
- static getDefaultInformationalPropertiesFromObject(object) {
201
- const objectClass = TypeDefaults.getObjectClass(object);
202
- let properties = [];
203
- if ('LCSProduct' === objectClass) {
204
- properties.push('name');
205
- }
206
- else if ('LCSSKU' === objectClass) {
207
- properties.push('optionName');
208
- }
209
- else if (['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
210
- properties.push('name');
211
- }
212
- return properties;
213
- }
214
- static getObjectClass(object) {
215
- return (object) ? object['flexPLMObjectClass'] : '';
216
- }
217
- }
218
- exports.TypeDefaults = TypeDefaults;
219
- TypeDefaults.NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';
220
- TypeDefaults.NO_OBJECT_CLASS = 'Please ensure that the flexPLMObjectClass property is provided.';
221
- TypeDefaults.NO_TYPE_PATH = 'Please ensure that the flexPLMTypePath property is provided.';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeDefaults = void 0;
4
+ class TypeDefaults {
5
+ constructor() {
6
+ }
7
+ /**Takes in full entity and returs the default FlexPLM
8
+ * object class.
9
+ *
10
+ * @param entity
11
+ * @returns string
12
+ */
13
+ static getDefaultObjectClass(entity) {
14
+ const entityType = this.getEntityType(entity);
15
+ let objectClass = '';
16
+ if ('item' === entityType) {
17
+ if (entity.roles.includes('family')) {
18
+ objectClass = 'LCSProduct';
19
+ }
20
+ else if (entity.roles.includes('color')) {
21
+ objectClass = 'LCSSKU';
22
+ }
23
+ }
24
+ else if ('project-item' === entityType) {
25
+ if (entity.roles.includes('family')) {
26
+ objectClass = 'LCSProductSeasonLink';
27
+ }
28
+ else if (entity.roles.includes('color')) {
29
+ objectClass = 'LCSSKUSeasonLink';
30
+ }
31
+ }
32
+ else if ('color' === entityType) {
33
+ objectClass = 'LCSColor';
34
+ }
35
+ else if ('custom-entity' === entityType) {
36
+ objectClass = 'LCSRevisableEntity';
37
+ }
38
+ else if ('project' === entityType) {
39
+ objectClass = 'LCSSeason';
40
+ }
41
+ else if ('assortment' === entityType) {
42
+ if ('LCSSeason' === entity.flex2vibeMapKeyRoot || entity.publishToFlexPLM) {
43
+ objectClass = 'LCSSeason';
44
+ }
45
+ else {
46
+ objectClass = 'SeasonGroup';
47
+ }
48
+ }
49
+ return objectClass;
50
+ }
51
+ /**Takes in full entity and returns the default FlexPLM type path
52
+ * object class.
53
+ *
54
+ * @param entity
55
+ * @returns string
56
+ */
57
+ static getDefaultObjectTypePath(entity) {
58
+ let typePath = '';
59
+ const entityType = this.getEntityType(entity);
60
+ switch (entityType) {
61
+ case 'item':
62
+ case 'project-item':
63
+ typePath = 'Product';
64
+ break;
65
+ case 'color':
66
+ typePath = 'Color';
67
+ break;
68
+ case 'custom-entity':
69
+ typePath = 'Revisable Entity';
70
+ break;
71
+ case 'project':
72
+ typePath = 'Season';
73
+ break;
74
+ case 'assortment':
75
+ if ('LCSSeason' === entity.flex2vibeMapKeyRoot || entity.publishToFlexPLM) {
76
+ typePath = 'Season';
77
+ }
78
+ else {
79
+ typePath = 'Season Group';
80
+ }
81
+ break;
82
+ }
83
+ return typePath;
84
+ }
85
+ /**Takes in full entity and returns the slugs for the default identifier
86
+ * properties. These properties are used when searching for an entity
87
+ * object class.
88
+ *
89
+ * @param entity
90
+ * @returns string[]
91
+ */
92
+ static getDefaultIdentifierProperties(entity) {
93
+ const identifierProps = [];
94
+ const entityType = this.getEntityType(entity);
95
+ switch (entityType) {
96
+ case 'item':
97
+ identifierProps.push('itemNumber');
98
+ break;
99
+ case 'project':
100
+ identifierProps.push('flexPLMSeasonName');
101
+ break;
102
+ case 'assortment':
103
+ if ('LCSSeason' === entity.flex2vibeMapKeyRoot || entity.publishToFlexPLM) {
104
+ identifierProps.push('flexPLMSeasonName');
105
+ }
106
+ else {
107
+ identifierProps.push('seasonGroupName');
108
+ }
109
+ break;
110
+ case 'color':
111
+ case 'custom-entity':
112
+ identifierProps.push('name');
113
+ break;
114
+ }
115
+ return identifierProps;
116
+ }
117
+ /** Takes in full entity and returns the slugs for informational
118
+ * properties. These properties are helpful when debugging issues
119
+ * where the identifier properties don't find a match.
120
+ *
121
+ * @param entity
122
+ * @returns string[]
123
+ */
124
+ static getDefaultInformationalProperties(entity) {
125
+ const entityType = this.getEntityType(entity);
126
+ let properties = [];
127
+ if ('item' === entityType) {
128
+ if (entity.roles.includes('family')) {
129
+ properties.push('name');
130
+ }
131
+ else if (entity.roles.includes('color')) {
132
+ properties.push('optionName');
133
+ }
134
+ }
135
+ else if (['project', 'assortment'].includes(entityType)) {
136
+ properties.push('name');
137
+ }
138
+ return properties;
139
+ }
140
+ /** Returns the VibeIQ entity type from an entity.
141
+ * Throws error if it can't determine the entity type
142
+ *
143
+ * @param entity
144
+ * @returns string
145
+ */
146
+ static getEntityType(entity) {
147
+ let entityType = entity['entityType'];
148
+ if (!entityType) {
149
+ const typePath = entity['typePath'];
150
+ if (typePath) {
151
+ const types = typePath.split(':');
152
+ if (types && types[0]) {
153
+ entityType = types[0];
154
+ }
155
+ }
156
+ }
157
+ if (!entityType) {
158
+ throw Error(TypeDefaults.NO_ENTITY_TYPE);
159
+ }
160
+ return entityType;
161
+ }
162
+ /**Takes in full object and returns the default VibeIQ
163
+ * entity class.
164
+ *
165
+ * @param entity
166
+ * @returns string
167
+ */
168
+ static getDefaultEntityClass(object) {
169
+ let entityClass = '';
170
+ let objectClass = TypeDefaults.getObjectClass(object);
171
+ if (['LCSProduct', 'LCSSKU'].includes(objectClass)) {
172
+ entityClass = 'item';
173
+ }
174
+ else if (['LCSProductSeasonLink', 'LCSSKUSeasonLink'].includes(objectClass)) {
175
+ entityClass = 'project-item';
176
+ }
177
+ else if ('LCSColor' === objectClass) {
178
+ entityClass = 'color';
179
+ }
180
+ else if (['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
181
+ entityClass = 'assortment';
182
+ }
183
+ else if (['LCSRevisableEntity', 'LCSLifecycleManaged', 'LCSLast', 'LCSMaterial'].includes(objectClass)) {
184
+ entityClass = 'custom-entity';
185
+ }
186
+ if (entityClass === '')
187
+ throw Error(TypeDefaults.NO_OBJECT_CLASS);
188
+ return entityClass;
189
+ }
190
+ /**Takes in full object and returns the default VibeIQ type path
191
+ * object class.
192
+ *
193
+ * @param object
194
+ * @returns string
195
+ */
196
+ static getDefaultEntityTypePath(object) {
197
+ let typePath = '';
198
+ const objectClass = TypeDefaults.getObjectClass(object);
199
+ switch (objectClass) {
200
+ case 'LCSProduct':
201
+ case 'LCSSKU':
202
+ typePath = 'item';
203
+ break;
204
+ case 'LCSProductSeasonLink':
205
+ case 'LCSSKUSeasonLink':
206
+ typePath = 'project-item';
207
+ break;
208
+ case 'LCSColor':
209
+ typePath = 'color';
210
+ break;
211
+ case 'LCSSeason':
212
+ case 'SeasonGroup':
213
+ typePath = 'assortment';
214
+ break;
215
+ }
216
+ if (typePath === '')
217
+ throw Error(TypeDefaults.NO_TYPE_PATH);
218
+ return typePath;
219
+ }
220
+ /**Takes in full entity and returns the slugs for the default identifier
221
+ * properties. These properties are used when searching for an entity
222
+ * object class.
223
+ *
224
+ * @param entity
225
+ * @returns string[]
226
+ */
227
+ static getDefaultIdentifierPropertiesFromObject(object) {
228
+ const identifierProps = [];
229
+ const objectClass = TypeDefaults.getObjectClass(object);
230
+ switch (objectClass) {
231
+ case 'LCSProduct':
232
+ case 'LCSSKU':
233
+ identifierProps.push('itemNumber');
234
+ break;
235
+ case 'LCSSeason':
236
+ identifierProps.push('flexPLMSeasonName');
237
+ break;
238
+ case 'SeasonGroup':
239
+ identifierProps.push('seasonGroupName');
240
+ break;
241
+ case 'LCSColor':
242
+ case 'LCSRevisableEntity':
243
+ case 'LCSLifecycleManaged':
244
+ case 'LCSLast':
245
+ case 'LCSMaterial':
246
+ identifierProps.push('name');
247
+ break;
248
+ }
249
+ return identifierProps;
250
+ }
251
+ /** Takes in full object and returns the slugs for informational
252
+ * properties. These properties are helpful when debugging issues
253
+ * where the identifier properties don't find a match.
254
+ *
255
+ * @param object
256
+ * @returns string[]
257
+ */
258
+ static getDefaultInformationalPropertiesFromObject(object) {
259
+ const objectClass = TypeDefaults.getObjectClass(object);
260
+ let properties = [];
261
+ if ('LCSProduct' === objectClass) {
262
+ properties.push('name');
263
+ }
264
+ else if ('LCSSKU' === objectClass) {
265
+ properties.push('optionName');
266
+ }
267
+ else if (['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
268
+ properties.push('name');
269
+ }
270
+ return properties;
271
+ }
272
+ static getObjectClass(object) {
273
+ return (object) ? object['flexPLMObjectClass'] : '';
274
+ }
275
+ }
276
+ exports.TypeDefaults = TypeDefaults;
277
+ TypeDefaults.NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';
278
+ TypeDefaults.NO_OBJECT_CLASS = 'Please ensure that the flexPLMObjectClass property is provided.';
279
+ TypeDefaults.NO_TYPE_PATH = 'Please ensure that the flexPLMTypePath property is provided.';
@@ -1 +1 @@
1
- export {};
1
+ export {};