@contrail/flexplm 1.1.17 → 1.1.18

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.
@@ -154,6 +154,7 @@ exports.mapping = {
154
154
  }
155
155
  },
156
156
  prefix: {
157
+ isInboundCreatable: () => true,
157
158
  vibe2flex: {
158
159
  transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
159
160
  rekey: {
@@ -15,5 +15,6 @@ export declare class TypeConversionUtils {
15
15
  static getIdentifierPropertiesFromObject(fileId: any, mapFileUtil: MapFileUtil, object: any): Promise<string[]>;
16
16
  static getInformationalPropertiesFromObject(fileId: any, mapFileUtil: MapFileUtil, object: any): Promise<string[]>;
17
17
  static getMapKeyFromObject(fileId: any, mapFileUtil: MapFileUtil, object: any, direction: string): Promise<string>;
18
+ static isInboundCreatableFromObject(fileId: string, mapFileUtil: MapFileUtil, object: any): Promise<boolean>;
18
19
  static getObjectType(object: any): any;
19
20
  }
@@ -180,6 +180,17 @@ class TypeConversionUtils {
180
180
  return type;
181
181
  }
182
182
  }
183
+ static async isInboundCreatableFromObject(fileId, mapFileUtil, object) {
184
+ let isInboundCreatable = false;
185
+ if (fileId) {
186
+ const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
187
+ const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
188
+ if (mapData && mapData['isInboundCreatable']) {
189
+ isInboundCreatable = await mapData['isInboundCreatable'](object);
190
+ }
191
+ }
192
+ return isInboundCreatable;
193
+ }
183
194
  static getObjectType(object) {
184
195
  let objectType = object['flexPLMObjectClass'];
185
196
  return objectType;
@@ -544,4 +544,41 @@ describe('conversion-utils', () => {
544
544
  }
545
545
  });
546
546
  });
547
+ describe('isInboundCreatableFromObject', () => {
548
+ const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
549
+ it('Revisable Entity\\packaging', async () => {
550
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
551
+ .mockImplementation(async () => {
552
+ return mapping;
553
+ });
554
+ const object = {
555
+ flexPLMObjectClass: 'LCSRevisableEntity',
556
+ flexPLMTypePath: 'Revisable Entity\\packaging'
557
+ };
558
+ try {
559
+ const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
560
+ expect(results).toBeFalsy();
561
+ }
562
+ finally {
563
+ spy.mockRestore();
564
+ }
565
+ });
566
+ it('Revisable Entity\\prefix', async () => {
567
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
568
+ .mockImplementation(async () => {
569
+ return mapping;
570
+ });
571
+ const object = {
572
+ flexPLMObjectClass: 'LCSRevisableEntity',
573
+ flexPLMTypePath: 'Revisable Entity\\prefix'
574
+ };
575
+ try {
576
+ const results = await type_conversion_utils_1.TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
577
+ expect(results).toBeTruthy();
578
+ }
579
+ finally {
580
+ spy.mockRestore();
581
+ }
582
+ });
583
+ });
547
584
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -160,6 +160,7 @@ exports.mapping = {
160
160
  }
161
161
  },
162
162
  prefix: {
163
+ isInboundCreatable: () => true,
163
164
  vibe2flex: {
164
165
  transformOrder: [{ processor: 'REKEY', rekeyDelete: true, rekeyTransformersKey: 'rekey' }],
165
166
  rekey: {
@@ -598,4 +598,47 @@ describe('conversion-utils', () => {
598
598
  });
599
599
  });
600
600
 
601
+
602
+ describe('isInboundCreatableFromObject', () =>{
603
+ const mapFileUtil = new MapFileUtil(new Entities());
604
+
605
+ it('Revisable Entity\\packaging', async () =>{
606
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
607
+ .mockImplementation(async () =>{
608
+ return mapping;
609
+ });
610
+ const object = {
611
+ flexPLMObjectClass: 'LCSRevisableEntity',
612
+ flexPLMTypePath: 'Revisable Entity\\packaging'
613
+ }
614
+
615
+ try{
616
+ const results = await TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
617
+ expect(results).toBeFalsy();
618
+
619
+ } finally {
620
+ spy.mockRestore();
621
+ }
622
+ });
623
+
624
+ it('Revisable Entity\\prefix', async () =>{
625
+ const spy = jest.spyOn(mapFileUtil, 'getMapFile')
626
+ .mockImplementation(async () =>{
627
+ return mapping;
628
+ });
629
+ const object = {
630
+ flexPLMObjectClass: 'LCSRevisableEntity',
631
+ flexPLMTypePath: 'Revisable Entity\\prefix'
632
+ }
633
+
634
+ try{
635
+ const results = await TypeConversionUtils.isInboundCreatableFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
636
+ expect(results).toBeTruthy();
637
+
638
+ } finally {
639
+ spy.mockRestore();
640
+ }
641
+ });
642
+
643
+ });
601
644
  });
@@ -336,6 +336,21 @@ export class TypeConversionUtils {
336
336
  //TODO use TypeDefaults?
337
337
  }
338
338
 
339
+ static async isInboundCreatableFromObject(fileId: string, mapFileUtil: MapFileUtil, object: any): Promise<boolean> {
340
+
341
+ let isInboundCreatable = false;
342
+ if(fileId){
343
+ const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
344
+
345
+ const mapData = await MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
346
+ if(mapData && mapData['isInboundCreatable']){
347
+ isInboundCreatable = await mapData['isInboundCreatable'](object);
348
+ }
349
+ }
350
+
351
+ return isInboundCreatable;
352
+ }
353
+
339
354
  static getObjectType(object:any) {
340
355
  let objectType = object['flexPLMObjectClass'];
341
356
  return objectType;