fng-audit 0.12.0-beta.290 → 0.12.0-beta.291

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.
@@ -106,7 +106,7 @@ function controller(fng, processArgs, options) {
106
106
  fng.app.get.apply(fng.app, processArgs(fng.options, [':model/:id/version/:version', function (req, res) {
107
107
  var resource = fng.getResource(req.params.model);
108
108
  if (resource) {
109
- getVersion(resource.model, req.params.id, req.params.version, true, getCallback(res));
109
+ getVersion(resource.model, req.params.id, req.params.version, true, "bail", getCallback(res));
110
110
  }
111
111
  else {
112
112
  res.status(404).send("No such resource as ".concat(req.params.model));
@@ -228,7 +228,11 @@ function getAuditTrail(fng, modelName, id, qry, callback) {
228
228
  callback();
229
229
  }
230
230
  }
231
- function getRevision(model, id, revisionCrit, doCleaning, callback) {
231
+ function getRevision(model, id, revisionCrit, doCleaning, errorHandling, callback) {
232
+ function reportError(obj, e) {
233
+ obj._errors = obj._errors || [];
234
+ obj._errors.push(e);
235
+ }
232
236
  if (exports.Audit) {
233
237
  model.findOne({ _id: id })
234
238
  .then(function (latest) {
@@ -241,15 +245,24 @@ function getRevision(model, id, revisionCrit, doCleaning, callback) {
241
245
  async.each(histories, function (history, eachCallback) {
242
246
  try {
243
247
  jsondiffpatch.unpatch(object, history.chg);
244
- eachCallback();
245
248
  }
246
249
  catch (e) {
247
- callback(new Error("While unpatching ".concat(model.modelName, " ").concat(id, " version ").concat(history.ver, ": ").concat(e.message)), null);
250
+ if (errorHandling === "bail") {
251
+ return callback(new Error("While unpatching ".concat(model.modelName, " ").concat(id, " version ").concat(history.ver, ": ").concat(e.message)), null);
252
+ }
253
+ else {
254
+ reportError(object, e);
255
+ }
248
256
  }
257
+ eachCallback();
249
258
  }, function (err) {
250
259
  if (err) {
251
- console.error(err);
252
- return callback(err, null);
260
+ if (errorHandling === "bail") {
261
+ return callback(err, null);
262
+ }
263
+ else {
264
+ reportError(object, err);
265
+ }
253
266
  }
254
267
  callback(null, doCleaning ? clean(object) : object);
255
268
  });
@@ -267,12 +280,12 @@ function getRevision(model, id, revisionCrit, doCleaning, callback) {
267
280
  callback(null);
268
281
  }
269
282
  }
270
- function getVersion(model, id, version, doCleaning, callback) {
271
- getRevision(model, id, { ver: { $gte: parseInt(version, 10) } }, doCleaning, callback);
283
+ function getVersion(model, id, version, doCleaning, errorHandling, callback) {
284
+ getRevision(model, id, { ver: { $gte: parseInt(version, 10) } }, doCleaning, errorHandling, callback);
272
285
  }
273
- function getSnapshot(model, id, snapshotDt, doCleaning, callback) {
286
+ function getSnapshot(model, id, snapshotDt, doCleaning, errorHandling, callback) {
274
287
  var dateAsObjectId = new Mongoose.Types.ObjectId(Math.floor(snapshotDt.getTime() / 1000).toString(16) + "0000000000000000");
275
- getRevision(model, id, { _id: { $gte: dateAsObjectId } }, doCleaning, callback);
288
+ getRevision(model, id, { _id: { $gte: dateAsObjectId } }, doCleaning, errorHandling, callback);
276
289
  }
277
290
  function auditAdHocEvent(user, description, details) {
278
291
  return __awaiter(this, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fng-audit",
3
- "version": "0.12.0-beta.290",
3
+ "version": "0.12.0-beta.291",
4
4
  "description": "Client part of forms-angular audit plugin",
5
5
  "homepage": "https://www.forms-angular.org/#/plugins",
6
6
  "files": [
@@ -26,7 +26,7 @@
26
26
  "@types/mocha": "10.0.7",
27
27
  "angular": "^1.8.3",
28
28
  "chai": "=4.3.10",
29
- "forms-angular": "0.12.0-beta.290",
29
+ "forms-angular": "0.12.0-beta.291",
30
30
  "grunt": "^1.6.1",
31
31
  "grunt-angular-templates": "^1.2.0",
32
32
  "grunt-contrib-concat": "2.1.0",