@resolveio/server-lib 4.1.1 → 4.1.2-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/fixtures/init.js +1 -1
- package/methods/logs.js +0 -103
- package/package.json +1 -1
- package/publications/logs.js +103 -0
|
@@ -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
|
-
|
|
73
|
-
type: String
|
|
74
|
-
optional: true
|
|
74
|
+
'roles.approvals.$.type': {
|
|
75
|
+
type: String
|
|
75
76
|
},
|
|
76
|
-
|
|
77
|
-
type:
|
|
78
|
-
blackbox: true,
|
|
79
|
-
optional: true
|
|
77
|
+
'roles.approvals.$.accounting_code': {
|
|
78
|
+
type: String
|
|
80
79
|
},
|
|
81
|
-
|
|
82
|
-
type: Array
|
|
83
|
-
optional: true
|
|
80
|
+
'roles.groups': {
|
|
81
|
+
type: Array
|
|
84
82
|
},
|
|
85
|
-
'
|
|
83
|
+
'roles.groups.$': {
|
|
86
84
|
type: Object
|
|
87
85
|
},
|
|
88
|
-
'
|
|
86
|
+
'roles.groups.$.name': {
|
|
89
87
|
type: String
|
|
90
88
|
},
|
|
91
|
-
'
|
|
92
|
-
type:
|
|
89
|
+
'roles.groups.$.views': {
|
|
90
|
+
type: Array
|
|
93
91
|
},
|
|
94
|
-
'
|
|
92
|
+
'roles.groups.$.views.$': {
|
|
95
93
|
type: String
|
|
96
94
|
},
|
|
97
|
-
'
|
|
98
|
-
type: String
|
|
95
|
+
'roles.groups.$.yard': {
|
|
96
|
+
type: String,
|
|
97
|
+
optional: true
|
|
98
|
+
},
|
|
99
|
+
'roles.notifications': {
|
|
100
|
+
type: Array
|
|
99
101
|
},
|
|
100
|
-
'
|
|
102
|
+
'roles.notifications.$': {
|
|
101
103
|
type: String
|
|
102
104
|
},
|
|
103
|
-
'
|
|
104
|
-
type:
|
|
105
|
+
'roles.miscs': {
|
|
106
|
+
type: Array
|
|
105
107
|
},
|
|
106
|
-
'
|
|
107
|
-
type:
|
|
108
|
-
optional: true
|
|
108
|
+
'roles.miscs.$': {
|
|
109
|
+
type: String
|
|
109
110
|
},
|
|
110
|
-
|
|
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;
|
package/methods/logs.js
CHANGED
|
@@ -1,39 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
3
|
var mongoose_1 = require("mongoose");
|
|
39
4
|
var log_collection_1 = require("../collections/log.collection");
|
|
@@ -89,74 +54,6 @@ function loadLogMethods(methodManager) {
|
|
|
89
54
|
},
|
|
90
55
|
skipValidation: true
|
|
91
56
|
},
|
|
92
|
-
superadminAPM: {
|
|
93
|
-
skipQueue: true,
|
|
94
|
-
function: function (date_start, date_end) {
|
|
95
|
-
var _this = this;
|
|
96
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
97
|
-
var latencies, subscriptions;
|
|
98
|
-
return __generator(this, function (_a) {
|
|
99
|
-
switch (_a.label) {
|
|
100
|
-
case 0: return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.aggregate([
|
|
101
|
-
{
|
|
102
|
-
$match: {
|
|
103
|
-
$and: [
|
|
104
|
-
{
|
|
105
|
-
createdAt: { $gte: date_start }
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
createdAt: { $lte: date_end }
|
|
109
|
-
}
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
$group: {
|
|
115
|
-
_id: '$method',
|
|
116
|
-
method: { $first: '$method' },
|
|
117
|
-
count: { $sum: 1 },
|
|
118
|
-
latency_min: { $min: '$latency_ms' },
|
|
119
|
-
latency_avg: { $avg: '$latency_ms' },
|
|
120
|
-
latency_max: { $max: '$latency_ms' }
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
])];
|
|
124
|
-
case 1:
|
|
125
|
-
latencies = _a.sent();
|
|
126
|
-
return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.aggregate([
|
|
127
|
-
{
|
|
128
|
-
$match: {
|
|
129
|
-
$and: [
|
|
130
|
-
{
|
|
131
|
-
createdAt: { $gte: date_start }
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
createdAt: { $lte: date_end }
|
|
135
|
-
}
|
|
136
|
-
]
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
$group: {
|
|
141
|
-
_id: '$subscription',
|
|
142
|
-
subscription: { $first: '$subscription' },
|
|
143
|
-
count: { $sum: 1 }
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
])];
|
|
147
|
-
case 2:
|
|
148
|
-
subscriptions = _a.sent();
|
|
149
|
-
resolve({
|
|
150
|
-
methods: latencies,
|
|
151
|
-
subscriptions: subscriptions
|
|
152
|
-
});
|
|
153
|
-
return [2 /*return*/];
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}); });
|
|
157
|
-
},
|
|
158
|
-
skipValidation: true
|
|
159
|
-
}
|
|
160
57
|
});
|
|
161
58
|
}
|
|
162
59
|
exports.loadLogMethods = loadLogMethods;
|
package/package.json
CHANGED
package/publications/logs.js
CHANGED
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
2
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
38
|
var simpl_schema_1 = require("simpl-schema");
|
|
4
39
|
var log_collection_1 = require("../collections/log.collection");
|
|
5
40
|
var log_method_latency_collection_1 = require("../collections/log-method-latency.collection");
|
|
41
|
+
var log_subscription_collection_1 = require("../collections/log-subscription.collection");
|
|
6
42
|
function loadLogPublications(subscriptionManager) {
|
|
7
43
|
subscriptionManager.publications({
|
|
8
44
|
logsWithType: {
|
|
@@ -27,6 +63,73 @@ function loadLogPublications(subscriptionManager) {
|
|
|
27
63
|
return log_method_latency_collection_1.LogMethodLatencies.find({}).sort({ date_start: -1 }).exec();
|
|
28
64
|
},
|
|
29
65
|
collections: ['log-method-latencies'],
|
|
66
|
+
},
|
|
67
|
+
superadminAPM: {
|
|
68
|
+
function: function (date_start, date_end) {
|
|
69
|
+
var _this = this;
|
|
70
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
71
|
+
var latencies, subscriptions;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0: return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.aggregate([
|
|
75
|
+
{
|
|
76
|
+
$match: {
|
|
77
|
+
$and: [
|
|
78
|
+
{
|
|
79
|
+
createdAt: { $gte: date_start }
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
createdAt: { $lte: date_end }
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
$group: {
|
|
89
|
+
_id: '$method',
|
|
90
|
+
method: { $first: '$method' },
|
|
91
|
+
count: { $sum: 1 },
|
|
92
|
+
latency_min: { $min: '$latency_ms' },
|
|
93
|
+
latency_avg: { $avg: '$latency_ms' },
|
|
94
|
+
latency_max: { $max: '$latency_ms' }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
])];
|
|
98
|
+
case 1:
|
|
99
|
+
latencies = _a.sent();
|
|
100
|
+
return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.aggregate([
|
|
101
|
+
{
|
|
102
|
+
$match: {
|
|
103
|
+
$and: [
|
|
104
|
+
{
|
|
105
|
+
createdAt: { $gte: date_start }
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
createdAt: { $lte: date_end }
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
$group: {
|
|
115
|
+
_id: '$subscription',
|
|
116
|
+
subscription: { $first: '$subscription' },
|
|
117
|
+
count: { $sum: 1 }
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
])];
|
|
121
|
+
case 2:
|
|
122
|
+
subscriptions = _a.sent();
|
|
123
|
+
resolve({
|
|
124
|
+
methods: latencies,
|
|
125
|
+
subscriptions: subscriptions
|
|
126
|
+
});
|
|
127
|
+
return [2 /*return*/];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}); });
|
|
131
|
+
},
|
|
132
|
+
collections: ['log-method-latencies', 'log-subscriptions'],
|
|
30
133
|
}
|
|
31
134
|
});
|
|
32
135
|
}
|