@sera4/essentia 1.1.19 → 1.1.20
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 +1 -1
- package/package.tar.gz +0 -0
- package/paper-trail/index.js +36 -8
package/package.json
CHANGED
package/package.tar.gz
CHANGED
|
Binary file
|
package/paper-trail/index.js
CHANGED
|
@@ -47,11 +47,14 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
47
47
|
als: null,
|
|
48
48
|
userModel: false,
|
|
49
49
|
userModelAttribute: 'userId',
|
|
50
|
+
tenantModel: false,
|
|
51
|
+
tenantModelAttribute: 'tenantId',
|
|
50
52
|
enableCompression: false,
|
|
51
53
|
enableMigration: false,
|
|
52
54
|
enableStrictDiff: true,
|
|
53
55
|
continuationNamespace: null,
|
|
54
56
|
continuationKey: 'userId',
|
|
57
|
+
continuationTenantKey: 'tenantId',
|
|
55
58
|
metaDataFields: null,
|
|
56
59
|
metaDataContinuationKey: 'metaData',
|
|
57
60
|
mysql: false,
|
|
@@ -322,6 +325,9 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
322
325
|
query[options.userModelAttribute] =
|
|
323
326
|
(store && store.get(options.continuationKey)) || opt.userId;
|
|
324
327
|
|
|
328
|
+
query[options.tenantModelAttribute] =
|
|
329
|
+
(store && store.get(options.continuationTenantKey)) || opt.tenantId;
|
|
330
|
+
|
|
325
331
|
if (options.mixedDocumentReference && utils.isValidUuidV4(instance.id)) {
|
|
326
332
|
query[options.defaultAttributes.documentUuid] = instance.id;
|
|
327
333
|
} else {
|
|
@@ -546,10 +552,20 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
546
552
|
allowNull: false,
|
|
547
553
|
};
|
|
548
554
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
555
|
+
if (options.userModel) {
|
|
556
|
+
attributes[options.userModelAttribute] = {
|
|
557
|
+
type: options.UUID ? Sequelize.UUID : Sequelize.INTEGER,
|
|
558
|
+
allowNull: true
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
if (options.tenantModel) {
|
|
563
|
+
attributes[options.tenantModelAttribute] = {
|
|
564
|
+
type: options.UUID ? Sequelize.UUID : Sequelize.INTEGER,
|
|
565
|
+
allowNull: true
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
|
|
553
569
|
|
|
554
570
|
if (options.UUID) {
|
|
555
571
|
attributes.id = {
|
|
@@ -584,6 +600,9 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
584
600
|
if (options.userModel)
|
|
585
601
|
indexes.push({ fields: [options.userModelAttribute]});
|
|
586
602
|
|
|
603
|
+
if (options.tenantModel)
|
|
604
|
+
indexes.push({ fields: [options.tenantModelAttribute]});
|
|
605
|
+
|
|
587
606
|
if (options.mixedDocumentReference) {
|
|
588
607
|
indexes.push({
|
|
589
608
|
name: "document_reference_uuid",
|
|
@@ -624,10 +643,19 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
624
643
|
log('models', models);
|
|
625
644
|
}
|
|
626
645
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
646
|
+
if (options.userModel) {
|
|
647
|
+
Revision.belongsTo(
|
|
648
|
+
sequelize.model(options.userModel),
|
|
649
|
+
options.belongsToUserOptions,
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (options.tenantModel) {
|
|
654
|
+
Revision.belongsTo(
|
|
655
|
+
sequelize.model(options.tenantModel),
|
|
656
|
+
options.belongsToTenantOptions,
|
|
657
|
+
);
|
|
658
|
+
}
|
|
631
659
|
};
|
|
632
660
|
|
|
633
661
|
if (options.enableRevisionChangeModel) {
|