@contrail/flexplm 1.1.13 → 1.1.14
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 +30 -0
- package/.github/workflows/flexplm-lib.yml +27 -0
- package/lib/flexplm-utils.spec.d.ts +1 -0
- package/lib/flexplm-utils.spec.js +26 -0
- package/lib/publish/base-process-publish-assortment.spec.d.ts +1 -0
- package/lib/publish/base-process-publish-assortment.spec.js +1053 -0
- package/lib/util/config-defaults.spec.d.ts +1 -0
- package/lib/util/config-defaults.spec.js +264 -0
- package/lib/util/data-converter.spec.d.ts +1 -0
- package/lib/util/data-converter.spec.js +591 -0
- package/lib/util/map-utils.d.ts +2 -2
- package/lib/util/map-utils.js +5 -28
- package/lib/util/map-utils.spec.d.ts +1 -0
- package/lib/util/map-utils.spec.js +89 -0
- package/lib/util/thumbnail-util.spec.d.ts +1 -0
- package/lib/util/thumbnail-util.spec.js +132 -0
- package/lib/util/type-conversion-utils-spec-mockData.js +21 -0
- package/lib/util/type-conversion-utils.d.ts +7 -0
- package/lib/util/type-conversion-utils.js +88 -4
- package/lib/util/type-conversion-utils.spec.d.ts +1 -0
- package/lib/util/type-conversion-utils.spec.js +547 -0
- package/lib/util/type-defaults.d.ts +5 -0
- package/lib/util/type-defaults.js +66 -0
- package/lib/util/type-defaults.spec.d.ts +1 -0
- package/lib/util/type-defaults.spec.js +460 -0
- package/lib/util/type-utils.spec.d.ts +1 -0
- package/lib/util/type-utils.spec.js +190 -0
- package/package.json +2 -2
- package/publish.bat +5 -0
- package/publish.sh +5 -0
- package/src/entity-processor/base-entity-processor.ts +183 -0
- package/src/flexplm-request.ts +28 -0
- package/src/flexplm-utils.spec.ts +27 -0
- package/src/flexplm-utils.ts +29 -0
- package/src/index.ts +20 -0
- package/src/interfaces/interfaces.ts +120 -0
- package/src/interfaces/item-family-changes.ts +67 -0
- package/src/interfaces/publish-change-data.ts +43 -0
- package/src/publish/base-process-publish-assortment-callback.ts +23 -0
- package/src/publish/base-process-publish-assortment.spec.ts +1239 -0
- package/src/publish/base-process-publish-assortment.ts +1024 -0
- package/src/publish/mockData.ts +4561 -0
- package/src/transform/identifier-conversion.ts +226 -0
- package/src/util/config-defaults.spec.ts +315 -0
- package/src/util/config-defaults.ts +79 -0
- package/src/util/data-converter-spec-mockData.ts +231 -0
- package/src/util/data-converter.spec.ts +872 -0
- package/src/util/data-converter.ts +389 -0
- package/src/util/federation.ts +172 -0
- package/src/util/flexplm-connect.ts +169 -0
- package/src/util/logger-config.ts +20 -0
- package/src/util/map-util-spec-mockData.ts +231 -0
- package/src/util/map-utils.spec.ts +103 -0
- package/src/util/map-utils.ts +40 -0
- package/src/util/mockData.ts +98 -0
- package/src/util/thumbnail-util.spec.ts +152 -0
- package/src/util/thumbnail-util.ts +128 -0
- package/src/util/type-conversion-utils-spec-mockData.ts +238 -0
- package/src/util/type-conversion-utils.spec.ts +601 -0
- package/src/util/type-conversion-utils.ts +345 -0
- package/src/util/type-defaults.spec.ts +592 -0
- package/src/util/type-defaults.ts +261 -0
- package/src/util/type-utils.spec.ts +227 -0
- package/src/util/type-utils.ts +124 -0
- package/tsconfig.json +27 -0
- package/tslint.json +57 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { FCConfig, EntityPayloadType } from '../interfaces/interfaces';
|
|
2
|
+
import { DataConverter } from '../util/data-converter';
|
|
3
|
+
import { TypeUtils } from '../util/type-utils';
|
|
4
|
+
import { FlexPLMConnect,} from '../util/flexplm-connect';
|
|
5
|
+
import { MapUtil } from '../util/map-utils';
|
|
6
|
+
import { MapFileUtil } from '@contrail/transform-data';
|
|
7
|
+
import { Entities } from '@contrail/sdk';
|
|
8
|
+
import { TypeConversionUtils } from '../util/type-conversion-utils';
|
|
9
|
+
|
|
10
|
+
const UNSUPPORTED_TYPE = 'Unsupported eventType.';
|
|
11
|
+
export class IncomingEntityResponse {
|
|
12
|
+
entity: any
|
|
13
|
+
earlyReturn: any
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export abstract class BaseEntityProcessor {
|
|
17
|
+
protected typeUtil: TypeUtils;
|
|
18
|
+
protected transformMapFile: string;
|
|
19
|
+
protected entities;
|
|
20
|
+
constructor(
|
|
21
|
+
protected config: FCConfig,
|
|
22
|
+
protected dc: DataConverter,
|
|
23
|
+
protected mapFileUtil: MapFileUtil,
|
|
24
|
+
protected baseType: string
|
|
25
|
+
) {
|
|
26
|
+
this.typeUtil = new TypeUtils();
|
|
27
|
+
this.transformMapFile = this.config['transformMapFile'];
|
|
28
|
+
this.entities = new Entities();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// inbound
|
|
32
|
+
async inbound(event: EntityPayloadType) {
|
|
33
|
+
const eventType = event.eventType;
|
|
34
|
+
console.log(`inbound entity: ${eventType}:${event.objectClass}`);
|
|
35
|
+
|
|
36
|
+
switch (eventType) {
|
|
37
|
+
case 'PERSIST':
|
|
38
|
+
return await this.handleIncomingUpdate(event);
|
|
39
|
+
case 'DELETE':
|
|
40
|
+
return await this.handleIncomingDelete(event);
|
|
41
|
+
default:
|
|
42
|
+
console.error(UNSUPPORTED_TYPE);
|
|
43
|
+
return {
|
|
44
|
+
status: 500,
|
|
45
|
+
data: { UNSUPPORTED_TYPE }
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async handleIncomingUpdate (event: EntityPayloadType) {
|
|
51
|
+
const inboundData = await this.getTransformedData(event);
|
|
52
|
+
const incomingEntityResponse = await this.getIncomingEntity(event, inboundData);
|
|
53
|
+
// This case means there was an early return in the getIncomingEntity method
|
|
54
|
+
if (incomingEntityResponse.earlyReturn) {
|
|
55
|
+
return incomingEntityResponse.earlyReturn;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const entity = incomingEntityResponse.entity;
|
|
59
|
+
if(!entity){
|
|
60
|
+
const message = 'No entity found';
|
|
61
|
+
console.debug(message);
|
|
62
|
+
return {
|
|
63
|
+
status: 404,
|
|
64
|
+
data: {message}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const diffs = await this.getUpdatesForEntity(entity, inboundData);
|
|
69
|
+
if(Object.getOwnPropertyNames(diffs).length == 0){
|
|
70
|
+
const message = 'No Changes to persist for entity: ' + entity.id;
|
|
71
|
+
console.log(message);
|
|
72
|
+
return {
|
|
73
|
+
status: 200,
|
|
74
|
+
data: {message}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return this.updateEntity(this.baseType, entity, diffs);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async handleIncomingDelete(event) {
|
|
82
|
+
console.warn('delete is not configured', event);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async getTransformedData(event) {
|
|
86
|
+
let inboundData = event.data;
|
|
87
|
+
console.debug('inboundData: ' + JSON.stringify(inboundData));
|
|
88
|
+
|
|
89
|
+
const objectClass = event.objectClass;
|
|
90
|
+
inboundData = await MapUtil.applyTransformMap(this.transformMapFile, this.mapFileUtil, inboundData, objectClass, 'flex2vibe');
|
|
91
|
+
console.debug('Transformed-inboundData: ' + JSON.stringify(inboundData));
|
|
92
|
+
return inboundData;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async getUpdatesForEntity(entity, inboundData) {
|
|
96
|
+
const vibeOwningKeys = await this.getVibeOwningKeys(entity);
|
|
97
|
+
let updates = {
|
|
98
|
+
typeId: entity.typeId,
|
|
99
|
+
roles: entity.roles,
|
|
100
|
+
id: entity.id,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
updates = await this.dc.setEntityValues(updates, inboundData, vibeOwningKeys);
|
|
104
|
+
for(const prop of ['typeId', 'roles', 'id']){
|
|
105
|
+
delete updates[prop];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return this.dc.getPersistableChanges(entity, updates);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async getVibeOwningKeys(entity) {
|
|
112
|
+
let vibeOwningKeys = [];
|
|
113
|
+
if (this.transformMapFile) {
|
|
114
|
+
//Technically the transform is flex->vibe. But the vibe entity being updated was passed in,
|
|
115
|
+
// so we use VIBE2FLEX_DIRECTION to get the mapKey
|
|
116
|
+
const mapKey = await TypeConversionUtils.getMapKey(this.transformMapFile, this.mapFileUtil, entity, TypeConversionUtils.VIBE2FLEX_DIRECTION);
|
|
117
|
+
|
|
118
|
+
const mapSection = await MapUtil.getFullMapSection(this.transformMapFile, this.mapFileUtil, mapKey);
|
|
119
|
+
vibeOwningKeys = mapSection?.vibeOwningKeys || [];
|
|
120
|
+
}
|
|
121
|
+
console.debug('vibeOwningKeys: ' + vibeOwningKeys);
|
|
122
|
+
return vibeOwningKeys;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async updateEntity(entityName, entity, diffs) {
|
|
126
|
+
const options = {
|
|
127
|
+
entityName: entityName,
|
|
128
|
+
id: entity['id'],
|
|
129
|
+
object: diffs
|
|
130
|
+
};
|
|
131
|
+
console.log('options: ' + JSON.stringify(options));
|
|
132
|
+
|
|
133
|
+
return await new Entities().update(options);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// This method must be implemented by derived classes
|
|
137
|
+
protected abstract getIncomingEntity(event, inboundData): Promise<IncomingEntityResponse>;
|
|
138
|
+
|
|
139
|
+
// outbound
|
|
140
|
+
|
|
141
|
+
async outbound(event) {
|
|
142
|
+
const entityType = event.entityType;
|
|
143
|
+
const eventType = event.eventType;
|
|
144
|
+
const entityId = event.id;
|
|
145
|
+
console.log(`outbound: ${entityType}:${entityId}`);
|
|
146
|
+
|
|
147
|
+
switch (eventType) {
|
|
148
|
+
case 'update':
|
|
149
|
+
case 'create':
|
|
150
|
+
return await this.handleOutgoingUpsert(entityType, event);
|
|
151
|
+
case 'delete':
|
|
152
|
+
return await this.handleOutgoingDelete(entityType, event);
|
|
153
|
+
default:
|
|
154
|
+
console.log(UNSUPPORTED_TYPE);
|
|
155
|
+
return {
|
|
156
|
+
status: 500,
|
|
157
|
+
data: { UNSUPPORTED_TYPE }
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async handleOutgoingUpsert(entityType, event) {
|
|
163
|
+
const objectClass = this.typeUtil.getEventObjectClass(entityType, event.newData);
|
|
164
|
+
if (!objectClass) {
|
|
165
|
+
const message = 'ObjectClass must have a value.';
|
|
166
|
+
console.log(message);
|
|
167
|
+
return {
|
|
168
|
+
status: 500,
|
|
169
|
+
data: { message }
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const payload = await this.getOutgoingUpsertPayload(entityType, event);
|
|
174
|
+
return await new FlexPLMConnect(this.config).sendToFlexPLM(payload);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async handleOutgoingDelete(entityType, event) {
|
|
178
|
+
console.warn('delete is not configured', entityType, event.oldData);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// This method must be implemented by derived classes
|
|
182
|
+
protected abstract getOutgoingUpsertPayload(entityType, event): Promise<EntityPayloadType>;
|
|
183
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import axios, { AxiosRequestConfig } from 'axios';
|
|
2
|
+
|
|
3
|
+
const BASE_URL: string = 'https://PP-2006031951wo.portal.ptc.io/Windchill/servlet/rest/cdee';
|
|
4
|
+
const BASE_CONFIG: AxiosRequestConfig = {
|
|
5
|
+
method: 'POST',
|
|
6
|
+
headers: {
|
|
7
|
+
'Accept': 'application/json',
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
'CSRF_NONCE': '2OaLp+0dWNBtrkTwtdDC491zaacu6Hykvqi/lpl6bZgJ/QXBrK/B1J5FErMkmAmktr/I3thcbO1Xn3HJ7Ne/l9kpaedUmn7H75Xey4ZbNLsenW+anM3vxIZ7ELosk3k=',
|
|
10
|
+
'Authorization': 'Basic d2NhZG1pbjpSZXRhaWwyMDIwLQ==',
|
|
11
|
+
'Cookie': 'JSESSIONID=36D5B3C74C1F963C6C73E9AF5B6BDA78.tomcat1; JSESSIONID=B8090C802D8548EA773C97F5886FAB79.tomcat1',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export class FlexPLMRequest {
|
|
16
|
+
static async request(path: string, data: any){
|
|
17
|
+
const config = Object.assign({}, BASE_CONFIG);
|
|
18
|
+
config.url = BASE_URL + path;
|
|
19
|
+
config.data = data;
|
|
20
|
+
try {
|
|
21
|
+
const resp = await axios(config);
|
|
22
|
+
return Promise.resolve(resp.data);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error(`${FlexPLMRequest} error: ${error.message}`);
|
|
25
|
+
return Promise.resolve(null);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FlexPLMUtils } from './flexplm-utils';
|
|
2
|
+
|
|
3
|
+
describe('Types Controller', () => {
|
|
4
|
+
|
|
5
|
+
beforeEach(async () => {
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('should convert a type path', () => {
|
|
9
|
+
expect(FlexPLMUtils.convertTypePath('Product')).toEqual('product');
|
|
10
|
+
expect(FlexPLMUtils.convertTypePath('Product\\Apparel')).toEqual('product:apparel');
|
|
11
|
+
expect(FlexPLMUtils.convertTypePath('Product\\Skin Care')).toEqual('product:skin_care');
|
|
12
|
+
expect(FlexPLMUtils.convertTypePath('Product\\Apparel\\Shirt')).toEqual('product:apparel:shirt');
|
|
13
|
+
expect(FlexPLMUtils.convertTypePath('Product\\Apparel\\[Shirt]')).toEqual('product:apparel:*shirt*');
|
|
14
|
+
expect(FlexPLMUtils.convertTypePath('')).toBeNull();
|
|
15
|
+
});
|
|
16
|
+
it('should compute level in tree', () => {
|
|
17
|
+
expect(FlexPLMUtils.computeLevelFromPath('product')).toEqual(1);
|
|
18
|
+
expect(FlexPLMUtils.computeLevelFromPath('product:apparel')).toEqual(2);
|
|
19
|
+
expect(FlexPLMUtils.computeLevelFromPath('product:apparel:dress:mini')).toEqual(4);
|
|
20
|
+
});
|
|
21
|
+
it('should get a parent type path', () => {
|
|
22
|
+
expect(FlexPLMUtils.getParentTypePath('product')).toBeNull();
|
|
23
|
+
expect(FlexPLMUtils.getParentTypePath('product:apparel')).toEqual('product');
|
|
24
|
+
expect(FlexPLMUtils.getParentTypePath('product:apparel:stuff')).toEqual('product:apparel');
|
|
25
|
+
expect(FlexPLMUtils.getParentTypePath('Product\\Apparel')).toEqual('product');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class FlexPLMUtils {
|
|
2
|
+
static convertTypePath = (path: string): string => {
|
|
3
|
+
if (!path) { return null; }
|
|
4
|
+
let newPath = path;
|
|
5
|
+
while (newPath.indexOf('\\') > 1) {
|
|
6
|
+
newPath = newPath.replace('\\', ':');
|
|
7
|
+
}
|
|
8
|
+
while (newPath.indexOf('[') > 1) {
|
|
9
|
+
newPath = newPath.replace('[', '*');
|
|
10
|
+
}
|
|
11
|
+
while (newPath.indexOf(']') > 1) {
|
|
12
|
+
newPath = newPath.replace(']', '*');
|
|
13
|
+
}
|
|
14
|
+
while (newPath.indexOf(' ') > 1) {
|
|
15
|
+
newPath = newPath.replace(' ', '_');
|
|
16
|
+
}
|
|
17
|
+
newPath = newPath.toLowerCase();
|
|
18
|
+
return newPath;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static getParentTypePath = (path: string): string => {
|
|
22
|
+
const newPath = FlexPLMUtils.convertTypePath(path);
|
|
23
|
+
return (!newPath || newPath.indexOf(':') < 0) ? null : newPath.substring(0, newPath.lastIndexOf(':'));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static computeLevelFromPath(path: string) {
|
|
27
|
+
return (path.match(/:/g) || []).length + 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './flexplm-request';
|
|
2
|
+
export * from './flexplm-utils';
|
|
3
|
+
export * from './util/config-defaults';
|
|
4
|
+
export * from './util/data-converter';
|
|
5
|
+
export * from './util/federation';
|
|
6
|
+
export * from './util/flexplm-connect';
|
|
7
|
+
export * from './interfaces/interfaces';
|
|
8
|
+
export * from './util/logger-config';
|
|
9
|
+
export * from './util/thumbnail-util';
|
|
10
|
+
export * from './util/type-conversion-utils';
|
|
11
|
+
export * from './util/type-defaults';
|
|
12
|
+
export * from './util/type-utils';
|
|
13
|
+
export * from './util/map-utils';
|
|
14
|
+
export * from './interfaces/interfaces';
|
|
15
|
+
export * from './interfaces/item-family-changes';
|
|
16
|
+
export * from './interfaces/publish-change-data';
|
|
17
|
+
export * from './publish/base-process-publish-assortment';
|
|
18
|
+
export * from './publish/base-process-publish-assortment-callback';
|
|
19
|
+
export * from './entity-processor/base-entity-processor';
|
|
20
|
+
export * from './transform/identifier-conversion';
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export interface FCConfig {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
orgSlug?: string;
|
|
4
|
+
action?: string;
|
|
5
|
+
configFile? :string;
|
|
6
|
+
eventObjectClassParam?: string;
|
|
7
|
+
eventFlexTypePathParam?: string;
|
|
8
|
+
flexplmConnect?: any;
|
|
9
|
+
taskId?: string;
|
|
10
|
+
apiHost: string;
|
|
11
|
+
userName(): string;
|
|
12
|
+
password(): string;
|
|
13
|
+
plmEnviornment?: string;
|
|
14
|
+
urlContext: string;
|
|
15
|
+
vibeEventEndpoint: string;
|
|
16
|
+
csrfEndpoint: string;
|
|
17
|
+
itemPreDevelopmentLifecycleStages: string[];
|
|
18
|
+
identifierAtts?: {
|
|
19
|
+
[key:string]: string[]
|
|
20
|
+
};
|
|
21
|
+
propertyMapping?: object;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ProductFederation {
|
|
25
|
+
entityReference: string;
|
|
26
|
+
objectClass: 'LCSProduct';
|
|
27
|
+
federatedId?: string;
|
|
28
|
+
flexPLMTypePath?: string;
|
|
29
|
+
vibeIQIdentifier?: string
|
|
30
|
+
}
|
|
31
|
+
export interface ProductData extends ProductFederation {
|
|
32
|
+
data: object;
|
|
33
|
+
productSeason: {
|
|
34
|
+
data: object;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface SeasonFederation {
|
|
39
|
+
entityReference: string;
|
|
40
|
+
objectClass: 'LCSSeason';
|
|
41
|
+
flexPLMSeasonName?: string;
|
|
42
|
+
federationId?: string;
|
|
43
|
+
flexPLMTypePath?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface SeasonGroupFederation {
|
|
47
|
+
entityReference: string;
|
|
48
|
+
objectClass: 'SeasonGroup';
|
|
49
|
+
seasonGroupName?: string;
|
|
50
|
+
federationId?: string;
|
|
51
|
+
flexPLMTypePath?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface SkuFederation {
|
|
55
|
+
entityReference: string;
|
|
56
|
+
objectClass: 'LCSSKU';
|
|
57
|
+
LCSProduct?: ProductFederation;
|
|
58
|
+
federatedId?: string;
|
|
59
|
+
flexPLMTypePath?: string;
|
|
60
|
+
vibeIQIdentifier?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface SkuData extends SkuFederation{
|
|
63
|
+
data: object;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface PayloadType {
|
|
67
|
+
eventType: string;
|
|
68
|
+
objectClass: string;
|
|
69
|
+
}
|
|
70
|
+
export interface AsyncPayloadType extends PayloadType {
|
|
71
|
+
taskId: string;
|
|
72
|
+
}
|
|
73
|
+
export interface AsyncEventsPayloadType extends AsyncPayloadType {
|
|
74
|
+
events?: PayloadType[];
|
|
75
|
+
eventsFileId?: string;
|
|
76
|
+
eventsDownloadLink?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface EntityPayloadType extends PayloadType {
|
|
80
|
+
entityReference: string;
|
|
81
|
+
federatedId?: string;
|
|
82
|
+
flexPLMTypePath?: string;
|
|
83
|
+
data: object;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface ItemPayloadType extends EntityPayloadType {
|
|
87
|
+
LCSProduct?: ProductFederation;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
91
|
+
///////// Custom seasonalPayload: start
|
|
92
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
93
|
+
export interface SeasonalPayload extends EntityPayloadType {
|
|
94
|
+
eventType: 'UPSERT_ON_SEASON' | 'REMOVE_FROM_SEASON';
|
|
95
|
+
objectClass: 'LCSProductSeasonLink' | 'LCSSKUSeasonLink';
|
|
96
|
+
LCSSeason : SeasonFederation;
|
|
97
|
+
LCSProduct? : ProductFederation;
|
|
98
|
+
LCSSKU? : SkuFederation;
|
|
99
|
+
carriedFromSeason? : object;
|
|
100
|
+
}
|
|
101
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
102
|
+
///////// Custom seasonalPayload: start
|
|
103
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
104
|
+
|
|
105
|
+
export interface ExportPayloadType extends AsyncPayloadType {
|
|
106
|
+
flexPLMTypePath: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface FederationRecord {
|
|
110
|
+
reference: string;
|
|
111
|
+
mappedReference: string
|
|
112
|
+
appIdentifier: string;
|
|
113
|
+
federationSchema: string
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface FlexPLMResponseData {
|
|
117
|
+
status: number;
|
|
118
|
+
data?: object;
|
|
119
|
+
error?: string;
|
|
120
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export class ItemFamilyChanges {
|
|
2
|
+
private _itemFamilyId:string;
|
|
3
|
+
public get itemFamilyId(){ return this._itemFamilyId; }
|
|
4
|
+
private _sinceDate:Date;
|
|
5
|
+
public get sinceDate(){ return this._sinceDate; }
|
|
6
|
+
|
|
7
|
+
familyAdd = false;
|
|
8
|
+
familyDelete = false;
|
|
9
|
+
familyUpdate = false;
|
|
10
|
+
familyItemRemoved = false;
|
|
11
|
+
itemFamilyObject = undefined;
|
|
12
|
+
|
|
13
|
+
colorAdds: string[] = [];
|
|
14
|
+
colorDeletes: string[] = [];
|
|
15
|
+
colorUpdates: string[] = [];
|
|
16
|
+
colorUnchanged: string[] = [];
|
|
17
|
+
|
|
18
|
+
assortmentItemFullChangeMap = new Map<string, any>();
|
|
19
|
+
assortmentItemDeleteMap = new Map<string, any>();
|
|
20
|
+
itemToFederatedIdMapping = new Map<string, string>();
|
|
21
|
+
constructor(itemFamilyId: string, sinceDate: Date){
|
|
22
|
+
this._itemFamilyId = itemFamilyId;
|
|
23
|
+
this._sinceDate = sinceDate;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public toString(): string{
|
|
27
|
+
let s = 'ItemFamilyChanges\n'
|
|
28
|
+
+ ' itemFamilyId: ' + this._itemFamilyId + '\n'
|
|
29
|
+
+ ' sinceDate: ' + this._sinceDate + '\n'
|
|
30
|
+
+ ' familyAdd: ' + this.familyAdd + '\n'
|
|
31
|
+
+ ' familyDelete: ' + this.familyDelete + '\n'
|
|
32
|
+
+ ' familyUpdate: ' + this.familyUpdate + '\n'
|
|
33
|
+
+ ' familyItemRemoved: ' + this.familyItemRemoved + '\n'
|
|
34
|
+
;
|
|
35
|
+
|
|
36
|
+
s += ' colorAdds: ['+ this.colorAdds + ']\n';
|
|
37
|
+
|
|
38
|
+
s += ' colorDeletes: ['+ this.colorDeletes + ']\n';
|
|
39
|
+
|
|
40
|
+
s += ' colorUpdates: ['+ this.colorUpdates + ']\n';
|
|
41
|
+
|
|
42
|
+
s += ' colorUnchanged: ['+ this.colorUnchanged + ']\n';
|
|
43
|
+
|
|
44
|
+
s += 'assortmentItemFullChangeMap:\n';
|
|
45
|
+
s += 'size: ' + this.assortmentItemFullChangeMap.size +'\n[';
|
|
46
|
+
for(const key of this.assortmentItemFullChangeMap.keys()){
|
|
47
|
+
s += key + ', ';
|
|
48
|
+
}
|
|
49
|
+
s += ']\n';
|
|
50
|
+
|
|
51
|
+
s += 'assortmentItemDeleteMap:\n';
|
|
52
|
+
s += 'size: ' + this.assortmentItemDeleteMap.size +'\n[';
|
|
53
|
+
for(const key of this.assortmentItemDeleteMap.keys()){
|
|
54
|
+
s += key + ', ';
|
|
55
|
+
}
|
|
56
|
+
s += ']\n';
|
|
57
|
+
|
|
58
|
+
s += 'itemToFederatedIdMapping:\n';
|
|
59
|
+
s += 'size: ' + this.itemToFederatedIdMapping.size +'\n[';
|
|
60
|
+
for(const key of this.itemToFederatedIdMapping.keys()){
|
|
61
|
+
s += key + ', ';
|
|
62
|
+
}
|
|
63
|
+
s += ']\n';
|
|
64
|
+
|
|
65
|
+
return s;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SeasonFederation } from './interfaces';
|
|
2
|
+
import { ItemFamilyChanges } from './item-family-changes';
|
|
3
|
+
|
|
4
|
+
export class PublishChangeData {
|
|
5
|
+
|
|
6
|
+
private _assortmentId: string;
|
|
7
|
+
public get assortmentId(){ return this._assortmentId; }
|
|
8
|
+
private _seasonFed: SeasonFederation;
|
|
9
|
+
public get seasonFed() { return Object.assign({}, this._seasonFed); }
|
|
10
|
+
private _assortmentPublishChangeId: string;
|
|
11
|
+
public get assortmentPublishChangeId() { return this._assortmentPublishChangeId; }
|
|
12
|
+
private _sinceDate: Date;
|
|
13
|
+
public get sinceDate(){ return this._sinceDate; }
|
|
14
|
+
private _publisher: object;
|
|
15
|
+
public get publisher(){ return this._publisher; }
|
|
16
|
+
|
|
17
|
+
itemToFederatedIdMapping: Map<string, string>;
|
|
18
|
+
releasedForDevelopmentItemIds: string[] = [];
|
|
19
|
+
itemFamilyChanges = new Map<string, ItemFamilyChanges>();
|
|
20
|
+
constructor(_assortmentId: string, _seasonFed: SeasonFederation, _assortmentPublishChangeId: string, _sinceDate: Date, _publisher = {}) {
|
|
21
|
+
this._assortmentId = _assortmentId;
|
|
22
|
+
this._seasonFed = _seasonFed;
|
|
23
|
+
this._assortmentPublishChangeId = _assortmentPublishChangeId;
|
|
24
|
+
this._sinceDate = _sinceDate;
|
|
25
|
+
this._publisher = _publisher;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
toString(){
|
|
29
|
+
let s = 'PublishChangeData\n'
|
|
30
|
+
+ 'assortmentId: ' + this._assortmentId + '\n'
|
|
31
|
+
+ 'seasonFed: ' + JSON.stringify(this._seasonFed) + '\n'
|
|
32
|
+
+ 'assortmentPublishChangeId: ' + this._assortmentPublishChangeId + '\n'
|
|
33
|
+
;
|
|
34
|
+
|
|
35
|
+
s += ' itemToFederatedIdMapping: ' + JSON.stringify(Object.fromEntries(this.itemToFederatedIdMapping)) + '\n';
|
|
36
|
+
s += 'itemFamilyChanges:\n';
|
|
37
|
+
for(const [key, value] of this.itemFamilyChanges){
|
|
38
|
+
s += ' ' + key + ' => ' + value.toString();
|
|
39
|
+
}
|
|
40
|
+
return s;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FCConfig } from '../interfaces/interfaces';
|
|
2
|
+
|
|
3
|
+
export class BaseProcessPublishAssortmentCallback {
|
|
4
|
+
private config: FCConfig;
|
|
5
|
+
|
|
6
|
+
constructor(_config:FCConfig){
|
|
7
|
+
this.config = _config;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public async process(event){
|
|
11
|
+
console.log('ProcessPublishAssortmentCallback-process()');
|
|
12
|
+
|
|
13
|
+
console.log('ProcessPublishAssortmentCallback-event: ' + JSON.stringify(event));
|
|
14
|
+
console.log('ProcessPublishAssortmentCallback-config: ' + JSON.stringify(this.config));
|
|
15
|
+
|
|
16
|
+
const statusCounts = this.config['statusCounts'];
|
|
17
|
+
console.log('statusCounts: ' + JSON.stringify(statusCounts));
|
|
18
|
+
return {
|
|
19
|
+
message: 'Done ProcessPublishAssortmentCallback-process()'
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|