@resolveio/server-lib 4.2.6-newrole → 4.2.7-debug
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/fixtures/init.js +1 -1
- package/managers/subscription.manager.js +112 -85
- package/package.json +1 -1
|
@@ -21,6 +21,13 @@ var schema = {
|
|
|
21
21
|
type: Date,
|
|
22
22
|
optional: true
|
|
23
23
|
},
|
|
24
|
+
readonly: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
optional: true
|
|
27
|
+
},
|
|
28
|
+
active: {
|
|
29
|
+
type: Boolean
|
|
30
|
+
},
|
|
24
31
|
attempts: {
|
|
25
32
|
type: Number,
|
|
26
33
|
optional: true
|
|
@@ -57,67 +64,53 @@ var schema = {
|
|
|
57
64
|
type: String
|
|
58
65
|
},
|
|
59
66
|
roles: {
|
|
60
|
-
type: Object
|
|
61
|
-
},
|
|
62
|
-
'roles.super_admin': {
|
|
63
|
-
type: Boolean
|
|
64
|
-
},
|
|
65
|
-
'roles.approvals': {
|
|
66
67
|
type: Array
|
|
67
68
|
},
|
|
68
|
-
'roles
|
|
69
|
-
type: Object
|
|
70
|
-
},
|
|
71
|
-
'roles.approvals.$.name': {
|
|
69
|
+
'roles.$': {
|
|
72
70
|
type: String
|
|
73
71
|
},
|
|
74
|
-
|
|
75
|
-
type: String
|
|
72
|
+
phonenumber: {
|
|
73
|
+
type: String,
|
|
74
|
+
optional: true
|
|
76
75
|
},
|
|
77
|
-
|
|
78
|
-
type:
|
|
76
|
+
other: {
|
|
77
|
+
type: Object,
|
|
78
|
+
blackbox: true,
|
|
79
|
+
optional: true
|
|
79
80
|
},
|
|
80
|
-
|
|
81
|
-
type: Array
|
|
81
|
+
assets: {
|
|
82
|
+
type: Array,
|
|
83
|
+
optional: true
|
|
82
84
|
},
|
|
83
|
-
'
|
|
85
|
+
'assets.$': {
|
|
84
86
|
type: Object
|
|
85
87
|
},
|
|
86
|
-
'
|
|
88
|
+
'assets.$.type': {
|
|
87
89
|
type: String
|
|
88
90
|
},
|
|
89
|
-
'
|
|
90
|
-
type: Array
|
|
91
|
-
},
|
|
92
|
-
'roles.groups.$.views.$': {
|
|
91
|
+
'assets.$.id_asset': {
|
|
93
92
|
type: String
|
|
94
93
|
},
|
|
95
|
-
'
|
|
96
|
-
type: String
|
|
97
|
-
optional: true
|
|
94
|
+
'assets.$.asset_number': {
|
|
95
|
+
type: String
|
|
98
96
|
},
|
|
99
|
-
'
|
|
100
|
-
type:
|
|
97
|
+
'assets.$.ownership': {
|
|
98
|
+
type: String
|
|
101
99
|
},
|
|
102
|
-
'
|
|
100
|
+
'assets.$.ownership_driver': {
|
|
103
101
|
type: String
|
|
104
102
|
},
|
|
105
|
-
'
|
|
106
|
-
type:
|
|
103
|
+
'assets.$.date_start': {
|
|
104
|
+
type: Date
|
|
107
105
|
},
|
|
108
|
-
'
|
|
109
|
-
type:
|
|
106
|
+
'assets.$.date_end': {
|
|
107
|
+
type: Date,
|
|
108
|
+
optional: true
|
|
110
109
|
},
|
|
111
|
-
|
|
112
|
-
phonenumber: {
|
|
110
|
+
id_function: {
|
|
113
111
|
type: String,
|
|
114
112
|
optional: true
|
|
115
113
|
},
|
|
116
|
-
other: {
|
|
117
|
-
type: Object,
|
|
118
|
-
optional: true,
|
|
119
|
-
blackbox: true
|
|
120
|
-
},
|
|
121
114
|
customers: {
|
|
122
115
|
type: Array,
|
|
123
116
|
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 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;
|
|
@@ -504,105 +504,132 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
504
504
|
SubscriptionManager.prototype.runOpLogQueue = function () {
|
|
505
505
|
var _this = this;
|
|
506
506
|
var that = this;
|
|
507
|
-
setInterval(function () {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
needIds_1[oplog.collection] = [oplog.doc['_id']];
|
|
528
|
-
}
|
|
529
|
-
else {
|
|
530
|
-
if (!needIds_1[oplog.collection].filter(function (a) { return a === oplog.doc['_id']; })[0]) {
|
|
531
|
-
needIds_1[oplog.collection].push(oplog.doc['_id']);
|
|
507
|
+
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
508
|
+
var oplogQueue_1, uniquePubs_1, uniqueOplog_1, needIds_1, _loop_3, i;
|
|
509
|
+
var _this = this;
|
|
510
|
+
return __generator(this, function (_a) {
|
|
511
|
+
switch (_a.label) {
|
|
512
|
+
case 0:
|
|
513
|
+
if (!this._oplogQueue.length) return [3 /*break*/, 5];
|
|
514
|
+
oplogQueue_1 = common_1.deepCopy(this._oplogQueue);
|
|
515
|
+
this._oplogQueue = [];
|
|
516
|
+
uniquePubs_1 = [];
|
|
517
|
+
uniqueOplog_1 = [];
|
|
518
|
+
needIds_1 = {};
|
|
519
|
+
console.log('----------------OPLOG QUEUE START BEFORE DATA--------------------', new Date(), oplogQueue_1.length);
|
|
520
|
+
oplogQueue_1.forEach(function (oplog) {
|
|
521
|
+
for (var i = 0; i < that._subscriptions.length; i++) {
|
|
522
|
+
var sub = that._subscriptions[i];
|
|
523
|
+
if (sub.collections.includes(oplog.collection)) {
|
|
524
|
+
var schemaErrors = null;
|
|
525
|
+
try {
|
|
526
|
+
index_1.ResolveIOServer.getMainDB().model(oplog.collection)['simplschema'].validate(sub.preSubscriptionData);
|
|
532
527
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
docs = _a.sent();
|
|
545
|
-
needIds_1[collection].forEach(function (id_doc) {
|
|
546
|
-
oplogQueue_1.filter(function (a) { return a.doc._id === id_doc; })[0].doc = docs.filter(function (a) { return a._id === id_doc; });
|
|
547
|
-
});
|
|
548
|
-
return [2 /*return*/];
|
|
549
|
-
}
|
|
550
|
-
});
|
|
551
|
-
}); });
|
|
552
|
-
oplogQueue_1.forEach(function (oplog) { return __awaiter(_this, void 0, void 0, function () {
|
|
553
|
-
var _loop_3, i;
|
|
554
|
-
return __generator(this, function (_a) {
|
|
555
|
-
_loop_3 = function (i) {
|
|
556
|
-
var _a;
|
|
557
|
-
var sub = that._subscriptions[i];
|
|
558
|
-
if (sub.collections.includes(oplog.collection)) {
|
|
559
|
-
if (sub.preSubscriptionData) {
|
|
560
|
-
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
561
|
-
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
562
|
-
uniquePubs_1.push(sub);
|
|
563
|
-
uniqueOplog_1.push(oplog);
|
|
528
|
+
catch (errors) {
|
|
529
|
+
schemaErrors = errors;
|
|
530
|
+
}
|
|
531
|
+
if (schemaErrors) {
|
|
532
|
+
if (!needIds_1[oplog.collection]) {
|
|
533
|
+
needIds_1[oplog.collection] = [oplog.doc['_id']];
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
if (!needIds_1[oplog.collection].filter(function (a) { return a === oplog.doc['_id']; })[0]) {
|
|
537
|
+
needIds_1[oplog.collection].push(oplog.doc['_id']);
|
|
538
|
+
}
|
|
564
539
|
}
|
|
565
|
-
return "continue";
|
|
566
540
|
}
|
|
567
541
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
_loop_3 = function (i) {
|
|
545
|
+
var collection, docs;
|
|
546
|
+
return __generator(this, function (_a) {
|
|
547
|
+
switch (_a.label) {
|
|
548
|
+
case 0:
|
|
549
|
+
collection = Object.keys(needIds_1)[i];
|
|
550
|
+
return [4 /*yield*/, index_1.ResolveIOServer.getMainDB().model(collection).find({ _id: { $in: needIds_1[collection] } })];
|
|
551
|
+
case 1:
|
|
552
|
+
docs = _a.sent();
|
|
553
|
+
needIds_1[collection].forEach(function (id_doc) {
|
|
554
|
+
oplogQueue_1.filter(function (a) { return a.doc._id === id_doc; })[0].doc = docs.filter(function (a) { return a._id === id_doc; });
|
|
555
|
+
});
|
|
556
|
+
return [2 /*return*/];
|
|
574
557
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
i = 0;
|
|
561
|
+
_a.label = 1;
|
|
562
|
+
case 1:
|
|
563
|
+
if (!(i < Object.keys(needIds_1).length)) return [3 /*break*/, 4];
|
|
564
|
+
return [5 /*yield**/, _loop_3(i)];
|
|
565
|
+
case 2:
|
|
566
|
+
_a.sent();
|
|
567
|
+
_a.label = 3;
|
|
568
|
+
case 3:
|
|
569
|
+
i++;
|
|
570
|
+
return [3 /*break*/, 1];
|
|
571
|
+
case 4:
|
|
572
|
+
console.log('----------------OPLOG QUEUE START AFTER DATA--------------------', new Date(), oplogQueue_1.length);
|
|
573
|
+
oplogQueue_1.forEach(function (oplog) { return __awaiter(_this, void 0, void 0, function () {
|
|
574
|
+
var _loop_4, i;
|
|
575
|
+
return __generator(this, function (_a) {
|
|
576
|
+
console.log('OPLOG QUEUE START - Oplog', oplog);
|
|
577
|
+
_loop_4 = function (i) {
|
|
578
|
+
var _a;
|
|
579
|
+
var sub = that._subscriptions[i];
|
|
580
|
+
if (sub.collections.includes(oplog.collection)) {
|
|
581
|
+
if (sub.preSubscriptionData) {
|
|
582
|
+
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
583
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
584
|
+
uniquePubs_1.push(sub);
|
|
585
|
+
uniqueOplog_1.push(oplog);
|
|
586
|
+
}
|
|
587
|
+
return "continue";
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
if (that._publications[sub.publication].preFunction) {
|
|
578
591
|
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
579
592
|
uniquePubs_1.push(sub);
|
|
580
593
|
uniqueOplog_1.push(oplog);
|
|
581
594
|
}
|
|
582
595
|
return "continue";
|
|
583
596
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
597
|
+
else {
|
|
598
|
+
if (that._publications[sub.publication].fetchFunction) {
|
|
599
|
+
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
|
|
600
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
601
|
+
uniquePubs_1.push(sub);
|
|
602
|
+
uniqueOplog_1.push(oplog);
|
|
603
|
+
}
|
|
604
|
+
return "continue";
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
609
|
+
uniquePubs_1.push(sub);
|
|
610
|
+
uniqueOplog_1.push(oplog);
|
|
611
|
+
}
|
|
612
|
+
return "continue";
|
|
613
|
+
}
|
|
589
614
|
}
|
|
590
|
-
return "continue";
|
|
591
615
|
}
|
|
616
|
+
};
|
|
617
|
+
for (i = 0; i < that._subscriptions.length; i++) {
|
|
618
|
+
_loop_4(i);
|
|
592
619
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}, 100);
|
|
620
|
+
return [2 /*return*/];
|
|
621
|
+
});
|
|
622
|
+
}); });
|
|
623
|
+
console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog_1.length);
|
|
624
|
+
uniqueOplog_1.forEach(function (oplog) {
|
|
625
|
+
console.log('OPLOG QUEUE END - Oplog', oplog);
|
|
626
|
+
_this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
|
|
627
|
+
});
|
|
628
|
+
_a.label = 5;
|
|
629
|
+
case 5: return [2 /*return*/];
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
}); }, 100);
|
|
606
633
|
};
|
|
607
634
|
SubscriptionManager.prototype.resendPubsForDelete = function (collection) {
|
|
608
635
|
var that = this;
|