@contrail/flexplm 1.0.10 → 1.0.12

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.
@@ -0,0 +1,12 @@
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
+ getEntityTypeClientOptions(objectClass: string, data: any): TypeClientOptions;
11
+ filterTypeProperties(type: any, newData: any): TypeProperty[];
12
+ }
@@ -0,0 +1,101 @@
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
+ class TypeUtils {
7
+ constructor() {
8
+ this.typesObj = new sdk_1.Types();
9
+ }
10
+ async getTypeById(id) {
11
+ const type = await this.typesObj.getType({
12
+ id,
13
+ relations: ['typeProperties', 'typeInterfaces']
14
+ });
15
+ return type;
16
+ }
17
+ async getByRootAndPath(options) {
18
+ const type = await this.typesObj.getByRootAndPath(options);
19
+ return type;
20
+ }
21
+ static getFlexPLMTypePath(entity) {
22
+ return entity['flexPLMTypePath'] || entity['flexTypePath'] || '';
23
+ }
24
+ getEventObjectClass(entityType, newData) {
25
+ let objectClass = '';
26
+ if ('item' === entityType) {
27
+ if (newData.roles.includes('family')) {
28
+ objectClass = 'LCSProduct';
29
+ }
30
+ else if (newData.roles.includes('color')) {
31
+ objectClass = 'LCSSKU';
32
+ }
33
+ }
34
+ else if ('project-item' === entityType) {
35
+ if (newData.roles.includes('family')) {
36
+ objectClass = 'LCSProductSeasonLink';
37
+ }
38
+ else if (newData.roles.includes('color')) {
39
+ objectClass = 'LCSSKUSeasonLink';
40
+ }
41
+ }
42
+ else if ('color' === entityType) {
43
+ objectClass = 'LCSColor';
44
+ }
45
+ else if ('custom-entity' === entityType) {
46
+ objectClass = 'LCSRevisableEntity';
47
+ }
48
+ return objectClass;
49
+ }
50
+ getEntityTypeClientOptions(objectClass, data) {
51
+ let tco;
52
+ if (['LCSProduct', 'LCSSKU'].includes(objectClass)) {
53
+ tco = {
54
+ root: 'item'
55
+ };
56
+ }
57
+ else if ('LCSSeason' === objectClass) {
58
+ tco = {
59
+ root: 'assortment'
60
+ };
61
+ }
62
+ else if ('LCSColor' === objectClass) {
63
+ tco = {
64
+ root: 'color'
65
+ };
66
+ }
67
+ else if (['LCSBusinessObject', 'LCSRevisableEntity', 'LCSLast'].includes(objectClass)) {
68
+ tco = {
69
+ root: 'custom-entity'
70
+ };
71
+ console.log('data: ' + data);
72
+ }
73
+ return tco;
74
+ }
75
+ filterTypeProperties(type, newData) {
76
+ let filteredProps = type['typeProperties'];
77
+ const typePath = type['typePath'];
78
+ if (typePath && (typePath.startsWith('item') || typePath.startsWith('project-item'))) {
79
+ if (app_framework_1.Logger.isDebugOn()) {
80
+ console.debug('typePath: ' + typePath);
81
+ console.debug('newData: ' + JSON.stringify(newData));
82
+ }
83
+ const roles = newData['roles'];
84
+ if (roles) {
85
+ const isFamily = roles.includes('family');
86
+ console.debug('isFamily: ' + isFamily);
87
+ filteredProps = filteredProps.filter(prop => {
88
+ const propertyLevel = prop.propertyLevel;
89
+ const applies = (isFamily && 'option' != propertyLevel) ||
90
+ (!isFamily && 'family' != propertyLevel);
91
+ return applies;
92
+ });
93
+ }
94
+ else {
95
+ console.error('filterTypeProperties():Entity missing role-id: ' + newData['id']);
96
+ }
97
+ }
98
+ return filteredProps;
99
+ }
100
+ }
101
+ exports.TypeUtils = TypeUtils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/dist/package.json DELETED
@@ -1,46 +0,0 @@
1
- {
2
- "name": "@contrail/flexplm",
3
- "version": "1.0.9",
4
- "description": "Library used for integration with flexplm.",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "scripts": {
8
- "build": "tsc",
9
- "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
10
- "lint": "tslint -p tsconfig.json",
11
- "test": "jest"
12
- },
13
- "keywords": [],
14
- "author": "",
15
- "license": "ISC",
16
- "devDependencies": {
17
- "@types/jest": "^29.5.2",
18
- "jest": "^29.5.0",
19
- "prettier": "^1.19.1",
20
- "ts-jest": "^29.1.1",
21
- "tslint": "^5.11.0",
22
- "tslint-config-prettier": "^1.18.0",
23
- "typescript": "^4.0.0"
24
- },
25
- "jest": {
26
- "moduleFileExtensions": [
27
- "js",
28
- "json",
29
- "ts"
30
- ],
31
- "rootDir": "src",
32
- "testRegex": ".spec.ts$",
33
- "transform": {
34
- "^.+\\.(t|j)s$": "ts-jest"
35
- },
36
- "coverageDirectory": "../coverage",
37
- "testEnvironment": "node"
38
- },
39
- "dependencies": {
40
- "@contrail/app-framework": "^1.2.0",
41
- "@contrail/sdk": "^1.2.11",
42
- "@contrail/transform-data": "^1.0.8",
43
- "axios": "^1.4.0",
44
- "p-limit": "^3.1.0"
45
- }
46
- }