@resolveio/server-lib 6.1.3-newrole → 6.1.4
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 +32 -39
- package/collections/user.collection.js.map +1 -1
- package/fixtures/init.js +1 -1
- package/fixtures/init.js.map +1 -1
- package/managers/subscription.manager.js +61 -48
- package/managers/subscription.manager.js.map +1 -1
- package/methods/accounts.js.map +1 -1
- package/methods/cron-jobs.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,6 +22,13 @@ 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
|
+
},
|
|
25
32
|
attempts: {
|
|
26
33
|
type: Number,
|
|
27
34
|
optional: true
|
|
@@ -58,67 +65,53 @@ var schema = {
|
|
|
58
65
|
type: String
|
|
59
66
|
},
|
|
60
67
|
roles: {
|
|
61
|
-
type: Object
|
|
62
|
-
},
|
|
63
|
-
'roles.super_admin': {
|
|
64
|
-
type: Boolean
|
|
65
|
-
},
|
|
66
|
-
'roles.approvals': {
|
|
67
68
|
type: Array
|
|
68
69
|
},
|
|
69
|
-
'roles
|
|
70
|
-
type: Object
|
|
71
|
-
},
|
|
72
|
-
'roles.approvals.$.name': {
|
|
70
|
+
'roles.$': {
|
|
73
71
|
type: String
|
|
74
72
|
},
|
|
75
|
-
|
|
76
|
-
type: String
|
|
73
|
+
phonenumber: {
|
|
74
|
+
type: String,
|
|
75
|
+
optional: true
|
|
77
76
|
},
|
|
78
|
-
|
|
79
|
-
type:
|
|
77
|
+
other: {
|
|
78
|
+
type: Object,
|
|
79
|
+
blackbox: true,
|
|
80
|
+
optional: true
|
|
80
81
|
},
|
|
81
|
-
|
|
82
|
-
type: Array
|
|
82
|
+
assets: {
|
|
83
|
+
type: Array,
|
|
84
|
+
optional: true
|
|
83
85
|
},
|
|
84
|
-
'
|
|
86
|
+
'assets.$': {
|
|
85
87
|
type: Object
|
|
86
88
|
},
|
|
87
|
-
'
|
|
89
|
+
'assets.$.type': {
|
|
88
90
|
type: String
|
|
89
91
|
},
|
|
90
|
-
'
|
|
91
|
-
type: Array
|
|
92
|
-
},
|
|
93
|
-
'roles.groups.$.views.$': {
|
|
92
|
+
'assets.$.id_asset': {
|
|
94
93
|
type: String
|
|
95
94
|
},
|
|
96
|
-
'
|
|
97
|
-
type: String
|
|
98
|
-
optional: true
|
|
95
|
+
'assets.$.asset_number': {
|
|
96
|
+
type: String
|
|
99
97
|
},
|
|
100
|
-
'
|
|
101
|
-
type:
|
|
98
|
+
'assets.$.ownership': {
|
|
99
|
+
type: String
|
|
102
100
|
},
|
|
103
|
-
'
|
|
101
|
+
'assets.$.ownership_driver': {
|
|
104
102
|
type: String
|
|
105
103
|
},
|
|
106
|
-
'
|
|
107
|
-
type:
|
|
104
|
+
'assets.$.date_start': {
|
|
105
|
+
type: Date
|
|
108
106
|
},
|
|
109
|
-
'
|
|
110
|
-
type:
|
|
107
|
+
'assets.$.date_end': {
|
|
108
|
+
type: Date,
|
|
109
|
+
optional: true
|
|
111
110
|
},
|
|
112
|
-
|
|
113
|
-
phonenumber: {
|
|
111
|
+
id_function: {
|
|
114
112
|
type: String,
|
|
115
113
|
optional: true
|
|
116
114
|
},
|
|
117
|
-
other: {
|
|
118
|
-
type: Object,
|
|
119
|
-
optional: true,
|
|
120
|
-
blackbox: true
|
|
121
|
-
},
|
|
122
115
|
customers: {
|
|
123
116
|
type: Array,
|
|
124
117
|
optional: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/user.collection.ts"],"names":[],"mappings":";;AAAA,qCAAwG;AACxG,+DAAiE;AACjE,6CAAwC;AACxC,kCAA2C;AAG3C,uEAA8E;AAE9E,IAAI,MAAM,GAAQ;IACjB,GAAG,EAAE;QACJ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C,CAAC;AACnF,aAAK,CAAC,UAAU,CAAC,GAAG,qCAAa,CAAC,QAAQ,CAAC,CAAC","file":"user.collection.js","sourcesContent":["import { Schema, Model, PassportLocalDocument, PassportLocalModel, PassportLocalSchema} from 'mongoose';\nimport * as passportLocalMongoose from 'passport-local-mongoose';\nimport SimpleSchema from 'simpl-schema';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\nimport { LookupTables } from '../models/report-builder.model';\nimport { buildRbSchema, buildRbLookups } from '../util/schema-report-builder';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\treadonly: {\n\t\ttype: Boolean,\n\t\toptional: true\n\t},\n\tactive: {\n\t\ttype: Boolean\n\t},\n\tattempts: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tlast: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tservices: {\n\t\ttype: Object,\n\t\toptional: true\n\t},\n\t'services.enrollment': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.forgot_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.reset_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tusername: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\temail: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tfullname: {\n\t\ttype: String\n\t},\n\troles: {\n\t\ttype: Array\n\t},\n\t'roles.$': {\n\t\ttype: String\n\t},\n\tphonenumber: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tother: {\n\t\ttype: Object,\n\t\tblackbox: true,\n\t\toptional: true\n\t},\n\tassets: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'assets.$': {\n\t\ttype: Object\n\t},\n\t'assets.$.type': {\n\t\ttype: String\n\t},\n\t'assets.$.id_asset': {\n\t\ttype: String\n\t},\n\t'assets.$.asset_number': {\n\t\ttype: String\n\t},\n\t'assets.$.ownership': {\n\t\ttype: String\n\t},\n\t'assets.$.ownership_driver': {\n\t\ttype: String\n\t},\n\t'assets.$.date_start': {\n\t\ttype: Date\n\t},\n\t'assets.$.date_end': {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tid_function: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomers: {\n\t\ttype: Array,\n\t\toptional: true,\n\t},\n\t'customers.$': {\n\t\ttype: Object\n\t},\n\t'customers.$.id_customer': {\n\t\ttype: String\n\t},\n\t'customers.$.customer': {\n\t\ttype: String\n\t},\n\tid_customer: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomer: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomer_type: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tdepartments: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'departments.$': {\n\t\ttype: Object\n\t},\n\t'departments.$.id_department': {\n\t\ttype: String\n\t},\n\t'departments.$.department': {\n\t\ttype: String\n\t}\n};\n\nconst DefaultSchema = <PassportLocalSchema>new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nDefaultSchema.plugin(passportLocalMongoose, {\n\tusernameUnique: true,\n\tlimitAttempts: true,\n\tmaxAttempts: 5,\n\tfindByUsername: (mongooseModel, queryParameters) => {\n\t\t// Add additional query parameter - AND condition - active: true\n\t\tqueryParameters.active = true;\n\t\treturn mongooseModel.findOne(queryParameters);\n\t}\n});\n\ninterface ResolveIOModel extends UserModel, PassportLocalDocument {}\nexport const Users: PassportLocalModel<ResolveIOModel> = ResolveIOServer.getMainDB().model('users', DefaultSchema);\n\nexport let ClientUsers: PassportLocalModel<ResolveIOModel> = null;\n\nif (ResolveIOServer.getSupportDB()) {\n\tClientUsers = ResolveIOServer.getSupportDB().model('client-users', DefaultSchema);\n}\n\nUsers['simplschema'] = new SimpleSchema(schema);\n\nschema._id = {\n\ttype: Schema.Types.Mixed\n};\n\nlet VersionSchema = new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nUsers['versionCollection'] = 'users.versions';\n\nexport const UserVersions: Model<ResolveIOModel> = ResolveIOServer.getMainDB().model(Users['versionCollection'], VersionSchema);\n\n//------------- Report Builder Schema\nlet rbLookups: LookupTables[] = [];\n\nlet rbSchema = Object.assign(schema, buildRbLookups(rbLookups, DefaultSchema, []));\nUsers['rbSchema'] = buildRbSchema(rbSchema);"]}
|
package/fixtures/init.js
CHANGED
|
@@ -37,8 +37,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
var app_version_collection_1 = require("../collections/app-version.collection");
|
|
40
|
-
var mongoose_1 = require("mongoose");
|
|
41
40
|
var active_subscription_collection_1 = require("../collections/active-subscription.collection");
|
|
41
|
+
var mongoose_1 = require("mongoose");
|
|
42
42
|
function loadServerInit() {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function () {
|
|
44
44
|
var appVersion;
|
package/fixtures/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fixtures/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gFAAoE;
|
|
1
|
+
{"version":3,"sources":["../../src/fixtures/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gFAAoE;AAEpE,gGAAoF;AACpF,qCAAiC;AAEjC,SAAsB,cAAc;;;;;wBAClB,qBAAM,oCAAW,CAAC,OAAO,EAAE,EAAA;;oBAAxC,UAAU,GAAG,SAA2B;oBAE5C,IAAI,CAAC,UAAU,EAAE;wBAChB,oCAAW,CAAC,MAAM,CAAC;4BAClB,GAAG,EAAE,gBAAK,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE;4BACnC,OAAO,EAAE,CAAC;yBACV,CAAC,CAAC;qBACH;oBAED,qBAAM,oDAAmB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,EAAA;;oBAA/C,SAA+C,CAAC;;;;;CAChD;AAXD,wCAWC","file":"init.js","sourcesContent":["import { AppVersions } from '../collections/app-version.collection';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { ActiveSubscriptions } from '../collections/active-subscription.collection';\nimport { Types } from 'mongoose';\n\nexport async function loadServerInit() {\n\tlet appVersion = await AppVersions.findOne();\n\n\tif (!appVersion) {\n\t\tAppVersions.create({\n\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\tversion: 1\n\t\t});\n\t}\n\n\tawait ActiveSubscriptions.deleteMany({}).exec();\n}"]}
|
|
@@ -135,16 +135,15 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
}, 25);
|
|
138
|
-
logged_in_users_collection_1.LoggedInUsers.find().then(function (loggedInUsers) {
|
|
139
|
-
_this._loggedInUsers = loggedInUsers;
|
|
140
|
-
}, function (err) {
|
|
141
|
-
console.log(err);
|
|
142
|
-
});
|
|
143
138
|
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
144
|
-
var userCopy, _loop_2, this_1, i;
|
|
145
|
-
return __generator(this, function (
|
|
146
|
-
switch (
|
|
139
|
+
var _a, userCopy, _loop_2, this_1, i, i, sub, _loop_3, this_2, j;
|
|
140
|
+
return __generator(this, function (_b) {
|
|
141
|
+
switch (_b.label) {
|
|
147
142
|
case 0:
|
|
143
|
+
_a = this;
|
|
144
|
+
return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.find()];
|
|
145
|
+
case 1:
|
|
146
|
+
_a._loggedInUsers = _b.sent();
|
|
148
147
|
userCopy = common_1.deepCopy(this._loggedInUsers);
|
|
149
148
|
_loop_2 = function (i) {
|
|
150
149
|
var loggedInUser;
|
|
@@ -181,17 +180,31 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
181
180
|
};
|
|
182
181
|
this_1 = this;
|
|
183
182
|
i = this._loggedInUsers.length - 1;
|
|
184
|
-
|
|
185
|
-
case 1:
|
|
186
|
-
if (!(i >= 0)) return [3 /*break*/, 4];
|
|
187
|
-
return [5 /*yield**/, _loop_2(i)];
|
|
183
|
+
_b.label = 2;
|
|
188
184
|
case 2:
|
|
189
|
-
|
|
190
|
-
|
|
185
|
+
if (!(i >= 0)) return [3 /*break*/, 5];
|
|
186
|
+
return [5 /*yield**/, _loop_2(i)];
|
|
191
187
|
case 3:
|
|
188
|
+
_b.sent();
|
|
189
|
+
_b.label = 4;
|
|
190
|
+
case 4:
|
|
192
191
|
i--;
|
|
193
|
-
return [3 /*break*/,
|
|
194
|
-
case
|
|
192
|
+
return [3 /*break*/, 2];
|
|
193
|
+
case 5:
|
|
194
|
+
for (i = 0; i < this._subscriptions.length; i++) {
|
|
195
|
+
sub = this._subscriptions[i];
|
|
196
|
+
_loop_3 = function (j) {
|
|
197
|
+
var client = sub.clients[j];
|
|
198
|
+
if (!this_2._loggedInUsers.some(function (a) { return a.id_ws === client.id_socket; })) {
|
|
199
|
+
sub.clients.splice(j, 1);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
this_2 = this;
|
|
203
|
+
for (j = sub.clients.length - 1; j >= 0; j--) {
|
|
204
|
+
_loop_3(j);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return [2 /*return*/];
|
|
195
208
|
}
|
|
196
209
|
});
|
|
197
210
|
}); }, 60000);
|
|
@@ -612,7 +625,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
612
625
|
var _this = this;
|
|
613
626
|
var that = this;
|
|
614
627
|
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
615
|
-
var uniqueOplog_1, uniquePubs, needIds_1,
|
|
628
|
+
var uniqueOplog_1, uniquePubs, needIds_1, _loop_4, i, _loop_5, i, _loop_6, this_3, i, i, pub;
|
|
616
629
|
var _this = this;
|
|
617
630
|
return __generator(this, function (_a) {
|
|
618
631
|
switch (_a.label) {
|
|
@@ -622,13 +635,13 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
622
635
|
this._oplogQueue = [];
|
|
623
636
|
uniquePubs = [];
|
|
624
637
|
needIds_1 = {};
|
|
625
|
-
|
|
638
|
+
_loop_4 = function (i) {
|
|
626
639
|
if (!that._subscriptions.some(function (a) { return a.collections.includes(uniqueOplog_1[i].collection); })) {
|
|
627
640
|
uniqueOplog_1.splice(i, 1);
|
|
628
641
|
}
|
|
629
642
|
};
|
|
630
643
|
for (i = uniqueOplog_1.length - 1; i >= 0; i--) {
|
|
631
|
-
|
|
644
|
+
_loop_4(i);
|
|
632
645
|
}
|
|
633
646
|
uniqueOplog_1.forEach(function (oplog) {
|
|
634
647
|
var schemaErrors = null;
|
|
@@ -649,7 +662,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
649
662
|
}
|
|
650
663
|
}
|
|
651
664
|
});
|
|
652
|
-
|
|
665
|
+
_loop_5 = function (i) {
|
|
653
666
|
var collection, docs;
|
|
654
667
|
return __generator(this, function (_a) {
|
|
655
668
|
switch (_a.label) {
|
|
@@ -681,7 +694,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
681
694
|
_a.label = 1;
|
|
682
695
|
case 1:
|
|
683
696
|
if (!(i < Object.keys(needIds_1).length)) return [3 /*break*/, 4];
|
|
684
|
-
return [5 /*yield**/,
|
|
697
|
+
return [5 /*yield**/, _loop_5(i)];
|
|
685
698
|
case 2:
|
|
686
699
|
_a.sent();
|
|
687
700
|
_a.label = 3;
|
|
@@ -689,13 +702,13 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
689
702
|
i++;
|
|
690
703
|
return [3 /*break*/, 1];
|
|
691
704
|
case 4:
|
|
692
|
-
|
|
693
|
-
var oplog,
|
|
705
|
+
_loop_6 = function (i) {
|
|
706
|
+
var oplog, _loop_7, j;
|
|
694
707
|
return __generator(this, function (_a) {
|
|
695
708
|
switch (_a.label) {
|
|
696
709
|
case 0:
|
|
697
710
|
oplog = uniqueOplog_1[i];
|
|
698
|
-
|
|
711
|
+
_loop_7 = function (j) {
|
|
699
712
|
var sub;
|
|
700
713
|
var _a;
|
|
701
714
|
return __generator(this, function (_b) {
|
|
@@ -723,9 +736,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
723
736
|
uniquePubs.push(common_1.deepCopy(sub));
|
|
724
737
|
_b.label = 3;
|
|
725
738
|
case 3:
|
|
726
|
-
if (
|
|
727
|
-
|
|
728
|
-
|
|
739
|
+
if (this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
740
|
+
this_3._nodeCache.del(this_3._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
741
|
+
this_3._subCache.splice(this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
729
742
|
}
|
|
730
743
|
_b.label = 4;
|
|
731
744
|
case 4: return [2 /*return*/, "continue"];
|
|
@@ -741,9 +754,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
741
754
|
}).exec()];
|
|
742
755
|
case 6:
|
|
743
756
|
_b.sent();
|
|
744
|
-
if (
|
|
745
|
-
|
|
746
|
-
|
|
757
|
+
if (this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
758
|
+
this_3._nodeCache.del(this_3._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
759
|
+
this_3._subCache.splice(this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
747
760
|
}
|
|
748
761
|
return [3 /*break*/, 8];
|
|
749
762
|
case 7:
|
|
@@ -767,9 +780,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
767
780
|
}).exec()];
|
|
768
781
|
case 10:
|
|
769
782
|
_b.sent();
|
|
770
|
-
if (
|
|
771
|
-
|
|
772
|
-
|
|
783
|
+
if (this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
784
|
+
this_3._nodeCache.del(this_3._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
785
|
+
this_3._subCache.splice(this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
773
786
|
}
|
|
774
787
|
return [3 /*break*/, 12];
|
|
775
788
|
case 11:
|
|
@@ -789,9 +802,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
789
802
|
}).exec()];
|
|
790
803
|
case 14:
|
|
791
804
|
_b.sent();
|
|
792
|
-
if (
|
|
793
|
-
|
|
794
|
-
|
|
805
|
+
if (this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
806
|
+
this_3._nodeCache.del(this_3._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
807
|
+
this_3._subCache.splice(this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
795
808
|
}
|
|
796
809
|
return [3 /*break*/, 16];
|
|
797
810
|
case 15:
|
|
@@ -806,7 +819,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
806
819
|
_a.label = 1;
|
|
807
820
|
case 1:
|
|
808
821
|
if (!(j >= 0)) return [3 /*break*/, 4];
|
|
809
|
-
return [5 /*yield**/,
|
|
822
|
+
return [5 /*yield**/, _loop_7(j)];
|
|
810
823
|
case 2:
|
|
811
824
|
_a.sent();
|
|
812
825
|
_a.label = 3;
|
|
@@ -817,12 +830,12 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
817
830
|
}
|
|
818
831
|
});
|
|
819
832
|
};
|
|
820
|
-
|
|
833
|
+
this_3 = this;
|
|
821
834
|
i = uniqueOplog_1.length - 1;
|
|
822
835
|
_a.label = 5;
|
|
823
836
|
case 5:
|
|
824
837
|
if (!(i >= 0)) return [3 /*break*/, 8];
|
|
825
|
-
return [5 /*yield**/,
|
|
838
|
+
return [5 /*yield**/, _loop_6(i)];
|
|
826
839
|
case 6:
|
|
827
840
|
_a.sent();
|
|
828
841
|
_a.label = 7;
|
|
@@ -849,24 +862,24 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
849
862
|
};
|
|
850
863
|
SubscriptionManager.prototype.resendPubsForDelete = function (collection) {
|
|
851
864
|
return __awaiter(this, void 0, void 0, function () {
|
|
852
|
-
var that, subCopy,
|
|
865
|
+
var that, subCopy, _loop_8, this_4, jj, _loop_9, zz;
|
|
853
866
|
var _this = this;
|
|
854
867
|
return __generator(this, function (_a) {
|
|
855
868
|
switch (_a.label) {
|
|
856
869
|
case 0:
|
|
857
870
|
that = this;
|
|
858
871
|
subCopy = common_1.deepCopy(that._subscriptions.filter(function (a) { return a.collections.includes(collection); }));
|
|
859
|
-
|
|
860
|
-
if (
|
|
861
|
-
|
|
862
|
-
|
|
872
|
+
_loop_8 = function (jj) {
|
|
873
|
+
if (this_4._subCache[jj].collection === collection || subCopy.some(function (a) { return a.publication === _this._subCache[jj].publication; })) {
|
|
874
|
+
this_4._nodeCache.del(this_4._subCache[jj].id);
|
|
875
|
+
this_4._subCache.splice(jj, 1);
|
|
863
876
|
}
|
|
864
877
|
};
|
|
865
|
-
|
|
878
|
+
this_4 = this;
|
|
866
879
|
for (jj = this._subCache.length - 1; jj >= 0; jj--) {
|
|
867
|
-
|
|
880
|
+
_loop_8(jj);
|
|
868
881
|
}
|
|
869
|
-
|
|
882
|
+
_loop_9 = function (zz) {
|
|
870
883
|
var sub, aa, client, bb, ws;
|
|
871
884
|
return __generator(this, function (_a) {
|
|
872
885
|
switch (_a.label) {
|
|
@@ -921,7 +934,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
921
934
|
_a.label = 1;
|
|
922
935
|
case 1:
|
|
923
936
|
if (!(zz >= 0)) return [3 /*break*/, 4];
|
|
924
|
-
return [5 /*yield**/,
|
|
937
|
+
return [5 /*yield**/, _loop_9(zz)];
|
|
925
938
|
case 2:
|
|
926
939
|
_a.sent();
|
|
927
940
|
_a.label = 3;
|