@sera4/essentia 1.1.21 → 1.1.23
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/package.json +2 -1
- package/package.tar.gz +0 -0
- package/paper-trail/index.js +26 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sera4/essentia",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
4
4
|
"description": "A library of utilities for Teleporte Web Services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"async": "^2.6.3",
|
|
33
33
|
"axios": "^0.21.4",
|
|
34
34
|
"deep-diff": "^1.0.2",
|
|
35
|
+
"diff": "^5.0.0",
|
|
35
36
|
"fast-safe-stringify": "^2.0.7",
|
|
36
37
|
"git-rev": "^0.2.1",
|
|
37
38
|
"lodash": "^4.17.21",
|
package/package.tar.gz
CHANGED
|
Binary file
|
package/paper-trail/index.js
CHANGED
|
@@ -40,9 +40,12 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
40
40
|
mixedDocumentReference: false,
|
|
41
41
|
underscored: false,
|
|
42
42
|
underscoredAttributes: false,
|
|
43
|
+
// always store these keys in a reference value if seen
|
|
44
|
+
includeReferences: [],
|
|
43
45
|
defaultAttributes: {
|
|
44
46
|
documentId: 'documentId',
|
|
45
47
|
revisionId: 'revisionId',
|
|
48
|
+
autoGenerated: 'autoGenerated'
|
|
46
49
|
},
|
|
47
50
|
als: null,
|
|
48
51
|
userModel: false,
|
|
@@ -220,6 +223,7 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
220
223
|
}
|
|
221
224
|
|
|
222
225
|
const destroyOperation = operation === 'destroy';
|
|
226
|
+
const createOperation = operation === 'create';
|
|
223
227
|
|
|
224
228
|
if (
|
|
225
229
|
instance.context &&
|
|
@@ -280,7 +284,20 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
280
284
|
);
|
|
281
285
|
}
|
|
282
286
|
|
|
283
|
-
let document
|
|
287
|
+
let document;
|
|
288
|
+
if (destroyOperation) {
|
|
289
|
+
document = { oldValues: currentVersion };
|
|
290
|
+
} else if (createOperation) {
|
|
291
|
+
document = { newValues: currentVersion };
|
|
292
|
+
} else {
|
|
293
|
+
document = { oldValues: previousVersion, newValues: currentVersion };
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const references = _.pick(instance.dataValues, options.includeReferences);
|
|
297
|
+
|
|
298
|
+
if (Object.keys(references).length) {
|
|
299
|
+
document['references'] = references;
|
|
300
|
+
}
|
|
284
301
|
|
|
285
302
|
if (options.mysql) {
|
|
286
303
|
document = JSON.stringify(document);
|
|
@@ -321,6 +338,8 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
321
338
|
}
|
|
322
339
|
}
|
|
323
340
|
|
|
341
|
+
query[options.defaultAttributes.autoGenerated] = opt.autoGenerated;
|
|
342
|
+
|
|
324
343
|
// in case of custom user models that are not 'userId'
|
|
325
344
|
query[options.userModelAttribute] =
|
|
326
345
|
(store && store.get(options.continuationKey)) || opt.userId;
|
|
@@ -547,6 +566,12 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
547
566
|
allowNull: false,
|
|
548
567
|
};
|
|
549
568
|
|
|
569
|
+
attributes[options.defaultAttributes.autoGenerated] = {
|
|
570
|
+
type: Sequelize.BOOLEAN,
|
|
571
|
+
defaultValue: false,
|
|
572
|
+
allowNull: false,
|
|
573
|
+
};
|
|
574
|
+
|
|
550
575
|
attributes[options.revisionAttribute] = {
|
|
551
576
|
type: Sequelize.INTEGER,
|
|
552
577
|
allowNull: false,
|