@sera4/essentia 1.1.19 → 1.1.21
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 +29 -5
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 {
|
|
@@ -547,10 +553,16 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
547
553
|
};
|
|
548
554
|
|
|
549
555
|
attributes[options.userModelAttribute] = {
|
|
550
|
-
type: Sequelize.INTEGER,
|
|
556
|
+
type: options.UUID ? Sequelize.UUID : Sequelize.INTEGER,
|
|
551
557
|
allowNull: true
|
|
552
558
|
};
|
|
553
559
|
|
|
560
|
+
attributes[options.tenantModelAttribute] = {
|
|
561
|
+
type: options.UUID ? Sequelize.UUID : Sequelize.INTEGER,
|
|
562
|
+
allowNull: true
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
|
|
554
566
|
if (options.UUID) {
|
|
555
567
|
attributes.id = {
|
|
556
568
|
primaryKey: true,
|
|
@@ -584,6 +596,9 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
584
596
|
if (options.userModel)
|
|
585
597
|
indexes.push({ fields: [options.userModelAttribute]});
|
|
586
598
|
|
|
599
|
+
if (options.tenantModel)
|
|
600
|
+
indexes.push({ fields: [options.tenantModelAttribute]});
|
|
601
|
+
|
|
587
602
|
if (options.mixedDocumentReference) {
|
|
588
603
|
indexes.push({
|
|
589
604
|
name: "document_reference_uuid",
|
|
@@ -624,10 +639,19 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
|
|
|
624
639
|
log('models', models);
|
|
625
640
|
}
|
|
626
641
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
642
|
+
if (options.userModel) {
|
|
643
|
+
Revision.belongsTo(
|
|
644
|
+
sequelize.model(options.userModel),
|
|
645
|
+
options.belongsToUserOptions,
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (options.tenantModel) {
|
|
650
|
+
Revision.belongsTo(
|
|
651
|
+
sequelize.model(options.tenantModel),
|
|
652
|
+
options.belongsToTenantOptions,
|
|
653
|
+
);
|
|
654
|
+
}
|
|
631
655
|
};
|
|
632
656
|
|
|
633
657
|
if (options.enableRevisionChangeModel) {
|