@resolveio/server-lib 4.2.9 → 4.3.0-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.
@@ -21,13 +21,6 @@ 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
- },
31
24
  attempts: {
32
25
  type: Number,
33
26
  optional: true
@@ -64,53 +57,67 @@ var schema = {
64
57
  type: String
65
58
  },
66
59
  roles: {
60
+ type: Object
61
+ },
62
+ 'roles.super_admin': {
63
+ type: Boolean
64
+ },
65
+ 'roles.approvals': {
67
66
  type: Array
68
67
  },
69
- 'roles.$': {
68
+ 'roles.approvals.$': {
69
+ type: Object
70
+ },
71
+ 'roles.approvals.$.name': {
70
72
  type: String
71
73
  },
72
- phonenumber: {
73
- type: String,
74
- optional: true
74
+ 'roles.approvals.$.type': {
75
+ type: String
75
76
  },
76
- other: {
77
- type: Object,
78
- blackbox: true,
79
- optional: true
77
+ 'roles.approvals.$.accounting_code': {
78
+ type: String
80
79
  },
81
- assets: {
82
- type: Array,
83
- optional: true
80
+ 'roles.groups': {
81
+ type: Array
84
82
  },
85
- 'assets.$': {
83
+ 'roles.groups.$': {
86
84
  type: Object
87
85
  },
88
- 'assets.$.type': {
86
+ 'roles.groups.$.name': {
89
87
  type: String
90
88
  },
91
- 'assets.$.id_asset': {
92
- type: String
89
+ 'roles.groups.$.views': {
90
+ type: Array
93
91
  },
94
- 'assets.$.asset_number': {
92
+ 'roles.groups.$.views.$': {
95
93
  type: String
96
94
  },
97
- 'assets.$.ownership': {
98
- type: String
95
+ 'roles.groups.$.yard': {
96
+ type: String,
97
+ optional: true
98
+ },
99
+ 'roles.notifications': {
100
+ type: Array
99
101
  },
100
- 'assets.$.ownership_driver': {
102
+ 'roles.notifications.$': {
101
103
  type: String
102
104
  },
103
- 'assets.$.date_start': {
104
- type: Date
105
+ 'roles.miscs': {
106
+ type: Array
105
107
  },
106
- 'assets.$.date_end': {
107
- type: Date,
108
- optional: true
108
+ 'roles.miscs.$': {
109
+ type: String
109
110
  },
110
- id_function: {
111
+ active: Boolean,
112
+ phonenumber: {
111
113
  type: String,
112
114
  optional: true
113
115
  },
116
+ other: {
117
+ type: Object,
118
+ optional: true,
119
+ blackbox: true
120
+ },
114
121
  customers: {
115
122
  type: Array,
116
123
  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;
@@ -504,7 +504,7 @@ var SubscriptionManager = /** @class */ (function () {
504
504
  var _this = this;
505
505
  var that = this;
506
506
  setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
507
- var oplogQueue_1, uniquePubs, uniqueOplog, needIds_1, _loop_3, i;
507
+ var oplogQueue_1, uniquePubs_1, uniqueOplog_1, needIds_1, _loop_3, i;
508
508
  var _this = this;
509
509
  return __generator(this, function (_a) {
510
510
  switch (_a.label) {
@@ -512,8 +512,8 @@ var SubscriptionManager = /** @class */ (function () {
512
512
  if (!this._oplogQueue.length) return [3 /*break*/, 5];
513
513
  oplogQueue_1 = common_1.deepCopy(this._oplogQueue);
514
514
  this._oplogQueue = [];
515
- uniquePubs = [];
516
- uniqueOplog = [];
515
+ uniquePubs_1 = [];
516
+ uniqueOplog_1 = [];
517
517
  needIds_1 = {};
518
518
  // console.log('----------------OPLOG QUEUE START BEFORE DATA--------------------', new Date(), oplogQueue.length);
519
519
  oplogQueue_1.forEach(function (oplog) {
@@ -550,7 +550,7 @@ var SubscriptionManager = /** @class */ (function () {
550
550
  case 1:
551
551
  docs = _a.sent();
552
552
  needIds_1[collection].forEach(function (id_doc) {
553
- oplogQueue_1.filter(function (a) { return a.doc._id === id_doc; })[0].doc = docs.filter(function (a) { return a._id === id_doc; });
553
+ oplogQueue_1.filter(function (a) { return a.doc._id === id_doc; })[0].doc = docs.filter(function (a) { return a._id === id_doc; })[0];
554
554
  });
555
555
  return [2 /*return*/];
556
556
  }
@@ -569,54 +569,59 @@ var SubscriptionManager = /** @class */ (function () {
569
569
  return [3 /*break*/, 1];
570
570
  case 4:
571
571
  // console.log('----------------OPLOG QUEUE START AFTER DATA--------------------', new Date(), oplogQueue.length);
572
- // oplogQueue.forEach(async (oplog) => {
573
- // // console.log('OPLOG QUEUE START - Oplog', oplog);
574
- // for (let i = 0; i < that._subscriptions.length; i++) {
575
- // let sub = that._subscriptions[i];
576
- // if (sub.collections.includes(oplog.collection)) {
577
- // if (sub.preSubscriptionData) {
578
- // if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
579
- // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
580
- // uniquePubs.push(sub);
581
- // uniqueOplog.push(oplog);
582
- // }
583
- // continue;
584
- // }
585
- // }
586
- // if (that._publications[sub.publication].preFunction) {
587
- // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
588
- // uniquePubs.push(sub);
589
- // uniqueOplog.push(oplog);
590
- // }
591
- // continue;
592
- // }
593
- // else {
594
- // if (that._publications[sub.publication].fetchFunction) {
595
- // if (that._publications[sub.publication].fetchFunction(oplog.doc, ...sub.subscriptionData)) {
596
- // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
597
- // uniquePubs.push(sub);
598
- // uniqueOplog.push(oplog);
599
- // }
600
- // continue;
601
- // }
602
- // }
603
- // else {
604
- // if (!uniquePubs.filter(a => a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)))[0]) {
605
- // uniquePubs.push(sub);
606
- // uniqueOplog.push(oplog);
607
- // }
608
- // continue;
609
- // }
610
- // }
611
- // }
612
- // }
613
- // });
572
+ oplogQueue_1.forEach(function (oplog) { return __awaiter(_this, void 0, void 0, function () {
573
+ var _loop_4, i;
574
+ return __generator(this, function (_a) {
575
+ _loop_4 = function (i) {
576
+ var _a;
577
+ var sub = that._subscriptions[i];
578
+ if (sub.collections.includes(oplog.collection)) {
579
+ if (sub.preSubscriptionData) {
580
+ if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
581
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
582
+ uniquePubs_1.push(sub);
583
+ uniqueOplog_1.push(oplog);
584
+ }
585
+ return "continue";
586
+ }
587
+ }
588
+ if (that._publications[sub.publication].preFunction) {
589
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
590
+ uniquePubs_1.push(sub);
591
+ uniqueOplog_1.push(oplog);
592
+ }
593
+ return "continue";
594
+ }
595
+ else {
596
+ if (that._publications[sub.publication].fetchFunction) {
597
+ if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [oplog.doc].concat(sub.subscriptionData))) {
598
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
599
+ uniquePubs_1.push(sub);
600
+ uniqueOplog_1.push(oplog);
601
+ }
602
+ return "continue";
603
+ }
604
+ }
605
+ else {
606
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)); })[0]) {
607
+ uniquePubs_1.push(sub);
608
+ uniqueOplog_1.push(oplog);
609
+ }
610
+ return "continue";
611
+ }
612
+ }
613
+ }
614
+ };
615
+ // console.log('OPLOG QUEUE START - Oplog', oplog);
616
+ for (i = 0; i < that._subscriptions.length; i++) {
617
+ _loop_4(i);
618
+ }
619
+ return [2 /*return*/];
620
+ });
621
+ }); });
614
622
  // // console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog.length);
615
- // uniqueOplog.forEach(oplog => {
616
- // // console.log('OPLOG QUEUE END - Oplog', oplog);
617
- // this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
618
- // });
619
- oplogQueue_1.forEach(function (oplog) {
623
+ uniqueOplog_1.forEach(function (oplog) {
624
+ // console.log('OPLOG QUEUE END - Oplog', oplog);
620
625
  _this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
621
626
  });
622
627
  _a.label = 5;
@@ -698,6 +703,7 @@ var SubscriptionManager = /** @class */ (function () {
698
703
  if ((_b = that._publications[sub.publication]).fetchFunction.apply(_b, [document].concat(sub.subscriptionData))) {
699
704
  that.sendPubData(sub, type, collection);
700
705
  }
706
+ // else
701
707
  }
702
708
  else {
703
709
  that.sendPubData(sub, type, collection);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "4.2.9",
3
+ "version": "4.3.0-newrole",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {