@contrail/flexplm 1.5.0-alpha.6fc44c4 → 1.5.0-alpha.98b8b06

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 (111) hide show
  1. package/lib/cli/commands/compile.d.ts +4 -0
  2. package/lib/cli/commands/compile.js +73 -0
  3. package/lib/cli/commands/compile.spec.d.ts +1 -0
  4. package/lib/cli/commands/compile.spec.js +80 -0
  5. package/lib/cli/commands/create.d.ts +5 -0
  6. package/lib/cli/commands/create.js +77 -0
  7. package/lib/cli/commands/create.spec.d.ts +1 -0
  8. package/lib/cli/commands/create.spec.js +78 -0
  9. package/lib/cli/commands/upload.d.ts +17 -0
  10. package/lib/cli/commands/upload.js +228 -0
  11. package/lib/cli/commands/upload.spec.d.ts +1 -0
  12. package/lib/cli/commands/upload.spec.js +88 -0
  13. package/lib/cli/index.d.ts +5 -0
  14. package/lib/cli/index.js +70 -0
  15. package/lib/cli/index.spec.d.ts +1 -0
  16. package/lib/cli/index.spec.js +85 -0
  17. package/lib/cli/template/mapping-template.ts.template +62 -0
  18. package/lib/entity-processor/base-entity-processor.d.ts +65 -0
  19. package/lib/entity-processor/base-entity-processor.js +71 -0
  20. package/lib/entity-processor/base-entity-processor.spec.js +1 -0
  21. package/lib/index.d.ts +1 -0
  22. package/lib/index.js +1 -0
  23. package/lib/interfaces/mapping-file.d.ts +460 -0
  24. package/lib/interfaces/mapping-file.js +2 -0
  25. package/lib/publish/base-process-publish-assortment.d.ts +25 -0
  26. package/lib/publish/base-process-publish-assortment.js +60 -6
  27. package/lib/publish/base-process-publish-assortment.spec.js +22 -4
  28. package/lib/publish/mockData.js +5 -0
  29. package/lib/transform/identifier-conversion-spec-mockData.js +34 -6
  30. package/lib/transform/identifier-conversion.d.ts +36 -0
  31. package/lib/transform/identifier-conversion.js +36 -0
  32. package/lib/transform/identifier-conversion.spec.js +7 -0
  33. package/lib/util/config-defaults.js +5 -0
  34. package/lib/util/config-defaults.spec.js +23 -0
  35. package/lib/util/data-converter-spec-mockData.js +17 -3
  36. package/lib/util/data-converter.d.ts +102 -0
  37. package/lib/util/data-converter.js +194 -33
  38. package/lib/util/data-converter.spec.js +389 -0
  39. package/lib/util/error-response-object.d.ts +5 -0
  40. package/lib/util/error-response-object.js +7 -0
  41. package/lib/util/event-short-message-status.js +1 -0
  42. package/lib/util/federation.js +8 -0
  43. package/lib/util/flexplm-connect.d.ts +7 -0
  44. package/lib/util/flexplm-connect.js +14 -0
  45. package/lib/util/logger-config.js +1 -0
  46. package/lib/util/map-util-spec-mockData.js +17 -3
  47. package/lib/util/map-utils.d.ts +27 -0
  48. package/lib/util/map-utils.js +27 -0
  49. package/lib/util/thumbnail-util.d.ts +21 -0
  50. package/lib/util/thumbnail-util.js +28 -1
  51. package/lib/util/thumbnail-util.spec.js +6 -0
  52. package/lib/util/type-conversion-utils-spec-mockData.js +3 -3
  53. package/lib/util/type-conversion-utils.d.ts +152 -1
  54. package/lib/util/type-conversion-utils.js +155 -1
  55. package/lib/util/type-defaults.d.ts +69 -0
  56. package/lib/util/type-defaults.js +96 -5
  57. package/lib/util/type-defaults.spec.js +94 -14
  58. package/lib/util/type-utils.d.ts +21 -0
  59. package/lib/util/type-utils.js +23 -0
  60. package/lib/util/type-utils.spec.js +2 -0
  61. package/package.json +21 -6
  62. package/scripts/copy-template.js +10 -0
  63. package/.github/pull_request_template.md +0 -31
  64. package/.github/workflows/flexplm-lib.yml +0 -27
  65. package/.github/workflows/publish-to-npm.yml +0 -121
  66. package/CHANGELOG.md +0 -42
  67. package/publish.bat +0 -5
  68. package/publish.sh +0 -5
  69. package/src/entity-processor/base-entity-processor.spec.ts +0 -689
  70. package/src/entity-processor/base-entity-processor.ts +0 -583
  71. package/src/flexplm-request.ts +0 -28
  72. package/src/flexplm-utils.spec.ts +0 -27
  73. package/src/flexplm-utils.ts +0 -29
  74. package/src/index.ts +0 -22
  75. package/src/interfaces/interfaces.ts +0 -122
  76. package/src/interfaces/item-family-changes.ts +0 -67
  77. package/src/interfaces/publish-change-data.ts +0 -43
  78. package/src/publish/base-process-publish-assortment-callback.ts +0 -50
  79. package/src/publish/base-process-publish-assortment.spec.ts +0 -1992
  80. package/src/publish/base-process-publish-assortment.ts +0 -1134
  81. package/src/publish/mockData.ts +0 -4561
  82. package/src/transform/identifier-conversion-spec-mockData.ts +0 -496
  83. package/src/transform/identifier-conversion.spec.ts +0 -383
  84. package/src/transform/identifier-conversion.ts +0 -282
  85. package/src/util/config-defaults.spec.ts +0 -430
  86. package/src/util/config-defaults.ts +0 -103
  87. package/src/util/data-converter-spec-mockData.ts +0 -231
  88. package/src/util/data-converter.spec.ts +0 -1165
  89. package/src/util/data-converter.ts +0 -766
  90. package/src/util/error-response-object.spec.ts +0 -116
  91. package/src/util/error-response-object.ts +0 -50
  92. package/src/util/event-short-message-status.ts +0 -22
  93. package/src/util/federation.ts +0 -172
  94. package/src/util/flexplm-connect.spec.ts +0 -132
  95. package/src/util/flexplm-connect.ts +0 -208
  96. package/src/util/logger-config.ts +0 -20
  97. package/src/util/map-util-spec-mockData.ts +0 -231
  98. package/src/util/map-utils.spec.ts +0 -103
  99. package/src/util/map-utils.ts +0 -41
  100. package/src/util/mockData.ts +0 -101
  101. package/src/util/thumbnail-util.spec.ts +0 -508
  102. package/src/util/thumbnail-util.ts +0 -272
  103. package/src/util/type-conversion-utils-spec-mockData.ts +0 -272
  104. package/src/util/type-conversion-utils.spec.ts +0 -1031
  105. package/src/util/type-conversion-utils.ts +0 -490
  106. package/src/util/type-defaults.spec.ts +0 -708
  107. package/src/util/type-defaults.ts +0 -284
  108. package/src/util/type-utils.spec.ts +0 -227
  109. package/src/util/type-utils.ts +0 -144
  110. package/tsconfig.json +0 -24
  111. package/tslint.json +0 -57
@@ -2,15 +2,84 @@ export declare class TypeDefaults {
2
2
  static NO_ENTITY_TYPE: string;
3
3
  static NO_OBJECT_CLASS: string;
4
4
  static NO_TYPE_PATH: string;
5
+ static processLCSMaterialAsItem: boolean;
5
6
  constructor();
7
+ /** Applies values from the resolved config to TypeDefaults static state.
8
+ * Currently toggles whether LCSMaterial is treated as an item (new) or a
9
+ * custom-entity (old) based on config.LCSMaterial.processAsItem.
10
+ * Technically this could cause side effects if different parts of the code
11
+ * expect different behavior, but in practice * @param config will be
12
+ * consistent across the app and this is simpler than passing this config
13
+ * through multiple layers of function calls.
14
+ */
15
+ static applyConfig(config: any): void;
16
+ static isPropertyTrue(value: any): boolean;
17
+ /**Takes in full entity and returs the default FlexPLM
18
+ * object class.
19
+ *
20
+ * @param entity
21
+ * @returns string
22
+ */
6
23
  static getDefaultObjectClass(entity: any): string;
24
+ /**Takes in full entity and returns the default FlexPLM type path
25
+ * object class.
26
+ *
27
+ * @param entity
28
+ * @returns string
29
+ */
7
30
  static getDefaultObjectTypePath(entity: any): string;
31
+ /**Takes in full entity and returns the slugs for the default identifier
32
+ * properties. These properties are used when searching for an entity
33
+ * object class.
34
+ *
35
+ * @param entity
36
+ * @returns string[]
37
+ */
8
38
  static getDefaultIdentifierProperties(entity: any): string[];
39
+ /** Takes in full entity and returns the slugs for informational
40
+ * properties. These properties are helpful when debugging issues
41
+ * where the identifier properties don't find a match.
42
+ *
43
+ * @param entity
44
+ * @returns string[]
45
+ */
9
46
  static getDefaultInformationalProperties(entity: any): string[];
47
+ /** Returns the VibeIQ entity type from an entity.
48
+ * Throws error if it can't determine the entity type
49
+ *
50
+ * @param entity
51
+ * @returns string
52
+ */
10
53
  static getEntityType(entity: any): any;
54
+ /**Takes in full object and returns the default VibeIQ
55
+ * entity class.
56
+ *
57
+ * @param entity
58
+ * @returns string
59
+ */
11
60
  static getDefaultEntityClass(object: any): string;
61
+ /**Takes in full object and returns the default VibeIQ type path
62
+ * object class.
63
+ *
64
+ * @param object
65
+ * @returns string
66
+ */
12
67
  static getDefaultEntityTypePath(object: any): string;
68
+ /**Takes in full entity and returns the slugs for the default identifier
69
+ * properties. These properties are used when searching for an entity
70
+ * object class.
71
+ *
72
+ * @param entity
73
+ * @returns string[]
74
+ */
13
75
  static getDefaultIdentifierPropertiesFromObject(object: any): string[];
76
+ /** Takes in full object and returns the slugs for informational
77
+ * properties. These properties are helpful when debugging issues
78
+ * where the identifier properties don't find a match.
79
+ *
80
+ * @param object
81
+ * @returns string[]
82
+ */
14
83
  static getDefaultInformationalPropertiesFromObject(object: any): string[];
15
84
  static getObjectClass(object: any): string;
16
85
  }
@@ -4,6 +4,26 @@ exports.TypeDefaults = void 0;
4
4
  class TypeDefaults {
5
5
  constructor() {
6
6
  }
7
+ /** Applies values from the resolved config to TypeDefaults static state.
8
+ * Currently toggles whether LCSMaterial is treated as an item (new) or a
9
+ * custom-entity (old) based on config.LCSMaterial.processAsItem.
10
+ * Technically this could cause side effects if different parts of the code
11
+ * expect different behavior, but in practice * @param config will be
12
+ * consistent across the app and this is simpler than passing this config
13
+ * through multiple layers of function calls.
14
+ */
15
+ static applyConfig(config) {
16
+ TypeDefaults.processLCSMaterialAsItem = TypeDefaults.isPropertyTrue(config?.LCSMaterial?.processAsItem);
17
+ }
18
+ static isPropertyTrue(value) {
19
+ return value === true || (typeof value === 'string' && value.toLowerCase() === 'true');
20
+ }
21
+ /**Takes in full entity and returs the default FlexPLM
22
+ * object class.
23
+ *
24
+ * @param entity
25
+ * @returns string
26
+ */
7
27
  static getDefaultObjectClass(entity) {
8
28
  const entityType = this.getEntityType(entity);
9
29
  let objectClass = '';
@@ -42,6 +62,12 @@ class TypeDefaults {
42
62
  }
43
63
  return objectClass;
44
64
  }
65
+ /**Takes in full entity and returns the default FlexPLM type path
66
+ * object class.
67
+ *
68
+ * @param entity
69
+ * @returns string
70
+ */
45
71
  static getDefaultObjectTypePath(entity) {
46
72
  let typePath = '';
47
73
  const entityType = this.getEntityType(entity);
@@ -70,6 +96,13 @@ class TypeDefaults {
70
96
  }
71
97
  return typePath;
72
98
  }
99
+ /**Takes in full entity and returns the slugs for the default identifier
100
+ * properties. These properties are used when searching for an entity
101
+ * object class.
102
+ *
103
+ * @param entity
104
+ * @returns string[]
105
+ */
73
106
  static getDefaultIdentifierProperties(entity) {
74
107
  const identifierProps = [];
75
108
  const entityType = this.getEntityType(entity);
@@ -95,6 +128,13 @@ class TypeDefaults {
95
128
  }
96
129
  return identifierProps;
97
130
  }
131
+ /** Takes in full entity and returns the slugs for informational
132
+ * properties. These properties are helpful when debugging issues
133
+ * where the identifier properties don't find a match.
134
+ *
135
+ * @param entity
136
+ * @returns string[]
137
+ */
98
138
  static getDefaultInformationalProperties(entity) {
99
139
  const entityType = this.getEntityType(entity);
100
140
  let properties = [];
@@ -111,6 +151,12 @@ class TypeDefaults {
111
151
  }
112
152
  return properties;
113
153
  }
154
+ /** Returns the VibeIQ entity type from an entity.
155
+ * Throws error if it can't determine the entity type
156
+ *
157
+ * @param entity
158
+ * @returns string
159
+ */
114
160
  static getEntityType(entity) {
115
161
  let entityType = entity['entityType'];
116
162
  if (!entityType) {
@@ -127,10 +173,22 @@ class TypeDefaults {
127
173
  }
128
174
  return entityType;
129
175
  }
176
+ /**Takes in full object and returns the default VibeIQ
177
+ * entity class.
178
+ *
179
+ * @param entity
180
+ * @returns string
181
+ */
130
182
  static getDefaultEntityClass(object) {
131
183
  let entityClass = '';
132
184
  let objectClass = TypeDefaults.getObjectClass(object);
133
- if (['LCSProduct', 'LCSSKU', 'LCSMaterial'].includes(objectClass)) {
185
+ const itemClasses = TypeDefaults.processLCSMaterialAsItem
186
+ ? ['LCSProduct', 'LCSSKU', 'LCSMaterial']
187
+ : ['LCSProduct', 'LCSSKU'];
188
+ const customEntityClasses = TypeDefaults.processLCSMaterialAsItem
189
+ ? ['LCSRevisableEntity', 'LCSLifecycleManaged', 'LCSLast']
190
+ : ['LCSRevisableEntity', 'LCSLifecycleManaged', 'LCSLast', 'LCSMaterial'];
191
+ if (itemClasses.includes(objectClass)) {
134
192
  entityClass = 'item';
135
193
  }
136
194
  else if (['LCSProductSeasonLink', 'LCSSKUSeasonLink'].includes(objectClass)) {
@@ -142,13 +200,19 @@ class TypeDefaults {
142
200
  else if (['LCSSeason', 'SeasonGroup'].includes(objectClass)) {
143
201
  entityClass = 'assortment';
144
202
  }
145
- else if (['LCSRevisableEntity', 'LCSLifecycleManaged', 'LCSLast'].includes(objectClass)) {
203
+ else if (customEntityClasses.includes(objectClass)) {
146
204
  entityClass = 'custom-entity';
147
205
  }
148
206
  if (entityClass === '')
149
207
  throw Error(TypeDefaults.NO_OBJECT_CLASS);
150
208
  return entityClass;
151
209
  }
210
+ /**Takes in full object and returns the default VibeIQ type path
211
+ * object class.
212
+ *
213
+ * @param object
214
+ * @returns string
215
+ */
152
216
  static getDefaultEntityTypePath(object) {
153
217
  let typePath = '';
154
218
  const objectClass = TypeDefaults.getObjectClass(object);
@@ -158,7 +222,9 @@ class TypeDefaults {
158
222
  typePath = 'item';
159
223
  break;
160
224
  case 'LCSMaterial':
161
- typePath = 'item:material';
225
+ if (TypeDefaults.processLCSMaterialAsItem) {
226
+ typePath = 'item:material';
227
+ }
162
228
  break;
163
229
  case 'LCSProductSeasonLink':
164
230
  case 'LCSSKUSeasonLink':
@@ -176,15 +242,29 @@ class TypeDefaults {
176
242
  throw Error(TypeDefaults.NO_TYPE_PATH);
177
243
  return typePath;
178
244
  }
245
+ /**Takes in full entity and returns the slugs for the default identifier
246
+ * properties. These properties are used when searching for an entity
247
+ * object class.
248
+ *
249
+ * @param entity
250
+ * @returns string[]
251
+ */
179
252
  static getDefaultIdentifierPropertiesFromObject(object) {
180
253
  const identifierProps = [];
181
254
  const objectClass = TypeDefaults.getObjectClass(object);
182
255
  switch (objectClass) {
183
256
  case 'LCSProduct':
184
257
  case 'LCSSKU':
185
- case 'LCSMaterial':
186
258
  identifierProps.push('itemNumber');
187
259
  break;
260
+ case 'LCSMaterial':
261
+ if (TypeDefaults.processLCSMaterialAsItem) {
262
+ identifierProps.push('itemNumber');
263
+ }
264
+ else {
265
+ identifierProps.push('name');
266
+ }
267
+ break;
188
268
  case 'LCSSeason':
189
269
  identifierProps.push('flexPLMSeasonName');
190
270
  break;
@@ -200,10 +280,20 @@ class TypeDefaults {
200
280
  }
201
281
  return identifierProps;
202
282
  }
283
+ /** Takes in full object and returns the slugs for informational
284
+ * properties. These properties are helpful when debugging issues
285
+ * where the identifier properties don't find a match.
286
+ *
287
+ * @param object
288
+ * @returns string[]
289
+ */
203
290
  static getDefaultInformationalPropertiesFromObject(object) {
204
291
  const objectClass = TypeDefaults.getObjectClass(object);
205
292
  let properties = [];
206
- if (['LCSProduct', 'LCSMaterial'].includes(objectClass)) {
293
+ const itemClasses = TypeDefaults.processLCSMaterialAsItem
294
+ ? ['LCSProduct', 'LCSMaterial']
295
+ : ['LCSProduct'];
296
+ if (itemClasses.includes(objectClass)) {
207
297
  properties.push('name');
208
298
  }
209
299
  else if ('LCSSKU' === objectClass) {
@@ -222,3 +312,4 @@ exports.TypeDefaults = TypeDefaults;
222
312
  TypeDefaults.NO_ENTITY_TYPE = 'Not able to determine the entity type of the entity object';
223
313
  TypeDefaults.NO_OBJECT_CLASS = 'Please ensure that the flexPLMObjectClass property is provided.';
224
314
  TypeDefaults.NO_TYPE_PATH = 'Please ensure that the flexPLMTypePath property is provided.';
315
+ TypeDefaults.processLCSMaterialAsItem = false;
@@ -304,7 +304,7 @@ describe('Type Defaults', () => {
304
304
  expect(() => type_defaults_1.TypeDefaults.getEntityType(entity)).toThrowError();
305
305
  expect(() => type_defaults_1.TypeDefaults.getEntityType(entity)).toThrow(type_defaults_1.TypeDefaults.NO_ENTITY_TYPE);
306
306
  });
307
- });
307
+ }); //getEntityType
308
308
  describe('getDefaultEntityClass', () => {
309
309
  it('item - LCSProduct', () => {
310
310
  const object = {
@@ -369,14 +369,27 @@ describe('Type Defaults', () => {
369
369
  const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
370
370
  expect(entityClass).toBe('custom-entity');
371
371
  });
372
- it('item - LCSMaterial', () => {
372
+ it('item - LCSMaterial - processAsItem=true', () => {
373
+ const object = {
374
+ flexPLMObjectClass: 'LCSMaterial'
375
+ };
376
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
377
+ try {
378
+ const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
379
+ expect(entityClass).toBe('item');
380
+ }
381
+ finally {
382
+ type_defaults_1.TypeDefaults.applyConfig({});
383
+ }
384
+ });
385
+ it('custom-entity - LCSMaterial - processAsItem=false (default)', () => {
373
386
  const object = {
374
387
  flexPLMObjectClass: 'LCSMaterial'
375
388
  };
376
389
  const entityClass = type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
377
- expect(entityClass).toBe('item');
390
+ expect(entityClass).toBe('custom-entity');
378
391
  });
379
- });
392
+ }); //getDefaultEntityClass
380
393
  describe('getDefaultEntityTypePath', () => {
381
394
  it('LCSProduct', () => {
382
395
  const object = {
@@ -427,14 +440,26 @@ describe('Type Defaults', () => {
427
440
  const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
428
441
  expect(typePath).toBe('assortment');
429
442
  });
430
- it('LCSMaterial', () => {
443
+ it('LCSMaterial - processAsItem=true', () => {
431
444
  const object = {
432
445
  flexPLMObjectClass: 'LCSMaterial'
433
446
  };
434
- const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
435
- expect(typePath).toBe('item:material');
447
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
448
+ try {
449
+ const typePath = type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object);
450
+ expect(typePath).toBe('item:material');
451
+ }
452
+ finally {
453
+ type_defaults_1.TypeDefaults.applyConfig({});
454
+ }
436
455
  });
437
- });
456
+ it('LCSMaterial - processAsItem=false (default) throws', () => {
457
+ const object = {
458
+ flexPLMObjectClass: 'LCSMaterial'
459
+ };
460
+ expect(() => type_defaults_1.TypeDefaults.getDefaultEntityTypePath(object)).toThrowError(type_defaults_1.TypeDefaults.NO_TYPE_PATH);
461
+ });
462
+ }); //getDefaultEntityTypePath
438
463
  describe('getDefaultIdentifierPropertiesFromObject', () => {
439
464
  it('LCSProduct', () => {
440
465
  const object = {
@@ -492,15 +517,29 @@ describe('Type Defaults', () => {
492
517
  expect(defaultIdentifiers).toContain('name');
493
518
  expect(defaultIdentifiers).toHaveLength(1);
494
519
  });
495
- it('LCSMaterial', () => {
520
+ it('LCSMaterial - processAsItem=true', () => {
521
+ const object = {
522
+ flexPLMObjectClass: 'LCSMaterial'
523
+ };
524
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
525
+ try {
526
+ const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
527
+ expect(defaultIdentifiers).toContain('itemNumber');
528
+ expect(defaultIdentifiers).toHaveLength(1);
529
+ }
530
+ finally {
531
+ type_defaults_1.TypeDefaults.applyConfig({});
532
+ }
533
+ });
534
+ it('LCSMaterial - processAsItem=false (default)', () => {
496
535
  const object = {
497
536
  flexPLMObjectClass: 'LCSMaterial'
498
537
  };
499
538
  const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultIdentifierPropertiesFromObject(object);
500
- expect(defaultIdentifiers).toContain('itemNumber');
539
+ expect(defaultIdentifiers).toContain('name');
501
540
  expect(defaultIdentifiers).toHaveLength(1);
502
541
  });
503
- });
542
+ }); //getDefaultIdentifierPropertiesFromObject
504
543
  describe('getDefaultInformationalPropertiesFromObject', () => {
505
544
  it('LCSProduct', () => {
506
545
  const object = {
@@ -534,13 +573,54 @@ describe('Type Defaults', () => {
534
573
  expect(defaultIdentifiers).toContain('name');
535
574
  expect(defaultIdentifiers).toHaveLength(1);
536
575
  });
537
- it('LCSMaterial', () => {
576
+ it('LCSMaterial - processAsItem=true', () => {
577
+ const object = {
578
+ flexPLMObjectClass: 'LCSMaterial'
579
+ };
580
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
581
+ try {
582
+ const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalPropertiesFromObject(object);
583
+ expect(defaultIdentifiers).toContain('name');
584
+ expect(defaultIdentifiers).toHaveLength(1);
585
+ }
586
+ finally {
587
+ type_defaults_1.TypeDefaults.applyConfig({});
588
+ }
589
+ });
590
+ it('LCSMaterial - processAsItem=false (default) yields no informational props', () => {
538
591
  const object = {
539
592
  flexPLMObjectClass: 'LCSMaterial'
540
593
  };
541
594
  const defaultIdentifiers = type_defaults_1.TypeDefaults.getDefaultInformationalPropertiesFromObject(object);
542
- expect(defaultIdentifiers).toContain('name');
543
- expect(defaultIdentifiers).toHaveLength(1);
595
+ expect(defaultIdentifiers).toHaveLength(0);
596
+ });
597
+ }); //getDefaultInformationalPropertiesFromObject
598
+ describe('applyConfig', () => {
599
+ afterEach(() => {
600
+ type_defaults_1.TypeDefaults.applyConfig({});
601
+ });
602
+ it('sets processLCSMaterialAsItem=true when processAsItem=true', () => {
603
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: true } });
604
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(true);
605
+ });
606
+ it('sets processLCSMaterialAsItem=true when processAsItem=\"true\" (string)', () => {
607
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: 'true' } });
608
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(true);
609
+ });
610
+ it('sets processLCSMaterialAsItem=false when processAsItem=false', () => {
611
+ type_defaults_1.TypeDefaults.processLCSMaterialAsItem = true;
612
+ type_defaults_1.TypeDefaults.applyConfig({ LCSMaterial: { processAsItem: false } });
613
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(false);
614
+ });
615
+ it('sets processLCSMaterialAsItem=false when LCSMaterial missing', () => {
616
+ type_defaults_1.TypeDefaults.processLCSMaterialAsItem = true;
617
+ type_defaults_1.TypeDefaults.applyConfig({});
618
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(false);
619
+ });
620
+ it('sets processLCSMaterialAsItem=false when config is null/undefined', () => {
621
+ type_defaults_1.TypeDefaults.processLCSMaterialAsItem = true;
622
+ type_defaults_1.TypeDefaults.applyConfig(undefined);
623
+ expect(type_defaults_1.TypeDefaults.processLCSMaterialAsItem).toBe(false);
544
624
  });
545
625
  });
546
626
  });
@@ -5,9 +5,30 @@ export declare class TypeUtils {
5
5
  constructor();
6
6
  getTypeById(id: any): Promise<import("@contrail/types").Type>;
7
7
  getByRootAndPath(options: TypeClientOptions): Promise<import("@contrail/types").Type>;
8
+ /** Deprecated: use TypeConversionUtils.getObjectTypePath() */
8
9
  static getFlexPLMTypePath(entity: any): any;
10
+ /** Deprecated: use TypeConversionUtils.getObjectClass()
11
+ *
12
+ * @param entityType
13
+ * @param newData
14
+ * @returns
15
+ */
9
16
  getEventObjectClass(entityType: string, newData: any): string;
17
+ /** Gets the VibeIQ entity type for the object data
18
+ * @param data: object data
19
+ */
10
20
  getEntityTypeClientOptionsUsingMapping(transformMapFile: any, mapFileUtil: any, data: any): Promise<TypeClientOptions>;
21
+ /** Gets the VibeIQ entity type for the object data
22
+ * @param objectClass: string object class
23
+ * @param data: object data
24
+ */
11
25
  getEntityTypeClientOptions(objectClass: string, data: any): TypeClientOptions;
26
+ /** This will filter the properties based the newData entity.
27
+ * It is assumed the type is correct for the entity
28
+ *
29
+ * @param type entire type object
30
+ * @param newData the entity being processed
31
+ * @returns TypeProperty[] of applicable properties
32
+ */
12
33
  filterTypeProperties(type: any, newData: any): TypeProperty[];
13
34
  }
@@ -9,6 +9,7 @@ class TypeUtils {
9
9
  this.typesObj = new sdk_1.Types();
10
10
  }
11
11
  async getTypeById(id) {
12
+ // this.logger.log('!-getTypeById: ' + id);
12
13
  const type = await this.typesObj.getType({
13
14
  id,
14
15
  relations: ['typeProperties', 'typeInterfaces']
@@ -19,9 +20,16 @@ class TypeUtils {
19
20
  const type = await this.typesObj.getByRootAndPath(options);
20
21
  return type;
21
22
  }
23
+ /** Deprecated: use TypeConversionUtils.getObjectTypePath() */
22
24
  static getFlexPLMTypePath(entity) {
23
25
  return entity['flexPLMTypePath'] || entity['flexTypePath'] || '';
24
26
  }
27
+ /** Deprecated: use TypeConversionUtils.getObjectClass()
28
+ *
29
+ * @param entityType
30
+ * @param newData
31
+ * @returns
32
+ */
25
33
  getEventObjectClass(entityType, newData) {
26
34
  let objectClass = '';
27
35
  if ('item' === entityType) {
@@ -48,6 +56,9 @@ class TypeUtils {
48
56
  }
49
57
  return objectClass;
50
58
  }
59
+ /** Gets the VibeIQ entity type for the object data
60
+ * @param data: object data
61
+ */
51
62
  async getEntityTypeClientOptionsUsingMapping(transformMapFile, mapFileUtil, data) {
52
63
  const root = await type_conversion_utils_1.TypeConversionUtils.getEntityClassFromObject(transformMapFile, mapFileUtil, data);
53
64
  const path = await type_conversion_utils_1.TypeConversionUtils.getEntityTypePathFromOjbect(transformMapFile, mapFileUtil, data);
@@ -57,6 +68,10 @@ class TypeUtils {
57
68
  };
58
69
  return tco;
59
70
  }
71
+ /** Gets the VibeIQ entity type for the object data
72
+ * @param objectClass: string object class
73
+ * @param data: object data
74
+ */
60
75
  getEntityTypeClientOptions(objectClass, data) {
61
76
  let tco;
62
77
  if (['LCSProduct', 'LCSSKU'].includes(objectClass)) {
@@ -75,6 +90,7 @@ class TypeUtils {
75
90
  };
76
91
  }
77
92
  else if (['LCSBusinessObject', 'LCSRevisableEntity', 'LCSLast'].includes(objectClass)) {
93
+ //TODO need to write logic using mapping file
78
94
  tco = {
79
95
  root: 'custom-entity'
80
96
  };
@@ -82,6 +98,13 @@ class TypeUtils {
82
98
  }
83
99
  return tco;
84
100
  }
101
+ /** This will filter the properties based the newData entity.
102
+ * It is assumed the type is correct for the entity
103
+ *
104
+ * @param type entire type object
105
+ * @param newData the entity being processed
106
+ * @returns TypeProperty[] of applicable properties
107
+ */
85
108
  filterTypeProperties(type, newData) {
86
109
  let filteredProps = type['typeProperties'];
87
110
  const typePath = type['typePath'];
@@ -103,6 +103,7 @@ describe('filterProperties-item', () => {
103
103
  expect(filteredProps.length).toEqual(len);
104
104
  });
105
105
  });
106
+ //project-item
106
107
  describe('filterProperties-project-item', () => {
107
108
  const projectItemType = {
108
109
  typePath: 'project-item'
@@ -152,6 +153,7 @@ describe('filterProperties-project-item', () => {
152
153
  expect(filteredProps.length).toEqual(len);
153
154
  });
154
155
  });
156
+ //color
155
157
  describe('filterProperties-color', () => {
156
158
  const colorType = {
157
159
  typePath: 'color'
package/package.json CHANGED
@@ -1,11 +1,18 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.5.0-alpha.6fc44c4",
3
+ "version": "1.5.0-alpha.98b8b06",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
+ "bin": {
8
+ "flexplm-mapping": "lib/cli/index.js"
9
+ },
10
+ "files": [
11
+ "lib/**/*",
12
+ "scripts/copy-template.js"
13
+ ],
7
14
  "scripts": {
8
- "build": "tsc",
15
+ "build": "tsc && node scripts/copy-template.js",
9
16
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
10
17
  "lint": "tslint -p tsconfig.json",
11
18
  "test": "jest",
@@ -25,6 +32,14 @@
25
32
  "tslint-config-prettier": "^1.18.0",
26
33
  "typescript": "^4.0.0"
27
34
  },
35
+ "peerDependencies": {
36
+ "typescript": ">=4.0.0"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "typescript": {
40
+ "optional": true
41
+ }
42
+ },
28
43
  "jest": {
29
44
  "moduleFileExtensions": [
30
45
  "js",
@@ -40,10 +55,10 @@
40
55
  "testEnvironment": "node"
41
56
  },
42
57
  "dependencies": {
43
- "@contrail/app-framework": "^1.3.4",
44
- "@contrail/sdk": "^1.4.3",
45
- "@contrail/transform-data": "^1.1.3",
46
- "@contrail/util": "^1.0.48",
58
+ "@contrail/app-framework": "^1.4.3",
59
+ "@contrail/sdk": "^1.5.10",
60
+ "@contrail/transform-data": "1.3.2-alpha.36321eb",
61
+ "@contrail/util": "^1.3.1",
47
62
  "axios": "^1.4.0",
48
63
  "p-limit": "^3.1.0"
49
64
  }
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const SRC = path.join('src', 'cli', 'template', 'mapping-template.ts.template');
6
+ const DST = path.join('lib', 'cli', 'template', 'mapping-template.ts.template');
7
+
8
+ fs.mkdirSync(path.dirname(DST), { recursive: true });
9
+ fs.copyFileSync(SRC, DST);
10
+ console.log(`Copied ${SRC} -> ${DST}`);
@@ -1,31 +0,0 @@
1
- ## What
2
- - [ ] Bugfix
3
- - [ ] Feature
4
- - [ ] Enhancement
5
-
6
- Description:
7
- <!--
8
- Describe the functional changes of the PR.
9
-
10
- If the mechanism of your change are complex, describe them in detail as you
11
- would if you were explaining them to a team mate.
12
-
13
- If the PR is simple, there is no need to repeat yourself. A small description
14
- is sufficient.
15
- -->
16
-
17
- ## Why
18
- <!--
19
- why is this change needed? Same rules as with #What
20
- -->
21
-
22
-
23
- ## Testing added
24
- <!--
25
- Describe the testing you added to this PR
26
- -->
27
-
28
-
29
- ## Link to Jira ticket(s)
30
- https://vibe-team.atlassian.net/browse/VIBE-TICKET_NUMBER_HERE
31
-
@@ -1,27 +0,0 @@
1
- name: flexplm-lib-tests
2
- on:
3
- pull_request:
4
- workflow_dispatch: # allow running in github actions manually
5
- jobs:
6
- test:
7
- runs-on: ubuntu-24.04
8
- strategy:
9
- matrix:
10
- node-version: [22.14.0, 24]
11
- steps:
12
- - name: Node.js
13
- uses: actions/setup-node@v3
14
- with:
15
- node-version: ${{ matrix.node-version }}
16
-
17
- - uses: actions/checkout@v3
18
-
19
- - name: NPM Install
20
- env:
21
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
22
- run: npm ci
23
-
24
- - name: Unit Tests -
25
- env:
26
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
27
- run: npm test