@resolveio/server-lib 5.0.14 → 5.0.15-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 +75 -22
- 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;
|
|
@@ -674,26 +674,79 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
674
674
|
}); }, 500);
|
|
675
675
|
};
|
|
676
676
|
SubscriptionManager.prototype.resendPubsForDelete = function (collection) {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
if (ws['id_socket'] === client.id_socket) {
|
|
689
|
-
that.sendPubDataOnce(ws, client.messageId, sub, 'delete', collection);
|
|
677
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
678
|
+
var that, jj, _loop_5, zz;
|
|
679
|
+
return __generator(this, function (_a) {
|
|
680
|
+
switch (_a.label) {
|
|
681
|
+
case 0:
|
|
682
|
+
that = this;
|
|
683
|
+
for (jj = this._subCache.length - 1; jj >= 0; jj--) {
|
|
684
|
+
if (this._subCache[jj].collection === collection) {
|
|
685
|
+
this._nodeCache.del(this._subCache[jj].id);
|
|
686
|
+
this._subCache.splice(jj, 1);
|
|
687
|
+
}
|
|
690
688
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
689
|
+
_loop_5 = function (zz) {
|
|
690
|
+
var sub;
|
|
691
|
+
return __generator(this, function (_a) {
|
|
692
|
+
switch (_a.label) {
|
|
693
|
+
case 0:
|
|
694
|
+
sub = that._subscriptions.filter(function (a) { return a.collections.includes(collection); })[zz];
|
|
695
|
+
if (!that._publications[sub.publication].ws_specific) return [3 /*break*/, 4];
|
|
696
|
+
if (!sub.clients.length) return [3 /*break*/, 1];
|
|
697
|
+
sub.clients.forEach(function (client) {
|
|
698
|
+
that._wss.clients.forEach(function (ws) {
|
|
699
|
+
if (ws['id_socket'] === client.id_socket) {
|
|
700
|
+
that.sendPubDataOnce(ws, client.messageId, sub, 'delete', collection);
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
return [3 /*break*/, 3];
|
|
705
|
+
case 1:
|
|
706
|
+
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
707
|
+
return [4 /*yield*/, active_subscription_collection_1.ActiveSubscriptions.deleteOne({
|
|
708
|
+
$and: [
|
|
709
|
+
{ publication: sub.publication },
|
|
710
|
+
{ subData: JSON.stringify(sub.subscriptionData) }
|
|
711
|
+
]
|
|
712
|
+
}).exec()];
|
|
713
|
+
case 2:
|
|
714
|
+
_a.sent();
|
|
715
|
+
_a.label = 3;
|
|
716
|
+
case 3: return [3 /*break*/, 7];
|
|
717
|
+
case 4:
|
|
718
|
+
if (!!sub.clients.length) return [3 /*break*/, 6];
|
|
719
|
+
that._subscriptions.splice(that._subscriptions.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
720
|
+
return [4 /*yield*/, active_subscription_collection_1.ActiveSubscriptions.deleteOne({
|
|
721
|
+
$and: [
|
|
722
|
+
{ publication: sub.publication },
|
|
723
|
+
{ subData: JSON.stringify(sub.subscriptionData) }
|
|
724
|
+
]
|
|
725
|
+
}).exec()];
|
|
726
|
+
case 5:
|
|
727
|
+
_a.sent();
|
|
728
|
+
return [3 /*break*/, 7];
|
|
729
|
+
case 6:
|
|
730
|
+
that.sendPubData(sub, 'delete', collection);
|
|
731
|
+
_a.label = 7;
|
|
732
|
+
case 7: return [2 /*return*/];
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
};
|
|
736
|
+
zz = that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).length - 1;
|
|
737
|
+
_a.label = 1;
|
|
738
|
+
case 1:
|
|
739
|
+
if (!(zz >= 0)) return [3 /*break*/, 4];
|
|
740
|
+
return [5 /*yield**/, _loop_5(zz)];
|
|
741
|
+
case 2:
|
|
742
|
+
_a.sent();
|
|
743
|
+
_a.label = 3;
|
|
744
|
+
case 3:
|
|
745
|
+
zz--;
|
|
746
|
+
return [3 /*break*/, 1];
|
|
747
|
+
case 4: return [2 /*return*/];
|
|
748
|
+
}
|
|
749
|
+
});
|
|
697
750
|
});
|
|
698
751
|
};
|
|
699
752
|
// Document: Inserted/Modified/Deleted Document
|
|
@@ -701,12 +754,12 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
701
754
|
// Check to see if any pubs need to refetch due to Mongo operation
|
|
702
755
|
SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type) {
|
|
703
756
|
return __awaiter(this, void 0, void 0, function () {
|
|
704
|
-
var that,
|
|
757
|
+
var that, _loop_6, this_1, i;
|
|
705
758
|
return __generator(this, function (_a) {
|
|
706
759
|
switch (_a.label) {
|
|
707
760
|
case 0:
|
|
708
761
|
that = this;
|
|
709
|
-
|
|
762
|
+
_loop_6 = function (i) {
|
|
710
763
|
var _a, _b, sub, removed, _c, _d, removed, removed, removed;
|
|
711
764
|
return __generator(this, function (_e) {
|
|
712
765
|
switch (_e.label) {
|
|
@@ -841,7 +894,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
841
894
|
_a.label = 1;
|
|
842
895
|
case 1:
|
|
843
896
|
if (!(i >= 0)) return [3 /*break*/, 4];
|
|
844
|
-
return [5 /*yield**/,
|
|
897
|
+
return [5 /*yield**/, _loop_6(i)];
|
|
845
898
|
case 2:
|
|
846
899
|
_a.sent();
|
|
847
900
|
_a.label = 3;
|