@resolveio/server-lib 4.4.8 → 4.4.10-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 +29 -32
- 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;
|
|
@@ -510,7 +510,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
510
510
|
var _this = this;
|
|
511
511
|
var that = this;
|
|
512
512
|
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
513
|
-
var uniqueOplog_1, uniquePubs, needIds_1, _loop_3, i, i, oplog,
|
|
513
|
+
var uniqueOplog_1, uniquePubs, needIds_1, _loop_3, i, _loop_4, i, i, oplog, _loop_5, j, state_1;
|
|
514
514
|
var _this = this;
|
|
515
515
|
return __generator(this, function (_a) {
|
|
516
516
|
switch (_a.label) {
|
|
@@ -520,6 +520,14 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
520
520
|
this._oplogQueue = [];
|
|
521
521
|
uniquePubs = [];
|
|
522
522
|
needIds_1 = {};
|
|
523
|
+
_loop_3 = function (i) {
|
|
524
|
+
if (!that._subscriptions.some(function (a) { return a.collections.includes(uniqueOplog_1[i].collection); })) {
|
|
525
|
+
uniqueOplog_1.splice(i, 1);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
for (i = uniqueOplog_1.length - 1; i >= 0; i--) {
|
|
529
|
+
_loop_3(i);
|
|
530
|
+
}
|
|
523
531
|
uniqueOplog_1.forEach(function (oplog) {
|
|
524
532
|
var schemaErrors = null;
|
|
525
533
|
try {
|
|
@@ -539,7 +547,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
539
547
|
}
|
|
540
548
|
}
|
|
541
549
|
});
|
|
542
|
-
|
|
550
|
+
_loop_4 = function (i) {
|
|
543
551
|
var collection, docs;
|
|
544
552
|
return __generator(this, function (_a) {
|
|
545
553
|
switch (_a.label) {
|
|
@@ -564,7 +572,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
564
572
|
_a.label = 1;
|
|
565
573
|
case 1:
|
|
566
574
|
if (!(i < Object.keys(needIds_1).length)) return [3 /*break*/, 4];
|
|
567
|
-
return [5 /*yield**/,
|
|
575
|
+
return [5 /*yield**/, _loop_4(i)];
|
|
568
576
|
case 2:
|
|
569
577
|
_a.sent();
|
|
570
578
|
_a.label = 3;
|
|
@@ -577,17 +585,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
577
585
|
case 5:
|
|
578
586
|
if (!(i >= 0)) return [3 /*break*/, 10];
|
|
579
587
|
oplog = uniqueOplog_1[i];
|
|
580
|
-
|
|
581
|
-
var _a,
|
|
582
|
-
return __generator(this, function (
|
|
583
|
-
switch (
|
|
588
|
+
_loop_5 = function (j) {
|
|
589
|
+
var _a, sub, _b;
|
|
590
|
+
return __generator(this, function (_c) {
|
|
591
|
+
switch (_c.label) {
|
|
584
592
|
case 0:
|
|
585
593
|
sub = that._subscriptions[j];
|
|
586
|
-
if (!(oplog.type === 'update')) return [3 /*break*/, 4];
|
|
587
594
|
if (!sub.collections.includes(oplog.collection)) return [3 /*break*/, 3];
|
|
588
595
|
if (sub.preSubscriptionData) {
|
|
589
596
|
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
590
597
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
598
|
+
sub['oplog'] = oplog;
|
|
591
599
|
uniquePubs.push(sub);
|
|
592
600
|
}
|
|
593
601
|
else {
|
|
@@ -597,12 +605,13 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
597
605
|
}
|
|
598
606
|
}
|
|
599
607
|
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
|
|
600
|
-
|
|
608
|
+
_b = sub;
|
|
601
609
|
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
602
610
|
case 1:
|
|
603
|
-
|
|
611
|
+
_b.preSubscriptionData = _c.sent();
|
|
604
612
|
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
605
613
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
614
|
+
sub['oplog'] = oplog;
|
|
606
615
|
uniquePubs.push(sub);
|
|
607
616
|
}
|
|
608
617
|
else {
|
|
@@ -615,6 +624,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
615
624
|
if (that._publications[sub.publication].fetchFunction) {
|
|
616
625
|
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
|
|
617
626
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
627
|
+
sub['oplog'] = oplog;
|
|
618
628
|
uniquePubs.push(sub);
|
|
619
629
|
}
|
|
620
630
|
else {
|
|
@@ -625,6 +635,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
625
635
|
}
|
|
626
636
|
else {
|
|
627
637
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
638
|
+
sub['oplog'] = oplog;
|
|
628
639
|
uniquePubs.push(sub);
|
|
629
640
|
}
|
|
630
641
|
else {
|
|
@@ -632,22 +643,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
632
643
|
}
|
|
633
644
|
return [2 /*return*/, "break"];
|
|
634
645
|
}
|
|
635
|
-
|
|
636
|
-
case 3: return [
|
|
637
|
-
case 4:
|
|
638
|
-
if (oplog.type === 'insert') {
|
|
639
|
-
if (sub.collections.includes(oplog.collection) && (that._publications[sub.publication].preFunction || !that._publications[sub.publication].fetchFunction || (_b = that._publications[sub.publication]).fetchFunction.apply(_b, [oplog.doc].concat(sub.subscriptionData)))) {
|
|
640
|
-
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
641
|
-
uniquePubs.push(sub);
|
|
642
|
-
}
|
|
643
|
-
else {
|
|
644
|
-
uniqueOplog_1.splice(i, 1);
|
|
645
|
-
}
|
|
646
|
-
return [2 /*return*/, "break"];
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
_d.label = 5;
|
|
650
|
-
case 5: return [2 /*return*/];
|
|
646
|
+
_c.label = 3;
|
|
647
|
+
case 3: return [2 /*return*/];
|
|
651
648
|
}
|
|
652
649
|
});
|
|
653
650
|
};
|
|
@@ -655,7 +652,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
655
652
|
_a.label = 6;
|
|
656
653
|
case 6:
|
|
657
654
|
if (!(j < that._subscriptions.length)) return [3 /*break*/, 9];
|
|
658
|
-
return [5 /*yield**/,
|
|
655
|
+
return [5 /*yield**/, _loop_5(j)];
|
|
659
656
|
case 7:
|
|
660
657
|
state_1 = _a.sent();
|
|
661
658
|
if (state_1 === "break")
|
|
@@ -668,8 +665,8 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
668
665
|
i--;
|
|
669
666
|
return [3 /*break*/, 5];
|
|
670
667
|
case 10:
|
|
671
|
-
|
|
672
|
-
_this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
|
|
668
|
+
uniquePubs.forEach(function (pub) {
|
|
669
|
+
_this.checkPubsForChanges(pub['oplog'].collection, pub['oplog'].doc, pub['oplog'].type);
|
|
673
670
|
});
|
|
674
671
|
_a.label = 11;
|
|
675
672
|
case 11: return [2 /*return*/];
|
|
@@ -699,12 +696,12 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
699
696
|
// Check to see if any pubs need to refetch due to Mongo operation
|
|
700
697
|
SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type) {
|
|
701
698
|
return __awaiter(this, void 0, void 0, function () {
|
|
702
|
-
var that,
|
|
699
|
+
var that, _loop_6, i;
|
|
703
700
|
return __generator(this, function (_a) {
|
|
704
701
|
switch (_a.label) {
|
|
705
702
|
case 0:
|
|
706
703
|
that = this;
|
|
707
|
-
|
|
704
|
+
_loop_6 = function (i) {
|
|
708
705
|
var _a, _b, sub, _c, _d;
|
|
709
706
|
return __generator(this, function (_e) {
|
|
710
707
|
switch (_e.label) {
|
|
@@ -770,7 +767,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
770
767
|
_a.label = 1;
|
|
771
768
|
case 1:
|
|
772
769
|
if (!(i < that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).length)) return [3 /*break*/, 4];
|
|
773
|
-
return [5 /*yield**/,
|
|
770
|
+
return [5 /*yield**/, _loop_6(i)];
|
|
774
771
|
case 2:
|
|
775
772
|
_a.sent();
|
|
776
773
|
_a.label = 3;
|