@resolveio/server-lib 20.9.7 → 20.9.8
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.js +22 -6
- package/managers/mongo.manager.js.map +1 -1
- package/managers/subscription.manager.d.ts +1 -0
- package/managers/subscription.manager.js +65 -14
- package/managers/subscription.manager.js.map +1 -1
- package/models/subscription.model.d.ts +2 -0
- package/models/subscription.model.js.map +1 -1
- package/package.json +1 -1
- package/util/subscription-dependency-context.d.ts +7 -0
- package/util/subscription-dependency-context.js +147 -44
- package/util/subscription-dependency-context.js.map +1 -1
|
@@ -124,6 +124,22 @@ var numCPUs = (0, os_1.cpus)().length;
|
|
|
124
124
|
var v8 = require('v8');
|
|
125
125
|
var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage;
|
|
126
126
|
var asyncLocalStorage = new AsyncLocalStorage();
|
|
127
|
+
function buildQueryMetaFromFindOptions(options) {
|
|
128
|
+
if (!options) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
var meta = {};
|
|
132
|
+
if (typeof options.limit === 'number') {
|
|
133
|
+
meta.limit = options.limit;
|
|
134
|
+
}
|
|
135
|
+
if (typeof options.skip === 'number') {
|
|
136
|
+
meta.skip = options.skip;
|
|
137
|
+
}
|
|
138
|
+
if (options.sort) {
|
|
139
|
+
meta.sort = (0, common_1.deepCopy)(options.sort);
|
|
140
|
+
}
|
|
141
|
+
return Object.keys(meta).length ? meta : null;
|
|
142
|
+
}
|
|
127
143
|
var MongoManager = /** @class */ (function () {
|
|
128
144
|
function MongoManager() {
|
|
129
145
|
this._collections = [];
|
|
@@ -330,7 +346,7 @@ var MongoManager = /** @class */ (function () {
|
|
|
330
346
|
if (resolveio_server_app_1.ResolveIOServer.getMainServer().getSubscriptionManager() && resolveio_server_app_1.ResolveIOServer.getMainServer().getSubscriptionManager().getEnableDebug()) {
|
|
331
347
|
console.log(new Date(), 'Mongo Find - Cache', collectionName);
|
|
332
348
|
}
|
|
333
|
-
(0, subscription_dependency_context_1.recordDependencyResult)(collectionName, result, { filter: filter });
|
|
349
|
+
(0, subscription_dependency_context_1.recordDependencyResult)(collectionName, result, { filter: filter, meta: buildQueryMetaFromFindOptions(safeOptions) });
|
|
334
350
|
return [2 /*return*/, result];
|
|
335
351
|
}
|
|
336
352
|
if (this._operationInProgress.has(cacheKey)) {
|
|
@@ -392,7 +408,7 @@ var MongoManager = /** @class */ (function () {
|
|
|
392
408
|
_b.sent();
|
|
393
409
|
return [7 /*endfinally*/];
|
|
394
410
|
case 6:
|
|
395
|
-
(0, subscription_dependency_context_1.recordDependencyResult)(collectionName, result, { filter: filter });
|
|
411
|
+
(0, subscription_dependency_context_1.recordDependencyResult)(collectionName, result, { filter: filter, meta: buildQueryMetaFromFindOptions(safeOptions) });
|
|
396
412
|
if (!this._operationInProgress.get(cacheKey).invalidatedDuringExecution) {
|
|
397
413
|
this.addToCache([collectionName], cacheKey, result);
|
|
398
414
|
}
|
|
@@ -417,7 +433,7 @@ var MongoManager = /** @class */ (function () {
|
|
|
417
433
|
if (resolveio_server_app_1.ResolveIOServer.getMainServer().getSubscriptionManager() && resolveio_server_app_1.ResolveIOServer.getMainServer().getSubscriptionManager().getEnableDebug()) {
|
|
418
434
|
console.log(new Date(), 'Mongo FindOne - Cache', collectionName);
|
|
419
435
|
}
|
|
420
|
-
(0, subscription_dependency_context_1.recordDependencyResult)(collectionName, result, { filter: filter });
|
|
436
|
+
(0, subscription_dependency_context_1.recordDependencyResult)(collectionName, result, { filter: filter, meta: buildQueryMetaFromFindOptions(safeOptions) });
|
|
421
437
|
return [2 /*return*/, result];
|
|
422
438
|
}
|
|
423
439
|
if (this._operationInProgress.has(cacheKey)) {
|
|
@@ -479,7 +495,7 @@ var MongoManager = /** @class */ (function () {
|
|
|
479
495
|
_b.sent();
|
|
480
496
|
return [7 /*endfinally*/];
|
|
481
497
|
case 6:
|
|
482
|
-
(0, subscription_dependency_context_1.recordDependencyResult)(collectionName, result, { filter: filter });
|
|
498
|
+
(0, subscription_dependency_context_1.recordDependencyResult)(collectionName, result, { filter: filter, meta: buildQueryMetaFromFindOptions(safeOptions) });
|
|
483
499
|
if (!this._operationInProgress.get(cacheKey).invalidatedDuringExecution) {
|
|
484
500
|
this.addToCache([collectionName], cacheKey, result);
|
|
485
501
|
}
|
|
@@ -2003,7 +2019,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
2003
2019
|
return [4 /*yield*/, resolveio_server_app_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).find(filter, options).toArray()];
|
|
2004
2020
|
case 3:
|
|
2005
2021
|
res = _b.sent();
|
|
2006
|
-
(0, subscription_dependency_context_1.recordDependencyResult)(this.collectionName, res, { filter: filter });
|
|
2022
|
+
(0, subscription_dependency_context_1.recordDependencyResult)(this.collectionName, res, { filter: filter, meta: buildQueryMetaFromFindOptions(safeOptions) });
|
|
2007
2023
|
return [2 /*return*/, res];
|
|
2008
2024
|
case 4:
|
|
2009
2025
|
err_16 = _b.sent();
|
|
@@ -2054,7 +2070,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
2054
2070
|
return [4 /*yield*/, resolveio_server_app_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).findOne({ _id: id }, options)];
|
|
2055
2071
|
case 3:
|
|
2056
2072
|
res = _b.sent();
|
|
2057
|
-
(0, subscription_dependency_context_1.recordDependencyResult)(this.collectionName, res, { filter: { _id: id } });
|
|
2073
|
+
(0, subscription_dependency_context_1.recordDependencyResult)(this.collectionName, res, { filter: { _id: id }, meta: buildQueryMetaFromFindOptions(safeOptions) });
|
|
2058
2074
|
return [2 /*return*/, res];
|
|
2059
2075
|
case 4:
|
|
2060
2076
|
err_17 = _b.sent();
|