@resolveio/server-lib 5.0.17 → 5.0.18-newrole
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/collections/user.collection.js +39 -32
- package/fixtures/init.js +1 -1
- package/managers/subscription.manager.js +32 -14
- package/package.json +1 -1
|
@@ -22,13 +22,6 @@ var schema = {
|
|
|
22
22
|
type: Date,
|
|
23
23
|
optional: true
|
|
24
24
|
},
|
|
25
|
-
readonly: {
|
|
26
|
-
type: Boolean,
|
|
27
|
-
optional: true
|
|
28
|
-
},
|
|
29
|
-
active: {
|
|
30
|
-
type: Boolean
|
|
31
|
-
},
|
|
32
25
|
attempts: {
|
|
33
26
|
type: Number,
|
|
34
27
|
optional: true
|
|
@@ -65,53 +58,67 @@ var schema = {
|
|
|
65
58
|
type: String
|
|
66
59
|
},
|
|
67
60
|
roles: {
|
|
61
|
+
type: Object
|
|
62
|
+
},
|
|
63
|
+
'roles.super_admin': {
|
|
64
|
+
type: Boolean
|
|
65
|
+
},
|
|
66
|
+
'roles.approvals': {
|
|
68
67
|
type: Array
|
|
69
68
|
},
|
|
70
|
-
'roles.$': {
|
|
69
|
+
'roles.approvals.$': {
|
|
70
|
+
type: Object
|
|
71
|
+
},
|
|
72
|
+
'roles.approvals.$.name': {
|
|
71
73
|
type: String
|
|
72
74
|
},
|
|
73
|
-
|
|
74
|
-
type: String
|
|
75
|
-
optional: true
|
|
75
|
+
'roles.approvals.$.type': {
|
|
76
|
+
type: String
|
|
76
77
|
},
|
|
77
|
-
|
|
78
|
-
type:
|
|
79
|
-
blackbox: true,
|
|
80
|
-
optional: true
|
|
78
|
+
'roles.approvals.$.accounting_code': {
|
|
79
|
+
type: String
|
|
81
80
|
},
|
|
82
|
-
|
|
83
|
-
type: Array
|
|
84
|
-
optional: true
|
|
81
|
+
'roles.groups': {
|
|
82
|
+
type: Array
|
|
85
83
|
},
|
|
86
|
-
'
|
|
84
|
+
'roles.groups.$': {
|
|
87
85
|
type: Object
|
|
88
86
|
},
|
|
89
|
-
'
|
|
87
|
+
'roles.groups.$.name': {
|
|
90
88
|
type: String
|
|
91
89
|
},
|
|
92
|
-
'
|
|
93
|
-
type:
|
|
90
|
+
'roles.groups.$.views': {
|
|
91
|
+
type: Array
|
|
94
92
|
},
|
|
95
|
-
'
|
|
93
|
+
'roles.groups.$.views.$': {
|
|
96
94
|
type: String
|
|
97
95
|
},
|
|
98
|
-
'
|
|
99
|
-
type: String
|
|
96
|
+
'roles.groups.$.yard': {
|
|
97
|
+
type: String,
|
|
98
|
+
optional: true
|
|
99
|
+
},
|
|
100
|
+
'roles.notifications': {
|
|
101
|
+
type: Array
|
|
100
102
|
},
|
|
101
|
-
'
|
|
103
|
+
'roles.notifications.$': {
|
|
102
104
|
type: String
|
|
103
105
|
},
|
|
104
|
-
'
|
|
105
|
-
type:
|
|
106
|
+
'roles.miscs': {
|
|
107
|
+
type: Array
|
|
106
108
|
},
|
|
107
|
-
'
|
|
108
|
-
type:
|
|
109
|
-
optional: true
|
|
109
|
+
'roles.miscs.$': {
|
|
110
|
+
type: String
|
|
110
111
|
},
|
|
111
|
-
|
|
112
|
+
active: Boolean,
|
|
113
|
+
phonenumber: {
|
|
112
114
|
type: String,
|
|
113
115
|
optional: true
|
|
114
116
|
},
|
|
117
|
+
other: {
|
|
118
|
+
type: Object,
|
|
119
|
+
optional: true,
|
|
120
|
+
blackbox: true
|
|
121
|
+
},
|
|
115
122
|
customers: {
|
|
116
123
|
type: Array,
|
|
117
124
|
optional: true,
|
package/fixtures/init.js
CHANGED
|
@@ -37,8 +37,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
var app_version_collection_1 = require("../collections/app-version.collection");
|
|
39
39
|
var logged_in_users_collection_1 = require("../collections/logged-in-users.collection");
|
|
40
|
-
var active_subscription_collection_1 = require("../collections/active-subscription.collection");
|
|
41
40
|
var mongoose_1 = require("mongoose");
|
|
41
|
+
var active_subscription_collection_1 = require("../collections/active-subscription.collection");
|
|
42
42
|
function loadServerInit() {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function () {
|
|
44
44
|
var appVersion;
|
|
@@ -675,7 +675,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
675
675
|
};
|
|
676
676
|
SubscriptionManager.prototype.resendPubsForDelete = function (collection) {
|
|
677
677
|
return __awaiter(this, void 0, void 0, function () {
|
|
678
|
-
var that, jj, _loop_5, zz;
|
|
678
|
+
var that, jj, subCopy, _loop_5, zz;
|
|
679
679
|
return __generator(this, function (_a) {
|
|
680
680
|
switch (_a.label) {
|
|
681
681
|
case 0:
|
|
@@ -686,12 +686,13 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
686
686
|
this._subCache.splice(jj, 1);
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
|
+
subCopy = common_1.deepCopy(that._subscriptions.filter(function (a) { return a.collections.includes(collection); }));
|
|
689
690
|
_loop_5 = function (zz) {
|
|
690
691
|
var sub;
|
|
691
692
|
return __generator(this, function (_a) {
|
|
692
693
|
switch (_a.label) {
|
|
693
694
|
case 0:
|
|
694
|
-
sub =
|
|
695
|
+
sub = subCopy[zz];
|
|
695
696
|
if (!that._publications[sub.publication].ws_specific) return [3 /*break*/, 4];
|
|
696
697
|
if (!sub.clients.length) return [3 /*break*/, 1];
|
|
697
698
|
sub.clients.forEach(function (client) {
|
|
@@ -703,7 +704,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
703
704
|
});
|
|
704
705
|
return [3 /*break*/, 3];
|
|
705
706
|
case 1:
|
|
706
|
-
|
|
707
|
+
if (that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
708
|
+
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
709
|
+
}
|
|
707
710
|
return [4 /*yield*/, active_subscription_collection_1.ActiveSubscriptions.deleteOne({
|
|
708
711
|
$and: [
|
|
709
712
|
{ publication: sub.publication },
|
|
@@ -716,7 +719,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
716
719
|
case 3: return [3 /*break*/, 7];
|
|
717
720
|
case 4:
|
|
718
721
|
if (!!sub.clients.length) return [3 /*break*/, 6];
|
|
719
|
-
|
|
722
|
+
if (that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
723
|
+
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
724
|
+
}
|
|
720
725
|
return [4 /*yield*/, active_subscription_collection_1.ActiveSubscriptions.deleteOne({
|
|
721
726
|
$and: [
|
|
722
727
|
{ publication: sub.publication },
|
|
@@ -733,7 +738,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
733
738
|
}
|
|
734
739
|
});
|
|
735
740
|
};
|
|
736
|
-
zz =
|
|
741
|
+
zz = subCopy.length - 1;
|
|
737
742
|
_a.label = 1;
|
|
738
743
|
case 1:
|
|
739
744
|
if (!(zz >= 0)) return [3 /*break*/, 4];
|
|
@@ -754,23 +759,26 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
754
759
|
// Check to see if any pubs need to refetch due to Mongo operation
|
|
755
760
|
SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type) {
|
|
756
761
|
return __awaiter(this, void 0, void 0, function () {
|
|
757
|
-
var that, _loop_6, this_1, i;
|
|
762
|
+
var that, subCopy, _loop_6, this_1, i;
|
|
758
763
|
return __generator(this, function (_a) {
|
|
759
764
|
switch (_a.label) {
|
|
760
765
|
case 0:
|
|
761
766
|
that = this;
|
|
767
|
+
subCopy = common_1.deepCopy(that._subscriptions.filter(function (a) { return a.collections.includes(collection); }));
|
|
762
768
|
_loop_6 = function (i) {
|
|
763
769
|
var _a, _b, sub, removed, _c, _d, removed, removed, removed;
|
|
764
770
|
return __generator(this, function (_e) {
|
|
765
771
|
switch (_e.label) {
|
|
766
772
|
case 0:
|
|
767
|
-
sub =
|
|
773
|
+
sub = subCopy[i];
|
|
768
774
|
if (!sub.preSubscriptionData) return [3 /*break*/, 3];
|
|
769
775
|
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 3];
|
|
770
776
|
removed = false;
|
|
771
777
|
if (this_1._subCache.some(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })) {
|
|
772
778
|
if (!sub.clients.length) {
|
|
773
|
-
|
|
779
|
+
if (that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })) {
|
|
780
|
+
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
781
|
+
}
|
|
774
782
|
active_subscription_collection_1.ActiveSubscriptions.deleteOne({
|
|
775
783
|
$and: [
|
|
776
784
|
{ publication: sub.publication },
|
|
@@ -780,7 +788,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
780
788
|
removed = true;
|
|
781
789
|
}
|
|
782
790
|
this_1._nodeCache.del(this_1._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
783
|
-
|
|
791
|
+
if (this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
792
|
+
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
793
|
+
}
|
|
784
794
|
}
|
|
785
795
|
if (!!removed) return [3 /*break*/, 2];
|
|
786
796
|
that.sendPubData(sub, type, collection);
|
|
@@ -845,7 +855,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
845
855
|
removed = false;
|
|
846
856
|
if (this_1._subCache.some(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })) {
|
|
847
857
|
if (!sub.clients.length) {
|
|
848
|
-
|
|
858
|
+
if (that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
859
|
+
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
860
|
+
}
|
|
849
861
|
active_subscription_collection_1.ActiveSubscriptions.deleteOne({
|
|
850
862
|
$and: [
|
|
851
863
|
{ publication: sub.publication },
|
|
@@ -855,7 +867,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
855
867
|
removed = true;
|
|
856
868
|
}
|
|
857
869
|
this_1._nodeCache.del(this_1._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
858
|
-
|
|
870
|
+
if (this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
871
|
+
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
872
|
+
}
|
|
859
873
|
}
|
|
860
874
|
if (!removed) {
|
|
861
875
|
that.sendPubData(sub, type, collection);
|
|
@@ -867,7 +881,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
867
881
|
removed = false;
|
|
868
882
|
if (this_1._subCache.some(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })) {
|
|
869
883
|
if (!sub.clients.length) {
|
|
870
|
-
|
|
884
|
+
if (that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
885
|
+
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
886
|
+
}
|
|
871
887
|
active_subscription_collection_1.ActiveSubscriptions.deleteOne({
|
|
872
888
|
$and: [
|
|
873
889
|
{ publication: sub.publication },
|
|
@@ -877,7 +893,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
877
893
|
removed = true;
|
|
878
894
|
}
|
|
879
895
|
this_1._nodeCache.del(this_1._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
880
|
-
|
|
896
|
+
if (this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
897
|
+
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
898
|
+
}
|
|
881
899
|
}
|
|
882
900
|
if (!removed) {
|
|
883
901
|
that.sendPubData(sub, type, collection);
|
|
@@ -890,7 +908,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
890
908
|
});
|
|
891
909
|
};
|
|
892
910
|
this_1 = this;
|
|
893
|
-
i =
|
|
911
|
+
i = subCopy.length - 1;
|
|
894
912
|
_a.label = 1;
|
|
895
913
|
case 1:
|
|
896
914
|
if (!(i >= 0)) return [3 /*break*/, 4];
|