SAP-BTP-Spielwiese/app1/node_modules/@sap/audit-logging/lib/base-messages/MessageBase.js
Markus Rettig 775ac7b58c completed step 3 from the tutorial
you must login with an BTP account in order to see the app
2024-02-08 16:13:36 +01:00

40 lines
956 B
JavaScript

'use strict';
var utils = require('../utils');
module.exports = MessageBase;
function MessageBase(content, transport) {
this._content = content;
this._transport = transport;
}
MessageBase.prototype.by = function (user) {
utils.validate.notEmptyString(user, 'user');
this._content.user = user;
return this;
};
MessageBase.prototype.tenant = function (tenant, subdomain) {
utils.validate.notEmptyString(tenant, 'tenant');
this._content.tenant = tenant;
this._transport.subdomain = subdomain;
return this;
};
MessageBase.prototype.at = function (ts) {
if (!(ts instanceof Date)) {
ts = new Date(ts);
}
this.customTime = ts.toISOString();
return this;
};
MessageBase.prototype._update = function () {
this._content.uuid = utils.uuid();
this._content.time = this.customTime || new Date().toISOString();
};
MessageBase.prototype._validateContent = function () {
utils.validate.provided(this._content.user, 'user');
};