@contrail/flexplm 1.0.4 → 1.0.5

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,114 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TypeUtils = void 0;
13
+ const app_framework_1 = require("@contrail/app-framework");
14
+ const sdk_1 = require("@contrail/sdk");
15
+ class TypeUtils {
16
+ constructor() {
17
+ this.typesObj = new sdk_1.Types();
18
+ }
19
+ getTypeById(id) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const type = yield this.typesObj.getType({
22
+ id,
23
+ relations: ['typeProperties', 'typeInterfaces']
24
+ });
25
+ return type;
26
+ });
27
+ }
28
+ getByRootAndPath(options) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const type = yield this.typesObj.getByRootAndPath(options);
31
+ return type;
32
+ });
33
+ }
34
+ static getFlexPLMTypePath(entity) {
35
+ return entity['flexPLMTypePath'] || entity['flexTypePath'] || '';
36
+ }
37
+ getEventObjectClass(entityType, newData) {
38
+ let objectClass = '';
39
+ if ('item' === entityType) {
40
+ if (newData.roles.includes('family')) {
41
+ objectClass = 'LCSProduct';
42
+ }
43
+ else if (newData.roles.includes('color')) {
44
+ objectClass = 'LCSSKU';
45
+ }
46
+ }
47
+ else if ('project-item' === entityType) {
48
+ if (newData.roles.includes('family')) {
49
+ objectClass = 'LCSProductSeasonLink';
50
+ }
51
+ else if (newData.roles.includes('color')) {
52
+ objectClass = 'LCSSKUSeasonLink';
53
+ }
54
+ }
55
+ else if ('color' === entityType) {
56
+ objectClass = 'LCSColor';
57
+ }
58
+ else if ('custom-entity' === entityType) {
59
+ objectClass = 'LCSRevisableEntity';
60
+ }
61
+ return objectClass;
62
+ }
63
+ getEntityTypeClientOptions(objectClass, data) {
64
+ let tco;
65
+ if (['LCSProduct', 'LCSSKU'].includes(objectClass)) {
66
+ tco = {
67
+ root: 'item'
68
+ };
69
+ }
70
+ else if ('LCSSeason' === objectClass) {
71
+ tco = {
72
+ root: 'assortment'
73
+ };
74
+ }
75
+ else if ('LCSColor' === objectClass) {
76
+ tco = {
77
+ root: 'color'
78
+ };
79
+ }
80
+ else if (['LCSBusinessObject', 'LCSRevisableEntity', 'LCSLast'].includes(objectClass)) {
81
+ tco = {
82
+ root: 'custom-entity'
83
+ };
84
+ console.log('data: ' + data);
85
+ }
86
+ return tco;
87
+ }
88
+ filterTypeProperties(type, newData) {
89
+ let filteredProps = type['typeProperties'];
90
+ const typePath = type['typePath'];
91
+ if (typePath && (typePath.startsWith('item') || typePath.startsWith('project-item'))) {
92
+ if (app_framework_1.Logger.isDebugOn()) {
93
+ console.debug('typePath: ' + typePath);
94
+ console.debug('newData: ' + JSON.stringify(newData));
95
+ }
96
+ const roles = newData['roles'];
97
+ if (roles) {
98
+ const isFamily = roles.includes('family');
99
+ console.debug('isFamily: ' + isFamily);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -37,6 +37,9 @@
37
37
  "testEnvironment": "node"
38
38
  },
39
39
  "dependencies": {
40
+ "@contrail/app-framework": "^1.2.0",
41
+ "@contrail/sdk": "^1.2.11",
42
+ "@contrail/transform-data": "^1.0.8",
40
43
  "axios": "^1.4.0"
41
44
  }
42
45
  }