@contrail/flexplm 1.3.0-alpha.0 → 1.3.0-alpha.3
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/.github/pull_request_template.md +31 -31
- package/.github/workflows/flexplm-lib.yml +27 -27
- package/CHANGELOG.md +1 -1
- package/lib/entity-processor/base-entity-processor.d.ts +42 -0
- package/lib/entity-processor/base-entity-processor.js +377 -0
- package/lib/entity-processor/base-entity-processor.spec.d.ts +1 -0
- package/lib/entity-processor/base-entity-processor.spec.js +426 -0
- package/lib/flexplm-request.d.ts +3 -0
- package/lib/flexplm-request.js +34 -0
- package/lib/flexplm-utils.d.ts +5 -0
- package/lib/flexplm-utils.js +33 -0
- package/lib/flexplm-utils.spec.d.ts +1 -0
- package/lib/flexplm-utils.spec.js +26 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.js +38 -0
- package/lib/interfaces/interfaces.d.ts +105 -0
- package/lib/interfaces/interfaces.js +2 -0
- package/lib/interfaces/item-family-changes.d.ts +20 -0
- package/lib/interfaces/item-family-changes.js +56 -0
- package/lib/interfaces/publish-change-data.d.ts +19 -0
- package/lib/interfaces/publish-change-data.js +32 -0
- package/lib/publish/base-process-publish-assortment-callback.d.ts +9 -0
- package/lib/publish/base-process-publish-assortment-callback.js +38 -0
- package/lib/publish/base-process-publish-assortment.d.ts +93 -0
- package/lib/publish/base-process-publish-assortment.js +944 -0
- package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -0
- package/lib/publish/base-process-publish-assortment.spec.js +1670 -0
- package/lib/publish/mockData.d.ts +1389 -0
- package/lib/publish/mockData.js +4519 -0
- package/lib/transform/identifier-conversion-spec-mockData.d.ts +0 -0
- package/lib/transform/identifier-conversion-spec-mockData.js +444 -0
- package/lib/transform/identifier-conversion.d.ts +15 -0
- package/lib/transform/identifier-conversion.js +212 -0
- package/lib/transform/identifier-conversion.spec.d.ts +1 -0
- package/lib/transform/identifier-conversion.spec.js +339 -0
- package/lib/util/config-defaults.d.ts +8 -0
- package/lib/util/config-defaults.js +85 -0
- package/lib/util/config-defaults.spec.d.ts +1 -0
- package/lib/util/config-defaults.spec.js +293 -0
- package/lib/util/data-converter-spec-mockData.d.ts +0 -0
- package/lib/util/data-converter-spec-mockData.js +205 -0
- package/lib/util/data-converter.d.ts +39 -0
- package/lib/util/data-converter.js +592 -0
- package/lib/util/data-converter.spec.d.ts +1 -0
- package/lib/util/data-converter.spec.js +904 -0
- package/lib/util/error-response-object.d.ts +4 -0
- package/lib/util/error-response-object.js +47 -0
- package/lib/util/error-response-object.spec.d.ts +1 -0
- package/lib/util/error-response-object.spec.js +99 -0
- package/lib/util/event-short-message-status.d.ts +18 -0
- package/lib/util/event-short-message-status.js +22 -0
- package/lib/util/federation.d.ts +15 -0
- package/lib/util/federation.js +149 -0
- package/lib/util/flexplm-connect.d.ts +22 -0
- package/lib/util/flexplm-connect.js +176 -0
- package/lib/util/flexplm-connect.spec.d.ts +1 -0
- package/lib/util/flexplm-connect.spec.js +88 -0
- package/lib/util/logger-config.d.ts +1 -0
- package/lib/util/logger-config.js +26 -0
- package/lib/util/map-util-spec-mockData.d.ts +0 -0
- package/lib/util/map-util-spec-mockData.js +205 -0
- package/lib/util/map-utils.d.ts +6 -0
- package/lib/util/map-utils.js +15 -0
- package/lib/util/map-utils.spec.d.ts +1 -0
- package/lib/util/map-utils.spec.js +89 -0
- package/lib/util/mockData.d.ts +79 -0
- package/lib/util/mockData.js +99 -0
- package/lib/util/thumbnail-util.d.ts +28 -0
- package/lib/util/thumbnail-util.js +202 -0
- package/lib/util/thumbnail-util.spec.d.ts +1 -0
- package/lib/util/thumbnail-util.spec.js +398 -0
- package/lib/util/type-conversion-utils-spec-mockData.d.ts +0 -0
- package/lib/util/type-conversion-utils-spec-mockData.js +259 -0
- package/lib/util/type-conversion-utils.d.ts +23 -0
- package/lib/util/type-conversion-utils.js +266 -0
- package/lib/util/type-conversion-utils.spec.d.ts +1 -0
- package/lib/util/type-conversion-utils.spec.js +868 -0
- package/lib/util/type-defaults.d.ts +16 -0
- package/lib/util/type-defaults.js +221 -0
- package/lib/util/type-defaults.spec.d.ts +1 -0
- package/lib/util/type-defaults.spec.js +516 -0
- package/lib/util/type-utils.d.ts +13 -0
- package/lib/util/type-utils.js +114 -0
- package/lib/util/type-utils.spec.d.ts +1 -0
- package/lib/util/type-utils.spec.js +190 -0
- package/package.json +1 -1
- package/publish.bat +4 -4
- package/publish.sh +4 -4
- package/src/entity-processor/base-entity-processor.spec.ts +157 -0
- package/src/entity-processor/base-entity-processor.ts +21 -2
- package/src/flexplm-request.ts +28 -28
- package/src/flexplm-utils.spec.ts +27 -27
- package/src/flexplm-utils.ts +29 -29
- package/src/index.ts +21 -21
- package/src/interfaces/item-family-changes.ts +66 -66
- package/src/interfaces/publish-change-data.ts +42 -42
- package/src/publish/base-process-publish-assortment-callback.ts +50 -50
- package/src/transform/identifier-conversion-spec-mockData.ts +495 -495
- package/src/transform/identifier-conversion.spec.ts +353 -353
- package/src/transform/identifier-conversion.ts +281 -281
- package/src/util/config-defaults.spec.ts +350 -350
- package/src/util/config-defaults.ts +92 -92
- package/src/util/data-converter-spec-mockData.ts +230 -230
- package/src/util/error-response-object.spec.ts +115 -115
- package/src/util/error-response-object.ts +49 -49
- package/src/util/federation.ts +172 -172
- package/src/util/logger-config.ts +19 -19
- package/src/util/map-util-spec-mockData.ts +230 -230
- package/src/util/map-utils.spec.ts +102 -102
- package/src/util/map-utils.ts +40 -40
- package/src/util/mockData.ts +97 -97
- package/src/util/thumbnail-util.spec.ts +190 -0
- package/src/util/thumbnail-util.ts +109 -1
- package/src/util/type-conversion-utils.spec.ts +25 -25
- package/src/util/type-conversion-utils.ts +10 -9
- package/src/util/type-defaults.spec.ts +668 -668
- package/src/util/type-defaults.ts +280 -280
- package/src/util/type-utils.spec.ts +227 -227
- package/src/util/type-utils.ts +144 -144
- package/tsconfig.json +28 -26
- package/tslint.json +57 -57
- package/scripts/output.png +0 -0
- package/scripts/test-get-request.ts +0 -35
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const type_defaults_1 = require("./type-defaults");
|
|
4
|
+
describe('Type Defaults', () => {
|
|
5
|
+
describe('getDefaultObjectClass', () => {
|
|
6
|
+
it('LCSProduct', () => {
|
|
7
|
+
const newData = {
|
|
8
|
+
entityType: 'item',
|
|
9
|
+
roles: ['family']
|
|
10
|
+
};
|
|
11
|
+
const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
|
|
12
|
+
expect(objectClass).toEqual('LCSProduct');
|
|
13
|
+
});
|
|
14
|
+
it('LCSSKU', () => {
|
|
15
|
+
const newData = {
|
|
16
|
+
entityType: 'item',
|
|
17
|
+
roles: ['color']
|
|
18
|
+
};
|
|
19
|
+
const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
|
|
20
|
+
expect(objectClass).toEqual('LCSSKU');
|
|
21
|
+
});
|
|
22
|
+
it('LCSProductSeasonLink', () => {
|
|
23
|
+
const newData = {
|
|
24
|
+
entityType: 'project-item',
|
|
25
|
+
roles: ['family']
|
|
26
|
+
};
|
|
27
|
+
const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
|
|
28
|
+
expect(objectClass).toEqual('LCSProductSeasonLink');
|
|
29
|
+
});
|
|
30
|
+
it('LCSSKUSeasonLink', () => {
|
|
31
|
+
const newData = {
|
|
32
|
+
entityType: 'project-item',
|
|
33
|
+
roles: ['color']
|
|
34
|
+
};
|
|
35
|
+
const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
|
|
36
|
+
expect(objectClass).toEqual('LCSSKUSeasonLink');
|
|
37
|
+
});
|
|
38
|
+
it('LCSColor', () => {
|
|
39
|
+
const newData = {
|
|
40
|
+
entityType: 'color'
|
|
41
|
+
};
|
|
42
|
+
const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
|
|
43
|
+
expect(objectClass).toEqual('LCSColor');
|
|
44
|
+
});
|
|
45
|
+
it('LCSRevisableEntity', () => {
|
|
46
|
+
const newData = {
|
|
47
|
+
entityType: 'custom-entity'
|
|
48
|
+
};
|
|
49
|
+
const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
|
|
50
|
+
expect(objectClass).toEqual('LCSRevisableEntity');
|
|
51
|
+
});
|
|
52
|
+
it('LCSSeason - project', () => {
|
|
53
|
+
const newData = {
|
|
54
|
+
entityType: 'project'
|
|
55
|
+
};
|
|
56
|
+
const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
|
|
57
|
+
expect(objectClass).toEqual('LCSSeason');
|
|
58
|
+
});
|
|
59
|
+
it('Season Group', () => {
|
|
60
|
+
const newData = {
|
|
61
|
+
entityType: 'assortment'
|
|
62
|
+
};
|
|
63
|
+
const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
|
|
64
|
+
expect(objectClass).toEqual('SeasonGroup');
|
|
65
|
+
});
|
|
66
|
+
it('LCSSeason - assortment - publishToFlexPLM=true', () => {
|
|
67
|
+
const newData = {
|
|
68
|
+
entityType: 'assortment',
|
|
69
|
+
publishToFlexPLM: true
|
|
70
|
+
};
|
|
71
|
+
const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
|
|
72
|
+
expect(objectClass).toEqual('LCSSeason');
|
|
73
|
+
});
|
|
74
|
+
it('LCSSeason - assortment - publishToFlexPLM=true', () => {
|
|
75
|
+
const newData = {
|
|
76
|
+
entityType: 'assortment',
|
|
77
|
+
flex2vibeMapKeyRoot: 'LCSSeason'
|
|
78
|
+
};
|
|
79
|
+
const objectClass = type_defaults_1.TypeDefaults.getDefaultObjectClass(newData);
|
|
80
|
+
expect(objectClass).toEqual('LCSSeason');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
describe('getDefaultObjectTypePath', () => {
|
|
84
|
+
it('item-family', () => {
|
|
85
|
+
const newData = {
|
|
86
|
+
entityType: 'item',
|
|
87
|
+
roles: ['family']
|
|
88
|
+
};
|
|
89
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
|
|
90
|
+
expect(typePath).toEqual('Product');
|
|
91
|
+
});
|
|
92
|
+
it('item-color', () => {
|
|
93
|
+
const newData = {
|
|
94
|
+
entityType: 'item',
|
|
95
|
+
roles: ['color']
|
|
96
|
+
};
|
|
97
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
|
|
98
|
+
expect(typePath).toEqual('Product');
|
|
99
|
+
});
|
|
100
|
+
it('project-item-family', () => {
|
|
101
|
+
const newData = {
|
|
102
|
+
entityType: 'project-item',
|
|
103
|
+
roles: ['family']
|
|
104
|
+
};
|
|
105
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
|
|
106
|
+
expect(typePath).toEqual('Product');
|
|
107
|
+
});
|
|
108
|
+
it('project-item-color', () => {
|
|
109
|
+
const newData = {
|
|
110
|
+
entityType: 'project-item',
|
|
111
|
+
roles: ['color']
|
|
112
|
+
};
|
|
113
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
|
|
114
|
+
expect(typePath).toEqual('Product');
|
|
115
|
+
});
|
|
116
|
+
it('color', () => {
|
|
117
|
+
const newData = {
|
|
118
|
+
entityType: 'color'
|
|
119
|
+
};
|
|
120
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
|
|
121
|
+
expect(typePath).toEqual('Color');
|
|
122
|
+
});
|
|
123
|
+
it('custom-entity', () => {
|
|
124
|
+
const newData = {
|
|
125
|
+
entityType: 'custom-entity'
|
|
126
|
+
};
|
|
127
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
|
|
128
|
+
expect(typePath).toEqual('Revisable Entity');
|
|
129
|
+
});
|
|
130
|
+
it('project', () => {
|
|
131
|
+
const newData = {
|
|
132
|
+
entityType: 'project'
|
|
133
|
+
};
|
|
134
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
|
|
135
|
+
expect(typePath).toEqual('Season');
|
|
136
|
+
});
|
|
137
|
+
it('assortment', () => {
|
|
138
|
+
const newData = {
|
|
139
|
+
entityType: 'assortment'
|
|
140
|
+
};
|
|
141
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
|
|
142
|
+
expect(typePath).toEqual('Season Group');
|
|
143
|
+
});
|
|
144
|
+
it('assortment - publishToFlexPLM=true', () => {
|
|
145
|
+
const newData = {
|
|
146
|
+
entityType: 'assortment',
|
|
147
|
+
publishToFlexPLM: true
|
|
148
|
+
};
|
|
149
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
|
|
150
|
+
expect(typePath).toEqual('Season');
|
|
151
|
+
});
|
|
152
|
+
it('assortment - flex2vibeMapKeyRoot=LCSSeason', () => {
|
|
153
|
+
const newData = {
|
|
154
|
+
entityType: 'assortment',
|
|
155
|
+
flex2vibeMapKeyRoot: 'LCSSeason'
|
|
156
|
+
};
|
|
157
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultObjectTypePath(newData);
|
|
158
|
+
expect(typePath).toEqual('Season');
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
describe('getDefaultIdentifiers', () => {
|
|
162
|
+
it('item-family', () => {
|
|
163
|
+
const newData = {
|
|
164
|
+
entityType: 'item',
|
|
165
|
+
roles: ['family']
|
|
166
|
+
};
|
|
167
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(newData);
|
|
168
|
+
expect(defaultIdentifiers).toContain('itemNumber');
|
|
169
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
170
|
+
});
|
|
171
|
+
it('item-color', () => {
|
|
172
|
+
const newData = {
|
|
173
|
+
entityType: 'item',
|
|
174
|
+
roles: ['color']
|
|
175
|
+
};
|
|
176
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(newData);
|
|
177
|
+
expect(defaultIdentifiers).toContain('itemNumber');
|
|
178
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
179
|
+
});
|
|
180
|
+
it('project', () => {
|
|
181
|
+
const newData = {
|
|
182
|
+
entityType: 'project'
|
|
183
|
+
};
|
|
184
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(newData);
|
|
185
|
+
expect(defaultIdentifiers).toContain('flexPLMSeasonName');
|
|
186
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
187
|
+
});
|
|
188
|
+
it('assortment', () => {
|
|
189
|
+
const newData = {
|
|
190
|
+
entityType: 'assortment'
|
|
191
|
+
};
|
|
192
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(newData);
|
|
193
|
+
expect(defaultIdentifiers).toContain('seasonGroupName');
|
|
194
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
195
|
+
});
|
|
196
|
+
it('assortment - publishToFlexPLM=true', () => {
|
|
197
|
+
const newData = {
|
|
198
|
+
entityType: 'assortment',
|
|
199
|
+
publishToFlexPLM: true
|
|
200
|
+
};
|
|
201
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(newData);
|
|
202
|
+
expect(defaultIdentifiers).toContain('flexPLMSeasonName');
|
|
203
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
204
|
+
});
|
|
205
|
+
it('assortment - flex2vibeMapKeyRoot=LCSSeason', () => {
|
|
206
|
+
const newData = {
|
|
207
|
+
entityType: 'assortment',
|
|
208
|
+
flex2vibeMapKeyRoot: 'LCSSeason'
|
|
209
|
+
};
|
|
210
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(newData);
|
|
211
|
+
expect(defaultIdentifiers).toContain('flexPLMSeasonName');
|
|
212
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
213
|
+
});
|
|
214
|
+
it('color', () => {
|
|
215
|
+
const newData = {
|
|
216
|
+
entityType: 'color'
|
|
217
|
+
};
|
|
218
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(newData);
|
|
219
|
+
expect(defaultIdentifiers).toContain('name');
|
|
220
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
221
|
+
});
|
|
222
|
+
it('custom-entity', () => {
|
|
223
|
+
const newData = {
|
|
224
|
+
entityType: 'custom-entity'
|
|
225
|
+
};
|
|
226
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierProperties(newData);
|
|
227
|
+
expect(defaultIdentifiers).toContain('name');
|
|
228
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
describe('getDefaultInformationalProperties', () => {
|
|
232
|
+
it('item-family', () => {
|
|
233
|
+
const newData = {
|
|
234
|
+
entityType: 'item',
|
|
235
|
+
roles: ['family']
|
|
236
|
+
};
|
|
237
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalProperties(newData);
|
|
238
|
+
expect(defaultIdentifiers).toContain('name');
|
|
239
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
240
|
+
});
|
|
241
|
+
it('item-color', () => {
|
|
242
|
+
const newData = {
|
|
243
|
+
entityType: 'item',
|
|
244
|
+
roles: ['color']
|
|
245
|
+
};
|
|
246
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalProperties(newData);
|
|
247
|
+
expect(defaultIdentifiers).toContain('optionName');
|
|
248
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
249
|
+
});
|
|
250
|
+
it('project', () => {
|
|
251
|
+
const newData = {
|
|
252
|
+
entityType: 'project'
|
|
253
|
+
};
|
|
254
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalProperties(newData);
|
|
255
|
+
expect(defaultIdentifiers).toContain('name');
|
|
256
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
257
|
+
});
|
|
258
|
+
it('assortment', () => {
|
|
259
|
+
const newData = {
|
|
260
|
+
entityType: 'assortment'
|
|
261
|
+
};
|
|
262
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalProperties(newData);
|
|
263
|
+
expect(defaultIdentifiers).toContain('name');
|
|
264
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
265
|
+
});
|
|
266
|
+
it('color', () => {
|
|
267
|
+
const newData = {
|
|
268
|
+
entityType: 'color'
|
|
269
|
+
};
|
|
270
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalProperties(newData);
|
|
271
|
+
expect(defaultIdentifiers).toHaveLength(0);
|
|
272
|
+
});
|
|
273
|
+
it('custom-entity', () => {
|
|
274
|
+
const newData = {
|
|
275
|
+
entityType: 'custom-entity'
|
|
276
|
+
};
|
|
277
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalProperties(newData);
|
|
278
|
+
expect(defaultIdentifiers).toHaveLength(0);
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
describe('getEntityType', () => {
|
|
282
|
+
it('entityType', () => {
|
|
283
|
+
const entityType = 'item';
|
|
284
|
+
const entity = {
|
|
285
|
+
entityType
|
|
286
|
+
};
|
|
287
|
+
const results = type_defaults_1.TypeDefaults.getEntityType(entity);
|
|
288
|
+
expect(results).toEqual(entityType);
|
|
289
|
+
});
|
|
290
|
+
it('entityType from type path', () => {
|
|
291
|
+
const entityType = 'item';
|
|
292
|
+
const typePath = 'item:product:apparel';
|
|
293
|
+
const entity = {
|
|
294
|
+
typePath: typePath
|
|
295
|
+
};
|
|
296
|
+
const results = type_defaults_1.TypeDefaults.getEntityType(entity);
|
|
297
|
+
expect(results).toEqual(entityType);
|
|
298
|
+
});
|
|
299
|
+
it('No entityType', () => {
|
|
300
|
+
const typePath = 'item:product:apparel';
|
|
301
|
+
const entity = {
|
|
302
|
+
someValue: typePath
|
|
303
|
+
};
|
|
304
|
+
expect(() => type_defaults_1.TypeDefaults.getEntityType(entity)).toThrowError();
|
|
305
|
+
expect(() => type_defaults_1.TypeDefaults.getEntityType(entity)).toThrow(type_defaults_1.TypeDefaults.NO_ENTITY_TYPE);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
describe('getDefaultEntityClass', () => {
|
|
309
|
+
it('item - LCSProduct', () => {
|
|
310
|
+
const object = {
|
|
311
|
+
flexPLMObjectClass: 'LCSProduct'
|
|
312
|
+
};
|
|
313
|
+
const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
314
|
+
expect(entityClass).toBe('item');
|
|
315
|
+
});
|
|
316
|
+
it('item - LCSSKU', () => {
|
|
317
|
+
const object = {
|
|
318
|
+
flexPLMObjectClass: 'LCSSKU'
|
|
319
|
+
};
|
|
320
|
+
const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
321
|
+
expect(entityClass).toBe('item');
|
|
322
|
+
});
|
|
323
|
+
it('project-item - LCSProductSeasonLink', () => {
|
|
324
|
+
const object = {
|
|
325
|
+
flexPLMObjectClass: 'LCSProductSeasonLink'
|
|
326
|
+
};
|
|
327
|
+
const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
328
|
+
expect(entityClass).toBe('project-item');
|
|
329
|
+
});
|
|
330
|
+
it('project-item - LCSSKUSeasonLink', () => {
|
|
331
|
+
const object = {
|
|
332
|
+
flexPLMObjectClass: 'LCSSKUSeasonLink'
|
|
333
|
+
};
|
|
334
|
+
const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
335
|
+
expect(entityClass).toBe('project-item');
|
|
336
|
+
});
|
|
337
|
+
it('color - LCSColor', () => {
|
|
338
|
+
const object = {
|
|
339
|
+
flexPLMObjectClass: 'LCSColor'
|
|
340
|
+
};
|
|
341
|
+
const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
342
|
+
expect(entityClass).toBe('color');
|
|
343
|
+
});
|
|
344
|
+
it('assortment - LCSSeason', () => {
|
|
345
|
+
const object = {
|
|
346
|
+
flexPLMObjectClass: 'LCSSeason'
|
|
347
|
+
};
|
|
348
|
+
const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
349
|
+
expect(entityClass).toBe('assortment');
|
|
350
|
+
});
|
|
351
|
+
it('assortment - SeasonGroup', () => {
|
|
352
|
+
const object = {
|
|
353
|
+
flexPLMObjectClass: 'SeasonGroup'
|
|
354
|
+
};
|
|
355
|
+
const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
356
|
+
expect(entityClass).toBe('assortment');
|
|
357
|
+
});
|
|
358
|
+
it('custom-entity - LCSRevisableEntity', () => {
|
|
359
|
+
const object = {
|
|
360
|
+
flexPLMObjectClass: 'LCSRevisableEntity'
|
|
361
|
+
};
|
|
362
|
+
const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
363
|
+
expect(entityClass).toBe('custom-entity');
|
|
364
|
+
});
|
|
365
|
+
it('custom-entity - LCSLifecycleManaged', () => {
|
|
366
|
+
const object = {
|
|
367
|
+
flexPLMObjectClass: 'LCSLifecycleManaged'
|
|
368
|
+
};
|
|
369
|
+
const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
370
|
+
expect(entityClass).toBe('custom-entity');
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
describe('getDefaultEntityTypePath', () => {
|
|
374
|
+
it('LCSProduct', () => {
|
|
375
|
+
const object = {
|
|
376
|
+
flexPLMObjectClass: 'LCSProduct'
|
|
377
|
+
};
|
|
378
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
|
|
379
|
+
expect(typePath).toBe('item');
|
|
380
|
+
});
|
|
381
|
+
it('LCSSKU', () => {
|
|
382
|
+
const object = {
|
|
383
|
+
flexPLMObjectClass: 'LCSSKU'
|
|
384
|
+
};
|
|
385
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
|
|
386
|
+
expect(typePath).toBe('item');
|
|
387
|
+
});
|
|
388
|
+
it('LCSProductSeasonLink', () => {
|
|
389
|
+
const object = {
|
|
390
|
+
flexPLMObjectClass: 'LCSProductSeasonLink'
|
|
391
|
+
};
|
|
392
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
|
|
393
|
+
expect(typePath).toBe('project-item');
|
|
394
|
+
});
|
|
395
|
+
it('LCSSKUSeasonLink', () => {
|
|
396
|
+
const object = {
|
|
397
|
+
flexPLMObjectClass: 'LCSSKUSeasonLink'
|
|
398
|
+
};
|
|
399
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
|
|
400
|
+
expect(typePath).toBe('project-item');
|
|
401
|
+
});
|
|
402
|
+
it('LCSColor', () => {
|
|
403
|
+
const object = {
|
|
404
|
+
flexPLMObjectClass: 'LCSColor'
|
|
405
|
+
};
|
|
406
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
|
|
407
|
+
expect(typePath).toBe('color');
|
|
408
|
+
});
|
|
409
|
+
it('LCSSeason', () => {
|
|
410
|
+
const object = {
|
|
411
|
+
flexPLMObjectClass: 'LCSSeason'
|
|
412
|
+
};
|
|
413
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
|
|
414
|
+
expect(typePath).toBe('assortment');
|
|
415
|
+
});
|
|
416
|
+
it('SeasonGroup', () => {
|
|
417
|
+
const object = {
|
|
418
|
+
flexPLMObjectClass: 'SeasonGroup'
|
|
419
|
+
};
|
|
420
|
+
const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
|
|
421
|
+
expect(typePath).toBe('assortment');
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
describe('getDefaultIdentifierPropertiesFromObject', () => {
|
|
425
|
+
it('LCSProduct', () => {
|
|
426
|
+
const object = {
|
|
427
|
+
flexPLMObjectClass: 'LCSProduct'
|
|
428
|
+
};
|
|
429
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
|
|
430
|
+
expect(defaultIdentifiers).toContain('itemNumber');
|
|
431
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
432
|
+
});
|
|
433
|
+
it('LCSSKU', () => {
|
|
434
|
+
const object = {
|
|
435
|
+
flexPLMObjectClass: 'LCSSKU'
|
|
436
|
+
};
|
|
437
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
|
|
438
|
+
expect(defaultIdentifiers).toContain('itemNumber');
|
|
439
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
440
|
+
});
|
|
441
|
+
it('LCSSeason', () => {
|
|
442
|
+
const object = {
|
|
443
|
+
flexPLMObjectClass: 'LCSSeason'
|
|
444
|
+
};
|
|
445
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
|
|
446
|
+
expect(defaultIdentifiers).toContain('flexPLMSeasonName');
|
|
447
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
448
|
+
});
|
|
449
|
+
it('SeasonGroup', () => {
|
|
450
|
+
const object = {
|
|
451
|
+
flexPLMObjectClass: 'SeasonGroup'
|
|
452
|
+
};
|
|
453
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
|
|
454
|
+
expect(defaultIdentifiers).toContain('seasonGroupName');
|
|
455
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
456
|
+
});
|
|
457
|
+
it('LCSColor', () => {
|
|
458
|
+
const object = {
|
|
459
|
+
flexPLMObjectClass: 'LCSColor'
|
|
460
|
+
};
|
|
461
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
|
|
462
|
+
expect(defaultIdentifiers).toContain('name');
|
|
463
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
464
|
+
});
|
|
465
|
+
it('LCSRevisableEntity', () => {
|
|
466
|
+
const object = {
|
|
467
|
+
flexPLMObjectClass: 'LCSRevisableEntity'
|
|
468
|
+
};
|
|
469
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
|
|
470
|
+
expect(defaultIdentifiers).toContain('name');
|
|
471
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
472
|
+
});
|
|
473
|
+
it('LCSLifecycleManaged', () => {
|
|
474
|
+
const object = {
|
|
475
|
+
flexPLMObjectClass: 'LCSLifecycleManaged'
|
|
476
|
+
};
|
|
477
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
|
|
478
|
+
expect(defaultIdentifiers).toContain('name');
|
|
479
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
describe('getDefaultInformationalPropertiesFromObject', () => {
|
|
483
|
+
it('LCSProduct', () => {
|
|
484
|
+
const object = {
|
|
485
|
+
flexPLMObjectClass: 'LCSProduct'
|
|
486
|
+
};
|
|
487
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalPropertiesFromObject(object);
|
|
488
|
+
expect(defaultIdentifiers).toContain('name');
|
|
489
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
490
|
+
});
|
|
491
|
+
it('LCSSKU', () => {
|
|
492
|
+
const object = {
|
|
493
|
+
flexPLMObjectClass: 'LCSSKU'
|
|
494
|
+
};
|
|
495
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalPropertiesFromObject(object);
|
|
496
|
+
expect(defaultIdentifiers).toContain('optionName');
|
|
497
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
498
|
+
});
|
|
499
|
+
it('LCSSeason', () => {
|
|
500
|
+
const object = {
|
|
501
|
+
flexPLMObjectClass: 'LCSSeason'
|
|
502
|
+
};
|
|
503
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalPropertiesFromObject(object);
|
|
504
|
+
expect(defaultIdentifiers).toContain('name');
|
|
505
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
506
|
+
});
|
|
507
|
+
it('SeasonGroup', () => {
|
|
508
|
+
const object = {
|
|
509
|
+
flexPLMObjectClass: 'SeasonGroup'
|
|
510
|
+
};
|
|
511
|
+
const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalPropertiesFromObject(object);
|
|
512
|
+
expect(defaultIdentifiers).toContain('name');
|
|
513
|
+
expect(defaultIdentifiers).toHaveLength(1);
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TypeClientOptions } from '@contrail/sdk';
|
|
2
|
+
import { TypeProperty } from '@contrail/types';
|
|
3
|
+
export declare class TypeUtils {
|
|
4
|
+
private typesObj;
|
|
5
|
+
constructor();
|
|
6
|
+
getTypeById(id: any): Promise<import("@contrail/types").Type>;
|
|
7
|
+
getByRootAndPath(options: TypeClientOptions): Promise<import("@contrail/types").Type>;
|
|
8
|
+
static getFlexPLMTypePath(entity: any): any;
|
|
9
|
+
getEventObjectClass(entityType: string, newData: any): string;
|
|
10
|
+
getEntityTypeClientOptionsUsingMapping(transformMapFile: any, mapFileUtil: any, data: any): Promise<TypeClientOptions>;
|
|
11
|
+
getEntityTypeClientOptions(objectClass: string, data: any): TypeClientOptions;
|
|
12
|
+
filterTypeProperties(type: any, newData: any): TypeProperty[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeUtils = void 0;
|
|
4
|
+
const app_framework_1 = require("@contrail/app-framework");
|
|
5
|
+
const sdk_1 = require("@contrail/sdk");
|
|
6
|
+
const type_conversion_utils_1 = require("./type-conversion-utils");
|
|
7
|
+
class TypeUtils {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.typesObj = new sdk_1.Types();
|
|
10
|
+
}
|
|
11
|
+
async getTypeById(id) {
|
|
12
|
+
const type = await this.typesObj.getType({
|
|
13
|
+
id,
|
|
14
|
+
relations: ['typeProperties', 'typeInterfaces']
|
|
15
|
+
});
|
|
16
|
+
return type;
|
|
17
|
+
}
|
|
18
|
+
async getByRootAndPath(options) {
|
|
19
|
+
const type = await this.typesObj.getByRootAndPath(options);
|
|
20
|
+
return type;
|
|
21
|
+
}
|
|
22
|
+
static getFlexPLMTypePath(entity) {
|
|
23
|
+
return entity['flexPLMTypePath'] || entity['flexTypePath'] || '';
|
|
24
|
+
}
|
|
25
|
+
getEventObjectClass(entityType, newData) {
|
|
26
|
+
let objectClass = '';
|
|
27
|
+
if ('item' === entityType) {
|
|
28
|
+
if (newData.roles.includes('family')) {
|
|
29
|
+
objectClass = 'LCSProduct';
|
|
30
|
+
}
|
|
31
|
+
else if (newData.roles.includes('color')) {
|
|
32
|
+
objectClass = 'LCSSKU';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if ('project-item' === entityType) {
|
|
36
|
+
if (newData.roles.includes('family')) {
|
|
37
|
+
objectClass = 'LCSProductSeasonLink';
|
|
38
|
+
}
|
|
39
|
+
else if (newData.roles.includes('color')) {
|
|
40
|
+
objectClass = 'LCSSKUSeasonLink';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if ('color' === entityType) {
|
|
44
|
+
objectClass = 'LCSColor';
|
|
45
|
+
}
|
|
46
|
+
else if ('custom-entity' === entityType) {
|
|
47
|
+
objectClass = 'LCSRevisableEntity';
|
|
48
|
+
}
|
|
49
|
+
return objectClass;
|
|
50
|
+
}
|
|
51
|
+
async getEntityTypeClientOptionsUsingMapping(transformMapFile, mapFileUtil, data) {
|
|
52
|
+
const root = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(transformMapFile, mapFileUtil, data);
|
|
53
|
+
const path = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(transformMapFile, mapFileUtil, data);
|
|
54
|
+
let tco = {
|
|
55
|
+
root,
|
|
56
|
+
path
|
|
57
|
+
};
|
|
58
|
+
return tco;
|
|
59
|
+
}
|
|
60
|
+
getEntityTypeClientOptions(objectClass, data) {
|
|
61
|
+
let tco;
|
|
62
|
+
if (['LCSProduct', 'LCSSKU'].includes(objectClass)) {
|
|
63
|
+
tco = {
|
|
64
|
+
root: 'item'
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
else if ('LCSSeason' === objectClass) {
|
|
68
|
+
tco = {
|
|
69
|
+
root: 'assortment'
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
else if ('LCSColor' === objectClass) {
|
|
73
|
+
tco = {
|
|
74
|
+
root: 'color'
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
else if (['LCSBusinessObject', 'LCSRevisableEntity', 'LCSLast'].includes(objectClass)) {
|
|
78
|
+
tco = {
|
|
79
|
+
root: 'custom-entity'
|
|
80
|
+
};
|
|
81
|
+
console.log('data: ' + data);
|
|
82
|
+
}
|
|
83
|
+
return tco;
|
|
84
|
+
}
|
|
85
|
+
filterTypeProperties(type, newData) {
|
|
86
|
+
let filteredProps = type['typeProperties'];
|
|
87
|
+
const typePath = type['typePath'];
|
|
88
|
+
const roles = newData['roles'];
|
|
89
|
+
if (typePath && (typePath.startsWith('item') || typePath.startsWith('project-item'))) {
|
|
90
|
+
if (app_framework_1.Logger.isDebugOn()) {
|
|
91
|
+
console.debug('filterTypeProperties():id: ' + newData?.id
|
|
92
|
+
+ ', typePath: ' + typePath
|
|
93
|
+
+ ', newData.roles: ' + newData?.roles);
|
|
94
|
+
}
|
|
95
|
+
if (roles) {
|
|
96
|
+
const isFamily = roles.includes('family');
|
|
97
|
+
if (app_framework_1.Logger.isDebugOn()) {
|
|
98
|
+
console.debug('isFamily: ' + isFamily);
|
|
99
|
+
}
|
|
100
|
+
filteredProps = filteredProps.filter(prop => {
|
|
101
|
+
const propertyLevel = prop.propertyLevel;
|
|
102
|
+
const applies = (isFamily && 'option' != propertyLevel) ||
|
|
103
|
+
(!isFamily && 'family' != propertyLevel);
|
|
104
|
+
return applies;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
console.error('filterTypeProperties():Entity missing role-id: ' + newData['id']);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return filteredProps;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.TypeUtils = TypeUtils;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|