@contrail/flexplm 1.4.0 → 1.5.0-alpha.14a4f1b

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 (112) hide show
  1. package/lib/cli/commands/compile.d.ts +4 -0
  2. package/lib/cli/commands/compile.js +73 -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 +5 -0
  6. package/lib/cli/commands/create.js +77 -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 +17 -0
  10. package/lib/cli/commands/upload.js +228 -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 +5 -0
  14. package/lib/cli/index.js +70 -0
  15. package/lib/cli/index.spec.d.ts +1 -0
  16. package/lib/cli/index.spec.js +85 -0
  17. package/lib/cli/template/mapping-template.ts.template +62 -0
  18. package/lib/entity-processor/base-entity-processor.d.ts +65 -0
  19. package/lib/entity-processor/base-entity-processor.js +71 -0
  20. package/lib/entity-processor/base-entity-processor.spec.js +1 -0
  21. package/lib/index.d.ts +1 -0
  22. package/lib/index.js +1 -0
  23. package/lib/interfaces/mapping-file.d.ts +460 -0
  24. package/lib/interfaces/mapping-file.js +2 -0
  25. package/lib/publish/base-process-publish-assortment.d.ts +25 -0
  26. package/lib/publish/base-process-publish-assortment.js +60 -6
  27. package/lib/publish/base-process-publish-assortment.spec.js +22 -4
  28. package/lib/publish/mockData.js +5 -0
  29. package/lib/transform/identifier-conversion-spec-mockData.js +34 -6
  30. package/lib/transform/identifier-conversion.d.ts +36 -0
  31. package/lib/transform/identifier-conversion.js +37 -1
  32. package/lib/transform/identifier-conversion.spec.js +35 -0
  33. package/lib/util/config-defaults.d.ts +18 -0
  34. package/lib/util/config-defaults.js +25 -15
  35. package/lib/util/config-defaults.spec.js +56 -0
  36. package/lib/util/data-converter-spec-mockData.js +17 -3
  37. package/lib/util/data-converter.d.ts +102 -0
  38. package/lib/util/data-converter.js +195 -34
  39. package/lib/util/data-converter.spec.js +430 -0
  40. package/lib/util/error-response-object.d.ts +5 -0
  41. package/lib/util/error-response-object.js +7 -0
  42. package/lib/util/event-short-message-status.js +1 -0
  43. package/lib/util/federation.js +8 -0
  44. package/lib/util/flexplm-connect.d.ts +7 -0
  45. package/lib/util/flexplm-connect.js +14 -0
  46. package/lib/util/logger-config.js +1 -0
  47. package/lib/util/map-util-spec-mockData.js +17 -3
  48. package/lib/util/map-utils.d.ts +27 -0
  49. package/lib/util/map-utils.js +27 -0
  50. package/lib/util/thumbnail-util.d.ts +21 -0
  51. package/lib/util/thumbnail-util.js +28 -1
  52. package/lib/util/thumbnail-util.spec.js +6 -0
  53. package/lib/util/type-conversion-utils-spec-mockData.js +3 -3
  54. package/lib/util/type-conversion-utils.d.ts +151 -0
  55. package/lib/util/type-conversion-utils.js +154 -0
  56. package/lib/util/type-defaults.d.ts +69 -0
  57. package/lib/util/type-defaults.js +98 -4
  58. package/lib/util/type-defaults.spec.js +114 -4
  59. package/lib/util/type-utils.d.ts +21 -0
  60. package/lib/util/type-utils.js +23 -0
  61. package/lib/util/type-utils.spec.js +2 -0
  62. package/package.json +21 -6
  63. package/scripts/copy-template.js +10 -0
  64. package/.github/pull_request_template.md +0 -31
  65. package/.github/workflows/flexplm-lib.yml +0 -27
  66. package/.github/workflows/publish-to-npm.yml +0 -121
  67. package/CHANGELOG.md +0 -40
  68. package/publish.bat +0 -5
  69. package/publish.sh +0 -5
  70. package/src/entity-processor/base-entity-processor.spec.ts +0 -689
  71. package/src/entity-processor/base-entity-processor.ts +0 -583
  72. package/src/flexplm-request.ts +0 -28
  73. package/src/flexplm-utils.spec.ts +0 -27
  74. package/src/flexplm-utils.ts +0 -29
  75. package/src/index.ts +0 -22
  76. package/src/interfaces/interfaces.ts +0 -122
  77. package/src/interfaces/item-family-changes.ts +0 -67
  78. package/src/interfaces/publish-change-data.ts +0 -43
  79. package/src/publish/base-process-publish-assortment-callback.ts +0 -50
  80. package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
  81. package/src/publish/base-process-publish-assortment.ts +0 -1134
  82. package/src/publish/mockData.ts +0 -4561
  83. package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
  84. package/src/transform/identifier-conversion.spec.ts +0 -354
  85. package/src/transform/identifier-conversion.ts +0 -282
  86. package/src/util/config-defaults.spec.ts +0 -392
  87. package/src/util/config-defaults.ts +0 -97
  88. package/src/util/data-converter-spec-mockData.ts +0 -231
  89. package/src/util/data-converter.spec.ts +0 -1120
  90. package/src/util/data-converter.ts +0 -766
  91. package/src/util/error-response-object.spec.ts +0 -116
  92. package/src/util/error-response-object.ts +0 -50
  93. package/src/util/event-short-message-status.ts +0 -22
  94. package/src/util/federation.ts +0 -172
  95. package/src/util/flexplm-connect.spec.ts +0 -132
  96. package/src/util/flexplm-connect.ts +0 -208
  97. package/src/util/logger-config.ts +0 -20
  98. package/src/util/map-util-spec-mockData.ts +0 -231
  99. package/src/util/map-utils.spec.ts +0 -103
  100. package/src/util/map-utils.ts +0 -41
  101. package/src/util/mockData.ts +0 -101
  102. package/src/util/thumbnail-util.spec.ts +0 -508
  103. package/src/util/thumbnail-util.ts +0 -272
  104. package/src/util/type-conversion-utils-spec-mockData.ts +0 -272
  105. package/src/util/type-conversion-utils.spec.ts +0 -1031
  106. package/src/util/type-conversion-utils.ts +0 -490
  107. package/src/util/type-defaults.spec.ts +0 -669
  108. package/src/util/type-defaults.ts +0 -281
  109. package/src/util/type-utils.spec.ts +0 -227
  110. package/src/util/type-utils.ts +0 -144
  111. package/tsconfig.json +0 -24
  112. package/tslint.json +0 -57
@@ -3,9 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TypeConversionUtils = void 0;
4
4
  const type_defaults_1 = require("./type-defaults");
5
5
  const map_utils_1 = require("./map-utils");
6
+ /** This class is helper functions to get the data for converting
7
+ * VibeIQ entities to / from FlexPLM Objects
8
+ */
6
9
  class TypeConversionUtils {
7
10
  constructor() {
8
11
  }
12
+ /** Takes in a VibeIQ entity object and returns the correct FlexPLM
13
+ * object class associated to the entity. Order of precedence
14
+ * Property 'flexPLMObjectClass'
15
+ * Map file entry in 'typeConversion:vibe2flex:<value>:getObjectClass()'
16
+ * for value from 'entityClass' or root from 'typePath'
17
+ * TypeDefaults.getDefaultObjectClass() function
18
+ * @param transformMapFile id for mapFile
19
+ * @param mapFileUtil class to get mapfile
20
+ * @param entity
21
+ * @returns Promise<string>
22
+ */
9
23
  static async getObjectClass(transformMapFile, mapFileUtil, entity) {
10
24
  let objectClass = entity['flexPLMObjectClass'];
11
25
  if (objectClass) {
@@ -23,6 +37,18 @@ class TypeConversionUtils {
23
37
  }
24
38
  return type_defaults_1.TypeDefaults.getDefaultObjectClass(entity);
25
39
  }
40
+ /** Takes in a VibeIQ entity object and returns the correct FlexPLM
41
+ * FlexType associated to the entity. Order of precedence
42
+ * Property 'flexPLMTypePath'
43
+ * Map file entry in 'typeConversion:vibe2flex:<value>:getSoftType()'
44
+ * for value from 'entityClass' or root from 'typePath'
45
+ * TypeDefaults.getDefaultObjectTypePath() function
46
+ *
47
+ * @param transformMapFile id for mapFile
48
+ * @param mapFileUtil class to get mapfile
49
+ * @param entity VibeIQ entity
50
+ * @returns Promise<string>
51
+ */
26
52
  static async getObjectTypePath(transformMapFile, mapFileUtil, entity) {
27
53
  let typePath = entity['flexPLMTypePath'];
28
54
  if (typePath) {
@@ -40,6 +66,18 @@ class TypeConversionUtils {
40
66
  }
41
67
  return type_defaults_1.TypeDefaults.getDefaultObjectTypePath(entity);
42
68
  }
69
+ /**Takes in a VibeIQ entity object and returns the correct
70
+ * identifier properties. Order of precedence
71
+ * Property 'flexPLMIdentifierProperties'
72
+ * Map file entry in 'typeConversion:vibe2flex:<value>:getIdentifierProperties()'
73
+ * for value from 'entityClass' or root from 'typePath'
74
+ * TypeDefaults.getDefaultIdentifierProperties() function
75
+ *
76
+ * @param transformMapFile id for mapFile
77
+ * @param mapFileUtil class to get mapfile
78
+ * @param entity
79
+ * @returns Promise<string[]>
80
+ */
43
81
  static async getIdentifierProperties(transformMapFile, mapFileUtil, entity) {
44
82
  let identifiers = entity['flexPLMIdentifierProperties'];
45
83
  if (identifiers) {
@@ -57,6 +95,18 @@ class TypeConversionUtils {
57
95
  }
58
96
  return type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(entity);
59
97
  }
98
+ /**Takes in a VibeIQ entity object and returns the correct
99
+ * informational properties. Order of precedence
100
+ * Property 'flexPLMInformationalProperties'
101
+ * Map file entry in 'typeConversion:vibe2flex:<value>:getInformationalProperties()'
102
+ * for value from 'entityClass' or root from 'typePath'
103
+ * TypeDefaults.getDefaultObjectTypePath() function
104
+ *
105
+ * @param transformMapFile id for mapFile
106
+ * @param mapFileUtil class to get mapfile
107
+ * @param entity
108
+ * @returns string
109
+ */
60
110
  static async getInformationalProperties(transformMapFile, mapFileUtil, entity) {
61
111
  let identifiers = entity['flexPLMInformationalProperties'];
62
112
  if (identifiers) {
@@ -74,6 +124,19 @@ class TypeConversionUtils {
74
124
  }
75
125
  return type_defaults_1.TypeDefaults.getDefaultInformationalProperties(entity);
76
126
  }
127
+ /**Takes in a VibeIQ entity object and returns the correct mapKey
128
+ * Order of precedence:
129
+ * Map file entry in 'typeConversion:<direction>:<value>:getObjectClass()'
130
+ * for value from 'entityClass' or root from 'typePath'
131
+ * TypeDefaults.getDefaultObjectClass() function
132
+ *
133
+ * @param transformMapFile
134
+ * @param mapFileUtil
135
+ * @param entity
136
+ * @param type
137
+ * @param direction
138
+ * @returns
139
+ */
77
140
  static async getMapKey(transformMapFile, mapFileUtil, entity, direction) {
78
141
  if (transformMapFile) {
79
142
  const type = this.getEntityType(entity);
@@ -85,6 +148,12 @@ class TypeConversionUtils {
85
148
  }
86
149
  return type_defaults_1.TypeDefaults.getDefaultObjectClass(entity);
87
150
  }
151
+ /** Returns the VibeIQ entity type from an entity.
152
+ * Throws error if it can't determine the entity type
153
+ *
154
+ * @param entity
155
+ * @returns string
156
+ */
88
157
  static getEntityType(entity) {
89
158
  let entityType = entity['entityType'];
90
159
  if (!entityType) {
@@ -101,6 +170,18 @@ class TypeConversionUtils {
101
170
  }
102
171
  return entityType;
103
172
  }
173
+ /** Takes in a FlexPLM object and returns the correct VibeIQ entity
174
+ * class associated to the object. Order of precedence
175
+ * Property 'vibeIQEntityClass'
176
+ * Map file entry in 'typeConversion:flex2vibe:<value>:getObjectClass()'
177
+ * for value from 'objectClass'
178
+ * TypeDefaults.getDefaultEntityClass() function
179
+ *
180
+ * @param fileId id for mapFile
181
+ * @param mapFileUtil class to get mapfile
182
+ * @param object FlexPLM object
183
+ * @returns Promise<string>
184
+ */
104
185
  static async getEntityClassFromObject(fileId, mapFileUtil, object) {
105
186
  let entityClass = object['vibeIQEntityClass'];
106
187
  if (entityClass) {
@@ -118,6 +199,17 @@ class TypeConversionUtils {
118
199
  }
119
200
  return type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
120
201
  }
202
+ /** Takes in a FlexPLM object and returns the correct VibeIQ uniqueness
203
+ * pool key. Order of precedence:
204
+ * Map file entry in 'typeConversion:flex2vibe:<value>:getUniquenessPool()'
205
+ * for value from 'objectClass'
206
+ * TypeDefaults.getDefaultEntityClass() function
207
+ *
208
+ * @param fileId id for mapFile
209
+ * @param mapFileUtil class to get mapfile
210
+ * @param object FlexPLM object
211
+ * @returns Promise<string>
212
+ */
121
213
  static async getUniquenessPoolKeyFromObject(fileId, mapFileUtil, object) {
122
214
  let uniquenessPool;
123
215
  if (fileId) {
@@ -135,6 +227,21 @@ class TypeConversionUtils {
135
227
  return type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
136
228
  }
137
229
  static async getEntityTypePathFromOjbect(fileId, mapFileUtil, object) {
230
+ return await this.getEntityTypePathFromObject(fileId, mapFileUtil, object);
231
+ }
232
+ /** Takes in a FlexPLM object and returns the correct VibeIQ
233
+ * type associated to the object. Order of precedence
234
+ * Property 'vibeIQTypePath'
235
+ * Map file entry in 'typeConversion:flex2vibe:<value>:getSoftType()'
236
+ * for value from 'objectClass' or root from 'flexPLMTypePath'
237
+ * TypeDefaults.getDefaultEntityTypePath() function
238
+ *
239
+ * @param transformMapFile id for mapFile
240
+ * @param mapFileUtil class to get mapfile
241
+ * @param entity VibeIQ entity
242
+ * @returns Promise<string>
243
+ */
244
+ static async getEntityTypePathFromObject(fileId, mapFileUtil, object) {
138
245
  let typePath = object['vibeIQTypePath'];
139
246
  if (typePath) {
140
247
  return typePath;
@@ -151,6 +258,18 @@ class TypeConversionUtils {
151
258
  }
152
259
  return type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
153
260
  }
261
+ /**Takes in a FlexPLM object and returns the correct
262
+ * identifier properties. Order of precedence
263
+ * Property 'vibeIQIdentifierProperties'
264
+ * Map file entry in 'typeConversion:flex2vibe:<value>:getIdentifierProperties()'
265
+ * for value from 'objectClass'
266
+ * TypeDefaults.getDefaultIdentifierPropertiesFromObject() function
267
+ *
268
+ * @param transformMapFile id for mapFile
269
+ * @param mapFileUtil class to get mapfile
270
+ * @param object
271
+ * @returns Promise<string[]>
272
+ */
154
273
  static async getIdentifierPropertiesFromObject(fileId, mapFileUtil, object) {
155
274
  let identifiers = object['vibeIQIdentifierProperties'];
156
275
  if (identifiers) {
@@ -168,6 +287,18 @@ class TypeConversionUtils {
168
287
  }
169
288
  return type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
170
289
  }
290
+ /**Takes in a FlexPLM object and returns the correct
291
+ * identifier properties. Order of precedence
292
+ * Property 'vibeIQIdentifierProperties'
293
+ * Map file entry in 'typeConversion:flex2vibe:<value>:getInformationalProperties()'
294
+ * for value from 'objectClass'
295
+ * TypeDefaults.getDefaultIdentifierPropertiesFromObject() function
296
+ *
297
+ * @param transformMapFile id for mapFile
298
+ * @param mapFileUtil class to get mapfile
299
+ * @param object
300
+ * @returns Promise<string[]>
301
+ */
171
302
  static async getInformationalPropertiesFromObject(fileId, mapFileUtil, object) {
172
303
  let identifiers = object['vibeIQInformationalProperties'];
173
304
  if (identifiers) {
@@ -195,6 +326,7 @@ class TypeConversionUtils {
195
326
  }
196
327
  return type;
197
328
  }
329
+ //TODO use TypeDefaults?
198
330
  }
199
331
  static async isInboundCreatableFromObject(fileId, mapFileUtil, object, context) {
200
332
  let isInboundCreatable = false;
@@ -228,6 +360,17 @@ class TypeConversionUtils {
228
360
  }
229
361
  return isOutboundCreatable;
230
362
  }
363
+ /** Takes in a FlexPLM object and determines whether inbound
364
+ * images should be synced. In most cases, the creation owning system
365
+ * will also control image syncing. Defaults to false if no mapping exists.
366
+ * Map file entry in '<mapKey>:syncInboundImages()'
367
+ *
368
+ * @param fileId id for mapFile
369
+ * @param mapFileUtil class to get mapfile
370
+ * @param object FlexPLM object
371
+ * @param context optional context object
372
+ * @returns Promise<boolean>
373
+ */
231
374
  static async syncInboundImages(fileId, mapFileUtil, object, context) {
232
375
  let syncImages = false;
233
376
  if (!fileId) {
@@ -249,6 +392,17 @@ class TypeConversionUtils {
249
392
  }
250
393
  return syncImages;
251
394
  }
395
+ /** Takes in a VibeIQ entity object and determines whether outbound
396
+ * images should be synced. In most cases, the creation owning system
397
+ * will also control image syncing. Defaults to true if no mapping exists.
398
+ * Map file entry in '<mapKey>:syncOutboundImages()'
399
+ *
400
+ * @param fileId id for mapFile
401
+ * @param mapFileUtil class to get mapfile
402
+ * @param entity VibeIQ entity
403
+ * @param context optional context object
404
+ * @returns Promise<boolean>
405
+ */
252
406
  static async syncOutboundImages(fileId, mapFileUtil, entity, context) {
253
407
  let syncImages = true;
254
408
  if (!fileId) {
@@ -2,15 +2,84 @@ export declare class TypeDefaults {
2
2
  static NO_ENTITY_TYPE: string;
3
3
  static NO_OBJECT_CLASS: string;
4
4
  static NO_TYPE_PATH: string;
5
+ static processLCSMaterialAsItem: boolean;
5
6
  constructor();
7
+ /** Applies values from the resolved config to TypeDefaults static state.
8
+ * Currently toggles whether LCSMaterial is treated as an item (new) or a
9
+ * custom-entity (old) based on config.LCSMaterial.processAsItem.
10
+ * Technically this could cause side effects if different parts of the code
11
+ * expect different behavior, but in practice * @param config will be
12
+ * consistent across the app and this is simpler than passing this config
13
+ * through multiple layers of function calls.
14
+ */
15
+ static applyConfig(config: any): void;
16
+ static isPropertyTrue(value: any): boolean;
17
+ /**Takes in full entity and returs the default FlexPLM
18
+ * object class.
19
+ *
20
+ * @param entity
21
+ * @returns string
22
+ */
6
23
  static getDefaultObjectClass(entity: any): string;
24
+ /**Takes in full entity and returns the default FlexPLM type path
25
+ * object class.
26
+ *
27
+ * @param entity
28
+ * @returns string
29
+ */
7
30
  static getDefaultObjectTypePath(entity: any): string;
31
+ /**Takes in full entity and returns the slugs for the default identifier
32
+ * properties. These properties are used when searching for an entity
33
+ * object class.
34
+ *
35
+ * @param entity
36
+ * @returns string[]
37
+ */
8
38
  static getDefaultIdentifierProperties(entity: any): string[];
39
+ /** Takes in full entity and returns the slugs for informational
40
+ * properties. These properties are helpful when debugging issues
41
+ * where the identifier properties don't find a match.
42
+ *
43
+ * @param entity
44
+ * @returns string[]
45
+ */
9
46
  static getDefaultInformationalProperties(entity: any): string[];
47
+ /** Returns the VibeIQ entity type from an entity.
48
+ * Throws error if it can't determine the entity type
49
+ *
50
+ * @param entity
51
+ * @returns string
52
+ */
10
53
  static getEntityType(entity: any): any;
54
+ /**Takes in full object and returns the default VibeIQ
55
+ * entity class.
56
+ *
57
+ * @param entity
58
+ * @returns string
59
+ */
11
60
  static getDefaultEntityClass(object: any): string;
61
+ /**Takes in full object and returns the default VibeIQ type path
62
+ * object class.
63
+ *
64
+ * @param object
65
+ * @returns string
66
+ */
12
67
  static getDefaultEntityTypePath(object: any): string;
68
+ /**Takes in full entity and returns the slugs for the default identifier
69
+ * properties. These properties are used when searching for an entity
70
+ * object class.
71
+ *
72
+ * @param entity
73
+ * @returns string[]
74
+ */
13
75
  static getDefaultIdentifierPropertiesFromObject(object: any): string[];
76
+ /** Takes in full object and returns the slugs for informational
77
+ * properties. These properties are helpful when debugging issues
78
+ * where the identifier properties don't find a match.
79
+ *
80
+ * @param object
81
+ * @returns string[]
82
+ */
14
83
  static getDefaultInformationalPropertiesFromObject(object: any): string[];
15
84
  static getObjectClass(object: any): string;
16
85
  }
@@ -4,6 +4,26 @@ exports.TypeDefaults = void 0;
4
4
  class TypeDefaults {
5
5
  constructor() {
6
6
  }
7
+ /** Applies values from the resolved config to TypeDefaults static state.
8
+ * Currently toggles whether LCSMaterial is treated as an item (new) or a
9
+ * custom-entity (old) based on config.LCSMaterial.processAsItem.
10
+ * Technically this could cause side effects if different parts of the code
11
+ * expect different behavior, but in practice * @param config will be
12
+ * consistent across the app and this is simpler than passing this config
13
+ * through multiple layers of function calls.
14
+ */
15
+ static applyConfig(config) {
16
+ TypeDefaults.processLCSMaterialAsItem = TypeDefaults.isPropertyTrue(config?.LCSMaterial?.processAsItem);
17
+ }
18
+ static isPropertyTrue(value) {
19
+ return value === true || (typeof value === 'string' && value.toLowerCase() === 'true');
20
+ }
21
+ /**Takes in full entity and returs the default FlexPLM
22
+ * object class.
23
+ *
24
+ * @param entity
25
+ * @returns string
26
+ */
7
27
  static getDefaultObjectClass(entity) {
8
28
  const entityType = this.getEntityType(entity);
9
29
  let objectClass = '';
@@ -42,6 +62,12 @@ class TypeDefaults {
42
62
  }
43
63
  return objectClass;
44
64
  }
65
+ /**Takes in full entity and returns the default FlexPLM type path
66
+ * object class.
67
+ *
68
+ * @param entity
69
+ * @returns string
70
+ */
45
71
  static getDefaultObjectTypePath(entity) {
46
72
  let typePath = '';
47
73
  const entityType = this.getEntityType(entity);
@@ -70,6 +96,13 @@ class TypeDefaults {
70
96
  }
71
97
  return typePath;
72
98
  }
99
+ /**Takes in full entity and returns the slugs for the default identifier
100
+ * properties. These properties are used when searching for an entity
101
+ * object class.
102
+ *
103
+ * @param entity
104
+ * @returns string[]
105
+ */
73
106
  static getDefaultIdentifierProperties(entity) {
74
107
  const identifierProps = [];
75
108
  const entityType = this.getEntityType(entity);
@@ -95,6 +128,13 @@ class TypeDefaults {
95
128
  }
96
129
  return identifierProps;
97
130
  }
131
+ /** Takes in full entity and returns the slugs for informational
132
+ * properties. These properties are helpful when debugging issues
133
+ * where the identifier properties don't find a match.
134
+ *
135
+ * @param entity
136
+ * @returns string[]
137
+ */
98
138
  static getDefaultInformationalProperties(entity) {
99
139
  const entityType = this.getEntityType(entity);
100
140
  let properties = [];
@@ -111,6 +151,12 @@ class TypeDefaults {
111
151
  }
112
152
  return properties;
113
153
  }
154
+ /** Returns the VibeIQ entity type from an entity.
155
+ * Throws error if it can't determine the entity type
156
+ *
157
+ * @param entity
158
+ * @returns string
159
+ */
114
160
  static getEntityType(entity) {
115
161
  let entityType = entity['entityType'];
116
162
  if (!entityType) {
@@ -127,10 +173,22 @@ class TypeDefaults {
127
173
  }
128
174
  return entityType;
129
175
  }
176
+ /**Takes in full object and returns the default VibeIQ
177
+ * entity class.
178
+ *
179
+ * @param entity
180
+ * @returns string
181
+ */
130
182
  static getDefaultEntityClass(object) {
131
183
  let entityClass = '';
132
184
  let objectClass = TypeDefaults.getObjectClass(object);
133
- if (['LCSProduct', 'LCSSKU'].includes(objectClass)) {
185
+ const itemClasses = TypeDefaults.processLCSMaterialAsItem
186
+ ? ['LCSProduct', 'LCSSKU', 'LCSMaterial']
187
+ : ['LCSProduct', 'LCSSKU'];
188
+ const customEntityClasses = TypeDefaults.processLCSMaterialAsItem
189
+ ? ['LCSRevisableEntity', 'LCSLifecycleManaged', 'LCSLast']
190
+ : ['LCSRevisableEntity', 'LCSLifecycleManaged', 'LCSLast', 'LCSMaterial'];
191
+ if (itemClasses.includes(objectClass)) {
134
192
  entityClass = 'item';
135
193
  }
136
194
  else if (['LCSProductSeasonLink', 'LCSSKUSeasonLink'].includes(objectClass)) {
@@ -142,13 +200,19 @@ class TypeDefaults {
142
200
  else if (['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
143
201
  entityClass = 'assortment';
144
202
  }
145
- else if (['LCSRevisableEntity', 'LCSLifecycleManaged', 'LCSLast', 'LCSMaterial'].includes(objectClass)) {
203
+ else if (customEntityClasses.includes(objectClass)) {
146
204
  entityClass = 'custom-entity';
147
205
  }
148
206
  if (entityClass === '')
149
207
  throw Error(TypeDefaults.NO_OBJECT_CLASS);
150
208
  return entityClass;
151
209
  }
210
+ /**Takes in full object and returns the default VibeIQ type path
211
+ * object class.
212
+ *
213
+ * @param object
214
+ * @returns string
215
+ */
152
216
  static getDefaultEntityTypePath(object) {
153
217
  let typePath = '';
154
218
  const objectClass = TypeDefaults.getObjectClass(object);
@@ -157,6 +221,11 @@ class TypeDefaults {
157
221
  case 'LCSSKU':
158
222
  typePath = 'item';
159
223
  break;
224
+ case 'LCSMaterial':
225
+ if (TypeDefaults.processLCSMaterialAsItem) {
226
+ typePath = 'item:material';
227
+ }
228
+ break;
160
229
  case 'LCSProductSeasonLink':
161
230
  case 'LCSSKUSeasonLink':
162
231
  typePath = 'project-item';
@@ -173,6 +242,13 @@ class TypeDefaults {
173
242
  throw Error(TypeDefaults.NO_TYPE_PATH);
174
243
  return typePath;
175
244
  }
245
+ /**Takes in full entity and returns the slugs for the default identifier
246
+ * properties. These properties are used when searching for an entity
247
+ * object class.
248
+ *
249
+ * @param entity
250
+ * @returns string[]
251
+ */
176
252
  static getDefaultIdentifierPropertiesFromObject(object) {
177
253
  const identifierProps = [];
178
254
  const objectClass = TypeDefaults.getObjectClass(object);
@@ -181,6 +257,14 @@ class TypeDefaults {
181
257
  case 'LCSSKU':
182
258
  identifierProps.push('itemNumber');
183
259
  break;
260
+ case 'LCSMaterial':
261
+ if (TypeDefaults.processLCSMaterialAsItem) {
262
+ identifierProps.push('itemNumber');
263
+ }
264
+ else {
265
+ identifierProps.push('name');
266
+ }
267
+ break;
184
268
  case 'LCSSeason':
185
269
  identifierProps.push('flexPLMSeasonName');
186
270
  break;
@@ -191,16 +275,25 @@ class TypeDefaults {
191
275
  case 'LCSRevisableEntity':
192
276
  case 'LCSLifecycleManaged':
193
277
  case 'LCSLast':
194
- case 'LCSMaterial':
195
278
  identifierProps.push('name');
196
279
  break;
197
280
  }
198
281
  return identifierProps;
199
282
  }
283
+ /** Takes in full object and returns the slugs for informational
284
+ * properties. These properties are helpful when debugging issues
285
+ * where the identifier properties don't find a match.
286
+ *
287
+ * @param object
288
+ * @returns string[]
289
+ */
200
290
  static getDefaultInformationalPropertiesFromObject(object) {
201
291
  const objectClass = TypeDefaults.getObjectClass(object);
202
292
  let properties = [];
203
- if ('LCSProduct' === objectClass) {
293
+ const itemClasses = TypeDefaults.processLCSMaterialAsItem
294
+ ? ['LCSProduct', 'LCSMaterial']
295
+ : ['LCSProduct'];
296
+ if (itemClasses.includes(objectClass)) {
204
297
  properties.push('name');
205
298
  }
206
299
  else if ('LCSSKU' === objectClass) {
@@ -219,3 +312,4 @@ exports.TypeDefaults = TypeDefaults;
219
312
  TypeDefaults.NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';
220
313
  TypeDefaults.NO_OBJECT_CLASS = 'Please ensure that the flexPLMObjectClass property is provided.';
221
314
  TypeDefaults.NO_TYPE_PATH = 'Please ensure that the flexPLMTypePath property is provided.';
315
+ TypeDefaults.processLCSMaterialAsItem = false;
@@ -304,7 +304,7 @@ describe('Type Defaults', () => {
304
304
  expect(() => type_defaults_1.TypeDefaults.getEntityType(entity)).toThrowError();
305
305
  expect(() => type_defaults_1.TypeDefaults.getEntityType(entity)).toThrow(type_defaults_1.TypeDefaults.NO_ENTITY_TYPE);
306
306
  });
307
- });
307
+ }); //getEntityType
308
308
  describe('getDefaultEntityClass', () => {
309
309
  it('item - LCSProduct', () => {
310
310
  const object = {
@@ -369,7 +369,27 @@ describe('Type Defaults', () => {
369
369
  const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
370
370
  expect(entityClass).toBe('custom-entity');
371
371
  });
372
- });
372
+ it('item - LCSMaterial - processAsItem=true', () => {
373
+ const object = {
374
+ flexPLMObjectClass: 'LCSMaterial'
375
+ };
376
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
377
+ try {
378
+ const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
379
+ expect(entityClass).toBe('item');
380
+ }
381
+ finally {
382
+ type_defaults_1.TypeDefaults.applyConfig({});
383
+ }
384
+ });
385
+ it('custom-entity - LCSMaterial - processAsItem=false (default)', () => {
386
+ const object = {
387
+ flexPLMObjectClass: 'LCSMaterial'
388
+ };
389
+ const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
390
+ expect(entityClass).toBe('custom-entity');
391
+ });
392
+ }); //getDefaultEntityClass
373
393
  describe('getDefaultEntityTypePath', () => {
374
394
  it('LCSProduct', () => {
375
395
  const object = {
@@ -420,7 +440,26 @@ describe('Type Defaults', () => {
420
440
  const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
421
441
  expect(typePath).toBe('assortment');
422
442
  });
423
- });
443
+ it('LCSMaterial - processAsItem=true', () => {
444
+ const object = {
445
+ flexPLMObjectClass: 'LCSMaterial'
446
+ };
447
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
448
+ try {
449
+ const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
450
+ expect(typePath).toBe('item:material');
451
+ }
452
+ finally {
453
+ type_defaults_1.TypeDefaults.applyConfig({});
454
+ }
455
+ });
456
+ it('LCSMaterial - processAsItem=false (default) throws', () => {
457
+ const object = {
458
+ flexPLMObjectClass: 'LCSMaterial'
459
+ };
460
+ expect(() => type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object)).toThrowError(type_defaults_1.TypeDefaults.NO_TYPE_PATH);
461
+ });
462
+ }); //getDefaultEntityTypePath
424
463
  describe('getDefaultIdentifierPropertiesFromObject', () => {
425
464
  it('LCSProduct', () => {
426
465
  const object = {
@@ -478,7 +517,29 @@ describe('Type Defaults', () => {
478
517
  expect(defaultIdentifiers).toContain('name');
479
518
  expect(defaultIdentifiers).toHaveLength(1);
480
519
  });
481
- });
520
+ it('LCSMaterial - processAsItem=true', () => {
521
+ const object = {
522
+ flexPLMObjectClass: 'LCSMaterial'
523
+ };
524
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
525
+ try {
526
+ const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
527
+ expect(defaultIdentifiers).toContain('itemNumber');
528
+ expect(defaultIdentifiers).toHaveLength(1);
529
+ }
530
+ finally {
531
+ type_defaults_1.TypeDefaults.applyConfig({});
532
+ }
533
+ });
534
+ it('LCSMaterial - processAsItem=false (default)', () => {
535
+ const object = {
536
+ flexPLMObjectClass: 'LCSMaterial'
537
+ };
538
+ const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
539
+ expect(defaultIdentifiers).toContain('name');
540
+ expect(defaultIdentifiers).toHaveLength(1);
541
+ });
542
+ }); //getDefaultIdentifierPropertiesFromObject
482
543
  describe('getDefaultInformationalPropertiesFromObject', () => {
483
544
  it('LCSProduct', () => {
484
545
  const object = {
@@ -512,5 +573,54 @@ describe('Type Defaults', () => {
512
573
  expect(defaultIdentifiers).toContain('name');
513
574
  expect(defaultIdentifiers).toHaveLength(1);
514
575
  });
576
+ it('LCSMaterial - processAsItem=true', () => {
577
+ const object = {
578
+ flexPLMObjectClass: 'LCSMaterial'
579
+ };
580
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
581
+ try {
582
+ const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalPropertiesFromObject(object);
583
+ expect(defaultIdentifiers).toContain('name');
584
+ expect(defaultIdentifiers).toHaveLength(1);
585
+ }
586
+ finally {
587
+ type_defaults_1.TypeDefaults.applyConfig({});
588
+ }
589
+ });
590
+ it('LCSMaterial - processAsItem=false (default) yields no informational props', () => {
591
+ const object = {
592
+ flexPLMObjectClass: 'LCSMaterial'
593
+ };
594
+ const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalPropertiesFromObject(object);
595
+ expect(defaultIdentifiers).toHaveLength(0);
596
+ });
597
+ }); //getDefaultInformationalPropertiesFromObject
598
+ describe('applyConfig', () => {
599
+ afterEach(() => {
600
+ type_defaults_1.TypeDefaults.applyConfig({});
601
+ });
602
+ it('sets processLCSMaterialAsItem=true when processAsItem=true', () => {
603
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
604
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(true);
605
+ });
606
+ it('sets processLCSMaterialAsItem=true when processAsItem=\"true\" (string)', () => {
607
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: 'true' } });
608
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(true);
609
+ });
610
+ it('sets processLCSMaterialAsItem=false when processAsItem=false', () => {
611
+ type_defaults_1.TypeDefaults.processLCSMaterialAsItem = true;
612
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: false } });
613
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(false);
614
+ });
615
+ it('sets processLCSMaterialAsItem=false when LCSMaterial missing', () => {
616
+ type_defaults_1.TypeDefaults.processLCSMaterialAsItem = true;
617
+ type_defaults_1.TypeDefaults.applyConfig({});
618
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(false);
619
+ });
620
+ it('sets processLCSMaterialAsItem=false when config is null/undefined', () => {
621
+ type_defaults_1.TypeDefaults.processLCSMaterialAsItem = true;
622
+ type_defaults_1.TypeDefaults.applyConfig(undefined);
623
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(false);
624
+ });
515
625
  });
516
626
  });