@contrail/flexplm 1.1.26 → 1.1.27
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/error-response-object.spec.ts +13 -0
- package/error-response-object.ts +38 -0
- package/lib/entity-processor/base-entity-processor.d.ts +2 -2
- package/lib/entity-processor/base-entity-processor.js +8 -1
- package/lib/publish/base-process-publish-assortment-callback.d.ts +2 -1
- package/lib/publish/base-process-publish-assortment-callback.js +21 -6
- package/package.json +2 -2
- package/src/entity-processor/base-entity-processor.ts +10 -1
- package/src/publish/base-process-publish-assortment-callback.ts +32 -10
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AppActionCallbackStatus } from "@contrail/app-framework";
|
|
2
|
+
import { ErrorResponseObject } from "./error-response-object";
|
|
3
|
+
|
|
4
|
+
describe('getResponse() Tests', () =>{
|
|
5
|
+
it('status set', () => {
|
|
6
|
+
const e = {
|
|
7
|
+
message: 'Test'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const response = ErrorResponseObject.getResponse(e);
|
|
11
|
+
expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
|
|
12
|
+
})
|
|
13
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AppActionCallBack, AppActionCallbackStatus } from "@contrail/app-framework";
|
|
2
|
+
|
|
3
|
+
export class ErrorResponseObject {
|
|
4
|
+
|
|
5
|
+
/** Returns a response, checking for multiple possible error details
|
|
6
|
+
*
|
|
7
|
+
* @param e
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
public static getResponse(e): AppActionCallBack {
|
|
11
|
+
const response: AppActionCallBack = {
|
|
12
|
+
status: AppActionCallbackStatus.FAILURE,
|
|
13
|
+
output: {
|
|
14
|
+
message: e.message
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
if(!e){
|
|
18
|
+
return response;
|
|
19
|
+
}
|
|
20
|
+
const output = response.output;
|
|
21
|
+
|
|
22
|
+
//Errors when persisting in VibeIQ
|
|
23
|
+
if(e?.details){
|
|
24
|
+
output.errorDetails = e.details;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//Has original cause
|
|
28
|
+
if(e?.cause){
|
|
29
|
+
const cause = {
|
|
30
|
+
code: e.cause.code,
|
|
31
|
+
message: e.cause.message,
|
|
32
|
+
};
|
|
33
|
+
output.cause = cause;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return response;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -26,8 +26,8 @@ export declare abstract class BaseEntityProcessor {
|
|
|
26
26
|
updateEntity(entityName: any, entity: any, diffs: any): Promise<any>;
|
|
27
27
|
protected abstract getIncomingEntity(event: any, inboundData: any): Promise<IncomingEntityResponse>;
|
|
28
28
|
protected abstract getCreateEntity(inboundData: any): Promise<IncomingEntityResponse>;
|
|
29
|
-
outbound(event: any): Promise<
|
|
30
|
-
handleOutgoingUpsert(entityType: any, event: any): Promise<
|
|
29
|
+
outbound(event: any): Promise<any>;
|
|
30
|
+
handleOutgoingUpsert(entityType: any, event: any): Promise<any>;
|
|
31
31
|
handleOutgoingDelete(entityType: any, event: any): Promise<void>;
|
|
32
32
|
protected abstract getOutgoingUpsertPayload(entityType: any, event: any): Promise<EntityPayloadType>;
|
|
33
33
|
}
|
|
@@ -152,7 +152,14 @@ class BaseEntityProcessor {
|
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
const payload = await this.getOutgoingUpsertPayload(entityType, event);
|
|
155
|
-
|
|
155
|
+
const flexResponse = await new flexplm_connect_1.FlexPLMConnect(this.config).sendToFlexPLM(payload);
|
|
156
|
+
const flexPayload = flexResponse?.results?.data?.payload[0];
|
|
157
|
+
if (flexPayload) {
|
|
158
|
+
const inboundData = await this.getTransformedData(flexPayload);
|
|
159
|
+
const inboundEntityUpdates = await this.getUpdatesForEntity(event.newData, inboundData);
|
|
160
|
+
flexResponse['inboundEntityUpdates'] = inboundEntityUpdates;
|
|
161
|
+
}
|
|
162
|
+
return flexResponse;
|
|
156
163
|
}
|
|
157
164
|
async handleOutgoingDelete(entityType, event) {
|
|
158
165
|
console.warn('delete is not configured', entityType, event.oldData);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { FCConfig } from
|
|
1
|
+
import { FCConfig } from "../interfaces/interfaces";
|
|
2
2
|
export declare class BaseProcessPublishAssortmentCallback {
|
|
3
3
|
private config;
|
|
4
4
|
constructor(_config: FCConfig);
|
|
5
5
|
process(event: any): Promise<{
|
|
6
6
|
message: string;
|
|
7
7
|
}>;
|
|
8
|
+
private checkFailuresAndSendNotification;
|
|
8
9
|
}
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseProcessPublishAssortmentCallback = void 0;
|
|
4
|
+
const sdk_1 = require("@contrail/sdk");
|
|
4
5
|
class BaseProcessPublishAssortmentCallback {
|
|
5
6
|
constructor(_config) {
|
|
6
7
|
this.config = _config;
|
|
7
8
|
}
|
|
8
9
|
async process(event) {
|
|
9
|
-
console.log(
|
|
10
|
-
console.log(
|
|
11
|
-
console.log(
|
|
12
|
-
const statusCounts = this.config[
|
|
13
|
-
console.log(
|
|
10
|
+
console.log("ProcessPublishAssortmentCallback-process()");
|
|
11
|
+
console.log("ProcessPublishAssortmentCallback-event: " + JSON.stringify(event));
|
|
12
|
+
console.log("ProcessPublishAssortmentCallback-config: " + JSON.stringify(this.config));
|
|
13
|
+
const statusCounts = this.config["statusCounts"];
|
|
14
|
+
console.log("statusCounts: " + JSON.stringify(statusCounts));
|
|
15
|
+
this.checkFailuresAndSendNotification(event);
|
|
14
16
|
return {
|
|
15
|
-
message:
|
|
17
|
+
message: "Done ProcessPublishAssortmentCallback-process()",
|
|
16
18
|
};
|
|
17
19
|
}
|
|
20
|
+
checkFailuresAndSendNotification(event) {
|
|
21
|
+
const statusCounts = JSON.parse(this.config["statusCounts"]);
|
|
22
|
+
if (statusCounts["INVALID"] > 0 || statusCounts["FAILURE"] > 0) {
|
|
23
|
+
new sdk_1.Notification().Dispatch({
|
|
24
|
+
message: `There were errors when publishing the season data. Please review the event and config information from context.`,
|
|
25
|
+
level: sdk_1.LogLevel.WARN,
|
|
26
|
+
context: {
|
|
27
|
+
event,
|
|
28
|
+
config: this.config,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
18
33
|
}
|
|
19
34
|
exports.BaseProcessPublishAssortmentCallback = BaseProcessPublishAssortmentCallback;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/flexplm",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.27",
|
|
4
4
|
"description": "Library used for integration with flexplm.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@contrail/app-framework": "^1.2.4",
|
|
42
|
-
"@contrail/sdk": "^1.3.
|
|
42
|
+
"@contrail/sdk": "^1.3.7",
|
|
43
43
|
"@contrail/transform-data": "^1.0.14",
|
|
44
44
|
"axios": "^1.4.0",
|
|
45
45
|
"p-limit": "^3.1.0"
|
|
@@ -197,7 +197,16 @@ export abstract class BaseEntityProcessor {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
const payload = await this.getOutgoingUpsertPayload(entityType, event);
|
|
200
|
-
|
|
200
|
+
const flexResponse: any = await new FlexPLMConnect(this.config).sendToFlexPLM(payload);
|
|
201
|
+
|
|
202
|
+
const flexPayload = flexResponse?.results?.data?.payload[0];
|
|
203
|
+
if(flexPayload) {
|
|
204
|
+
const inboundData = await this.getTransformedData(flexPayload);
|
|
205
|
+
const inboundEntityUpdates = await this.getUpdatesForEntity(event.newData, inboundData)
|
|
206
|
+
flexResponse['inboundEntityUpdates'] = inboundEntityUpdates;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return flexResponse;
|
|
201
210
|
}
|
|
202
211
|
|
|
203
212
|
async handleOutgoingDelete(entityType, event) {
|
|
@@ -1,23 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LogLevel, Notification } from "@contrail/sdk";
|
|
2
|
+
import { FCConfig } from "../interfaces/interfaces";
|
|
2
3
|
|
|
3
4
|
export class BaseProcessPublishAssortmentCallback {
|
|
4
5
|
private config: FCConfig;
|
|
5
6
|
|
|
6
|
-
constructor(_config:FCConfig){
|
|
7
|
+
constructor(_config: FCConfig) {
|
|
7
8
|
this.config = _config;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
public async process(event){
|
|
11
|
-
console.log(
|
|
11
|
+
public async process(event) {
|
|
12
|
+
console.log("ProcessPublishAssortmentCallback-process()");
|
|
12
13
|
|
|
13
|
-
console.log(
|
|
14
|
-
|
|
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
|
+
this.checkFailuresAndSendNotification(event);
|
|
15
25
|
|
|
16
|
-
const statusCounts = this.config['statusCounts'];
|
|
17
|
-
console.log('statusCounts: ' + JSON.stringify(statusCounts));
|
|
18
26
|
return {
|
|
19
|
-
message:
|
|
27
|
+
message: "Done ProcessPublishAssortmentCallback-process()",
|
|
20
28
|
};
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
|
|
31
|
+
private checkFailuresAndSendNotification(event) {
|
|
32
|
+
const statusCounts = JSON.parse(this.config["statusCounts"]);
|
|
33
|
+
|
|
34
|
+
if (statusCounts["INVALID"] > 0 || statusCounts["FAILURE"] > 0) {
|
|
35
|
+
new Notification().Dispatch({
|
|
36
|
+
message: `There were errors when publishing the season data. Please review the event and config information from context.`,
|
|
37
|
+
level: LogLevel.WARN,
|
|
38
|
+
context: {
|
|
39
|
+
event,
|
|
40
|
+
config: this.config,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|