@contrail/flexplm 1.1.30 → 1.1.31

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.
@@ -12,15 +12,17 @@ class BaseProcessPublishAssortmentCallback {
12
12
  console.log("ProcessPublishAssortmentCallback-config: " + JSON.stringify(this.config));
13
13
  const statusCounts = this.config["statusCounts"];
14
14
  console.log("statusCounts: " + JSON.stringify(statusCounts));
15
- this.checkFailuresAndSendNotification(event);
15
+ const statMessage = (statusCounts)
16
+ ? await this.checkFailuresAndSendNotification(event)
17
+ : 'no statusCount';
16
18
  return {
17
- message: "Done ProcessPublishAssortmentCallback-process()",
19
+ message: "Done ProcessPublishAssortmentCallback-process(): " + statMessage,
18
20
  };
19
21
  }
20
- checkFailuresAndSendNotification(event) {
22
+ async checkFailuresAndSendNotification(event) {
21
23
  const statusCounts = JSON.parse(this.config["statusCounts"]);
22
24
  if (statusCounts["INVALID"] > 0 || statusCounts["FAILURE"] > 0) {
23
- new sdk_1.Notification().Dispatch({
25
+ await new sdk_1.Notification().Dispatch({
24
26
  message: `There were errors when publishing the season data. Please review the event and config information from context.`,
25
27
  level: sdk_1.LogLevel.WARN,
26
28
  context: {
@@ -28,7 +30,9 @@ class BaseProcessPublishAssortmentCallback {
28
30
  config: this.config,
29
31
  },
30
32
  });
33
+ return 'sent notification';
31
34
  }
35
+ return 'no notification needed';
32
36
  }
33
37
  }
34
38
  exports.BaseProcessPublishAssortmentCallback = BaseProcessPublishAssortmentCallback;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.1.30",
3
+ "version": "1.1.31",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -21,18 +21,20 @@ export class BaseProcessPublishAssortmentCallback {
21
21
  const statusCounts = this.config["statusCounts"];
22
22
  console.log("statusCounts: " + JSON.stringify(statusCounts));
23
23
 
24
- this.checkFailuresAndSendNotification(event);
24
+ const statMessage =(statusCounts)
25
+ ?await this.checkFailuresAndSendNotification(event)
26
+ :'no statusCount';
25
27
 
26
28
  return {
27
- message: "Done ProcessPublishAssortmentCallback-process()",
29
+ message: "Done ProcessPublishAssortmentCallback-process(): " + statMessage,
28
30
  };
29
31
  }
30
32
 
31
- private checkFailuresAndSendNotification(event) {
33
+ private async checkFailuresAndSendNotification(event): Promise<string> {
32
34
  const statusCounts = JSON.parse(this.config["statusCounts"]);
33
35
 
34
36
  if (statusCounts["INVALID"] > 0 || statusCounts["FAILURE"] > 0) {
35
- new Notification().Dispatch({
37
+ await new Notification().Dispatch({
36
38
  message: `There were errors when publishing the season data. Please review the event and config information from context.`,
37
39
  level: LogLevel.WARN,
38
40
  context: {
@@ -40,6 +42,9 @@ export class BaseProcessPublishAssortmentCallback {
40
42
  config: this.config,
41
43
  },
42
44
  });
45
+ return 'sent notification';
43
46
  }
47
+
48
+ return 'no notification needed';
44
49
  }
45
50
  }
@@ -1,116 +1,116 @@
1
- import { AppActionCallbackStatus } from "@contrail/app-framework";
2
- import { ErrorResponseObject } from "./error-response-object";
3
-
4
- describe('getResponse() Tests', () =>{
5
- it('no error provided', () => {
6
- const e = undefined;
7
-
8
- const response = ErrorResponseObject.getResponse(e);
9
- expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
10
- expect(response?.output?.message).toMatch('No error provided');
11
- });
12
- it('error with message', () => {
13
- const e = {
14
- message: 'Test'
15
- };
16
-
17
- const response = ErrorResponseObject.getResponse(e);
18
- expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
19
- expect(response?.output?.message).toMatch('Test');
20
- });
21
-
22
- it('error with details', () => {
23
- const details = {
24
- message: 'Detail Message',
25
- itemType: [
26
- {
27
- message: "Type 'item:product:newBalance:apparel' cannot be assigned to a property with type 'item'."
28
- }]
29
- };
30
- const e = {
31
- message: 'Test',
32
- details
33
-
34
- };
35
-
36
- const response = ErrorResponseObject.getResponse(e);
37
- expect(response).toBeTruthy();
38
- expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
39
- expect(response.output.message).toMatch('Test');
40
-
41
- const errorDetails = response.output.errorDetails;
42
- expect(errorDetails).toBeTruthy();
43
- expect(errorDetails.message).toMatch('Detail Message');
44
- expect(errorDetails).toHaveProperty('itemType');
45
- });
46
-
47
- it('error with cause', () => {
48
- const cause = {
49
- code: 401,
50
- message: 'cause message'
51
- };
52
- const e = {
53
- message: 'Test',
54
- cause
55
- };
56
-
57
- const response = ErrorResponseObject.getResponse(e);
58
- expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
59
- expect(response?.output?.message).toMatch('Test');
60
- const resCause = response.output.cause;
61
-
62
- expect(resCause).toBeTruthy();
63
- expect(resCause.code).toBe(401);
64
- expect(resCause.message).toMatch('cause message');
65
-
66
- });
67
-
68
- it('error with code', () => {
69
- const e = {
70
- message: 'Test',
71
- code: 404
72
- };
73
-
74
- const response = ErrorResponseObject.getResponse(e);
75
- expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
76
- expect(response?.output?.message).toMatch('Test');
77
- expect(response.output.code).toBe(404);
78
- });
79
-
80
- it('error with code', () => {
81
- const e = {
82
- message: 'Test',
83
- name: 'Error'
84
- };
85
-
86
- const response = ErrorResponseObject.getResponse(e);
87
- expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
88
- expect(response?.output?.message).toMatch('Test');
89
- expect(response.output.errorName).toMatch('Error');
90
- });
91
-
92
- it('error with errno', () => {
93
- const e = {
94
- message: 'Test',
95
- errno: 500
96
- };
97
-
98
- const response = ErrorResponseObject.getResponse(e);
99
- expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
100
- expect(response?.output?.message).toMatch('Test');
101
- expect(response.output.errno).toBe(500);
102
- });
103
-
104
- it('error with type', () => {
105
- const e = {
106
- message: 'Test',
107
- type: 'system'
108
- };
109
-
110
- const response = ErrorResponseObject.getResponse(e);
111
- expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
112
- expect(response?.output?.message).toMatch('Test');
113
- expect(response.output.type).toMatch('system');
114
- });
115
-
1
+ import { AppActionCallbackStatus } from "@contrail/app-framework";
2
+ import { ErrorResponseObject } from "./error-response-object";
3
+
4
+ describe('getResponse() Tests', () =>{
5
+ it('no error provided', () => {
6
+ const e = undefined;
7
+
8
+ const response = ErrorResponseObject.getResponse(e);
9
+ expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
10
+ expect(response?.output?.message).toMatch('No error provided');
11
+ });
12
+ it('error with message', () => {
13
+ const e = {
14
+ message: 'Test'
15
+ };
16
+
17
+ const response = ErrorResponseObject.getResponse(e);
18
+ expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
19
+ expect(response?.output?.message).toMatch('Test');
20
+ });
21
+
22
+ it('error with details', () => {
23
+ const details = {
24
+ message: 'Detail Message',
25
+ itemType: [
26
+ {
27
+ message: "Type 'item:product:newBalance:apparel' cannot be assigned to a property with type 'item'."
28
+ }]
29
+ };
30
+ const e = {
31
+ message: 'Test',
32
+ details
33
+
34
+ };
35
+
36
+ const response = ErrorResponseObject.getResponse(e);
37
+ expect(response).toBeTruthy();
38
+ expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
39
+ expect(response.output.message).toMatch('Test');
40
+
41
+ const errorDetails = response.output.errorDetails;
42
+ expect(errorDetails).toBeTruthy();
43
+ expect(errorDetails.message).toMatch('Detail Message');
44
+ expect(errorDetails).toHaveProperty('itemType');
45
+ });
46
+
47
+ it('error with cause', () => {
48
+ const cause = {
49
+ code: 401,
50
+ message: 'cause message'
51
+ };
52
+ const e = {
53
+ message: 'Test',
54
+ cause
55
+ };
56
+
57
+ const response = ErrorResponseObject.getResponse(e);
58
+ expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
59
+ expect(response?.output?.message).toMatch('Test');
60
+ const resCause = response.output.cause;
61
+
62
+ expect(resCause).toBeTruthy();
63
+ expect(resCause.code).toBe(401);
64
+ expect(resCause.message).toMatch('cause message');
65
+
66
+ });
67
+
68
+ it('error with code', () => {
69
+ const e = {
70
+ message: 'Test',
71
+ code: 404
72
+ };
73
+
74
+ const response = ErrorResponseObject.getResponse(e);
75
+ expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
76
+ expect(response?.output?.message).toMatch('Test');
77
+ expect(response.output.code).toBe(404);
78
+ });
79
+
80
+ it('error with code', () => {
81
+ const e = {
82
+ message: 'Test',
83
+ name: 'Error'
84
+ };
85
+
86
+ const response = ErrorResponseObject.getResponse(e);
87
+ expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
88
+ expect(response?.output?.message).toMatch('Test');
89
+ expect(response.output.errorName).toMatch('Error');
90
+ });
91
+
92
+ it('error with errno', () => {
93
+ const e = {
94
+ message: 'Test',
95
+ errno: 500
96
+ };
97
+
98
+ const response = ErrorResponseObject.getResponse(e);
99
+ expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
100
+ expect(response?.output?.message).toMatch('Test');
101
+ expect(response.output.errno).toBe(500);
102
+ });
103
+
104
+ it('error with type', () => {
105
+ const e = {
106
+ message: 'Test',
107
+ type: 'system'
108
+ };
109
+
110
+ const response = ErrorResponseObject.getResponse(e);
111
+ expect(response.status).toMatch(AppActionCallbackStatus.FAILURE);
112
+ expect(response?.output?.message).toMatch('Test');
113
+ expect(response.output.type).toMatch('system');
114
+ });
115
+
116
116
  });
@@ -1,50 +1,50 @@
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
- if(!e){
12
- const response: AppActionCallBack = {
13
- status: AppActionCallbackStatus.FAILURE,
14
- output: {
15
- message: 'No error provided.'
16
- }
17
- };
18
- return response;
19
- }
20
-
21
- const response: AppActionCallBack = {
22
- status: AppActionCallbackStatus.FAILURE,
23
- output: {
24
- message: e.message
25
- }
26
- };
27
- const output = response.output;
28
-
29
- //Errors when persisting in VibeIQ
30
- if(e.details) output.errorDetails = e.details;
31
-
32
- if(e.code) output.code = e.code;
33
- if(e.errno) output.errno = e.errno;
34
- if(e.type) output.type = e.type;
35
- if(e.name) output.errorName = e.name;
36
-
37
- //Has original cause
38
- if(e.cause){
39
- output.cause = {};
40
- const cause = output.cause;
41
- if(e.cause.code) cause.code = e.cause.code;
42
- if(e.cause.message) cause.message = e.cause.message;
43
- }
44
-
45
- if(e.stack){
46
- console.log('ErrorResponseObject.getResponse stack: ' + e.stack);
47
- }
48
- return response;
49
- }
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
+ if(!e){
12
+ const response: AppActionCallBack = {
13
+ status: AppActionCallbackStatus.FAILURE,
14
+ output: {
15
+ message: 'No error provided.'
16
+ }
17
+ };
18
+ return response;
19
+ }
20
+
21
+ const response: AppActionCallBack = {
22
+ status: AppActionCallbackStatus.FAILURE,
23
+ output: {
24
+ message: e.message
25
+ }
26
+ };
27
+ const output = response.output;
28
+
29
+ //Errors when persisting in VibeIQ
30
+ if(e.details) output.errorDetails = e.details;
31
+
32
+ if(e.code) output.code = e.code;
33
+ if(e.errno) output.errno = e.errno;
34
+ if(e.type) output.type = e.type;
35
+ if(e.name) output.errorName = e.name;
36
+
37
+ //Has original cause
38
+ if(e.cause){
39
+ output.cause = {};
40
+ const cause = output.cause;
41
+ if(e.cause.code) cause.code = e.cause.code;
42
+ if(e.cause.message) cause.message = e.cause.message;
43
+ }
44
+
45
+ if(e.stack){
46
+ console.log('ErrorResponseObject.getResponse stack: ' + e.stack);
47
+ }
48
+ return response;
49
+ }
50
50
  }