@resolveio/server-lib 9.8.13 → 9.9.1
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/managers/mongo.manager.d.ts +0 -1
- package/managers/mongo.manager.js +39 -28
- package/managers/mongo.manager.js.map +1 -1
- package/managers/subscription.manager.d.ts +3 -3
- package/managers/subscription.manager.js +100 -76
- package/managers/subscription.manager.js.map +1 -1
- package/models/subscription.model.d.ts +1 -0
- package/models/subscription.model.js.map +1 -1
- package/package.json +1 -1
|
@@ -92,12 +92,11 @@ var MongoManager = /** @class */ (function () {
|
|
|
92
92
|
else {
|
|
93
93
|
_mongoQueue.cbs_next.push(mongoQueue.cbs[0]);
|
|
94
94
|
}
|
|
95
|
-
_mongoQueue.next_run = _mongoQueue.last_run ? moment(_mongoQueue.last_run).add(1, 'second').toDate() : null;
|
|
96
95
|
}
|
|
97
96
|
else {
|
|
98
97
|
mongoQueue._id = this._mongoQueueId;
|
|
99
98
|
this._mongoQueueId += 1;
|
|
100
|
-
this._mongoQueue.
|
|
99
|
+
this._mongoQueue.splice(0, 0, mongoQueue);
|
|
101
100
|
}
|
|
102
101
|
};
|
|
103
102
|
MongoManager.prototype.runQueue = function () {
|
|
@@ -122,9 +121,9 @@ var MongoManager = /** @class */ (function () {
|
|
|
122
121
|
mongoQueue.running = false;
|
|
123
122
|
}
|
|
124
123
|
else {
|
|
125
|
-
mongoQueue.last_run = new Date();
|
|
126
124
|
if (!mongoQueue.name_function_addt) {
|
|
127
125
|
(_a = index_1.ResolveIOServer.getMainDB().collection(mongoQueue.name_collection))[mongoQueue.name_function].apply(_a, mongoQueue.data_function).then(function (res) {
|
|
126
|
+
mongoQueue.next_run = moment().add(1, 'second').toDate();
|
|
128
127
|
mongoQueue.cacheId = _this._mongoQueueCacheId;
|
|
129
128
|
_this._mongoQueueCacheId += 1;
|
|
130
129
|
_this.addToCache(mongoQueue.cacheId, res);
|
|
@@ -146,11 +145,14 @@ var MongoManager = /** @class */ (function () {
|
|
|
146
145
|
mongoQueue.cbs_next.forEach(function (cb) {
|
|
147
146
|
cb(err, null, false);
|
|
148
147
|
});
|
|
149
|
-
|
|
148
|
+
if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
|
|
149
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
150
|
+
}
|
|
150
151
|
});
|
|
151
152
|
}
|
|
152
153
|
else {
|
|
153
154
|
(_b = (_c = index_1.ResolveIOServer.getMainDB().collection(mongoQueue.name_collection))[mongoQueue.name_function].apply(_c, mongoQueue.data_function))[mongoQueue.name_function_addt].apply(_b, mongoQueue.data_function_addt).then(function (res) {
|
|
155
|
+
mongoQueue.next_run = moment().add(1, 'second').toDate();
|
|
154
156
|
mongoQueue.cacheId = _this._mongoQueueCacheId;
|
|
155
157
|
_this._mongoQueueCacheId += 1;
|
|
156
158
|
_this.addToCache(mongoQueue.cacheId, res);
|
|
@@ -172,7 +174,9 @@ var MongoManager = /** @class */ (function () {
|
|
|
172
174
|
mongoQueue.cbs_next.forEach(function (cb) {
|
|
173
175
|
cb(err, null, false);
|
|
174
176
|
});
|
|
175
|
-
|
|
177
|
+
if (_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id) >= 0) {
|
|
178
|
+
_this._mongoQueue.splice(_this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
179
|
+
}
|
|
176
180
|
});
|
|
177
181
|
}
|
|
178
182
|
}
|
|
@@ -193,9 +197,12 @@ var MongoManager = /** @class */ (function () {
|
|
|
193
197
|
if (nodeCacheSize > this._heapLimit) {
|
|
194
198
|
var deleteCount = 0;
|
|
195
199
|
var queueArr = this._mongoQueue.filter(function (a) { return a.cacheId; });
|
|
196
|
-
for (var zz =
|
|
200
|
+
for (var zz = queueArr.length - 1; zz >= 0; zz--) {
|
|
197
201
|
this._nodeCache.del(queueArr[zz].cacheId);
|
|
198
202
|
queueArr[zz].cacheId = 0;
|
|
203
|
+
if (this._mongoQueue.map(function (a) { return a._id; }).indexOf(queueArr[zz]._id) >= 0) {
|
|
204
|
+
this._mongoQueue.splice(this._mongoQueue.map(function (a) { return a._id; }).indexOf(queueArr[zz]._id), 1);
|
|
205
|
+
}
|
|
199
206
|
deleteCount += 1;
|
|
200
207
|
nodeCacheSize = this._nodeCache.getStats().vsize;
|
|
201
208
|
if (nodeCacheSize < this._heapLimit * 0.75) {
|
|
@@ -207,11 +214,15 @@ var MongoManager = /** @class */ (function () {
|
|
|
207
214
|
this._nodeCache.set(id, JSON.stringify(data));
|
|
208
215
|
};
|
|
209
216
|
MongoManager.prototype.invalidateQueryCache = function (collection) {
|
|
210
|
-
var
|
|
211
|
-
|
|
212
|
-
|
|
217
|
+
var queueArr = this._mongoQueue.filter(function (a) { return (a.name_collection === collection || a.lookup_collections.includes(collection)); });
|
|
218
|
+
for (var i = queueArr.length - 1; i >= 0; i--) {
|
|
219
|
+
var queue = queueArr[i];
|
|
220
|
+
this._nodeCache.del(queue.cacheId);
|
|
213
221
|
queue.cacheId = 0;
|
|
214
|
-
|
|
222
|
+
if (this._mongoQueue.map(function (a) { return a._id; }).indexOf(queue._id) >= 0) {
|
|
223
|
+
this._mongoQueue.splice(this._mongoQueue.map(function (a) { return a._id; }).indexOf(queue._id), 1);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
215
226
|
};
|
|
216
227
|
return MongoManager;
|
|
217
228
|
}());
|
|
@@ -414,7 +425,7 @@ var Collection = /** @class */ (function () {
|
|
|
414
425
|
case 2:
|
|
415
426
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).deleteMany(filter, options).then(function (res) {
|
|
416
427
|
if (res.acknowledged) {
|
|
417
|
-
index_1.ResolveIOServer.
|
|
428
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
418
429
|
resolve(res.deletedCount);
|
|
419
430
|
}
|
|
420
431
|
else {
|
|
@@ -459,7 +470,7 @@ var Collection = /** @class */ (function () {
|
|
|
459
470
|
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc['_id'], __v: doc['__v'] } }, versionDoc, { upsert: true });
|
|
460
471
|
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc['_id'] }, { '_id.__v': { $lt: doc['__v'] - 1 } }] });
|
|
461
472
|
}
|
|
462
|
-
index_1.ResolveIOServer.
|
|
473
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(this.collectionName);
|
|
463
474
|
resolve(1);
|
|
464
475
|
}
|
|
465
476
|
else {
|
|
@@ -472,7 +483,7 @@ var Collection = /** @class */ (function () {
|
|
|
472
483
|
else {
|
|
473
484
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).deleteOne(filter, options).then(function (res) {
|
|
474
485
|
if (res.acknowledged) {
|
|
475
|
-
index_1.ResolveIOServer.
|
|
486
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
476
487
|
resolve(res.deletedCount);
|
|
477
488
|
}
|
|
478
489
|
else {
|
|
@@ -611,7 +622,7 @@ var Collection = /** @class */ (function () {
|
|
|
611
622
|
versionDoc['_id'] = { _id: doc['_id'], __v: doc['__v'] };
|
|
612
623
|
index_1.ResolveIOServer.getMongoManager().collection(_this.versionCollection).replaceOne({ _id: { _id: doc['_id'], __v: doc['__v'] } }, versionDoc, { upsert: true });
|
|
613
624
|
}
|
|
614
|
-
index_1.ResolveIOServer.
|
|
625
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
615
626
|
resolve(doc);
|
|
616
627
|
}
|
|
617
628
|
else {
|
|
@@ -678,7 +689,7 @@ var Collection = /** @class */ (function () {
|
|
|
678
689
|
versionDoc['_id'] = { _id: doc['_id'], __v: doc['__v'] };
|
|
679
690
|
index_1.ResolveIOServer.getMongoManager().collection(_this.versionCollection).replaceOne({ _id: { _id: doc['_id'], __v: doc['__v'] } }, versionDoc, { upsert: true });
|
|
680
691
|
}
|
|
681
|
-
index_1.ResolveIOServer.
|
|
692
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
682
693
|
resolve(doc);
|
|
683
694
|
}
|
|
684
695
|
else {
|
|
@@ -762,7 +773,7 @@ var Collection = /** @class */ (function () {
|
|
|
762
773
|
versionDoc['_id'] = { _id: doc['_id'], __v: doc['__v'] };
|
|
763
774
|
index_1.ResolveIOServer.getMongoManager().collection(_this.versionCollection).replaceOne({ _id: { _id: doc['_id'], __v: doc['__v'] } }, versionDoc, { upsert: true });
|
|
764
775
|
}
|
|
765
|
-
index_1.ResolveIOServer.
|
|
776
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
766
777
|
resolve(doc);
|
|
767
778
|
}
|
|
768
779
|
else {
|
|
@@ -837,7 +848,7 @@ var Collection = /** @class */ (function () {
|
|
|
837
848
|
if (validDocs.length) {
|
|
838
849
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).insertMany(validDocs, options).then(function (res) {
|
|
839
850
|
if (res.acknowledged) {
|
|
840
|
-
index_1.ResolveIOServer.
|
|
851
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
841
852
|
resolve(validDocs);
|
|
842
853
|
}
|
|
843
854
|
else {
|
|
@@ -896,7 +907,7 @@ var Collection = /** @class */ (function () {
|
|
|
896
907
|
}
|
|
897
908
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).insertOne(doc, options).then(function (res) {
|
|
898
909
|
if (res.acknowledged) {
|
|
899
|
-
index_1.ResolveIOServer.
|
|
910
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
900
911
|
resolve(doc);
|
|
901
912
|
}
|
|
902
913
|
else {
|
|
@@ -975,7 +986,7 @@ var Collection = /** @class */ (function () {
|
|
|
975
986
|
}
|
|
976
987
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options).then(function (res) {
|
|
977
988
|
if (res.acknowledged) {
|
|
978
|
-
index_1.ResolveIOServer.
|
|
989
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
979
990
|
resolve(res.modifiedCount);
|
|
980
991
|
}
|
|
981
992
|
else {
|
|
@@ -1017,7 +1028,7 @@ var Collection = /** @class */ (function () {
|
|
|
1017
1028
|
}
|
|
1018
1029
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, updatedDoc, options).then(function (res) {
|
|
1019
1030
|
if (res.acknowledged) {
|
|
1020
|
-
index_1.ResolveIOServer.
|
|
1031
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1021
1032
|
resolve(res.modifiedCount);
|
|
1022
1033
|
}
|
|
1023
1034
|
else {
|
|
@@ -1057,7 +1068,7 @@ var Collection = /** @class */ (function () {
|
|
|
1057
1068
|
}
|
|
1058
1069
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options).then(function (res) {
|
|
1059
1070
|
if (res.acknowledged) {
|
|
1060
|
-
index_1.ResolveIOServer.
|
|
1071
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1061
1072
|
resolve(res.modifiedCount);
|
|
1062
1073
|
}
|
|
1063
1074
|
else {
|
|
@@ -1119,14 +1130,14 @@ var Collection = /** @class */ (function () {
|
|
|
1119
1130
|
route: ''
|
|
1120
1131
|
});
|
|
1121
1132
|
}
|
|
1122
|
-
index_1.ResolveIOServer.
|
|
1133
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1123
1134
|
resolve(res.ok);
|
|
1124
1135
|
}, function (err) { return reject(err); });
|
|
1125
1136
|
}
|
|
1126
1137
|
else {
|
|
1127
1138
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options).then(function (res) {
|
|
1128
1139
|
if (res.acknowledged) {
|
|
1129
|
-
index_1.ResolveIOServer.
|
|
1140
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1130
1141
|
resolve(res.modifiedCount);
|
|
1131
1142
|
}
|
|
1132
1143
|
else {
|
|
@@ -1216,7 +1227,7 @@ var Collection = /** @class */ (function () {
|
|
|
1216
1227
|
case 2:
|
|
1217
1228
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateMany(filter, update, options).then(function (res) {
|
|
1218
1229
|
if (res.acknowledged) {
|
|
1219
|
-
index_1.ResolveIOServer.
|
|
1230
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1220
1231
|
resolve(res.modifiedCount);
|
|
1221
1232
|
}
|
|
1222
1233
|
else {
|
|
@@ -1292,7 +1303,7 @@ var Collection = /** @class */ (function () {
|
|
|
1292
1303
|
}
|
|
1293
1304
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options).then(function (res) {
|
|
1294
1305
|
if (res.acknowledged) {
|
|
1295
|
-
index_1.ResolveIOServer.
|
|
1306
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1296
1307
|
resolve(res.modifiedCount);
|
|
1297
1308
|
}
|
|
1298
1309
|
else {
|
|
@@ -1340,7 +1351,7 @@ var Collection = /** @class */ (function () {
|
|
|
1340
1351
|
}
|
|
1341
1352
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options).then(function (res) {
|
|
1342
1353
|
if (res.acknowledged) {
|
|
1343
|
-
index_1.ResolveIOServer.
|
|
1354
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1344
1355
|
resolve(res.modifiedCount);
|
|
1345
1356
|
}
|
|
1346
1357
|
else {
|
|
@@ -1413,7 +1424,7 @@ var Collection = /** @class */ (function () {
|
|
|
1413
1424
|
messageId: 0,
|
|
1414
1425
|
route: ''
|
|
1415
1426
|
});
|
|
1416
|
-
index_1.ResolveIOServer.
|
|
1427
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1417
1428
|
resolve(res.ok);
|
|
1418
1429
|
}
|
|
1419
1430
|
else {
|
|
@@ -1424,7 +1435,7 @@ var Collection = /** @class */ (function () {
|
|
|
1424
1435
|
else {
|
|
1425
1436
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options).then(function (res) {
|
|
1426
1437
|
if (res.acknowledged) {
|
|
1427
|
-
index_1.ResolveIOServer.
|
|
1438
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1428
1439
|
resolve(res.modifiedCount);
|
|
1429
1440
|
}
|
|
1430
1441
|
else {
|