@resolveio/server-lib 4.3.8 → 4.3.9-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;
@@ -508,12 +508,12 @@ 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 oplogQueue, uniquePubs_1, uniqueOplog_1, needIds_1, _loop_3, i, i, oplog, _loop_4, i_1;
511
+ var oplogQueue, uniquePubs_1, uniqueOplog_1, needIds_1, _loop_3, i, _loop_4, i;
512
512
  var _this = this;
513
513
  return __generator(this, function (_a) {
514
514
  switch (_a.label) {
515
515
  case 0:
516
- if (!this._oplogQueue.length) return [3 /*break*/, 11];
516
+ if (!this._oplogQueue.length) return [3 /*break*/, 9];
517
517
  oplogQueue = common_1.deepCopy(this._oplogQueue);
518
518
  this._oplogQueue = [];
519
519
  uniquePubs_1 = [];
@@ -576,107 +576,120 @@ var SubscriptionManager = /** @class */ (function () {
576
576
  i++;
577
577
  return [3 /*break*/, 1];
578
578
  case 4:
579
- i = uniqueOplog_1.length - 1;
580
- _a.label = 5;
581
- case 5:
582
- if (!(i >= 0)) return [3 /*break*/, 10];
583
- oplog = uniqueOplog_1[i];
584
- _loop_4 = function (i_1) {
585
- var _a, sub, _b;
586
- return __generator(this, function (_c) {
587
- switch (_c.label) {
579
+ _loop_4 = function (i) {
580
+ var oplog, _loop_5, j;
581
+ return __generator(this, function (_a) {
582
+ switch (_a.label) {
588
583
  case 0:
589
- sub = that._subscriptions[i_1];
590
- if (!sub.collections.includes(oplog.collection)) return [3 /*break*/, 3];
591
- if (sub.preSubscriptionData) {
592
- if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
593
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)[0]; })) {
594
- uniquePubs_1.push(sub);
595
- }
596
- else {
597
- uniqueOplog_1.splice(i_1, 1);
598
- }
599
- return [2 /*return*/, "continue"];
600
- }
601
- }
602
- if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
603
- _b = sub;
604
- return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
605
- case 1:
606
- _b.preSubscriptionData = _c.sent();
607
- if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
608
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0]; })) {
609
- uniquePubs_1.push(sub);
610
- }
611
- else {
612
- uniqueOplog_1.splice(i_1, 1);
613
- }
614
- return [2 /*return*/, "continue"];
615
- }
616
- return [3 /*break*/, 3];
617
- case 2:
618
- if (that._publications[sub.publication].ws_specific) {
619
- sub.clients.forEach(function (client) {
620
- var _a;
621
- if (that._publications[sub.publication].fetchFunction) {
622
- if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document, client.id_user].concat(sub.subscriptionData))) {
623
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0]) {
624
- uniquePubs_1.push(sub);
584
+ oplog = uniqueOplog_1[i];
585
+ _loop_5 = function (j) {
586
+ var _a, sub, _b;
587
+ return __generator(this, function (_c) {
588
+ switch (_c.label) {
589
+ case 0:
590
+ sub = that._subscriptions[j];
591
+ if (!sub.collections.includes(oplog.collection)) return [3 /*break*/, 3];
592
+ if (sub.preSubscriptionData) {
593
+ if (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {
594
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)[0]; })) {
595
+ uniquePubs_1.push(sub);
596
+ }
597
+ else {
598
+ uniqueOplog_1.splice(i, 1);
599
+ }
600
+ return [2 /*return*/, "continue"];
601
+ }
602
+ }
603
+ if (!that._publications[sub.publication].preFunction) return [3 /*break*/, 2];
604
+ _b = sub;
605
+ return [4 /*yield*/, that._publications[sub.publication].preFunction(sub.subscriptionData)];
606
+ case 1:
607
+ _b.preSubscriptionData = _c.sent();
608
+ if (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {
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
+ }
612
+ else {
613
+ uniqueOplog_1.splice(i, 1);
614
+ }
615
+ return [2 /*return*/, "continue"];
616
+ }
617
+ return [3 /*break*/, 3];
618
+ case 2:
619
+ if (that._publications[sub.publication].ws_specific) {
620
+ sub.clients.forEach(function (client) {
621
+ var _a;
622
+ if (that._publications[sub.publication].fetchFunction) {
623
+ if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document, client.id_user].concat(sub.subscriptionData))) {
624
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData); })[0]) {
625
+ uniquePubs_1.push(sub);
626
+ }
627
+ else {
628
+ uniqueOplog_1.splice(i, 1);
629
+ }
630
+ }
631
+ }
632
+ });
625
633
  }
626
634
  else {
627
- uniqueOplog_1.splice(i_1, 1);
635
+ if (that._publications[sub.publication].fetchFunction) {
636
+ if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document].concat(sub.subscriptionData))) {
637
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0]; })) {
638
+ uniquePubs_1.push(sub);
639
+ }
640
+ else {
641
+ uniqueOplog_1.splice(i, 1);
642
+ }
643
+ return [2 /*return*/, "continue"];
644
+ }
645
+ }
646
+ else {
647
+ if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0]; })) {
648
+ uniquePubs_1.push(sub);
649
+ }
650
+ else {
651
+ uniqueOplog_1.splice(i, 1);
652
+ }
653
+ return [2 /*return*/, "continue"];
654
+ }
628
655
  }
629
- }
656
+ _c.label = 3;
657
+ case 3: return [2 /*return*/];
630
658
  }
631
659
  });
632
- }
633
- else {
634
- if (that._publications[sub.publication].fetchFunction) {
635
- if ((_a = that._publications[sub.publication]).fetchFunction.apply(_a, [document].concat(sub.subscriptionData))) {
636
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0]; })) {
637
- uniquePubs_1.push(sub);
638
- }
639
- else {
640
- uniqueOplog_1.splice(i_1, 1);
641
- }
642
- return [2 /*return*/, "continue"];
643
- }
644
- }
645
- else {
646
- if (!uniquePubs_1.filter(function (a) { return a.publication === sub.publication && ((!a.subscriptionData && !sub.subscriptionData) || JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0]; })) {
647
- uniquePubs_1.push(sub);
648
- }
649
- else {
650
- uniqueOplog_1.splice(i_1, 1);
651
- }
652
- return [2 /*return*/, "continue"];
653
- }
654
- }
655
- _c.label = 3;
656
- case 3: return [2 /*return*/];
660
+ };
661
+ j = 0;
662
+ _a.label = 1;
663
+ case 1:
664
+ if (!(j < that._subscriptions.length)) return [3 /*break*/, 4];
665
+ return [5 /*yield**/, _loop_5(j)];
666
+ case 2:
667
+ _a.sent();
668
+ _a.label = 3;
669
+ case 3:
670
+ j++;
671
+ return [3 /*break*/, 1];
672
+ case 4: return [2 /*return*/];
657
673
  }
658
674
  });
659
675
  };
660
- i_1 = 0;
661
- _a.label = 6;
676
+ i = uniqueOplog_1.length - 1;
677
+ _a.label = 5;
678
+ case 5:
679
+ if (!(i >= 0)) return [3 /*break*/, 8];
680
+ return [5 /*yield**/, _loop_4(i)];
662
681
  case 6:
663
- if (!(i_1 < that._subscriptions.length)) return [3 /*break*/, 9];
664
- return [5 /*yield**/, _loop_4(i_1)];
665
- case 7:
666
682
  _a.sent();
667
- _a.label = 8;
668
- case 8:
669
- i_1++;
670
- return [3 /*break*/, 6];
671
- case 9:
683
+ _a.label = 7;
684
+ case 7:
672
685
  i--;
673
686
  return [3 /*break*/, 5];
674
- case 10:
687
+ case 8:
675
688
  uniqueOplog_1.forEach(function (oplog) {
676
689
  _this.checkPubsForChanges(oplog.collection, oplog.doc, oplog.type);
677
690
  });
678
- _a.label = 11;
679
- case 11: return [2 /*return*/];
691
+ _a.label = 9;
692
+ case 9: return [2 /*return*/];
680
693
  }
681
694
  });
682
695
  }); }, 500);
@@ -703,12 +716,12 @@ var SubscriptionManager = /** @class */ (function () {
703
716
  // Check to see if any pubs need to refetch due to Mongo operation
704
717
  SubscriptionManager.prototype.checkPubsForChanges = function (collection, document, type) {
705
718
  return __awaiter(this, void 0, void 0, function () {
706
- var that, _loop_5, i;
719
+ var that, _loop_6, i;
707
720
  return __generator(this, function (_a) {
708
721
  switch (_a.label) {
709
722
  case 0:
710
723
  that = this;
711
- _loop_5 = function (i) {
724
+ _loop_6 = function (i) {
712
725
  var _a, _b, sub, _c, _d;
713
726
  return __generator(this, function (_e) {
714
727
  switch (_e.label) {
@@ -774,7 +787,7 @@ var SubscriptionManager = /** @class */ (function () {
774
787
  _a.label = 1;
775
788
  case 1:
776
789
  if (!(i < that._subscriptions.filter(function (a) { return a.collections.includes(collection); }).length)) return [3 /*break*/, 4];
777
- return [5 /*yield**/, _loop_5(i)];
790
+ return [5 /*yield**/, _loop_6(i)];
778
791
  case 2:
779
792
  _a.sent();
780
793
  _a.label = 3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "4.3.8",
3
+ "version": "4.3.9-newrole",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {