notification-processor 4.19.4 → 4.20.0
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,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
|
|
5
|
+
// Generated by CoffeeScript 2.7.0
|
|
6
|
+
(function () {
|
|
7
|
+
var IgnoredError;
|
|
8
|
+
|
|
9
|
+
module.exports = IgnoredError = function () {
|
|
10
|
+
var IgnoredError = function IgnoredError(message, cause) {
|
|
11
|
+
_classCallCheck(this, IgnoredError);
|
|
12
|
+
|
|
13
|
+
this.cause = cause;
|
|
14
|
+
this.name = this.constructor.name;
|
|
15
|
+
this.message = message;
|
|
16
|
+
this.stack = new Error().stack;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
;
|
|
20
|
+
|
|
21
|
+
IgnoredError.prototype = new Error();
|
|
22
|
+
|
|
23
|
+
IgnoredError.prototype.constructor = IgnoredError;
|
|
24
|
+
|
|
25
|
+
return IgnoredError;
|
|
26
|
+
}.call(this);
|
|
27
|
+
}).call(undefined);
|
|
@@ -6,7 +6,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
6
6
|
|
|
7
7
|
// Generated by CoffeeScript 2.7.0
|
|
8
8
|
(function () {
|
|
9
|
-
var AWS, MonitoringCenterObserver, Promise, _, debug, moment, retry;
|
|
9
|
+
var AWS, MESSAGE_PROPERTIES, MonitoringCenterObserver, Promise, TYPE_PROPERTIES, _, debug, moment, retry;
|
|
10
10
|
|
|
11
11
|
_ = require("lodash");
|
|
12
12
|
|
|
@@ -20,6 +20,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
20
20
|
|
|
21
21
|
moment = require("moment");
|
|
22
22
|
|
|
23
|
+
TYPE_PROPERTIES = ["cause.type", "type"];
|
|
24
|
+
|
|
25
|
+
MESSAGE_PROPERTIES = ["cause.message", "message"];
|
|
26
|
+
|
|
23
27
|
module.exports = MonitoringCenterObserver = function () {
|
|
24
28
|
function MonitoringCenterObserver(_ref) {
|
|
25
29
|
var sender = _ref.sender,
|
|
@@ -67,14 +71,12 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
67
71
|
}
|
|
68
72
|
}, {
|
|
69
73
|
key: "uploadTrackingFile",
|
|
70
|
-
value: function uploadTrackingFile(
|
|
74
|
+
value: function uploadTrackingFile(payload, executionStatus) {
|
|
71
75
|
var _this2 = this;
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return this._mapper(id, notification, error, executionStatus).then(function (record) {
|
|
77
|
+
return this._mapper(_.merge({ executionStatus: executionStatus }, payload)).tap(function (record) {
|
|
78
|
+
return debug("Record to save in firehose %j", record);
|
|
79
|
+
}).then(function (record) {
|
|
78
80
|
var __uploadToFirehose, uploadParams;
|
|
79
81
|
if (_.isEmpty(record)) {
|
|
80
82
|
return;
|
|
@@ -101,9 +103,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
101
103
|
}
|
|
102
104
|
}, {
|
|
103
105
|
key: "_mapper",
|
|
104
|
-
value: function _mapper(
|
|
106
|
+
value: function _mapper(_ref2) {
|
|
105
107
|
var _this3 = this;
|
|
106
108
|
|
|
109
|
+
var id = _ref2.id,
|
|
110
|
+
notification = _ref2.notification,
|
|
111
|
+
error = _ref2.error,
|
|
112
|
+
warnings = _ref2.warnings,
|
|
113
|
+
executionStatus = _ref2.executionStatus;
|
|
114
|
+
|
|
107
115
|
return Promise.method(this.sender.monitoringCenterFields.bind(this.sender))(notification).then(function (_ref3) {
|
|
108
116
|
var eventType = _ref3.eventType,
|
|
109
117
|
resource = _ref3.resource,
|
|
@@ -122,9 +130,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
122
130
|
if (!eventId) {
|
|
123
131
|
return Promise.resolve({});
|
|
124
132
|
}
|
|
125
|
-
theRequest = _.get(
|
|
126
|
-
errorType = _this3._retrieveMessageFromError(
|
|
127
|
-
errorMessage = _this3._retrieveMessageFromError(
|
|
133
|
+
theRequest = _.get(error, "detail.request") || _.get(error, "cause.detail.request");
|
|
134
|
+
errorType = _this3._retrieveMessageFromError(error, TYPE_PROPERTIES, "unknown");
|
|
135
|
+
errorMessage = _this3._retrieveMessageFromError(error, MESSAGE_PROPERTIES, "");
|
|
128
136
|
now = new Date();
|
|
129
137
|
return {
|
|
130
138
|
id: id,
|
|
@@ -147,9 +155,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
147
155
|
clientId: _this3.clientId,
|
|
148
156
|
job: _this3.job,
|
|
149
157
|
app: _this3.app,
|
|
150
|
-
error: _.omit(
|
|
158
|
+
error: _.omit(error, ["detail.request", "cause.detail.request"]),
|
|
151
159
|
request: _.omit(theRequest, _.castArray(_this3.propertiesToOmit).concat("auth")),
|
|
152
|
-
tags: _.get(
|
|
160
|
+
tags: _.get(error, "tags", []),
|
|
153
161
|
message: partialMessage || notification.message
|
|
154
162
|
}),
|
|
155
163
|
status: executionStatus,
|
|
@@ -161,15 +169,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
161
169
|
output_message: errorMessage,
|
|
162
170
|
user_settings_version: null, //TODO
|
|
163
171
|
env_version: null, //TODO
|
|
164
|
-
code_version: null //TODO
|
|
172
|
+
code_version: null, //TODO
|
|
173
|
+
warnings: warnings != null ? warnings.map(function (warning) {
|
|
174
|
+
return {
|
|
175
|
+
type: _this3._retrieveMessageFromError(warning, TYPE_PROPERTIES, "unknown"),
|
|
176
|
+
message: _this3._retrieveMessageFromError(warning, MESSAGE_PROPERTIES, "")
|
|
177
|
+
};
|
|
178
|
+
}) : void 0
|
|
165
179
|
};
|
|
166
180
|
});
|
|
167
181
|
}
|
|
168
182
|
}, {
|
|
169
183
|
key: "_retrieveMessageFromError",
|
|
170
|
-
value: function _retrieveMessageFromError(
|
|
171
|
-
return
|
|
172
|
-
return _.get(
|
|
184
|
+
value: function _retrieveMessageFromError(error, properties, defaultValue) {
|
|
185
|
+
return error && _(properties).map(function (property) {
|
|
186
|
+
return _.get(error, property);
|
|
173
187
|
}).reject(_.isEmpty).get(0, defaultValue);
|
|
174
188
|
}
|
|
175
189
|
}]);
|
package/lib/processor.js
CHANGED
|
@@ -12,6 +12,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
12
12
|
(function () {
|
|
13
13
|
var ENABLE_EVENTS,
|
|
14
14
|
EventEmitter,
|
|
15
|
+
IgnoredError,
|
|
15
16
|
NonRetryable,
|
|
16
17
|
Processor,
|
|
17
18
|
Promise,
|
|
@@ -28,6 +29,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
28
29
|
|
|
29
30
|
NonRetryable = require("./exceptions/non.retryable");
|
|
30
31
|
|
|
32
|
+
IgnoredError = require("./exceptions/ignored.error");
|
|
33
|
+
|
|
31
34
|
EventEmitter = require("events");
|
|
32
35
|
|
|
33
36
|
Promise = require("bluebird");
|
|
@@ -93,6 +96,13 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
93
96
|
};
|
|
94
97
|
execute().tap(function () {
|
|
95
98
|
return _this2._emitEvent("successful", { context: context, id: id, notification: notification });
|
|
99
|
+
}).catch(IgnoredError, function (error) {
|
|
100
|
+
return _this2._emitEvent("successful", {
|
|
101
|
+
context: context,
|
|
102
|
+
id: id,
|
|
103
|
+
notification: notification,
|
|
104
|
+
warnings: [error]
|
|
105
|
+
});
|
|
96
106
|
}).catch(function (error) {
|
|
97
107
|
if (!(error instanceof NonRetryable)) {
|
|
98
108
|
throw error;
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
// Generated by CoffeeScript 2.7.0
|
|
4
4
|
(function () {
|
|
5
|
-
var MESSAGE_PROPERTIES, NonRetryableError, Promise, RequestError, StatusCodeError, _, __isIncludedInStatusesError, _safeParse, _type, errorConditions, httpStatus, request;
|
|
5
|
+
var IgnoredError, MESSAGE_PROPERTIES, NonRetryableError, Promise, RequestError, StatusCodeError, _, __isIncludedInStatusesError, _safeParse, _type, errorConditions, httpStatus, request;
|
|
6
6
|
|
|
7
7
|
_ = require("lodash");
|
|
8
8
|
|
|
9
9
|
NonRetryableError = require("../exceptions/non.retryable");
|
|
10
10
|
|
|
11
|
+
IgnoredError = require("../exceptions/ignored.error");
|
|
12
|
+
|
|
11
13
|
Promise = require("bluebird");
|
|
12
14
|
|
|
13
15
|
request = require("request-promise");
|
|
@@ -102,7 +104,7 @@
|
|
|
102
104
|
}
|
|
103
105
|
});
|
|
104
106
|
}).catch(__isIncludedInStatusesError(silentErrors), function (err) {
|
|
105
|
-
|
|
107
|
+
throw new IgnoredError("An error has ocurred in that request but should be ignored", _.omit(err, "response"));
|
|
106
108
|
}).catch(__isIncludedInStatusesError(nonRetryable), function (err) {
|
|
107
109
|
throw new NonRetryableError("An error has ocurred in that request", _.omit(err, "response"));
|
|
108
110
|
});
|