@contrail/flexplm 1.2.1 → 1.3.0-alpha.3
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/.claude/settings.local.json +1 -2
- package/.github/pull_request_template.md +31 -31
- package/.github/workflows/flexplm-lib.yml +27 -27
- package/lib/entity-processor/base-entity-processor.js +16 -2
- package/lib/entity-processor/base-entity-processor.spec.js +124 -0
- package/lib/util/flexplm-connect.d.ts +5 -1
- package/lib/util/flexplm-connect.js +8 -3
- package/lib/util/flexplm-connect.spec.d.ts +1 -0
- package/lib/util/flexplm-connect.spec.js +88 -0
- package/lib/util/thumbnail-util.d.ts +9 -0
- package/lib/util/thumbnail-util.js +88 -0
- package/lib/util/thumbnail-util.spec.js +156 -0
- package/lib/util/type-conversion-utils-spec-mockData.js +18 -0
- package/lib/util/type-conversion-utils.d.ts +2 -0
- package/lib/util/type-conversion-utils.js +43 -0
- package/lib/util/type-conversion-utils.spec.js +160 -0
- package/package.json +1 -1
- package/publish.bat +4 -4
- package/publish.sh +4 -4
- package/src/entity-processor/base-entity-processor.spec.ts +157 -0
- package/src/entity-processor/base-entity-processor.ts +21 -2
- package/src/flexplm-request.ts +28 -28
- package/src/flexplm-utils.spec.ts +27 -27
- package/src/flexplm-utils.ts +29 -29
- package/src/index.ts +21 -21
- package/src/interfaces/item-family-changes.ts +66 -66
- package/src/interfaces/publish-change-data.ts +42 -42
- package/src/publish/base-process-publish-assortment-callback.ts +50 -50
- package/src/transform/identifier-conversion-spec-mockData.ts +495 -495
- package/src/transform/identifier-conversion.spec.ts +353 -353
- package/src/transform/identifier-conversion.ts +281 -281
- package/src/util/config-defaults.spec.ts +350 -350
- package/src/util/config-defaults.ts +92 -92
- package/src/util/data-converter-spec-mockData.ts +230 -230
- package/src/util/error-response-object.spec.ts +115 -115
- package/src/util/error-response-object.ts +49 -49
- package/src/util/federation.ts +172 -172
- package/src/util/flexplm-connect.spec.ts +132 -0
- package/src/util/flexplm-connect.ts +14 -5
- package/src/util/logger-config.ts +19 -19
- package/src/util/map-util-spec-mockData.ts +230 -230
- package/src/util/map-utils.spec.ts +102 -102
- package/src/util/map-utils.ts +40 -40
- package/src/util/mockData.ts +97 -97
- package/src/util/thumbnail-util.spec.ts +190 -0
- package/src/util/thumbnail-util.ts +109 -1
- package/src/util/type-conversion-utils-spec-mockData.ts +18 -0
- package/src/util/type-conversion-utils.spec.ts +184 -0
- package/src/util/type-conversion-utils.ts +75 -0
- package/src/util/type-defaults.spec.ts +668 -668
- package/src/util/type-defaults.ts +280 -280
- package/src/util/type-utils.spec.ts +227 -227
- package/src/util/type-utils.ts +144 -144
- package/tsconfig.json +28 -26
- package/tslint.json +57 -57
- package/scripts/output.png +0 -0
- package/scripts/test-get-request.ts +0 -35
|
@@ -7,6 +7,7 @@ import { MapFileUtil } from '@contrail/transform-data';
|
|
|
7
7
|
import { Entities } from '@contrail/sdk';
|
|
8
8
|
import { TypeProperty } from '@contrail/types';
|
|
9
9
|
import { TypeConversionUtils } from '../util/type-conversion-utils';
|
|
10
|
+
import { ThumbnailUtil } from '../util/thumbnail-util';
|
|
10
11
|
import { EventShortMessageStatus } from '../util/event-short-message-status';
|
|
11
12
|
|
|
12
13
|
const UNSUPPORTED_TYPE = 'Unsupported eventType.';
|
|
@@ -84,6 +85,15 @@ export abstract class BaseEntityProcessor {
|
|
|
84
85
|
return createEntityResponse.earlyReturn;
|
|
85
86
|
}
|
|
86
87
|
const createdEntity = await this.createEntity(this.baseType, createEntityResponse.entity);
|
|
88
|
+
const shouldSyncThumbnail = await TypeConversionUtils.syncInboundImages(
|
|
89
|
+
this.transformMapFile, this.mapFileUtil, event.data
|
|
90
|
+
);
|
|
91
|
+
if (shouldSyncThumbnail) {
|
|
92
|
+
const thumbnailUpdates = await new ThumbnailUtil(this.config).syncThumbnailToVibeIQ({ entityId: createdEntity.id, primaryViewableId: createdEntity.primaryViewableId, event, entityName: this.baseType });
|
|
93
|
+
if (thumbnailUpdates) {
|
|
94
|
+
await this.updateEntity(this.baseType, createdEntity, thumbnailUpdates);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
87
97
|
const statusMsg = this.getInboundStatusMessage({
|
|
88
98
|
status: EventShortMessageStatus.SUCCESS,
|
|
89
99
|
statusMessage: EventShortMessageStatus.CREATED,
|
|
@@ -96,7 +106,16 @@ export abstract class BaseEntityProcessor {
|
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
const diffs = await this.getUpdatesForEntity(entity, inboundData);
|
|
99
|
-
|
|
109
|
+
const shouldSyncThumbnail = await TypeConversionUtils.syncInboundImages(
|
|
110
|
+
this.transformMapFile, this.mapFileUtil, event.data
|
|
111
|
+
);
|
|
112
|
+
let thumbnailUpdates;
|
|
113
|
+
if (shouldSyncThumbnail) {
|
|
114
|
+
thumbnailUpdates = await new ThumbnailUtil(this.config).syncThumbnailToVibeIQ({ entityId: entity.id, primaryViewableId: entity.primaryViewableId, event, entityName: this.baseType });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const allUpdates = { ...diffs, ...thumbnailUpdates };
|
|
118
|
+
if(Object.getOwnPropertyNames(allUpdates).length == 0){
|
|
100
119
|
const statusMsg = this.getInboundStatusMessage({
|
|
101
120
|
status: EventShortMessageStatus.SUCCESS,
|
|
102
121
|
statusMessage: EventShortMessageStatus.NO_CHANGES,
|
|
@@ -112,7 +131,7 @@ export abstract class BaseEntityProcessor {
|
|
|
112
131
|
};
|
|
113
132
|
}
|
|
114
133
|
|
|
115
|
-
const updatedEntity = await this.updateEntity(this.baseType, entity,
|
|
134
|
+
const updatedEntity = await this.updateEntity(this.baseType, entity, allUpdates);
|
|
116
135
|
const statusMsg = this.getInboundStatusMessage({
|
|
117
136
|
status: EventShortMessageStatus.SUCCESS,
|
|
118
137
|
statusMessage: EventShortMessageStatus.UPDATED,
|
package/src/flexplm-request.ts
CHANGED
|
@@ -1,28 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,27 +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
|
-
});
|
|
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
|
+
});
|
package/src/flexplm-utils.ts
CHANGED
|
@@ -1,29 +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
|
-
}
|
|
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
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
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/error-response-object';
|
|
6
|
-
export * from './util/event-short-message-status';
|
|
7
|
-
export * from './util/federation';
|
|
8
|
-
export * from './util/flexplm-connect';
|
|
9
|
-
export * from './interfaces/interfaces';
|
|
10
|
-
export * from './util/logger-config';
|
|
11
|
-
export * from './util/thumbnail-util';
|
|
12
|
-
export * from './util/type-conversion-utils';
|
|
13
|
-
export * from './util/type-defaults';
|
|
14
|
-
export * from './util/type-utils';
|
|
15
|
-
export * from './util/map-utils';
|
|
16
|
-
export * from './interfaces/interfaces';
|
|
17
|
-
export * from './interfaces/item-family-changes';
|
|
18
|
-
export * from './interfaces/publish-change-data';
|
|
19
|
-
export * from './publish/base-process-publish-assortment';
|
|
20
|
-
export * from './publish/base-process-publish-assortment-callback';
|
|
21
|
-
export * from './entity-processor/base-entity-processor';
|
|
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/error-response-object';
|
|
6
|
+
export * from './util/event-short-message-status';
|
|
7
|
+
export * from './util/federation';
|
|
8
|
+
export * from './util/flexplm-connect';
|
|
9
|
+
export * from './interfaces/interfaces';
|
|
10
|
+
export * from './util/logger-config';
|
|
11
|
+
export * from './util/thumbnail-util';
|
|
12
|
+
export * from './util/type-conversion-utils';
|
|
13
|
+
export * from './util/type-defaults';
|
|
14
|
+
export * from './util/type-utils';
|
|
15
|
+
export * from './util/map-utils';
|
|
16
|
+
export * from './interfaces/interfaces';
|
|
17
|
+
export * from './interfaces/item-family-changes';
|
|
18
|
+
export * from './interfaces/publish-change-data';
|
|
19
|
+
export * from './publish/base-process-publish-assortment';
|
|
20
|
+
export * from './publish/base-process-publish-assortment-callback';
|
|
21
|
+
export * from './entity-processor/base-entity-processor';
|
|
22
22
|
export * from './transform/identifier-conversion';
|
|
@@ -1,67 +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
|
-
}
|
|
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
67
|
}
|
|
@@ -1,43 +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
|
-
|
|
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
43
|
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { LogLevel, Notification } from "@contrail/sdk";
|
|
2
|
-
import { FCConfig } from "../interfaces/interfaces";
|
|
3
|
-
|
|
4
|
-
export class BaseProcessPublishAssortmentCallback {
|
|
5
|
-
private config: FCConfig;
|
|
6
|
-
|
|
7
|
-
constructor(_config: FCConfig) {
|
|
8
|
-
this.config = _config;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
public async process(event) {
|
|
12
|
-
console.log("ProcessPublishAssortmentCallback-process()");
|
|
13
|
-
|
|
14
|
-
console.log(
|
|
15
|
-
"ProcessPublishAssortmentCallback-event: " + JSON.stringify(event)
|
|
16
|
-
);
|
|
17
|
-
console.log(
|
|
18
|
-
"ProcessPublishAssortmentCallback-config: " + JSON.stringify(this.config)
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const statusCounts = this.config["statusCounts"];
|
|
22
|
-
console.log("statusCounts: " + JSON.stringify(statusCounts));
|
|
23
|
-
|
|
24
|
-
const statMessage =(statusCounts && 'undefined' !== statusCounts)
|
|
25
|
-
?await this.checkFailuresAndSendNotification(event)
|
|
26
|
-
:'no statusCount';
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
message: "Done ProcessPublishAssortmentCallback-process(): " + statMessage,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private async checkFailuresAndSendNotification(event): Promise<string> {
|
|
34
|
-
const statusCounts = JSON.parse(this.config["statusCounts"]);
|
|
35
|
-
|
|
36
|
-
if (statusCounts["INVALID"] > 0 || statusCounts["FAILURE"] > 0) {
|
|
37
|
-
await new Notification().Dispatch({
|
|
38
|
-
message: `There were errors when publishing the season data. Please review the event and config information from context.`,
|
|
39
|
-
level: LogLevel.WARN,
|
|
40
|
-
context: {
|
|
41
|
-
event,
|
|
42
|
-
config: this.config,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
return 'sent notification';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return 'no notification needed';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
import { LogLevel, Notification } from "@contrail/sdk";
|
|
2
|
+
import { FCConfig } from "../interfaces/interfaces";
|
|
3
|
+
|
|
4
|
+
export class BaseProcessPublishAssortmentCallback {
|
|
5
|
+
private config: FCConfig;
|
|
6
|
+
|
|
7
|
+
constructor(_config: FCConfig) {
|
|
8
|
+
this.config = _config;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public async process(event) {
|
|
12
|
+
console.log("ProcessPublishAssortmentCallback-process()");
|
|
13
|
+
|
|
14
|
+
console.log(
|
|
15
|
+
"ProcessPublishAssortmentCallback-event: " + JSON.stringify(event)
|
|
16
|
+
);
|
|
17
|
+
console.log(
|
|
18
|
+
"ProcessPublishAssortmentCallback-config: " + JSON.stringify(this.config)
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const statusCounts = this.config["statusCounts"];
|
|
22
|
+
console.log("statusCounts: " + JSON.stringify(statusCounts));
|
|
23
|
+
|
|
24
|
+
const statMessage =(statusCounts && 'undefined' !== statusCounts)
|
|
25
|
+
?await this.checkFailuresAndSendNotification(event)
|
|
26
|
+
:'no statusCount';
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
message: "Done ProcessPublishAssortmentCallback-process(): " + statMessage,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private async checkFailuresAndSendNotification(event): Promise<string> {
|
|
34
|
+
const statusCounts = JSON.parse(this.config["statusCounts"]);
|
|
35
|
+
|
|
36
|
+
if (statusCounts["INVALID"] > 0 || statusCounts["FAILURE"] > 0) {
|
|
37
|
+
await new Notification().Dispatch({
|
|
38
|
+
message: `There were errors when publishing the season data. Please review the event and config information from context.`,
|
|
39
|
+
level: LogLevel.WARN,
|
|
40
|
+
context: {
|
|
41
|
+
event,
|
|
42
|
+
config: this.config,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
return 'sent notification';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return 'no notification needed';
|
|
49
|
+
}
|
|
50
|
+
}
|