notification-processor 5.0.3 → 5.1.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.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/lib/exceptions/ignored.error.js +0 -27
- package/lib/exceptions/non.retryable.js +0 -27
- package/lib/index.js +0 -25
- package/lib/observers/delay.levels.js +0 -32
- package/lib/observers/incidentsApi.observer.js +0 -109
- package/lib/observers/logger.observer.js +0 -59
- package/lib/observers/monitoringCenter.observer.js +0 -234
- package/lib/observers/redis.observer.js +0 -90
- package/lib/processor.builder.js +0 -134
- package/lib/processor.js +0 -132
- package/lib/processors/deadletter.processor.js +0 -45
- package/lib/processors/job/index.js +0 -38
- package/lib/processors/job/job.processor.js +0 -150
- package/lib/processors/job/notification.api.js +0 -237
- package/lib/processors/maxRetries.processor.js +0 -88
- package/lib/processors/request.async.processor.js +0 -56
- package/lib/processors/request.processor.js +0 -114
- package/lib/processors/requestWithRetries.async.processor.js +0 -22
- package/lib/senders/async.producteca.sender.js +0 -145
- package/lib/senders/index.js +0 -10
- package/lib/senders/meli.sender.js +0 -46
- package/lib/senders/producteca.sender.js +0 -34
- package/lib/services/oAuthApi.js +0 -77
- package/lib/services/redis.js +0 -16
- package/lib/services/userIdTranslator.js +0 -111
- package/lib/sources/aws.sqs.source.js +0 -37
- package/lib/sources/index.js +0 -12
- package/lib/sources/queue.source.js +0 -26
- package/lib/sources/service.bus.source.js +0 -26
- package/lib/sources/table.source.js +0 -20
- package/lib/sources/unknown.source.js +0 -15
- package/lib/specHelpers/fixture.js +0 -29
- package/lib/specHelpers/redis.observer.mock.js +0 -65
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# [5.1.0](https://github.com/Parsimotion/notification-processor/compare/v5.0.3...v5.1.0) (2025-09-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* agrego @ ([45d5ba1](https://github.com/Parsimotion/notification-processor/commit/45d5ba148a55a3d58655ac55daae48c08a9c6ff8))
|
|
7
|
+
* agrego timeout para processor en maxretries ([8588bb6](https://github.com/Parsimotion/notification-processor/commit/8588bb60e1adec72a9447f838700ef0535d1daf2))
|
|
8
|
+
|
|
1
9
|
## [5.0.3](https://github.com/Parsimotion/notification-processor/compare/v5.0.2...v5.0.3) (2025-07-24)
|
|
2
10
|
|
|
3
11
|
|
package/package.json
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
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);
|
|
@@ -1,27 +0,0 @@
|
|
|
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 NonRetryable;
|
|
8
|
-
|
|
9
|
-
module.exports = NonRetryable = function () {
|
|
10
|
-
var NonRetryable = function NonRetryable(message, cause) {
|
|
11
|
-
_classCallCheck(this, NonRetryable);
|
|
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
|
-
NonRetryable.prototype = new Error();
|
|
22
|
-
|
|
23
|
-
NonRetryable.prototype.constructor = NonRetryable;
|
|
24
|
-
|
|
25
|
-
return NonRetryable;
|
|
26
|
-
}.call(this);
|
|
27
|
-
}).call(undefined);
|
package/lib/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Generated by CoffeeScript 2.7.0
|
|
4
|
-
(function () {
|
|
5
|
-
module.exports = {
|
|
6
|
-
Builder: require("./processor.builder"),
|
|
7
|
-
Observers: {
|
|
8
|
-
LoggerObserver: require("./observers/logger.observer"),
|
|
9
|
-
IncidentsApi: require("./observers/incidentsApi.observer"),
|
|
10
|
-
MonitoringCenter: require("./observers/monitoringCenter.observer")
|
|
11
|
-
},
|
|
12
|
-
Processors: {
|
|
13
|
-
DeadLetterProcessor: require("./processors/deadletter.processor"),
|
|
14
|
-
RequestProcessor: require("./processors/request.processor"),
|
|
15
|
-
RequestAsyncProcessor: require("./processors/requestWithRetries.async.processor"),
|
|
16
|
-
JobProcessor: require("./processors/job"),
|
|
17
|
-
MaxRetriesProcessor: require("./processors/maxRetries.processor")
|
|
18
|
-
},
|
|
19
|
-
Exceptions: {
|
|
20
|
-
NonRetryable: require("./exceptions/non.retryable")
|
|
21
|
-
},
|
|
22
|
-
Sources: require("./sources"),
|
|
23
|
-
Senders: require("./senders")
|
|
24
|
-
};
|
|
25
|
-
}).call(undefined);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Generated by CoffeeScript 2.7.0
|
|
4
|
-
(function () {
|
|
5
|
-
var convert;
|
|
6
|
-
|
|
7
|
-
convert = require("convert-units");
|
|
8
|
-
|
|
9
|
-
//delay : { name, value: amount of milliseconds where this delay level is considered to start }
|
|
10
|
-
module.exports = { //milliseconds
|
|
11
|
-
minimal: {
|
|
12
|
-
name: "Minimal",
|
|
13
|
-
value: 0
|
|
14
|
-
},
|
|
15
|
-
mild: {
|
|
16
|
-
name: "Mild",
|
|
17
|
-
value: process.env.MILD_DELAY || convert(2).from('s').to('ms')
|
|
18
|
-
},
|
|
19
|
-
moderate: {
|
|
20
|
-
name: "Moderate",
|
|
21
|
-
value: process.env.MODERATE_DELAY || convert(10).from('s').to('ms')
|
|
22
|
-
},
|
|
23
|
-
high: {
|
|
24
|
-
name: "High",
|
|
25
|
-
value: process.env.HIGH_DELAY || convert(5).from('min').to('ms')
|
|
26
|
-
},
|
|
27
|
-
huge: {
|
|
28
|
-
name: "Huge",
|
|
29
|
-
value: process.env.HUGE_DELAY || convert(10).from('min').to('ms')
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}).call(undefined);
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4
|
-
|
|
5
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
-
|
|
7
|
-
// Generated by CoffeeScript 2.7.0
|
|
8
|
-
(function () {
|
|
9
|
-
var IncidentsApiObserver, Promise, ServiceBusClient, _, debug, encode;
|
|
10
|
-
|
|
11
|
-
_ = require("lodash");
|
|
12
|
-
|
|
13
|
-
Promise = require("bluebird");
|
|
14
|
-
|
|
15
|
-
var _require = require("@azure/service-bus");
|
|
16
|
-
|
|
17
|
-
ServiceBusClient = _require.ServiceBusClient;
|
|
18
|
-
|
|
19
|
-
var _require2 = require("url-safe-base64");
|
|
20
|
-
|
|
21
|
-
encode = _require2.encode;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
debug = require("debug")("notification-processor:observers:incidents-api");
|
|
25
|
-
|
|
26
|
-
module.exports = IncidentsApiObserver = function () {
|
|
27
|
-
function IncidentsApiObserver(_ref) {
|
|
28
|
-
var sender = _ref.sender,
|
|
29
|
-
clientId = _ref.clientId,
|
|
30
|
-
app = _ref.app,
|
|
31
|
-
job = _ref.job,
|
|
32
|
-
_ref$propertiesToOmit = _ref.propertiesToOmit,
|
|
33
|
-
propertiesToOmit = _ref$propertiesToOmit === undefined ? "auth" : _ref$propertiesToOmit,
|
|
34
|
-
_ref$connection = _ref.connection,
|
|
35
|
-
connectionString = _ref$connection.connectionString,
|
|
36
|
-
topic = _ref$connection.topic;
|
|
37
|
-
|
|
38
|
-
_classCallCheck(this, IncidentsApiObserver);
|
|
39
|
-
|
|
40
|
-
this.publishToTopic = this.publishToTopic.bind(this);
|
|
41
|
-
this.sender = sender;
|
|
42
|
-
this.clientId = clientId;
|
|
43
|
-
this.app = app;
|
|
44
|
-
this.job = job;
|
|
45
|
-
this.propertiesToOmit = propertiesToOmit;
|
|
46
|
-
this.messageSender = this._buildMessageSender(connectionString, topic);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
_createClass(IncidentsApiObserver, [{
|
|
50
|
-
key: "listenTo",
|
|
51
|
-
value: function listenTo(observable) {
|
|
52
|
-
return observable.on("unsuccessful_non_retryable", this.publishToTopic);
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "publishToTopic",
|
|
56
|
-
value: function publishToTopic(_ref2) {
|
|
57
|
-
var _this = this;
|
|
58
|
-
|
|
59
|
-
var id = _ref2.id,
|
|
60
|
-
notification = _ref2.notification,
|
|
61
|
-
error = _ref2.error;
|
|
62
|
-
|
|
63
|
-
var $message;
|
|
64
|
-
$message = Promise.props({
|
|
65
|
-
body: this._mapper(id, notification, error.cause)
|
|
66
|
-
});
|
|
67
|
-
return $message.tap(function (message) {
|
|
68
|
-
return debug("To publish message %o", message);
|
|
69
|
-
}).then(function (message) {
|
|
70
|
-
return _this.messageSender.send(message);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "_mapper",
|
|
75
|
-
value: function _mapper(id, notification, err) {
|
|
76
|
-
var _this2 = this;
|
|
77
|
-
|
|
78
|
-
return Promise.props({
|
|
79
|
-
resource: Promise.method(this.sender.resource)(notification),
|
|
80
|
-
user: Promise.method(this.sender.user)(notification)
|
|
81
|
-
}).then(function (_ref3) {
|
|
82
|
-
var resource = _ref3.resource,
|
|
83
|
-
user = _ref3.user;
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
id: encode([_this2.app, _this2.job, resource].join("_")),
|
|
87
|
-
app: _this2.app,
|
|
88
|
-
job: _this2.job,
|
|
89
|
-
resource: "" + resource,
|
|
90
|
-
notification: notification,
|
|
91
|
-
user: "" + user,
|
|
92
|
-
clientId: _this2.clientId,
|
|
93
|
-
error: _.omit(err, "detail.request"),
|
|
94
|
-
request: _.omit(_.get(err, "detail.request"), _this2.propertiesToOmit),
|
|
95
|
-
type: _.get(err, "type", "unknown_error"),
|
|
96
|
-
tags: _.get(err, "tags", [])
|
|
97
|
-
};
|
|
98
|
-
}).then(JSON.stringify);
|
|
99
|
-
}
|
|
100
|
-
}, {
|
|
101
|
-
key: "_buildMessageSender",
|
|
102
|
-
value: function _buildMessageSender(connectionString, topic) {
|
|
103
|
-
return ServiceBusClient.createFromConnectionString(connectionString).createQueueClient(topic).createSender();
|
|
104
|
-
}
|
|
105
|
-
}]);
|
|
106
|
-
|
|
107
|
-
return IncidentsApiObserver;
|
|
108
|
-
}();
|
|
109
|
-
}).call(undefined);
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Generated by CoffeeScript 2.7.0
|
|
4
|
-
(function () {
|
|
5
|
-
var errorToJson;
|
|
6
|
-
|
|
7
|
-
errorToJson = require("error-to-json");
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
listenTo: function listenTo(observable) {
|
|
11
|
-
observable.on("started", function (_ref) {
|
|
12
|
-
var log = _ref.context.log,
|
|
13
|
-
notification = _ref.notification,
|
|
14
|
-
id = _ref.id;
|
|
15
|
-
|
|
16
|
-
return log.info("A new message has been received", {
|
|
17
|
-
id: id,
|
|
18
|
-
notification: JSON.stringify(notification)
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
observable.on("successful", function (_ref2) {
|
|
22
|
-
var log = _ref2.context.log,
|
|
23
|
-
id = _ref2.id;
|
|
24
|
-
|
|
25
|
-
return log.info("The process was successful", { id: id });
|
|
26
|
-
});
|
|
27
|
-
observable.on("unsuccessful", function (_ref3) {
|
|
28
|
-
var log = _ref3.context.log,
|
|
29
|
-
id = _ref3.id,
|
|
30
|
-
notification = _ref3.notification,
|
|
31
|
-
error = _ref3.error;
|
|
32
|
-
|
|
33
|
-
return log.error("The process was unsuccessful", {
|
|
34
|
-
id: id,
|
|
35
|
-
notification: JSON.stringify(notification),
|
|
36
|
-
error: JSON.stringify(errorToJson(error))
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
observable.on("unsuccessful_non_retryable", function (_ref4) {
|
|
40
|
-
var log = _ref4.context.log,
|
|
41
|
-
id = _ref4.id,
|
|
42
|
-
notification = _ref4.notification,
|
|
43
|
-
error = _ref4.error;
|
|
44
|
-
|
|
45
|
-
return log.error("The process was unsuccessful but it can't be retried", {
|
|
46
|
-
id: id,
|
|
47
|
-
notification: JSON.stringify(notification),
|
|
48
|
-
error: JSON.stringify(errorToJson(error))
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
return observable.on("ignored", function (_ref5) {
|
|
52
|
-
var log = _ref5.context.log,
|
|
53
|
-
id = _ref5.id;
|
|
54
|
-
|
|
55
|
-
return log.verbose("The message was ignored", { id: id });
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}).call(undefined);
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4
|
-
|
|
5
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
-
|
|
7
|
-
// Generated by CoffeeScript 2.7.0
|
|
8
|
-
(function () {
|
|
9
|
-
var AWS, MESSAGE_PROPERTIES, MonitoringCenterObserver, Promise, TYPE_PROPERTIES, _, debug, moment, retry;
|
|
10
|
-
|
|
11
|
-
_ = require("lodash");
|
|
12
|
-
|
|
13
|
-
Promise = require("bluebird");
|
|
14
|
-
|
|
15
|
-
retry = require("bluebird-retry");
|
|
16
|
-
|
|
17
|
-
debug = require("debug")("notification-processor:observers:monitor-center");
|
|
18
|
-
|
|
19
|
-
AWS = require("aws-sdk");
|
|
20
|
-
|
|
21
|
-
moment = require("moment");
|
|
22
|
-
|
|
23
|
-
TYPE_PROPERTIES = ["cause.type", "type"];
|
|
24
|
-
|
|
25
|
-
MESSAGE_PROPERTIES = ["cause.message", "message"];
|
|
26
|
-
|
|
27
|
-
module.exports = MonitoringCenterObserver = function () {
|
|
28
|
-
function MonitoringCenterObserver(_ref) {
|
|
29
|
-
var sender = _ref.sender,
|
|
30
|
-
clientId = _ref.clientId,
|
|
31
|
-
app1 = _ref.app,
|
|
32
|
-
job1 = _ref.job,
|
|
33
|
-
_ref$propertiesToOmit = _ref.propertiesToOmit,
|
|
34
|
-
propertiesToOmit = _ref$propertiesToOmit === undefined ? "auth" : _ref$propertiesToOmit,
|
|
35
|
-
_ref$connection = _ref.connection,
|
|
36
|
-
accessKeyId = _ref$connection.accessKeyId,
|
|
37
|
-
secretAccessKey = _ref$connection.secretAccessKey,
|
|
38
|
-
deliveryStream = _ref$connection.deliveryStream,
|
|
39
|
-
jobsDeliveryStream = _ref$connection.jobsDeliveryStream,
|
|
40
|
-
region = _ref$connection.region;
|
|
41
|
-
|
|
42
|
-
_classCallCheck(this, MonitoringCenterObserver);
|
|
43
|
-
|
|
44
|
-
this.registerRecord = this.registerRecord.bind(this);
|
|
45
|
-
this._registerJob = this._registerJob.bind(this);
|
|
46
|
-
this._registerExecution = this._registerExecution.bind(this);
|
|
47
|
-
this.sender = sender;
|
|
48
|
-
this.clientId = clientId;
|
|
49
|
-
this.app = app1;
|
|
50
|
-
this.job = job1;
|
|
51
|
-
this.propertiesToOmit = propertiesToOmit;
|
|
52
|
-
this.deliveryStream = deliveryStream;
|
|
53
|
-
this.jobsDeliveryStream = jobsDeliveryStream;
|
|
54
|
-
this.firehose = new AWS.Firehose({ accessKeyId: accessKeyId, secretAccessKey: secretAccessKey, region: region });
|
|
55
|
-
this.uploadToFirehose = Promise.promisify(this.firehose.putRecord).bind(this.firehose);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
_createClass(MonitoringCenterObserver, [{
|
|
59
|
-
key: "listenTo",
|
|
60
|
-
value: function listenTo(observable) {
|
|
61
|
-
var _this = this;
|
|
62
|
-
|
|
63
|
-
observable.on("unsuccessful_non_retryable", function (payload) {
|
|
64
|
-
return _this.registerRecord(payload, "unsuccessful");
|
|
65
|
-
});
|
|
66
|
-
observable.on("unsuccessful", function (payload) {
|
|
67
|
-
return _this.registerRecord(payload, "unsuccessful");
|
|
68
|
-
});
|
|
69
|
-
observable.on("started", function (payload) {
|
|
70
|
-
return _this.registerRecord(payload, "pending");
|
|
71
|
-
});
|
|
72
|
-
return observable.on("successful", function (payload) {
|
|
73
|
-
return _this.registerRecord(payload, "successful");
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}, {
|
|
77
|
-
key: "registerRecord",
|
|
78
|
-
value: function registerRecord(payload, executionStatus) {
|
|
79
|
-
var _this2 = this;
|
|
80
|
-
|
|
81
|
-
var deliveryStreamName, jobId;
|
|
82
|
-
jobId = _.get(payload, 'notification.message.JobId');
|
|
83
|
-
deliveryStreamName = jobId ? this.jobsDeliveryStream : this.deliveryStream;
|
|
84
|
-
return this._mapper(_.merge({ executionStatus: executionStatus, jobId: jobId }, payload)).tap(function (record) {
|
|
85
|
-
return debug("Record to save in firehose %s %j", deliveryStreamName, record);
|
|
86
|
-
}).then(function (record) {
|
|
87
|
-
var __uploadToFirehose, uploadParams;
|
|
88
|
-
if (_.isEmpty(record)) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
uploadParams = {
|
|
92
|
-
DeliveryStreamName: deliveryStreamName,
|
|
93
|
-
Record: {
|
|
94
|
-
Data: JSON.stringify(record)
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
debug("Uploading record " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName);
|
|
98
|
-
__uploadToFirehose = function __uploadToFirehose() {
|
|
99
|
-
return _this2.uploadToFirehose(uploadParams);
|
|
100
|
-
};
|
|
101
|
-
return retry(__uploadToFirehose, {
|
|
102
|
-
throw_original: true
|
|
103
|
-
}).tap(function () {
|
|
104
|
-
return debug("Uploaded record " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName);
|
|
105
|
-
}).catch(function (e) {
|
|
106
|
-
// We'll do nothing with this error
|
|
107
|
-
return debug("Error uploading record " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName + " %o", e);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}, {
|
|
112
|
-
key: "_mapper",
|
|
113
|
-
value: function _mapper(_ref2) {
|
|
114
|
-
var _this3 = this;
|
|
115
|
-
|
|
116
|
-
var id = _ref2.id,
|
|
117
|
-
notification = _ref2.notification,
|
|
118
|
-
error = _ref2.error,
|
|
119
|
-
warnings = _ref2.warnings,
|
|
120
|
-
executionStatus = _ref2.executionStatus,
|
|
121
|
-
jobId = _ref2.jobId;
|
|
122
|
-
|
|
123
|
-
return Promise.method(this.sender.monitoringCenterFields.bind(this.sender))(notification).then(function (_ref3) {
|
|
124
|
-
var eventType = _ref3.eventType,
|
|
125
|
-
resource = _ref3.resource,
|
|
126
|
-
companyId = _ref3.companyId,
|
|
127
|
-
userId = _ref3.userId,
|
|
128
|
-
externalReference = _ref3.externalReference,
|
|
129
|
-
userExternalReference = _ref3.userExternalReference,
|
|
130
|
-
eventId = _ref3.eventId,
|
|
131
|
-
eventTimestamp = _ref3.eventTimestamp,
|
|
132
|
-
parentEventId = _ref3.parentEventId,
|
|
133
|
-
app = _ref3.app,
|
|
134
|
-
job = _ref3.job,
|
|
135
|
-
partialMessage = _ref3.partialMessage;
|
|
136
|
-
|
|
137
|
-
var basicRegister, errorType, executionRegister, now, theRequest;
|
|
138
|
-
if (!eventId) {
|
|
139
|
-
return Promise.resolve({});
|
|
140
|
-
}
|
|
141
|
-
theRequest = _.get(error, "detail.request") || _.get(error, "cause.detail.request");
|
|
142
|
-
errorType = _this3._retrieveMessageFromError(error, TYPE_PROPERTIES, "unknown");
|
|
143
|
-
if (/the operation did not complete within the allocated time/gi.test(errorType)) {
|
|
144
|
-
errorType = "timed_out";
|
|
145
|
-
}
|
|
146
|
-
now = new Date();
|
|
147
|
-
basicRegister = { id: id, app: app, companyId: companyId, now: now, executionStatus: executionStatus, errorType: errorType, job: job };
|
|
148
|
-
executionRegister = { eventType: eventType, userId: userId, eventId: eventId, parentEventId: parentEventId, externalReference: externalReference, userExternalReference: userExternalReference, error: error, theRequest: theRequest, partialMessage: partialMessage, notification: notification, resource: resource, eventTimestamp: eventTimestamp, warnings: warnings };
|
|
149
|
-
if (jobId) {
|
|
150
|
-
return _this3._registerJob(basicRegister, jobId);
|
|
151
|
-
} else {
|
|
152
|
-
return _this3._registerExecution(basicRegister, executionRegister);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}, {
|
|
157
|
-
key: "_registerJob",
|
|
158
|
-
value: function _registerJob(basicRegister, jobId) {
|
|
159
|
-
return {
|
|
160
|
-
id: basicRegister.id,
|
|
161
|
-
app: basicRegister.app || parseInt(this.clientId) || null,
|
|
162
|
-
trigger_id: jobId,
|
|
163
|
-
trigger_mode: "scheduled",
|
|
164
|
-
company: basicRegister.companyId,
|
|
165
|
-
start_time: basicRegister.now.getTime(),
|
|
166
|
-
integration: this.app + "|" + (basicRegister.job || this.job),
|
|
167
|
-
error_type: basicRegister.errorType,
|
|
168
|
-
status: basicRegister.executionStatus
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
}, {
|
|
172
|
-
key: "_registerExecution",
|
|
173
|
-
value: function _registerExecution(basicRegister, executionRegister) {
|
|
174
|
-
var _this4 = this;
|
|
175
|
-
|
|
176
|
-
var errorMessage, now, ref;
|
|
177
|
-
now = basicRegister.now;
|
|
178
|
-
errorMessage = this._retrieveMessageFromError(executionRegister.error, MESSAGE_PROPERTIES, "");
|
|
179
|
-
return {
|
|
180
|
-
id: basicRegister.id,
|
|
181
|
-
executionId: basicRegister.id,
|
|
182
|
-
app: basicRegister.app || parseInt(this.clientId) || null,
|
|
183
|
-
type: executionRegister.eventType || "service-bus",
|
|
184
|
-
company: basicRegister.companyId,
|
|
185
|
-
user: executionRegister.userId,
|
|
186
|
-
event: executionRegister.eventId,
|
|
187
|
-
parent: executionRegister.parentEventId,
|
|
188
|
-
externalreference: executionRegister.externalReference,
|
|
189
|
-
userexternalreference: executionRegister.userExternalReference,
|
|
190
|
-
timestamp: now.getTime(),
|
|
191
|
-
date: now.toISOString(),
|
|
192
|
-
year: moment(now).format('YYYY'),
|
|
193
|
-
month: moment(now).format('MM'),
|
|
194
|
-
day: moment(now).format('DD'),
|
|
195
|
-
hour: moment(now).format('HH'),
|
|
196
|
-
payload: JSON.stringify({
|
|
197
|
-
clientId: this.clientId,
|
|
198
|
-
job: this.job,
|
|
199
|
-
app: this.app,
|
|
200
|
-
error: _.omit(executionRegister.error, ["detail.request", "cause.detail.request"]),
|
|
201
|
-
request: _.omit(executionRegister.theRequest, _.castArray(this.propertiesToOmit).concat("auth")),
|
|
202
|
-
tags: _.get(executionRegister.error, "tags", []),
|
|
203
|
-
message: executionRegister.partialMessage || executionRegister.notification.message
|
|
204
|
-
}),
|
|
205
|
-
status: basicRegister.executionStatus,
|
|
206
|
-
resource: executionRegister.resource,
|
|
207
|
-
integration: this.app + "|" + (basicRegister.job || this.job),
|
|
208
|
-
// Generic app fields
|
|
209
|
-
event_timestamp: executionRegister.eventTimestamp || now.getTime(),
|
|
210
|
-
error_type: basicRegister.errorType,
|
|
211
|
-
output_message: errorMessage,
|
|
212
|
-
user_settings_version: null, //TODO
|
|
213
|
-
env_version: null, //TODO
|
|
214
|
-
code_version: null, //TODO
|
|
215
|
-
warnings: (ref = executionRegister.warnings) != null ? ref.map(function (warning) {
|
|
216
|
-
return {
|
|
217
|
-
type: _this4._retrieveMessageFromError(warning, TYPE_PROPERTIES, "unknown"),
|
|
218
|
-
message: _this4._retrieveMessageFromError(warning, MESSAGE_PROPERTIES, "")
|
|
219
|
-
};
|
|
220
|
-
}) : void 0
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
}, {
|
|
224
|
-
key: "_retrieveMessageFromError",
|
|
225
|
-
value: function _retrieveMessageFromError(error, properties, defaultValue) {
|
|
226
|
-
return error && _(properties).map(function (property) {
|
|
227
|
-
return _.get(error, property);
|
|
228
|
-
}).reject(_.isEmpty).get(0, defaultValue);
|
|
229
|
-
}
|
|
230
|
-
}]);
|
|
231
|
-
|
|
232
|
-
return MonitoringCenterObserver;
|
|
233
|
-
}();
|
|
234
|
-
}).call(undefined);
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4
|
-
|
|
5
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
-
|
|
7
|
-
// Generated by CoffeeScript 2.7.0
|
|
8
|
-
(function () {
|
|
9
|
-
var Promise, Redis, RedisObserver, _;
|
|
10
|
-
|
|
11
|
-
_ = require("lodash");
|
|
12
|
-
|
|
13
|
-
Redis = require("../services/redis");
|
|
14
|
-
|
|
15
|
-
Promise = require("bluebird");
|
|
16
|
-
|
|
17
|
-
module.exports = RedisObserver = function () {
|
|
18
|
-
function RedisObserver(_ref) {
|
|
19
|
-
var _ref$redis = _ref.redis,
|
|
20
|
-
redis = _ref$redis === undefined ? {} : _ref$redis;
|
|
21
|
-
|
|
22
|
-
_classCallCheck(this, RedisObserver);
|
|
23
|
-
|
|
24
|
-
this.publish = this.publish.bind(this);
|
|
25
|
-
this._getChannel = this._getChannel.bind(this);
|
|
26
|
-
this._messagePath_ = this._messagePath_.bind(this);
|
|
27
|
-
this._buildValue_ = this._buildValue_.bind(this);
|
|
28
|
-
this._channelPrefix_ = this._channelPrefix_.bind(this);
|
|
29
|
-
_.defaults(redis, {
|
|
30
|
-
host: process.env.REDIS_HOST,
|
|
31
|
-
port: process.env.REDIS_PORT,
|
|
32
|
-
db: process.env.REDIS_DB,
|
|
33
|
-
auth: process.env.REDIS_AUTH
|
|
34
|
-
});
|
|
35
|
-
this.redis = Redis.createClient(redis.port, redis.host, {
|
|
36
|
-
db: redis.db
|
|
37
|
-
});
|
|
38
|
-
if (redis.auth) {
|
|
39
|
-
this.redis.auth(redis.auth);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
_createClass(RedisObserver, [{
|
|
44
|
-
key: "publish",
|
|
45
|
-
value: function publish(notification, value) {
|
|
46
|
-
var _this = this;
|
|
47
|
-
|
|
48
|
-
return Promise.props({
|
|
49
|
-
channel: this._getChannel(notification),
|
|
50
|
-
value: this._buildValue_(value)
|
|
51
|
-
}).then(function (_ref2) {
|
|
52
|
-
var channel = _ref2.channel,
|
|
53
|
-
value = _ref2.value;
|
|
54
|
-
|
|
55
|
-
return _this.redis.publishAsync(channel, value);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
key: "_getChannel",
|
|
60
|
-
value: function _getChannel(notification) {
|
|
61
|
-
return Promise.props({
|
|
62
|
-
channelPrefix: this._channelPrefix_(notification.type),
|
|
63
|
-
messagePath: this._messagePath_(notification)
|
|
64
|
-
}).then(function (_ref3) {
|
|
65
|
-
var channelPrefix = _ref3.channelPrefix,
|
|
66
|
-
messagePath = _ref3.messagePath;
|
|
67
|
-
|
|
68
|
-
return channelPrefix + "/" + messagePath;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
key: "_messagePath_",
|
|
73
|
-
value: function _messagePath_() {
|
|
74
|
-
throw new Error("not supported `_messagePath_`");
|
|
75
|
-
}
|
|
76
|
-
}, {
|
|
77
|
-
key: "_buildValue_",
|
|
78
|
-
value: function _buildValue_() {
|
|
79
|
-
throw new Error("not supported `_buildValue_`");
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "_channelPrefix_",
|
|
83
|
-
value: function _channelPrefix_(type) {
|
|
84
|
-
throw new Error("not supported `_channelPrefix_`");
|
|
85
|
-
}
|
|
86
|
-
}]);
|
|
87
|
-
|
|
88
|
-
return RedisObserver;
|
|
89
|
-
}();
|
|
90
|
-
}).call(undefined);
|