@resolveio/server-lib 4.3.5 → 4.3.7-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;
@@ -519,7 +519,6 @@ var SubscriptionManager = /** @class */ (function () {
519
519
  this._oplogQueue = [];
520
520
  uniqueOplog_1 = [];
521
521
  needIds_1 = {};
522
- // console.log('----------------OPLOG QUEUE START BEFORE DATA--------------------', new Date(), oplogQueue.length);
523
522
  oplogQueue.forEach(function (oplog) {
524
523
  if (!uniqueOplog_1.filter(function (a) { return JSON.stringify(a) === JSON.stringify(oplog); }).length) {
525
524
  uniqueOplog_1.push(oplog);
@@ -577,9 +576,7 @@ var SubscriptionManager = /** @class */ (function () {
577
576
  i++;
578
577
  return [3 /*break*/, 1];
579
578
  case 4:
580
- // console.log('----------------OPLOG QUEUE END--------------------', new Date(), uniqueOplog.length);
581
579
  uniqueOplog_1.forEach(function (oplog) {
582
- // console.log('OPLOG QUEUE END - Oplog', oplog);
583
580
  _this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
584
581
  });
585
582
  _a.label = 5;
@@ -609,70 +606,90 @@ var SubscriptionManager = /** @class */ (function () {
609
606
  // Collection: Collection Document Lives In
610
607
  // Check to see if any pubs need to refetch due to Mongo operation
611
608
  SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type) {
612
- var _this = this;
613
- var that = this;
614
- that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).forEach(function (sub) { return __awaiter(_this, void 0, void 0, function () {
615
- var _a, _b;
616
- var _c, _d;
617
- return __generator(this, function (_e) {
618
- switch (_e.label) {
609
+ return __awaiter(this, void 0, void 0, function () {
610
+ var that, _loop_4, i;
611
+ return __generator(this, function (_a) {
612
+ switch (_a.label) {
619
613
  case 0:
620
- if (!sub.preSubscriptionData) return [3 /*break*/, 2];
621
- if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 2];
622
- that.sendPubData(sub, type, collection);
623
- _a = sub;
624
- return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
625
- case 1:
626
- _a.preSubscriptionData = _e.sent();
627
- _e.label = 2;
628
- case 2:
629
- if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 4];
630
- _b = sub;
631
- return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
632
- case 3:
633
- _b.preSubscriptionData = _e.sent();
634
- if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
635
- that.sendPubData(sub, type, collection);
636
- }
637
- return [3 /*break*/, 5];
638
- case 4:
639
- if (that._publications[sub.publication].ws_specific) {
640
- sub.clients.forEach(function (client) {
641
- var _a;
642
- if (that._publications[sub.publication].fetchFunction) {
643
- if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document, client.id_user].concat(sub.subscriptionData))) {
644
- that._wss.clients.forEach(function (ws) {
645
- if (ws['id_socket'] === client.id_socket) {
646
- that.sendPubDataOnce(ws, client.messageId, sub, type, collection);
614
+ that = this;
615
+ _loop_4 = function (i) {
616
+ var sub, _a, _b;
617
+ var _c, _d;
618
+ return __generator(this, function (_e) {
619
+ switch (_e.label) {
620
+ case 0:
621
+ sub = that._subscriptions.filter(function (a) { return a.collections.includes(collection); })[i];
622
+ if (!sub.preSubscriptionData) return [3 /*break*/, 2];
623
+ if (!that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) return [3 /*break*/, 2];
624
+ that.sendPubData(sub, type, collection);
625
+ _a = sub;
626
+ return [4 /*yield*/, (_c = that._publications[sub.publication]).preFunction.apply(_c, sub.subscriptionData)];
627
+ case 1:
628
+ _a.preSubscriptionData = _e.sent();
629
+ return [2 /*return*/, "continue"];
630
+ case 2:
631
+ if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 4];
632
+ _b = sub;
633
+ return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
634
+ case 3:
635
+ _b.preSubscriptionData = _e.sent();
636
+ if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
637
+ that.sendPubData(sub, type, collection);
638
+ }
639
+ return [3 /*break*/, 5];
640
+ case 4:
641
+ if (that._publications[sub.publication].ws_specific) {
642
+ sub.clients.forEach(function (client) {
643
+ var _a;
644
+ if (that._publications[sub.publication].fetchFunction) {
645
+ if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document, client.id_user].concat(sub.subscriptionData))) {
646
+ that._wss.clients.forEach(function (ws) {
647
+ if (ws['id_socket'] === client.id_socket) {
648
+ that.sendPubDataOnce(ws, client.messageId, sub, type, collection);
649
+ }
650
+ });
651
+ }
652
+ }
653
+ else {
654
+ that._wss.clients.forEach(function (ws) {
655
+ if (ws['id_socket'] === client.id_socket) {
656
+ that.sendPubDataOnce(ws, client.messageId, sub, type, collection);
657
+ }
658
+ });
659
+ }
660
+ });
661
+ }
662
+ else {
663
+ if (that._publications[sub.publication].fetchFunction) {
664
+ if ((_d = that._publications[sub.publication]).fetchFunction.apply(_d, [document].concat(sub.subscriptionData))) {
665
+ that.sendPubData(sub, type, collection);
666
+ }
667
+ // else
668
+ }
669
+ else {
670
+ that.sendPubData(sub, type, collection);
647
671
  }
648
- });
649
- }
650
- }
651
- else {
652
- that._wss.clients.forEach(function (ws) {
653
- if (ws['id_socket'] === client.id_socket) {
654
- that.sendPubDataOnce(ws, client.messageId, sub, type, collection);
655
672
  }
656
- });
673
+ _e.label = 5;
674
+ case 5: return [2 /*return*/];
657
675
  }
658
676
  });
659
- }
660
- else {
661
- if (that._publications[sub.publication].fetchFunction) {
662
- if ((_d = that._publications[sub.publication]).fetchFunction.apply(_d, [document].concat(sub.subscriptionData))) {
663
- that.sendPubData(sub, type, collection);
664
- }
665
- // else
666
- }
667
- else {
668
- that.sendPubData(sub, type, collection);
669
- }
670
- }
671
- _e.label = 5;
672
- case 5: return [2 /*return*/];
677
+ };
678
+ i = 0;
679
+ _a.label = 1;
680
+ case 1:
681
+ if (!(i < that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).length)) return [3 /*break*/, 4];
682
+ return [5 /*yield**/, _loop_4(i)];
683
+ case 2:
684
+ _a.sent();
685
+ _a.label = 3;
686
+ case 3:
687
+ i++;
688
+ return [3 /*break*/, 1];
689
+ case 4: return [2 /*return*/];
673
690
  }
674
691
  });
675
- }); });
692
+ });
676
693
  };
677
694
  SubscriptionManager.prototype.checkSupportPubsForChanges = function (collection, document) {
678
695
  var _this = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "4.3.5",
3
+ "version": "4.3.7-newrole",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {