@resolveio/server-lib 6.3.5 → 6.3.6-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/collections/user.collection.js.map +1 -1
- package/managers/subscription.manager.js +45 -100
- package/managers/subscription.manager.js.map +1 -1
- package/methods/accounts.js.map +1 -1
- package/methods/cron-jobs.js.map +1 -1
- 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,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/user.collection.ts"],"names":[],"mappings":";;AAAA,qCAAwG;AACxG,+DAAiE;AACjE,6CAAwC;AACxC,kCAA2C;AAG3C,uEAA8E;AAE9E,IAAI,MAAM,GAAQ;IACjB,GAAG,EAAE;QACJ,IAAI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AAY,EAAG,CAAC,KAAK,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;CACzF;AAED,aAAK,CAAC,aAAa,CAAC,GAAG,IAAI,sBAAY,CAAC,MAAM,CAAC,CAAC;AAEhD,MAAM,CAAC,GAAG,GAAG;IACZ,IAAI,EAAE,iBAAM,CAAC,KAAK,CAAC,KAAK;CACxB,CAAC;AAEF,IAAI,aAAa,GAAG,IAAI,iBAAM,CAAC,MAAM,EAAE;IACtC,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,IAAI;CAChB,CAAC,CAAC;AAEH,aAAK,CAAC,mBAAmB,CAAC,GAAG,gBAAgB,CAAC;AAEjC,QAAA,YAAY,GAA0B,uBAAe,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,aAAK,CAAC,mBAAmB,CAAC,EAAE,aAAa,CAAC,CAAC;AAEhI,qCAAqC;AACrC,IAAI,SAAS,GAAmB,EAAE,CAAC;AAEnC,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,sCAAc,CAAC,SAAS,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC;AACnF,aAAK,CAAC,UAAU,CAAC,GAAG,qCAAa,CAAC,QAAQ,CAAC,CAAC","file":"user.collection.js","sourcesContent":["import { Schema, Model, PassportLocalDocument, PassportLocalModel, PassportLocalSchema} from 'mongoose';\nimport * as passportLocalMongoose from 'passport-local-mongoose';\nimport SimpleSchema from 'simpl-schema';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\nimport { LookupTables } from '../models/report-builder.model';\nimport { buildRbSchema, buildRbLookups } from '../util/schema-report-builder';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tattempts: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tlast: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tservices: {\n\t\ttype: Object,\n\t\toptional: true\n\t},\n\t'services.enrollment': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.forgot_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'services.reset_password': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tusername: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\temail: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tfullname: {\n\t\ttype: String\n\t},\n\troles: {\n\t\ttype: Object\n\t},\n\t'roles.super_admin': {\n\t\ttype: Boolean\n\t},\n\t'roles.approvals': {\n\t\ttype: Array\n\t},\n\t'roles.approvals.$': {\n\t\ttype: Object\n\t},\n\t'roles.approvals.$.name': {\n\t\ttype: String\n\t},\n\t'roles.approvals.$.type': {\n\t\ttype: String\n\t},\n\t'roles.approvals.$.accounting_code': {\n\t\ttype: String\n\t},\n\t'roles.groups': {\n\t\ttype: Array\n\t},\n\t'roles.groups.$': {\n\t\ttype: Object\n\t},\n\t'roles.groups.$.name': {\n\t\ttype: String\n\t},\n\t'roles.groups.$.views': {\n\t\ttype: Array\n\t},\n\t'roles.groups.$.views.$': {\n\t\ttype: String\n\t},\n\t'roles.groups.$.yard': {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t'roles.notifications': {\n\t\ttype: Array\n\t},\n\t'roles.notifications.$': {\n\t\ttype: String\n\t},\n\t'roles.miscs': {\n\t\ttype: Array\n\t},\n\t'roles.miscs.$': {\n\t\ttype: String\n\t},\n\tactive: Boolean,\n\tphonenumber: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tother: {\n\t\ttype: Object,\n\t\toptional: true,\n\t\tblackbox: true\n\t},\n\tcustomers: {\n\t\ttype: Array,\n\t\toptional: true,\n\t},\n\t'customers.$': {\n\t\ttype: Object\n\t},\n\t'customers.$.id_customer': {\n\t\ttype: String\n\t},\n\t'customers.$.customer': {\n\t\ttype: String\n\t},\n\tid_customer: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomer: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tcustomer_type: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tdepartments: {\n\t\ttype: Array,\n\t\toptional: true\n\t},\n\t'departments.$': {\n\t\ttype: Object\n\t},\n\t'departments.$.id_department': {\n\t\ttype: String\n\t},\n\t'departments.$.department': {\n\t\ttype: String\n\t}\n};\n\nconst DefaultSchema = <PassportLocalSchema>new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nDefaultSchema.plugin(passportLocalMongoose, {\n\tusernameUnique: true,\n\tlimitAttempts: true,\n\tmaxAttempts: 5,\n\tfindByUsername: (mongooseModel, queryParameters) => {\n\t\t// Add additional query parameter - AND condition - active: true\n\t\tqueryParameters.active = true;\n\t\treturn mongooseModel.findOne(queryParameters);\n\t}\n});\n\ninterface ResolveIOModel extends UserModel, PassportLocalDocument {}\nexport const Users: PassportLocalModel<ResolveIOModel> = (<any>ResolveIOServer.getMainDB()).model('users', DefaultSchema);\n\nexport let ClientUsers: PassportLocalModel<ResolveIOModel> = null;\n\nif (ResolveIOServer.getSupportDB()) {\n\tClientUsers = (<any>ResolveIOServer.getSupportDB()).model('client-users', DefaultSchema);\n}\n\nUsers['simplschema'] = new SimpleSchema(schema);\n\nschema._id = {\n\ttype: Schema.Types.Mixed\n};\n\nlet VersionSchema = new Schema(schema, {\n\tskipVersioning: true,\n\tversionKey: false,\n\ttimestamps: true\n});\n\nUsers['versionCollection'] = 'users.versions';\n\nexport const UserVersions: Model<ResolveIOModel> = ResolveIOServer.getMainDB().model(Users['versionCollection'], VersionSchema);\n\n//------------- Report Builder Schema\nlet rbLookups: LookupTables[] = [];\n\nlet rbSchema = Object.assign(schema, buildRbLookups(rbLookups, DefaultSchema, []));\nUsers['rbSchema'] = buildRbSchema(rbSchema);"]}
|
|
@@ -508,7 +508,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
508
508
|
var _this = this;
|
|
509
509
|
var that = this;
|
|
510
510
|
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
511
|
-
var uniqueOplog_1, uniquePubs, _loop_4, i, _loop_5,
|
|
511
|
+
var uniqueOplog_1, uniquePubs, _loop_4, i, _loop_5, i, i, pub;
|
|
512
512
|
return __generator(this, function (_a) {
|
|
513
513
|
if (this._oplogQueue.length) {
|
|
514
514
|
uniqueOplog_1 = common_1.deepCopy(this._oplogQueue);
|
|
@@ -531,7 +531,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
531
531
|
if (sub.collections.includes(oplog.collection)) {
|
|
532
532
|
if (sub.preSubscriptionData) {
|
|
533
533
|
if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
|
|
534
|
-
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)
|
|
534
|
+
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
535
535
|
if (!sub.clients.length) {
|
|
536
536
|
that._subscriptions.splice(j, 1);
|
|
537
537
|
}
|
|
@@ -539,10 +539,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
539
539
|
sub['oplog'] = oplog;
|
|
540
540
|
uniquePubs.push(common_1.deepCopy(sub));
|
|
541
541
|
}
|
|
542
|
-
if (this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
543
|
-
this_3._nodeCache.del(this_3._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
544
|
-
this_3._subCache.splice(this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
545
|
-
}
|
|
546
542
|
}
|
|
547
543
|
return "continue";
|
|
548
544
|
}
|
|
@@ -550,10 +546,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
550
546
|
if (that._publications[sub.publication].preFunction) {
|
|
551
547
|
if (!sub.clients.length) {
|
|
552
548
|
that._subscriptions.splice(j, 1);
|
|
553
|
-
if (this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
554
|
-
this_3._nodeCache.del(this_3._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
555
|
-
this_3._subCache.splice(this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
556
|
-
}
|
|
557
549
|
}
|
|
558
550
|
else {
|
|
559
551
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData) && JSON.stringify(oplog) === JSON.stringify(a.oplog); }).length) {
|
|
@@ -568,10 +560,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
568
560
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
569
561
|
if (!sub.clients.length) {
|
|
570
562
|
that._subscriptions.splice(j, 1);
|
|
571
|
-
if (this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
572
|
-
this_3._nodeCache.del(this_3._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
573
|
-
this_3._subCache.splice(this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
574
|
-
}
|
|
575
563
|
}
|
|
576
564
|
else {
|
|
577
565
|
sub['oplog'] = oplog;
|
|
@@ -584,10 +572,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
584
572
|
if (!uniquePubs.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }).length) {
|
|
585
573
|
if (!sub.clients.length) {
|
|
586
574
|
that._subscriptions.splice(j, 1);
|
|
587
|
-
if (this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
588
|
-
this_3._nodeCache.del(this_3._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
589
|
-
this_3._subCache.splice(this_3._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
590
|
-
}
|
|
591
575
|
}
|
|
592
576
|
else {
|
|
593
577
|
sub['oplog'] = oplog;
|
|
@@ -603,7 +587,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
603
587
|
_loop_6(j);
|
|
604
588
|
}
|
|
605
589
|
};
|
|
606
|
-
this_3 = this;
|
|
607
590
|
for (i = uniqueOplog_1.length - 1; i >= 0; i--) {
|
|
608
591
|
_loop_5(i);
|
|
609
592
|
}
|
|
@@ -618,18 +601,18 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
618
601
|
};
|
|
619
602
|
SubscriptionManager.prototype.resendPubsForDelete = function (collection) {
|
|
620
603
|
return __awaiter(this, void 0, void 0, function () {
|
|
621
|
-
var that, subCopy, _loop_7,
|
|
604
|
+
var that, subCopy, _loop_7, this_3, jj, _loop_8, zz;
|
|
622
605
|
var _this = this;
|
|
623
606
|
return __generator(this, function (_a) {
|
|
624
607
|
that = this;
|
|
625
608
|
subCopy = common_1.deepCopy(that._subscriptions.filter(function (a) { return a.collections.includes(collection); }));
|
|
626
609
|
_loop_7 = function (jj) {
|
|
627
|
-
if (
|
|
628
|
-
|
|
629
|
-
|
|
610
|
+
if (this_3._subCache[jj].collection === collection || subCopy.some(function (a) { return a.publication === _this._subCache[jj].publication; })) {
|
|
611
|
+
this_3._nodeCache.del(this_3._subCache[jj].id);
|
|
612
|
+
this_3._subCache.splice(jj, 1);
|
|
630
613
|
}
|
|
631
614
|
};
|
|
632
|
-
|
|
615
|
+
this_3 = this;
|
|
633
616
|
for (jj = this._subCache.length - 1; jj >= 0; jj--) {
|
|
634
617
|
_loop_7(jj);
|
|
635
618
|
}
|
|
@@ -677,10 +660,6 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
677
660
|
that = this;
|
|
678
661
|
if (sub.preSubscriptionData) {
|
|
679
662
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
680
|
-
if (this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
681
|
-
this._nodeCache.del(this._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
682
|
-
this._subCache.splice(this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
683
|
-
}
|
|
684
663
|
that.sendPubData(sub, type, collection);
|
|
685
664
|
return [2 /*return*/];
|
|
686
665
|
}
|
|
@@ -691,19 +670,11 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
691
670
|
case 1:
|
|
692
671
|
_a.preSubscriptionData = _d.sent();
|
|
693
672
|
if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
|
|
694
|
-
if (this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
695
|
-
this._nodeCache.del(this._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
696
|
-
this._subCache.splice(this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
697
|
-
}
|
|
698
673
|
that.sendPubData(sub, type, collection);
|
|
699
674
|
}
|
|
700
675
|
return [3 /*break*/, 3];
|
|
701
676
|
case 2:
|
|
702
677
|
if (that._publications[sub.publication].ws_specific) {
|
|
703
|
-
if (this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
704
|
-
this._nodeCache.del(this._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
705
|
-
this._subCache.splice(this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
706
|
-
}
|
|
707
678
|
for (k = 0; k < sub.clients.length; k++) {
|
|
708
679
|
client = sub.clients[k];
|
|
709
680
|
if (that._publications[sub.publication].fetchFunction) {
|
|
@@ -729,19 +700,11 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
729
700
|
else {
|
|
730
701
|
if (that._publications[sub.publication].fetchFunction) {
|
|
731
702
|
if ((_c = that._publications[sub.publication]).fetchFunction.apply(_c, __spreadArrays([document], sub.subscriptionData))) {
|
|
732
|
-
if (this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
733
|
-
this._nodeCache.del(this._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
734
|
-
this._subCache.splice(this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
735
|
-
}
|
|
736
703
|
that.sendPubData(sub, type, collection);
|
|
737
704
|
}
|
|
738
705
|
// else
|
|
739
706
|
}
|
|
740
707
|
else {
|
|
741
|
-
if (this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }) >= 0) {
|
|
742
|
-
this._nodeCache.del(this._subCache.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0].id);
|
|
743
|
-
this._subCache.splice(this._subCache.findIndex(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); }), 1);
|
|
744
|
-
}
|
|
745
708
|
that.sendPubData(sub, type, collection);
|
|
746
709
|
}
|
|
747
710
|
}
|
|
@@ -912,76 +875,58 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
912
875
|
var _this = this;
|
|
913
876
|
return __generator(this, function (_b) {
|
|
914
877
|
that = this;
|
|
915
|
-
if (
|
|
878
|
+
if (subscription.publication !== 'superadminAPM' && subscription.publication !== 'loggedInUsers') {
|
|
879
|
+
that._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));
|
|
880
|
+
}
|
|
881
|
+
(_a = that._publications[subscription.publication].function).call.apply(_a, __spreadArrays([Object.assign({}, that, SubscriptionManager.prototype)], subscription.subscriptionData)).then(function (res) {
|
|
882
|
+
var nodeCacheSize = _this._nodeCache.getStats().vsize;
|
|
883
|
+
if (nodeCacheSize > 500000000) {
|
|
884
|
+
var neededSizeIndex = 0;
|
|
885
|
+
for (var zz = 0; zz < _this._subCache.length; zz++) {
|
|
886
|
+
_this._nodeCache.del(_this._subCache[zz].id);
|
|
887
|
+
if (_this._nodeCache.getStats().vsize < 500000000) {
|
|
888
|
+
neededSizeIndex = zz;
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
// console.log('Cache: ' + 'Too Big - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));
|
|
893
|
+
_this._subCache.splice(0, neededSizeIndex);
|
|
894
|
+
}
|
|
895
|
+
if (_this._subCache.some(function (a) { return a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); })) {
|
|
896
|
+
_this._subCache.splice(_this._subCache.findIndex(function (a) { return a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); }), 1);
|
|
897
|
+
}
|
|
898
|
+
var cacheId = _this._cacheId++;
|
|
899
|
+
_this._nodeCache.set(cacheId, res);
|
|
900
|
+
_this._subCache.push({ collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, id: cacheId });
|
|
901
|
+
// console.log('Cache: ' + 'Create - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));
|
|
916
902
|
subscription.clients.forEach(function (client) {
|
|
917
903
|
that._wss.clients.forEach(function (ws) {
|
|
918
904
|
if (ws['id_socket'] === client.id_socket) {
|
|
919
905
|
var serverRes = {
|
|
920
906
|
messageId: client.messageId,
|
|
921
907
|
hasError: false,
|
|
922
|
-
data:
|
|
908
|
+
data: res
|
|
923
909
|
};
|
|
924
|
-
// console.log('Cache: ' + 'Found - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));
|
|
925
910
|
_this.sendWS(ws, serverRes);
|
|
926
|
-
resolve(true);
|
|
927
911
|
}
|
|
928
912
|
});
|
|
929
913
|
});
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
that.
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
_this.
|
|
941
|
-
if (_this._nodeCache.getStats().vsize < 500000000) {
|
|
942
|
-
neededSizeIndex = zz;
|
|
943
|
-
break;
|
|
944
|
-
}
|
|
914
|
+
resolve(true);
|
|
915
|
+
}, function (err) {
|
|
916
|
+
subscription.clients.forEach(function (client) {
|
|
917
|
+
that._wss.clients.forEach(function (ws) {
|
|
918
|
+
if (ws['id_socket'] === client.id_socket) {
|
|
919
|
+
var serverRes = {
|
|
920
|
+
messageId: client.messageId,
|
|
921
|
+
hasError: true,
|
|
922
|
+
data: err
|
|
923
|
+
};
|
|
924
|
+
_this.sendWS(ws, serverRes);
|
|
945
925
|
}
|
|
946
|
-
// console.log('Cache: ' + 'Too Big - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));
|
|
947
|
-
_this._subCache.splice(0, neededSizeIndex);
|
|
948
|
-
}
|
|
949
|
-
if (_this._subCache.some(function (a) { return a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); })) {
|
|
950
|
-
_this._subCache.splice(_this._subCache.findIndex(function (a) { return a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); }), 1);
|
|
951
|
-
}
|
|
952
|
-
var cacheId = _this._cacheId++;
|
|
953
|
-
_this._nodeCache.set(cacheId, res);
|
|
954
|
-
_this._subCache.push({ collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, id: cacheId });
|
|
955
|
-
// console.log('Cache: ' + 'Create - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));
|
|
956
|
-
subscription.clients.forEach(function (client) {
|
|
957
|
-
that._wss.clients.forEach(function (ws) {
|
|
958
|
-
if (ws['id_socket'] === client.id_socket) {
|
|
959
|
-
var serverRes = {
|
|
960
|
-
messageId: client.messageId,
|
|
961
|
-
hasError: false,
|
|
962
|
-
data: res
|
|
963
|
-
};
|
|
964
|
-
_this.sendWS(ws, serverRes);
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
});
|
|
968
|
-
resolve(true);
|
|
969
|
-
}, function (err) {
|
|
970
|
-
subscription.clients.forEach(function (client) {
|
|
971
|
-
that._wss.clients.forEach(function (ws) {
|
|
972
|
-
if (ws['id_socket'] === client.id_socket) {
|
|
973
|
-
var serverRes = {
|
|
974
|
-
messageId: client.messageId,
|
|
975
|
-
hasError: true,
|
|
976
|
-
data: err
|
|
977
|
-
};
|
|
978
|
-
_this.sendWS(ws, serverRes);
|
|
979
|
-
}
|
|
980
|
-
});
|
|
981
926
|
});
|
|
982
|
-
reject(err);
|
|
983
927
|
});
|
|
984
|
-
|
|
928
|
+
reject(err);
|
|
929
|
+
});
|
|
985
930
|
return [2 /*return*/];
|
|
986
931
|
});
|
|
987
932
|
}); });
|