@contrail/flexplm 1.3.0 → 1.3.1-alpha.3e8dbdd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/commands/compile.d.ts +1 -0
- package/lib/cli/commands/compile.js +71 -0
- package/lib/cli/commands/compile.spec.d.ts +1 -0
- package/lib/cli/commands/compile.spec.js +80 -0
- package/lib/cli/commands/create.d.ts +1 -0
- package/lib/cli/commands/create.js +75 -0
- package/lib/cli/commands/create.spec.d.ts +1 -0
- package/lib/cli/commands/create.spec.js +78 -0
- package/lib/cli/commands/upload.d.ts +10 -0
- package/lib/cli/commands/upload.js +226 -0
- package/lib/cli/commands/upload.spec.d.ts +1 -0
- package/lib/cli/commands/upload.spec.js +88 -0
- package/lib/cli/index.d.ts +2 -0
- package/lib/cli/index.js +64 -0
- package/lib/cli/index.spec.d.ts +1 -0
- package/lib/cli/index.spec.js +79 -0
- package/lib/cli/template/mapping-template.ts.template +62 -0
- package/lib/entity-processor/base-entity-processor.d.ts +89 -42
- package/lib/entity-processor/base-entity-processor.js +438 -385
- package/lib/entity-processor/base-entity-processor.spec.d.ts +1 -1
- package/lib/entity-processor/base-entity-processor.spec.js +398 -397
- package/lib/flexplm-request.d.ts +3 -3
- package/lib/flexplm-request.js +34 -34
- package/lib/flexplm-utils.d.ts +5 -5
- package/lib/flexplm-utils.js +33 -33
- package/lib/flexplm-utils.spec.d.ts +1 -1
- package/lib/flexplm-utils.spec.js +26 -26
- package/lib/index.d.ts +23 -22
- package/lib/index.js +39 -38
- package/lib/interfaces/interfaces.d.ts +105 -105
- package/lib/interfaces/interfaces.js +2 -2
- package/lib/interfaces/item-family-changes.d.ts +20 -20
- package/lib/interfaces/item-family-changes.js +56 -56
- package/lib/interfaces/mapping-file.d.ts +460 -0
- package/lib/interfaces/mapping-file.js +2 -0
- package/lib/interfaces/publish-change-data.d.ts +19 -19
- package/lib/interfaces/publish-change-data.js +32 -32
- package/lib/publish/base-process-publish-assortment-callback.d.ts +9 -9
- package/lib/publish/base-process-publish-assortment-callback.js +38 -38
- package/lib/publish/base-process-publish-assortment.d.ts +118 -93
- package/lib/publish/base-process-publish-assortment.js +998 -944
- package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -1
- package/lib/publish/base-process-publish-assortment.spec.js +1688 -1670
- package/lib/publish/mockData.d.ts +1389 -1389
- package/lib/publish/mockData.js +4524 -4519
- package/lib/transform/identifier-conversion-spec-mockData.js +472 -444
- package/lib/transform/identifier-conversion.d.ts +51 -15
- package/lib/transform/identifier-conversion.js +248 -212
- package/lib/transform/identifier-conversion.spec.d.ts +1 -1
- package/lib/transform/identifier-conversion.spec.js +343 -339
- package/lib/util/config-defaults.d.ts +8 -8
- package/lib/util/config-defaults.js +88 -85
- package/lib/util/config-defaults.spec.d.ts +1 -1
- package/lib/util/config-defaults.spec.js +302 -293
- package/lib/util/data-converter-spec-mockData.js +219 -205
- package/lib/util/data-converter.d.ts +136 -39
- package/lib/util/data-converter.js +718 -592
- package/lib/util/data-converter.spec.d.ts +1 -1
- package/lib/util/data-converter.spec.js +906 -904
- package/lib/util/error-response-object.d.ts +9 -4
- package/lib/util/error-response-object.js +54 -47
- package/lib/util/error-response-object.spec.d.ts +1 -1
- package/lib/util/error-response-object.spec.js +99 -99
- package/lib/util/event-short-message-status.d.ts +19 -19
- package/lib/util/event-short-message-status.js +24 -23
- package/lib/util/federation.d.ts +15 -15
- package/lib/util/federation.js +157 -149
- package/lib/util/flexplm-connect.d.ts +29 -22
- package/lib/util/flexplm-connect.js +190 -176
- package/lib/util/flexplm-connect.spec.d.ts +1 -1
- package/lib/util/flexplm-connect.spec.js +88 -88
- package/lib/util/logger-config.d.ts +1 -1
- package/lib/util/logger-config.js +27 -26
- package/lib/util/map-util-spec-mockData.js +219 -205
- package/lib/util/map-utils.d.ts +33 -6
- package/lib/util/map-utils.js +42 -15
- package/lib/util/map-utils.spec.d.ts +1 -1
- package/lib/util/map-utils.spec.js +89 -89
- package/lib/util/mockData.d.ts +80 -80
- package/lib/util/mockData.js +103 -103
- package/lib/util/thumbnail-util.d.ts +55 -34
- package/lib/util/thumbnail-util.js +242 -215
- package/lib/util/thumbnail-util.spec.d.ts +1 -1
- package/lib/util/thumbnail-util.spec.js +440 -434
- package/lib/util/type-conversion-utils-spec-mockData.js +259 -259
- package/lib/util/type-conversion-utils.d.ts +163 -23
- package/lib/util/type-conversion-utils.js +408 -265
- package/lib/util/type-conversion-utils.spec.d.ts +1 -1
- package/lib/util/type-conversion-utils.spec.js +868 -868
- package/lib/util/type-defaults.d.ts +74 -16
- package/lib/util/type-defaults.js +279 -221
- package/lib/util/type-defaults.spec.d.ts +1 -1
- package/lib/util/type-defaults.spec.js +516 -516
- package/lib/util/type-utils.d.ts +34 -13
- package/lib/util/type-utils.js +137 -114
- package/lib/util/type-utils.spec.d.ts +1 -1
- package/lib/util/type-utils.spec.js +192 -190
- package/package.json +21 -6
- package/scripts/copy-template.js +10 -0
- package/.claude/settings.local.json +0 -8
- package/.github/pull_request_template.md +0 -31
- package/.github/workflows/flexplm-lib.yml +0 -27
- package/.github/workflows/publish-to-npm.yml +0 -124
- package/CHANGELOG.md +0 -32
- package/publish.bat +0 -5
- package/publish.sh +0 -5
- package/src/entity-processor/base-entity-processor.spec.ts +0 -460
- package/src/entity-processor/base-entity-processor.ts +0 -515
- package/src/flexplm-request.ts +0 -28
- package/src/flexplm-utils.spec.ts +0 -27
- package/src/flexplm-utils.ts +0 -29
- package/src/index.ts +0 -22
- package/src/interfaces/interfaces.ts +0 -122
- package/src/interfaces/item-family-changes.ts +0 -67
- package/src/interfaces/publish-change-data.ts +0 -43
- package/src/publish/base-process-publish-assortment-callback.ts +0 -50
- package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
- package/src/publish/base-process-publish-assortment.ts +0 -1134
- package/src/publish/mockData.ts +0 -4561
- package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
- package/src/transform/identifier-conversion.spec.ts +0 -354
- package/src/transform/identifier-conversion.ts +0 -282
- package/src/util/config-defaults.spec.ts +0 -350
- package/src/util/config-defaults.ts +0 -93
- package/src/util/data-converter-spec-mockData.ts +0 -231
- package/src/util/data-converter.spec.ts +0 -1041
- package/src/util/data-converter.ts +0 -762
- package/src/util/error-response-object.spec.ts +0 -116
- package/src/util/error-response-object.ts +0 -50
- package/src/util/event-short-message-status.ts +0 -22
- package/src/util/federation.ts +0 -172
- package/src/util/flexplm-connect.spec.ts +0 -132
- package/src/util/flexplm-connect.ts +0 -208
- package/src/util/logger-config.ts +0 -20
- package/src/util/map-util-spec-mockData.ts +0 -231
- package/src/util/map-utils.spec.ts +0 -103
- package/src/util/map-utils.ts +0 -41
- package/src/util/mockData.ts +0 -101
- package/src/util/thumbnail-util.spec.ts +0 -508
- package/src/util/thumbnail-util.ts +0 -272
- package/src/util/type-conversion-utils-spec-mockData.ts +0 -271
- package/src/util/type-conversion-utils.spec.ts +0 -968
- package/src/util/type-conversion-utils.ts +0 -460
- package/src/util/type-defaults.spec.ts +0 -669
- package/src/util/type-defaults.ts +0 -281
- package/src/util/type-utils.spec.ts +0 -227
- package/src/util/type-utils.ts +0 -144
- package/tsconfig.json +0 -29
- package/tslint.json +0 -57
|
@@ -1,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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (
|
|
249
|
-
return
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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';
|