@resolveio/server-lib 4.2.5-newrole → 4.2.6-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.
|
@@ -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;
|
|
@@ -12,8 +12,8 @@ export declare class SubscriptionManager {
|
|
|
12
12
|
constructor(mainServer: any, wss: WebSocket.Server, serverConfig: any);
|
|
13
13
|
publications(method: SubscriptionModel): void;
|
|
14
14
|
loggedInLatency(ws: WebSocket): Promise<void>;
|
|
15
|
-
subscribe(ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]): Promise<void>;
|
|
16
|
-
unsubscribe(ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]): Promise<void>;
|
|
15
|
+
subscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]): Promise<void>;
|
|
16
|
+
unsubscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]): Promise<void>;
|
|
17
17
|
unsubscribeAll(ws: WebSocket): Promise<void>;
|
|
18
18
|
private getPublicationCollections;
|
|
19
19
|
private tailOpLog;
|
|
@@ -131,10 +131,10 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
131
131
|
});
|
|
132
132
|
};
|
|
133
133
|
// Subscribe to publication
|
|
134
|
-
SubscriptionManager.prototype.subscribe = function (ws, messageId, publication) {
|
|
134
|
+
SubscriptionManager.prototype.subscribe = function (messageDate, ws, messageId, publication) {
|
|
135
135
|
var subscriptionData = [];
|
|
136
|
-
for (var _i =
|
|
137
|
-
subscriptionData[_i -
|
|
136
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
|
137
|
+
subscriptionData[_i - 4] = arguments[_i];
|
|
138
138
|
}
|
|
139
139
|
return __awaiter(this, void 0, void 0, function () {
|
|
140
140
|
var _a, that, pub, valObj, valKeys, rootKeys, i, sub, _b, newActiveSub, begDate, endDate, billUser;
|
|
@@ -199,6 +199,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
199
199
|
if (!sub) {
|
|
200
200
|
sub = that._subscriptions.filter(function (a) { return a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData); })[0];
|
|
201
201
|
}
|
|
202
|
+
// console.log('Subscribe', new Date(), 'Success', sub);
|
|
202
203
|
// Send pub data to client who just subscribed only, don't want to send to existing clients since nothing has changed
|
|
203
204
|
that.sendPubDataOnce(ws, messageId, sub, 'newSub', that.getPublicationCollections(publication)[0]);
|
|
204
205
|
if (!(that._publications[sub.publication].preFunction && !sub.preSubscriptionData)) return [3 /*break*/, 3];
|
|
@@ -270,10 +271,10 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
270
271
|
});
|
|
271
272
|
};
|
|
272
273
|
// Unsubscribe from publication
|
|
273
|
-
SubscriptionManager.prototype.unsubscribe = function (ws, messageId, publication) {
|
|
274
|
+
SubscriptionManager.prototype.unsubscribe = function (messageDate, ws, messageId, publication) {
|
|
274
275
|
var subscriptionData = [];
|
|
275
|
-
for (var _i =
|
|
276
|
-
subscriptionData[_i -
|
|
276
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
|
277
|
+
subscriptionData[_i - 4] = arguments[_i];
|
|
277
278
|
}
|
|
278
279
|
return __awaiter(this, void 0, void 0, function () {
|
|
279
280
|
var that, sub, i, activeSub;
|
|
@@ -509,7 +510,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
509
510
|
var uniquePubs_1 = [];
|
|
510
511
|
var uniqueOplog_1 = [];
|
|
511
512
|
var needIds_1 = {};
|
|
513
|
+
console.log('----------------OPLOG QUEUE START--------------------', new Date(), oplogQueue_1.length);
|
|
512
514
|
oplogQueue_1.forEach(function (oplog) {
|
|
515
|
+
console.log('OPLOG QUEUE START - Oplog', oplog);
|
|
513
516
|
for (var i = 0; i < that._subscriptions.length; i++) {
|
|
514
517
|
var sub = that._subscriptions[i];
|
|
515
518
|
if (sub.collections.includes(oplog.collection)) {
|
|
@@ -550,90 +553,55 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
550
553
|
oplogQueue_1.forEach(function (oplog) { return __awaiter(_this, void 0, void 0, function () {
|
|
551
554
|
var _loop_3, i;
|
|
552
555
|
return __generator(this, function (_a) {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if (sub.preSubscriptionData) {
|
|
563
|
-
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
564
|
-
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0]) {
|
|
565
|
-
uniquePubs_1.push(sub);
|
|
566
|
-
uniqueOplog_1.push(oplog);
|
|
567
|
-
}
|
|
568
|
-
return [2 /*return*/, "continue"];
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
|
|
572
|
-
_b = sub;
|
|
573
|
-
return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
|
|
574
|
-
case 1:
|
|
575
|
-
_b.preSubscriptionData = _c.sent();
|
|
576
|
-
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
577
|
-
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
578
|
-
uniquePubs_1.push(sub);
|
|
579
|
-
uniqueOplog_1.push(oplog);
|
|
580
|
-
}
|
|
581
|
-
return [2 /*return*/, "continue"];
|
|
582
|
-
}
|
|
583
|
-
return [3 /*break*/, 3];
|
|
584
|
-
case 2:
|
|
585
|
-
if (that._publications[sub.publication].ws_specific) {
|
|
586
|
-
sub.clients.forEach(function (client) {
|
|
587
|
-
var _a;
|
|
588
|
-
if (that._publications[sub.publication].fetchFunction) {
|
|
589
|
-
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc, client.id_user].concat(sub.subscriptionData))) {
|
|
590
|
-
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0]) {
|
|
591
|
-
uniquePubs_1.push(sub);
|
|
592
|
-
uniqueOplog_1.push(oplog);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
else {
|
|
599
|
-
if (that._publications[sub.publication].fetchFunction) {
|
|
600
|
-
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
|
|
601
|
-
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
602
|
-
uniquePubs_1.push(sub);
|
|
603
|
-
uniqueOplog_1.push(oplog);
|
|
604
|
-
}
|
|
605
|
-
return [2 /*return*/, "continue"];
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
else {
|
|
609
|
-
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
610
|
-
uniquePubs_1.push(sub);
|
|
611
|
-
uniqueOplog_1.push(oplog);
|
|
612
|
-
}
|
|
613
|
-
return [2 /*return*/, "continue"];
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
_c.label = 3;
|
|
617
|
-
case 3: return [2 /*return*/];
|
|
556
|
+
_loop_3 = function (i) {
|
|
557
|
+
var _a;
|
|
558
|
+
var sub = that._subscriptions[i];
|
|
559
|
+
if (sub.collections.includes(oplog.collection)) {
|
|
560
|
+
if (sub.preSubscriptionData) {
|
|
561
|
+
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
562
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
563
|
+
uniquePubs_1.push(sub);
|
|
564
|
+
uniqueOplog_1.push(oplog);
|
|
618
565
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
566
|
+
return "continue";
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
if (that._publications[sub.publication].preFunction) {
|
|
570
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
571
|
+
uniquePubs_1.push(sub);
|
|
572
|
+
uniqueOplog_1.push(oplog);
|
|
573
|
+
}
|
|
574
|
+
return "continue";
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
if (that._publications[sub.publication].fetchFunction) {
|
|
578
|
+
if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
|
|
579
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
580
|
+
uniquePubs_1.push(sub);
|
|
581
|
+
uniqueOplog_1.push(oplog);
|
|
582
|
+
}
|
|
583
|
+
return "continue";
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
|
|
588
|
+
uniquePubs_1.push(sub);
|
|
589
|
+
uniqueOplog_1.push(oplog);
|
|
590
|
+
}
|
|
591
|
+
return "continue";
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
for (i = 0; i < that._subscriptions.length; i++) {
|
|
597
|
+
_loop_3(i);
|
|
633
598
|
}
|
|
599
|
+
return [2 /*return*/];
|
|
634
600
|
});
|
|
635
601
|
}); });
|
|
602
|
+
console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog_1.length);
|
|
636
603
|
uniqueOplog_1.forEach(function (oplog) {
|
|
604
|
+
console.log('OPLOG QUEUE END - Oplog', oplog);
|
|
637
605
|
_this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
|
|
638
606
|
});
|
|
639
607
|
}
|
|
@@ -817,6 +785,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
817
785
|
hasError: false,
|
|
818
786
|
data: res
|
|
819
787
|
};
|
|
788
|
+
// console.log('Send Pub Data Once 1', new Date(), 'Success', subscription);
|
|
820
789
|
_this.sendWS(ws, serverRes);
|
|
821
790
|
}, function (err) {
|
|
822
791
|
var serverRes = {
|
|
@@ -824,6 +793,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
824
793
|
hasError: true,
|
|
825
794
|
data: err
|
|
826
795
|
};
|
|
796
|
+
// console.log('Send Pub Data Once 1', new Date(), 'Error', subscription);
|
|
827
797
|
_this.sendWS(ws, serverRes);
|
|
828
798
|
});
|
|
829
799
|
}
|
|
@@ -834,6 +804,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
834
804
|
hasError: false,
|
|
835
805
|
data: res
|
|
836
806
|
};
|
|
807
|
+
// console.log('Send Pub Data Once 2', new Date(), 'Success', subscription);
|
|
837
808
|
_this.sendWS(ws, serverRes);
|
|
838
809
|
}, function (err) {
|
|
839
810
|
var serverRes = {
|
|
@@ -841,6 +812,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
841
812
|
hasError: true,
|
|
842
813
|
data: err
|
|
843
814
|
};
|
|
815
|
+
// console.log('Send Pub Data Once 2', new Date(), 'Error', subscription);
|
|
844
816
|
_this.sendWS(ws, serverRes);
|
|
845
817
|
});
|
|
846
818
|
}
|
package/package.json
CHANGED
package/server-app.js
CHANGED
|
@@ -278,11 +278,11 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
278
278
|
pub = data.shift();
|
|
279
279
|
// Subscribe
|
|
280
280
|
if (subType === 'sub') {
|
|
281
|
-
(_a = this._subscriptionManager).subscribe.apply(_a, [ws, messageId, pub].concat(data));
|
|
281
|
+
(_a = this._subscriptionManager).subscribe.apply(_a, [messageDate, ws, messageId, pub].concat(data));
|
|
282
282
|
}
|
|
283
283
|
// Unsubscribe
|
|
284
284
|
else {
|
|
285
|
-
(_b = this._subscriptionManager).unsubscribe.apply(_b, [ws, messageId, pub].concat(data));
|
|
285
|
+
(_b = this._subscriptionManager).unsubscribe.apply(_b, [messageDate, ws, messageId, pub].concat(data));
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
else {
|