fng-audit 0.12.0-beta.221 → 0.12.0-beta.223
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/dist/server/fng-audit.js +61 -65
- package/package.json +2 -2
package/dist/server/fng-audit.js
CHANGED
|
@@ -534,74 +534,70 @@ function plugin(schema, options) {
|
|
|
534
534
|
Document middleware. "this" is the document
|
|
535
535
|
*/
|
|
536
536
|
schema.pre("save", function (next) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
537
|
+
function doTheCreate(theAuditRec) {
|
|
538
|
+
exports.Audit.create(theAuditRec)
|
|
539
|
+
.then(function () {
|
|
540
|
+
// nothing to do
|
|
541
|
+
})
|
|
542
|
+
.catch(function (err) {
|
|
543
|
+
console.log("Error creating audit object: ".concat(err.message));
|
|
544
|
+
})
|
|
545
|
+
.finally(function () {
|
|
546
|
+
next();
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
if (this._noAudit || !exports.Audit) {
|
|
550
|
+
next();
|
|
551
|
+
}
|
|
552
|
+
else if (this.isNew) {
|
|
553
|
+
// No point in auditing if we don't have a user, as the document itself does the job
|
|
554
|
+
var user = getPseudoField('user', this) || getPseudoField('_usr', this);
|
|
555
|
+
if (user) {
|
|
556
|
+
var auditRec_1 = {
|
|
557
|
+
c: this.constructor.modelName,
|
|
558
|
+
cId: this._id,
|
|
559
|
+
op: 'create',
|
|
560
|
+
user: user
|
|
561
|
+
};
|
|
562
|
+
if (typeof auditOptions.addPropFunc === "function") {
|
|
563
|
+
auditOptions.addPropFunc(auditRec_1, this, null, null, {})
|
|
564
|
+
.then(function (xtra) {
|
|
559
565
|
if (xtra) {
|
|
560
|
-
|
|
566
|
+
auditRec_1.xtra = xtra;
|
|
561
567
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
exports.Audit.create(auditRec)
|
|
565
|
-
.then(function () {
|
|
566
|
-
// nothing to do
|
|
567
|
-
})
|
|
568
|
-
.catch(function (err) {
|
|
569
|
-
console.log("Error creating audit object: ".concat(err.message));
|
|
570
|
-
})
|
|
571
|
-
.finally(function () {
|
|
572
|
-
next();
|
|
573
|
-
});
|
|
574
|
-
return [3 /*break*/, 5];
|
|
575
|
-
case 4:
|
|
576
|
-
next();
|
|
577
|
-
_a.label = 5;
|
|
578
|
-
case 5: return [3 /*break*/, 7];
|
|
579
|
-
case 6:
|
|
580
|
-
that_1 = this;
|
|
581
|
-
try {
|
|
582
|
-
getHiddenFields(that_1.constructor.collection.collectionName, options);
|
|
583
|
-
that_1.constructor.findOne({ _id: that_1._id })
|
|
584
|
-
.then(function (original) {
|
|
585
|
-
auditFromObject(that_1, original, that_1, options, next);
|
|
586
|
-
})
|
|
587
|
-
.catch(function (err) {
|
|
588
|
-
if (auditOptions.errorHandler) {
|
|
589
|
-
auditOptions.errorHandler(err.message);
|
|
590
|
-
}
|
|
591
|
-
next();
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
catch (e) {
|
|
595
|
-
if (auditOptions.errorHandler) {
|
|
596
|
-
auditOptions.errorHandler(e.message);
|
|
597
|
-
}
|
|
598
|
-
next();
|
|
599
|
-
}
|
|
600
|
-
_a.label = 7;
|
|
601
|
-
case 7: return [2 /*return*/];
|
|
568
|
+
doTheCreate(auditRec_1);
|
|
569
|
+
});
|
|
602
570
|
}
|
|
603
|
-
|
|
604
|
-
|
|
571
|
+
else {
|
|
572
|
+
doTheCreate(auditRec_1);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
next();
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
var that_1 = this;
|
|
581
|
+
try {
|
|
582
|
+
getHiddenFields(that_1.constructor.collection.collectionName, options);
|
|
583
|
+
that_1.constructor.findOne({ _id: that_1._id })
|
|
584
|
+
.then(function (original) {
|
|
585
|
+
auditFromObject(that_1, original, that_1, options, next);
|
|
586
|
+
})
|
|
587
|
+
.catch(function (err) {
|
|
588
|
+
if (auditOptions.errorHandler) {
|
|
589
|
+
auditOptions.errorHandler(err.message);
|
|
590
|
+
}
|
|
591
|
+
next();
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
catch (e) {
|
|
595
|
+
if (auditOptions.errorHandler) {
|
|
596
|
+
auditOptions.errorHandler(e.message);
|
|
597
|
+
}
|
|
598
|
+
next();
|
|
599
|
+
}
|
|
600
|
+
}
|
|
605
601
|
});
|
|
606
602
|
// prior to mongoose 7, pre("remove") was used to intercept deleted documents. in mongoose 7, remove() no longer
|
|
607
603
|
// exists, and instead, deleteOne() is used both to delete a document that has already been retrieved from the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fng-audit",
|
|
3
|
-
"version": "0.12.0-beta.
|
|
3
|
+
"version": "0.12.0-beta.223",
|
|
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.1",
|
|
27
27
|
"angular": "^1.8.3",
|
|
28
28
|
"chai": "4.3.7",
|
|
29
|
-
"forms-angular": "0.12.0-beta.
|
|
29
|
+
"forms-angular": "0.12.0-beta.223",
|
|
30
30
|
"grunt": "^1.5.3",
|
|
31
31
|
"grunt-angular-templates": "^1.2.0",
|
|
32
32
|
"grunt-contrib-concat": "2.1.0",
|