historical-deadletter-processor
Version:
historical-deadletter-processor
57 lines (44 loc) • 2.05 kB
JavaScript
;
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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// Generated by CoffeeScript 2.7.0
(function () {
var Mapper, _, encode, normalizeError;
_ = require("lodash");
var _require = require("url-safe-base64");
encode = _require.encode;
normalizeError = require("./normalize.error");
module.exports = Mapper = function () {
function Mapper(_ref) {
var sender = _ref.sender,
app = _ref.app,
job = _ref.job,
propertiesToOmit = _ref.propertiesToOmit,
clientId = _ref.clientId;
_classCallCheck(this, Mapper);
this.sender = sender;
this.app = app;
this.job = job;
this.propertiesToOmit = propertiesToOmit;
this.clientId = clientId;
}
_createClass(Mapper, [{
key: "map",
value: function map(notification, err) {
var id, resource;
resource = this.sender.resource(notification);
id = encode(this.app + "_" + this.job + "_" + resource);
return _.merge({
id: id,
app: this.app,
job: this.job,
resource: "" + resource,
notification: JSON.stringify(notification),
user: "" + this.sender.user(notification),
clientId: this.clientId
}, normalizeError(err, this.propertiesToOmit));
}
}]);
return Mapper;
}();
}).call(undefined);