@resolveio/server-lib 4.6.13-newrole → 4.6.14
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 +32 -39
- package/fixtures/init.js +1 -1
- package/methods/logs.js +103 -0
- package/package.json +1 -1
- package/publications/logs.js +0 -121
|
@@ -22,6 +22,13 @@ 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
|
+
},
|
|
25
32
|
attempts: {
|
|
26
33
|
type: Number,
|
|
27
34
|
optional: true
|
|
@@ -58,67 +65,53 @@ var schema = {
|
|
|
58
65
|
type: String
|
|
59
66
|
},
|
|
60
67
|
roles: {
|
|
61
|
-
type: Object
|
|
62
|
-
},
|
|
63
|
-
'roles.super_admin': {
|
|
64
|
-
type: Boolean
|
|
65
|
-
},
|
|
66
|
-
'roles.approvals': {
|
|
67
68
|
type: Array
|
|
68
69
|
},
|
|
69
|
-
'roles
|
|
70
|
-
type: Object
|
|
71
|
-
},
|
|
72
|
-
'roles.approvals.$.name': {
|
|
70
|
+
'roles.$': {
|
|
73
71
|
type: String
|
|
74
72
|
},
|
|
75
|
-
|
|
76
|
-
type: String
|
|
73
|
+
phonenumber: {
|
|
74
|
+
type: String,
|
|
75
|
+
optional: true
|
|
77
76
|
},
|
|
78
|
-
|
|
79
|
-
type:
|
|
77
|
+
other: {
|
|
78
|
+
type: Object,
|
|
79
|
+
blackbox: true,
|
|
80
|
+
optional: true
|
|
80
81
|
},
|
|
81
|
-
|
|
82
|
-
type: Array
|
|
82
|
+
assets: {
|
|
83
|
+
type: Array,
|
|
84
|
+
optional: true
|
|
83
85
|
},
|
|
84
|
-
'
|
|
86
|
+
'assets.$': {
|
|
85
87
|
type: Object
|
|
86
88
|
},
|
|
87
|
-
'
|
|
89
|
+
'assets.$.type': {
|
|
88
90
|
type: String
|
|
89
91
|
},
|
|
90
|
-
'
|
|
91
|
-
type: Array
|
|
92
|
-
},
|
|
93
|
-
'roles.groups.$.views.$': {
|
|
92
|
+
'assets.$.id_asset': {
|
|
94
93
|
type: String
|
|
95
94
|
},
|
|
96
|
-
'
|
|
97
|
-
type: String
|
|
98
|
-
optional: true
|
|
95
|
+
'assets.$.asset_number': {
|
|
96
|
+
type: String
|
|
99
97
|
},
|
|
100
|
-
'
|
|
101
|
-
type:
|
|
98
|
+
'assets.$.ownership': {
|
|
99
|
+
type: String
|
|
102
100
|
},
|
|
103
|
-
'
|
|
101
|
+
'assets.$.ownership_driver': {
|
|
104
102
|
type: String
|
|
105
103
|
},
|
|
106
|
-
'
|
|
107
|
-
type:
|
|
104
|
+
'assets.$.date_start': {
|
|
105
|
+
type: Date
|
|
108
106
|
},
|
|
109
|
-
'
|
|
110
|
-
type:
|
|
107
|
+
'assets.$.date_end': {
|
|
108
|
+
type: Date,
|
|
109
|
+
optional: true
|
|
111
110
|
},
|
|
112
|
-
|
|
113
|
-
phonenumber: {
|
|
111
|
+
id_function: {
|
|
114
112
|
type: String,
|
|
115
113
|
optional: true
|
|
116
114
|
},
|
|
117
|
-
other: {
|
|
118
|
-
type: Object,
|
|
119
|
-
optional: true,
|
|
120
|
-
blackbox: true
|
|
121
|
-
},
|
|
122
115
|
customers: {
|
|
123
116
|
type: Array,
|
|
124
117
|
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 mongoose_1 = require("mongoose");
|
|
41
40
|
var active_subscription_collection_1 = require("../collections/active-subscription.collection");
|
|
41
|
+
var mongoose_1 = require("mongoose");
|
|
42
42
|
function loadServerInit() {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function () {
|
|
44
44
|
var appVersion;
|
package/methods/logs.js
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
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 mongoose_1 = require("mongoose");
|
|
4
39
|
var log_collection_1 = require("../collections/log.collection");
|
|
@@ -55,6 +90,74 @@ function loadLogMethods(methodManager) {
|
|
|
55
90
|
},
|
|
56
91
|
skipValidation: true
|
|
57
92
|
},
|
|
93
|
+
superadminAPM: {
|
|
94
|
+
skipQueue: true,
|
|
95
|
+
function: function (date_start, date_end) {
|
|
96
|
+
var _this = this;
|
|
97
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
98
|
+
var latencies, subscriptions;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0: return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.aggregate([
|
|
102
|
+
{
|
|
103
|
+
$match: {
|
|
104
|
+
$and: [
|
|
105
|
+
{
|
|
106
|
+
createdAt: { $gte: date_start }
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
createdAt: { $lte: date_end }
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
$group: {
|
|
116
|
+
_id: '$method',
|
|
117
|
+
method: { $first: '$method' },
|
|
118
|
+
count: { $sum: 1 },
|
|
119
|
+
latency_min: { $min: '$latency_ms' },
|
|
120
|
+
latency_avg: { $avg: '$latency_ms' },
|
|
121
|
+
latency_max: { $max: '$latency_ms' }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
]).allowDiskUse(true)];
|
|
125
|
+
case 1:
|
|
126
|
+
latencies = _a.sent();
|
|
127
|
+
return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.aggregate([
|
|
128
|
+
{
|
|
129
|
+
$match: {
|
|
130
|
+
$and: [
|
|
131
|
+
{
|
|
132
|
+
createdAt: { $gte: date_start }
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
createdAt: { $lte: date_end }
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
$group: {
|
|
142
|
+
_id: '$subscription',
|
|
143
|
+
subscription: { $first: '$subscription' },
|
|
144
|
+
count: { $sum: 1 }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
]).allowDiskUse(true)];
|
|
148
|
+
case 2:
|
|
149
|
+
subscriptions = _a.sent();
|
|
150
|
+
resolve({
|
|
151
|
+
methods: latencies,
|
|
152
|
+
subscriptions: subscriptions
|
|
153
|
+
});
|
|
154
|
+
return [2 /*return*/];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}); });
|
|
158
|
+
},
|
|
159
|
+
skipValidation: true
|
|
160
|
+
}
|
|
58
161
|
});
|
|
59
162
|
}
|
|
60
163
|
exports.loadLogMethods = loadLogMethods;
|
package/package.json
CHANGED
package/publications/logs.js
CHANGED
|
@@ -1,44 +1,8 @@
|
|
|
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 simpl_schema_1 = require("simpl-schema");
|
|
39
4
|
var log_collection_1 = require("../collections/log.collection");
|
|
40
5
|
var log_method_latency_collection_1 = require("../collections/log-method-latency.collection");
|
|
41
|
-
var log_subscription_collection_1 = require("../collections/log-subscription.collection");
|
|
42
6
|
function loadLogPublications(subscriptionManager) {
|
|
43
7
|
subscriptionManager.publications({
|
|
44
8
|
logsWithType: {
|
|
@@ -64,91 +28,6 @@ function loadLogPublications(subscriptionManager) {
|
|
|
64
28
|
},
|
|
65
29
|
collections: ['log-method-latencies'],
|
|
66
30
|
},
|
|
67
|
-
superadminAPM: {
|
|
68
|
-
check: new simpl_schema_1.default({
|
|
69
|
-
date_start: {
|
|
70
|
-
type: Date
|
|
71
|
-
},
|
|
72
|
-
date_end: {
|
|
73
|
-
type: Date
|
|
74
|
-
}
|
|
75
|
-
}),
|
|
76
|
-
function: function (date_start, date_end) {
|
|
77
|
-
var _this = this;
|
|
78
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
79
|
-
var latencies, subscriptions;
|
|
80
|
-
return __generator(this, function (_a) {
|
|
81
|
-
switch (_a.label) {
|
|
82
|
-
case 0: return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.aggregate([
|
|
83
|
-
{
|
|
84
|
-
$match: {
|
|
85
|
-
$and: [
|
|
86
|
-
{
|
|
87
|
-
createdAt: { $gte: date_start }
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
createdAt: { $lte: date_end }
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
$group: {
|
|
97
|
-
_id: '$method',
|
|
98
|
-
method: { $first: '$method' },
|
|
99
|
-
count: { $sum: 1 },
|
|
100
|
-
latency_min: { $min: '$latency_ms' },
|
|
101
|
-
latency_avg: { $avg: '$latency_ms' },
|
|
102
|
-
latency_max: { $max: '$latency_ms' }
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
$sort: {
|
|
107
|
-
latency_avg: -1
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
])];
|
|
111
|
-
case 1:
|
|
112
|
-
latencies = _a.sent();
|
|
113
|
-
return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.aggregate([
|
|
114
|
-
{
|
|
115
|
-
$match: {
|
|
116
|
-
$and: [
|
|
117
|
-
{
|
|
118
|
-
createdAt: { $gte: date_start }
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
createdAt: { $lte: date_end }
|
|
122
|
-
}
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
$group: {
|
|
128
|
-
_id: '$subscription',
|
|
129
|
-
subscription: { $first: '$subscription' },
|
|
130
|
-
count: { $sum: 1 }
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
$sort: {
|
|
135
|
-
count: -1
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
])];
|
|
139
|
-
case 2:
|
|
140
|
-
subscriptions = _a.sent();
|
|
141
|
-
resolve({
|
|
142
|
-
methods: latencies,
|
|
143
|
-
subscriptions: subscriptions
|
|
144
|
-
});
|
|
145
|
-
return [2 /*return*/];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}); });
|
|
149
|
-
},
|
|
150
|
-
collections: ['log-method-latencies', 'log-subscriptions'],
|
|
151
|
-
}
|
|
152
31
|
});
|
|
153
32
|
}
|
|
154
33
|
exports.loadLogPublications = loadLogPublications;
|