@resolveio/server-lib 5.0.9 → 5.0.10-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 +30 -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;
|
|
@@ -698,13 +698,14 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
698
698
|
case 0:
|
|
699
699
|
that = this;
|
|
700
700
|
_loop_5 = function (i) {
|
|
701
|
-
var _a, _b, sub, _c, _d;
|
|
701
|
+
var _a, _b, sub, removed, _c, _d, removed, removed, removed;
|
|
702
702
|
return __generator(this, function (_e) {
|
|
703
703
|
switch (_e.label) {
|
|
704
704
|
case 0:
|
|
705
705
|
sub = that._subscriptions.filter(function (a) { return a.collections.includes(collection); })[i];
|
|
706
|
-
if (!sub.preSubscriptionData) return [3 /*break*/,
|
|
707
|
-
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/,
|
|
706
|
+
if (!sub.preSubscriptionData) return [3 /*break*/, 3];
|
|
707
|
+
if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 3];
|
|
708
|
+
removed = false;
|
|
708
709
|
if (this_1._subCache.some(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })) {
|
|
709
710
|
if (!sub.clients.length) {
|
|
710
711
|
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
@@ -714,22 +715,26 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
714
715
|
{ subData: JSON.stringify(sub.subscriptionData) }
|
|
715
716
|
]
|
|
716
717
|
}).exec();
|
|
718
|
+
removed = true;
|
|
717
719
|
}
|
|
718
720
|
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
719
721
|
}
|
|
722
|
+
if (!!removed) return [3 /*break*/, 2];
|
|
720
723
|
that.sendPubData(sub, type, collection);
|
|
721
724
|
_c = sub;
|
|
722
725
|
return [4 /*yield*/, (_a = that._publications[sub.publication]).preFunction.apply(_a, sub.subscriptionData)];
|
|
723
726
|
case 1:
|
|
724
727
|
_c.preSubscriptionData = _e.sent();
|
|
725
|
-
|
|
726
|
-
case 2:
|
|
727
|
-
|
|
728
|
+
_e.label = 2;
|
|
729
|
+
case 2: return [2 /*return*/, "continue"];
|
|
730
|
+
case 3:
|
|
731
|
+
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 5];
|
|
728
732
|
_d = sub;
|
|
729
733
|
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
730
|
-
case
|
|
734
|
+
case 4:
|
|
731
735
|
_d.preSubscriptionData = _e.sent();
|
|
732
736
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
737
|
+
removed = false;
|
|
733
738
|
if (this_1._subCache.some(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })) {
|
|
734
739
|
if (!sub.clients.length) {
|
|
735
740
|
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
@@ -739,13 +744,16 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
739
744
|
{ subData: JSON.stringify(sub.subscriptionData) }
|
|
740
745
|
]
|
|
741
746
|
}).exec();
|
|
747
|
+
removed = true;
|
|
742
748
|
}
|
|
743
749
|
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
744
750
|
}
|
|
745
|
-
|
|
751
|
+
if (!removed) {
|
|
752
|
+
that.sendPubData(sub, type, collection);
|
|
753
|
+
}
|
|
746
754
|
}
|
|
747
|
-
return [3 /*break*/,
|
|
748
|
-
case
|
|
755
|
+
return [3 /*break*/, 6];
|
|
756
|
+
case 5:
|
|
749
757
|
if (that._publications[sub.publication].ws_specific) {
|
|
750
758
|
sub.clients.forEach(function (client) {
|
|
751
759
|
var _a;
|
|
@@ -770,6 +778,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
770
778
|
else {
|
|
771
779
|
if (that._publications[sub.publication].fetchFunction) {
|
|
772
780
|
if ((_b = that._publications[sub.publication]).fetchFunction.apply(_b, [document].concat(sub.subscriptionData))) {
|
|
781
|
+
removed = false;
|
|
773
782
|
if (this_1._subCache.some(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })) {
|
|
774
783
|
if (!sub.clients.length) {
|
|
775
784
|
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
@@ -779,14 +788,18 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
779
788
|
{ subData: JSON.stringify(sub.subscriptionData) }
|
|
780
789
|
]
|
|
781
790
|
}).exec();
|
|
791
|
+
removed = true;
|
|
782
792
|
}
|
|
783
793
|
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
784
794
|
}
|
|
785
|
-
|
|
795
|
+
if (!removed) {
|
|
796
|
+
that.sendPubData(sub, type, collection);
|
|
797
|
+
}
|
|
786
798
|
}
|
|
787
799
|
// else
|
|
788
800
|
}
|
|
789
801
|
else {
|
|
802
|
+
removed = false;
|
|
790
803
|
if (this_1._subCache.some(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })) {
|
|
791
804
|
if (!sub.clients.length) {
|
|
792
805
|
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
@@ -796,14 +809,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
796
809
|
{ subData: JSON.stringify(sub.subscriptionData) }
|
|
797
810
|
]
|
|
798
811
|
}).exec();
|
|
812
|
+
removed = true;
|
|
799
813
|
}
|
|
800
814
|
this_1._subCache.splice(this_1._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
801
815
|
}
|
|
802
|
-
|
|
816
|
+
if (!removed) {
|
|
817
|
+
that.sendPubData(sub, type, collection);
|
|
818
|
+
}
|
|
803
819
|
}
|
|
804
820
|
}
|
|
805
|
-
_e.label =
|
|
806
|
-
case
|
|
821
|
+
_e.label = 6;
|
|
822
|
+
case 6: return [2 /*return*/];
|
|
807
823
|
}
|
|
808
824
|
});
|
|
809
825
|
};
|