@contrail/flexplm 1.3.0 → 1.3.1-alpha.3507ab6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +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 +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 +62 -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 +460 -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,265 +1,408 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeConversionUtils = void 0;
4
- const type_defaults_1 = require("./type-defaults");
5
- const map_utils_1 = require("./map-utils");
6
- class TypeConversionUtils {
7
- constructor() {
8
- }
9
- static async getObjectClass(transformMapFile, mapFileUtil, entity) {
10
- let objectClass = entity['flexPLMObjectClass'];
11
- if (objectClass) {
12
- return objectClass;
13
- }
14
- if (transformMapFile) {
15
- const mapSectionKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
16
- const mapData = await mapFileUtil.getMappingSection(transformMapFile, mapSectionKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
17
- if (mapData['getClass']) {
18
- objectClass = await mapData['getClass'](entity);
19
- }
20
- }
21
- if (objectClass) {
22
- return objectClass;
23
- }
24
- return type_defaults_1.TypeDefaults.getDefaultObjectClass(entity);
25
- }
26
- static async getObjectTypePath(transformMapFile, mapFileUtil, entity) {
27
- let typePath = entity['flexPLMTypePath'];
28
- if (typePath) {
29
- return typePath;
30
- }
31
- if (transformMapFile) {
32
- const mapSectionKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
33
- const mapData = await mapFileUtil.getMappingSection(transformMapFile, mapSectionKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
34
- if (mapData['getSoftType']) {
35
- typePath = await mapData['getSoftType'](entity);
36
- }
37
- }
38
- if (typePath) {
39
- return typePath;
40
- }
41
- return type_defaults_1.TypeDefaults.getDefaultObjectTypePath(entity);
42
- }
43
- static async getIdentifierProperties(transformMapFile, mapFileUtil, entity) {
44
- let identifiers = entity['flexPLMIdentifierProperties'];
45
- if (identifiers) {
46
- return identifiers;
47
- }
48
- if (transformMapFile) {
49
- const mapKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
50
- const mapData = await map_utils_1.MapUtil.getFullMapSection(transformMapFile, mapFileUtil, mapKey);
51
- if (mapData && mapData['getIdentifierProperties']) {
52
- identifiers = await mapData['getIdentifierProperties'](entity);
53
- }
54
- }
55
- if (identifiers) {
56
- return identifiers;
57
- }
58
- return type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(entity);
59
- }
60
- static async getInformationalProperties(transformMapFile, mapFileUtil, entity) {
61
- let identifiers = entity['flexPLMInformationalProperties'];
62
- if (identifiers) {
63
- return identifiers;
64
- }
65
- if (transformMapFile) {
66
- const mapKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
67
- const mapData = await map_utils_1.MapUtil.getFullMapSection(transformMapFile, mapFileUtil, mapKey);
68
- if (mapData && mapData['getInformationalProperties']) {
69
- identifiers = await mapData['getInformationalProperties'](entity);
70
- }
71
- }
72
- if (identifiers) {
73
- return identifiers;
74
- }
75
- return type_defaults_1.TypeDefaults.getDefaultInformationalProperties(entity);
76
- }
77
- static async getMapKey(transformMapFile, mapFileUtil, entity, direction) {
78
- if (transformMapFile) {
79
- const type = this.getEntityType(entity);
80
- const mappingData = await mapFileUtil.getMappingSection(transformMapFile, 'typeConversion', direction);
81
- if (mappingData && mappingData[type] && mappingData[type]['getMapKey']) {
82
- const mapKey = await mappingData[type]['getMapKey'](entity);
83
- return mapKey;
84
- }
85
- }
86
- return type_defaults_1.TypeDefaults.getDefaultObjectClass(entity);
87
- }
88
- static getEntityType(entity) {
89
- let entityType = entity['entityType'];
90
- if (!entityType) {
91
- const typePath = entity['typePath'];
92
- if (typePath) {
93
- const types = typePath.split(':');
94
- if (types && types[0]) {
95
- entityType = types[0];
96
- }
97
- }
98
- }
99
- if (!entityType) {
100
- throw Error(TypeConversionUtils.NO_ENTITY_TYPE);
101
- }
102
- return entityType;
103
- }
104
- static async getEntityClassFromObject(fileId, mapFileUtil, object) {
105
- let entityClass = object['vibeIQEntityClass'];
106
- if (entityClass) {
107
- return entityClass;
108
- }
109
- if (fileId) {
110
- const mapSectionKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
111
- const mapData = await mapFileUtil.getMappingSection(fileId, mapSectionKey, TypeConversionUtils.FLEX2VIBE_DIRECTION);
112
- if (mapData['getClass']) {
113
- entityClass = await mapData['getClass'](object);
114
- }
115
- }
116
- if (entityClass) {
117
- return entityClass;
118
- }
119
- return type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
120
- }
121
- static async getEntityTypePathFromOjbect(fileId, mapFileUtil, object) {
122
- let typePath = object['vibeIQTypePath'];
123
- if (typePath) {
124
- return typePath;
125
- }
126
- if (fileId) {
127
- const mapSectionKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
128
- const mapData = await mapFileUtil.getMappingSection(fileId, mapSectionKey, TypeConversionUtils.FLEX2VIBE_DIRECTION);
129
- if (mapData['getSoftType']) {
130
- typePath = await mapData['getSoftType'](object);
131
- }
132
- }
133
- if (typePath) {
134
- return typePath;
135
- }
136
- return type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
137
- }
138
- static async getIdentifierPropertiesFromObject(fileId, mapFileUtil, object) {
139
- let identifiers = object['vibeIQIdentifierProperties'];
140
- if (identifiers) {
141
- return identifiers;
142
- }
143
- if (fileId) {
144
- const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
145
- const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
146
- if (mapData && mapData['getIdentifierProperties']) {
147
- identifiers = await mapData['getIdentifierProperties'](object);
148
- }
149
- }
150
- if (identifiers) {
151
- return identifiers;
152
- }
153
- return type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
154
- }
155
- static async getInformationalPropertiesFromObject(fileId, mapFileUtil, object) {
156
- let identifiers = object['vibeIQInformationalProperties'];
157
- if (identifiers) {
158
- return identifiers;
159
- }
160
- if (fileId) {
161
- const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
162
- const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
163
- if (mapData && mapData['getInformationalProperties']) {
164
- identifiers = await mapData['getInformationalProperties'](object);
165
- }
166
- }
167
- if (identifiers) {
168
- return identifiers;
169
- }
170
- return type_defaults_1.TypeDefaults.getDefaultInformationalPropertiesFromObject(object);
171
- }
172
- static async getMapKeyFromObject(fileId, mapFileUtil, object, direction) {
173
- const type = this.getObjectType(object);
174
- if (fileId) {
175
- const mappingData = await mapFileUtil.getMappingSection(fileId, 'typeConversion', direction);
176
- if (mappingData && mappingData[type] && mappingData[type]['getMapKey']) {
177
- const mapKey = await mappingData[type]['getMapKey'](object);
178
- return mapKey;
179
- }
180
- return type;
181
- }
182
- }
183
- static async isInboundCreatableFromObject(fileId, mapFileUtil, object, context) {
184
- let isInboundCreatable = false;
185
- if (fileId) {
186
- const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
187
- const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
188
- if (mapData && mapData['isInboundCreatable']) {
189
- isInboundCreatable = await mapData['isInboundCreatable'](object, context);
190
- }
191
- }
192
- return isInboundCreatable;
193
- }
194
- static async isOutboundCreatableFromEntity(fileId, mapFileUtil, entity, context) {
195
- let isOutboundCreatable = true;
196
- if (!fileId) {
197
- return isOutboundCreatable;
198
- }
199
- let mapKey;
200
- try {
201
- mapKey = await this.getMapKey(fileId, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
202
- }
203
- catch {
204
- return isOutboundCreatable;
205
- }
206
- if (!mapKey) {
207
- return isOutboundCreatable;
208
- }
209
- const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
210
- if (mapData && mapData['isOutboundCreatable']) {
211
- isOutboundCreatable = await mapData['isOutboundCreatable'](entity, context);
212
- }
213
- return isOutboundCreatable;
214
- }
215
- static async syncInboundImages(fileId, mapFileUtil, object, context) {
216
- let syncImages = false;
217
- if (!fileId) {
218
- return syncImages;
219
- }
220
- let mapKey;
221
- try {
222
- mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
223
- }
224
- catch {
225
- return syncImages;
226
- }
227
- if (!mapKey) {
228
- return syncImages;
229
- }
230
- const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
231
- if (mapData && mapData['syncInboundImages']) {
232
- syncImages = await mapData['syncInboundImages'](object, context);
233
- }
234
- return syncImages;
235
- }
236
- static async syncOutboundImages(fileId, mapFileUtil, entity, context) {
237
- let syncImages = true;
238
- if (!fileId) {
239
- return syncImages;
240
- }
241
- let mapKey;
242
- try {
243
- mapKey = await this.getMapKey(fileId, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
244
- }
245
- catch {
246
- return syncImages;
247
- }
248
- if (!mapKey) {
249
- return syncImages;
250
- }
251
- const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
252
- if (mapData && mapData['syncOutboundImages']) {
253
- syncImages = await mapData['syncOutboundImages'](entity, context);
254
- }
255
- return syncImages;
256
- }
257
- static getObjectType(object) {
258
- let objectType = object['flexPLMObjectClass'];
259
- return objectType;
260
- }
261
- }
262
- exports.TypeConversionUtils = TypeConversionUtils;
263
- TypeConversionUtils.NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';
264
- TypeConversionUtils.VIBE2FLEX_DIRECTION = 'vibe2flex';
265
- TypeConversionUtils.FLEX2VIBE_DIRECTION = 'flex2vibe';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeConversionUtils = void 0;
4
+ const type_defaults_1 = require("./type-defaults");
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
+ */
9
+ class TypeConversionUtils {
10
+ constructor() {
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
+ */
23
+ static async getObjectClass(transformMapFile, mapFileUtil, entity) {
24
+ let objectClass = entity['flexPLMObjectClass'];
25
+ if (objectClass) {
26
+ return objectClass;
27
+ }
28
+ if (transformMapFile) {
29
+ const mapSectionKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
30
+ const mapData = await mapFileUtil.getMappingSection(transformMapFile, mapSectionKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
31
+ if (mapData['getClass']) {
32
+ objectClass = await mapData['getClass'](entity);
33
+ }
34
+ }
35
+ if (objectClass) {
36
+ return objectClass;
37
+ }
38
+ return type_defaults_1.TypeDefaults.getDefaultObjectClass(entity);
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
+ */
52
+ static async getObjectTypePath(transformMapFile, mapFileUtil, entity) {
53
+ let typePath = entity['flexPLMTypePath'];
54
+ if (typePath) {
55
+ return typePath;
56
+ }
57
+ if (transformMapFile) {
58
+ const mapSectionKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
59
+ const mapData = await mapFileUtil.getMappingSection(transformMapFile, mapSectionKey, TypeConversionUtils.VIBE2FLEX_DIRECTION);
60
+ if (mapData['getSoftType']) {
61
+ typePath = await mapData['getSoftType'](entity);
62
+ }
63
+ }
64
+ if (typePath) {
65
+ return typePath;
66
+ }
67
+ return type_defaults_1.TypeDefaults.getDefaultObjectTypePath(entity);
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
+ */
81
+ static async getIdentifierProperties(transformMapFile, mapFileUtil, entity) {
82
+ let identifiers = entity['flexPLMIdentifierProperties'];
83
+ if (identifiers) {
84
+ return identifiers;
85
+ }
86
+ if (transformMapFile) {
87
+ const mapKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
88
+ const mapData = await map_utils_1.MapUtil.getFullMapSection(transformMapFile, mapFileUtil, mapKey);
89
+ if (mapData && mapData['getIdentifierProperties']) {
90
+ identifiers = await mapData['getIdentifierProperties'](entity);
91
+ }
92
+ }
93
+ if (identifiers) {
94
+ return identifiers;
95
+ }
96
+ return type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(entity);
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
+ */
110
+ static async getInformationalProperties(transformMapFile, mapFileUtil, entity) {
111
+ let identifiers = entity['flexPLMInformationalProperties'];
112
+ if (identifiers) {
113
+ return identifiers;
114
+ }
115
+ if (transformMapFile) {
116
+ const mapKey = await this.getMapKey(transformMapFile, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
117
+ const mapData = await map_utils_1.MapUtil.getFullMapSection(transformMapFile, mapFileUtil, mapKey);
118
+ if (mapData && mapData['getInformationalProperties']) {
119
+ identifiers = await mapData['getInformationalProperties'](entity);
120
+ }
121
+ }
122
+ if (identifiers) {
123
+ return identifiers;
124
+ }
125
+ return type_defaults_1.TypeDefaults.getDefaultInformationalProperties(entity);
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
+ */
140
+ static async getMapKey(transformMapFile, mapFileUtil, entity, direction) {
141
+ if (transformMapFile) {
142
+ const type = this.getEntityType(entity);
143
+ const mappingData = await mapFileUtil.getMappingSection(transformMapFile, 'typeConversion', direction);
144
+ if (mappingData && mappingData[type] && mappingData[type]['getMapKey']) {
145
+ const mapKey = await mappingData[type]['getMapKey'](entity);
146
+ return mapKey;
147
+ }
148
+ }
149
+ return type_defaults_1.TypeDefaults.getDefaultObjectClass(entity);
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
+ */
157
+ static getEntityType(entity) {
158
+ let entityType = entity['entityType'];
159
+ if (!entityType) {
160
+ const typePath = entity['typePath'];
161
+ if (typePath) {
162
+ const types = typePath.split(':');
163
+ if (types && types[0]) {
164
+ entityType = types[0];
165
+ }
166
+ }
167
+ }
168
+ if (!entityType) {
169
+ throw Error(TypeConversionUtils.NO_ENTITY_TYPE);
170
+ }
171
+ return entityType;
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
+ */
185
+ static async getEntityClassFromObject(fileId, mapFileUtil, object) {
186
+ let entityClass = object['vibeIQEntityClass'];
187
+ if (entityClass) {
188
+ return entityClass;
189
+ }
190
+ if (fileId) {
191
+ const mapSectionKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
192
+ const mapData = await mapFileUtil.getMappingSection(fileId, mapSectionKey, TypeConversionUtils.FLEX2VIBE_DIRECTION);
193
+ if (mapData['getClass']) {
194
+ entityClass = await mapData['getClass'](object);
195
+ }
196
+ }
197
+ if (entityClass) {
198
+ return entityClass;
199
+ }
200
+ return type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
201
+ }
202
+ static async getEntityTypePathFromOjbect(fileId, mapFileUtil, object) {
203
+ return await this.getEntityTypePathFromObject(fileId, mapFileUtil, object);
204
+ }
205
+ /** Takes in a FlexPLM object and returns the correct VibeIQ
206
+ * type associated to the object. Order of precedence
207
+ * Property 'vibeIQTypePath'
208
+ * Map file entry in 'typeConversion:flex2vibe:<value>:getSoftType()'
209
+ * for value from 'objectClass' or root from 'flexPLMTypePath'
210
+ * TypeDefaults.getDefaultEntityTypePath() function
211
+ *
212
+ * @param transformMapFile id for mapFile
213
+ * @param mapFileUtil class to get mapfile
214
+ * @param entity VibeIQ entity
215
+ * @returns Promise<string>
216
+ */
217
+ static async getEntityTypePathFromObject(fileId, mapFileUtil, object) {
218
+ let typePath = object['vibeIQTypePath'];
219
+ if (typePath) {
220
+ return typePath;
221
+ }
222
+ if (fileId) {
223
+ const mapSectionKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
224
+ const mapData = await mapFileUtil.getMappingSection(fileId, mapSectionKey, TypeConversionUtils.FLEX2VIBE_DIRECTION);
225
+ if (mapData['getSoftType']) {
226
+ typePath = await mapData['getSoftType'](object);
227
+ }
228
+ }
229
+ if (typePath) {
230
+ return typePath;
231
+ }
232
+ return type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
233
+ }
234
+ /**Takes in a FlexPLM object and returns the correct
235
+ * identifier properties. Order of precedence
236
+ * Property 'vibeIQIdentifierProperties'
237
+ * Map file entry in 'typeConversion:flex2vibe:<value>:getIdentifierProperties()'
238
+ * for value from 'objectClass'
239
+ * TypeDefaults.getDefaultIdentifierPropertiesFromObject() function
240
+ *
241
+ * @param transformMapFile id for mapFile
242
+ * @param mapFileUtil class to get mapfile
243
+ * @param object
244
+ * @returns Promise<string[]>
245
+ */
246
+ static async getIdentifierPropertiesFromObject(fileId, mapFileUtil, object) {
247
+ let identifiers = object['vibeIQIdentifierProperties'];
248
+ if (identifiers) {
249
+ return identifiers;
250
+ }
251
+ if (fileId) {
252
+ const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
253
+ const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
254
+ if (mapData && mapData['getIdentifierProperties']) {
255
+ identifiers = await mapData['getIdentifierProperties'](object);
256
+ }
257
+ }
258
+ if (identifiers) {
259
+ return identifiers;
260
+ }
261
+ return type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
262
+ }
263
+ /**Takes in a FlexPLM object and returns the correct
264
+ * identifier properties. Order of precedence
265
+ * Property 'vibeIQIdentifierProperties'
266
+ * Map file entry in 'typeConversion:flex2vibe:<value>:getInformationalProperties()'
267
+ * for value from 'objectClass'
268
+ * TypeDefaults.getDefaultIdentifierPropertiesFromObject() function
269
+ *
270
+ * @param transformMapFile id for mapFile
271
+ * @param mapFileUtil class to get mapfile
272
+ * @param object
273
+ * @returns Promise<string[]>
274
+ */
275
+ static async getInformationalPropertiesFromObject(fileId, mapFileUtil, object) {
276
+ let identifiers = object['vibeIQInformationalProperties'];
277
+ if (identifiers) {
278
+ return identifiers;
279
+ }
280
+ if (fileId) {
281
+ const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
282
+ const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
283
+ if (mapData && mapData['getInformationalProperties']) {
284
+ identifiers = await mapData['getInformationalProperties'](object);
285
+ }
286
+ }
287
+ if (identifiers) {
288
+ return identifiers;
289
+ }
290
+ return type_defaults_1.TypeDefaults.getDefaultInformationalPropertiesFromObject(object);
291
+ }
292
+ static async getMapKeyFromObject(fileId, mapFileUtil, object, direction) {
293
+ const type = this.getObjectType(object);
294
+ if (fileId) {
295
+ const mappingData = await mapFileUtil.getMappingSection(fileId, 'typeConversion', direction);
296
+ if (mappingData && mappingData[type] && mappingData[type]['getMapKey']) {
297
+ const mapKey = await mappingData[type]['getMapKey'](object);
298
+ return mapKey;
299
+ }
300
+ return type;
301
+ }
302
+ //TODO use TypeDefaults?
303
+ }
304
+ static async isInboundCreatableFromObject(fileId, mapFileUtil, object, context) {
305
+ let isInboundCreatable = false;
306
+ if (fileId) {
307
+ const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
308
+ const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
309
+ if (mapData && mapData['isInboundCreatable']) {
310
+ isInboundCreatable = await mapData['isInboundCreatable'](object, context);
311
+ }
312
+ }
313
+ return isInboundCreatable;
314
+ }
315
+ static async isOutboundCreatableFromEntity(fileId, mapFileUtil, entity, context) {
316
+ let isOutboundCreatable = true;
317
+ if (!fileId) {
318
+ return isOutboundCreatable;
319
+ }
320
+ let mapKey;
321
+ try {
322
+ mapKey = await this.getMapKey(fileId, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
323
+ }
324
+ catch {
325
+ return isOutboundCreatable;
326
+ }
327
+ if (!mapKey) {
328
+ return isOutboundCreatable;
329
+ }
330
+ const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
331
+ if (mapData && mapData['isOutboundCreatable']) {
332
+ isOutboundCreatable = await mapData['isOutboundCreatable'](entity, context);
333
+ }
334
+ return isOutboundCreatable;
335
+ }
336
+ /** Takes in a FlexPLM object and determines whether inbound
337
+ * images should be synced. In most cases, the creation owning system
338
+ * will also control image syncing. Defaults to false if no mapping exists.
339
+ * Map file entry in '<mapKey>:syncInboundImages()'
340
+ *
341
+ * @param fileId id for mapFile
342
+ * @param mapFileUtil class to get mapfile
343
+ * @param object FlexPLM object
344
+ * @param context optional context object
345
+ * @returns Promise<boolean>
346
+ */
347
+ static async syncInboundImages(fileId, mapFileUtil, object, context) {
348
+ let syncImages = false;
349
+ if (!fileId) {
350
+ return syncImages;
351
+ }
352
+ let mapKey;
353
+ try {
354
+ mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
355
+ }
356
+ catch {
357
+ return syncImages;
358
+ }
359
+ if (!mapKey) {
360
+ return syncImages;
361
+ }
362
+ const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
363
+ if (mapData && mapData['syncInboundImages']) {
364
+ syncImages = await mapData['syncInboundImages'](object, context);
365
+ }
366
+ return syncImages;
367
+ }
368
+ /** Takes in a VibeIQ entity object and determines whether outbound
369
+ * images should be synced. In most cases, the creation owning system
370
+ * will also control image syncing. Defaults to true if no mapping exists.
371
+ * Map file entry in '<mapKey>:syncOutboundImages()'
372
+ *
373
+ * @param fileId id for mapFile
374
+ * @param mapFileUtil class to get mapfile
375
+ * @param entity VibeIQ entity
376
+ * @param context optional context object
377
+ * @returns Promise<boolean>
378
+ */
379
+ static async syncOutboundImages(fileId, mapFileUtil, entity, context) {
380
+ let syncImages = true;
381
+ if (!fileId) {
382
+ return syncImages;
383
+ }
384
+ let mapKey;
385
+ try {
386
+ mapKey = await this.getMapKey(fileId, mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
387
+ }
388
+ catch {
389
+ return syncImages;
390
+ }
391
+ if (!mapKey) {
392
+ return syncImages;
393
+ }
394
+ const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
395
+ if (mapData && mapData['syncOutboundImages']) {
396
+ syncImages = await mapData['syncOutboundImages'](entity, context);
397
+ }
398
+ return syncImages;
399
+ }
400
+ static getObjectType(object) {
401
+ let objectType = object['flexPLMObjectClass'];
402
+ return objectType;
403
+ }
404
+ }
405
+ exports.TypeConversionUtils = TypeConversionUtils;
406
+ TypeConversionUtils.NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';
407
+ TypeConversionUtils.VIBE2FLEX_DIRECTION = 'vibe2flex';
408
+ TypeConversionUtils.FLEX2VIBE_DIRECTION = 'flex2vibe';