@resolveio/server-lib 4.6.10 → 4.6.11-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/report-builder.js +35 -32
- package/package.json +1 -1
|
@@ -22,13 +22,6 @@ 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
|
-
},
|
|
32
25
|
attempts: {
|
|
33
26
|
type: Number,
|
|
34
27
|
optional: true
|
|
@@ -65,53 +58,67 @@ var schema = {
|
|
|
65
58
|
type: String
|
|
66
59
|
},
|
|
67
60
|
roles: {
|
|
61
|
+
type: Object
|
|
62
|
+
},
|
|
63
|
+
'roles.super_admin': {
|
|
64
|
+
type: Boolean
|
|
65
|
+
},
|
|
66
|
+
'roles.approvals': {
|
|
68
67
|
type: Array
|
|
69
68
|
},
|
|
70
|
-
'roles.$': {
|
|
69
|
+
'roles.approvals.$': {
|
|
70
|
+
type: Object
|
|
71
|
+
},
|
|
72
|
+
'roles.approvals.$.name': {
|
|
71
73
|
type: String
|
|
72
74
|
},
|
|
73
|
-
|
|
74
|
-
type: String
|
|
75
|
-
optional: true
|
|
75
|
+
'roles.approvals.$.type': {
|
|
76
|
+
type: String
|
|
76
77
|
},
|
|
77
|
-
|
|
78
|
-
type:
|
|
79
|
-
blackbox: true,
|
|
80
|
-
optional: true
|
|
78
|
+
'roles.approvals.$.accounting_code': {
|
|
79
|
+
type: String
|
|
81
80
|
},
|
|
82
|
-
|
|
83
|
-
type: Array
|
|
84
|
-
optional: true
|
|
81
|
+
'roles.groups': {
|
|
82
|
+
type: Array
|
|
85
83
|
},
|
|
86
|
-
'
|
|
84
|
+
'roles.groups.$': {
|
|
87
85
|
type: Object
|
|
88
86
|
},
|
|
89
|
-
'
|
|
87
|
+
'roles.groups.$.name': {
|
|
90
88
|
type: String
|
|
91
89
|
},
|
|
92
|
-
'
|
|
93
|
-
type:
|
|
90
|
+
'roles.groups.$.views': {
|
|
91
|
+
type: Array
|
|
94
92
|
},
|
|
95
|
-
'
|
|
93
|
+
'roles.groups.$.views.$': {
|
|
96
94
|
type: String
|
|
97
95
|
},
|
|
98
|
-
'
|
|
99
|
-
type: String
|
|
96
|
+
'roles.groups.$.yard': {
|
|
97
|
+
type: String,
|
|
98
|
+
optional: true
|
|
99
|
+
},
|
|
100
|
+
'roles.notifications': {
|
|
101
|
+
type: Array
|
|
100
102
|
},
|
|
101
|
-
'
|
|
103
|
+
'roles.notifications.$': {
|
|
102
104
|
type: String
|
|
103
105
|
},
|
|
104
|
-
'
|
|
105
|
-
type:
|
|
106
|
+
'roles.miscs': {
|
|
107
|
+
type: Array
|
|
106
108
|
},
|
|
107
|
-
'
|
|
108
|
-
type:
|
|
109
|
-
optional: true
|
|
109
|
+
'roles.miscs.$': {
|
|
110
|
+
type: String
|
|
110
111
|
},
|
|
111
|
-
|
|
112
|
+
active: Boolean,
|
|
113
|
+
phonenumber: {
|
|
112
114
|
type: String,
|
|
113
115
|
optional: true
|
|
114
116
|
},
|
|
117
|
+
other: {
|
|
118
|
+
type: Object,
|
|
119
|
+
optional: true,
|
|
120
|
+
blackbox: true
|
|
121
|
+
},
|
|
115
122
|
customers: {
|
|
116
123
|
type: Array,
|
|
117
124
|
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;
|
|
@@ -209,14 +209,11 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
209
209
|
if (date_interval === void 0) { date_interval = ''; }
|
|
210
210
|
if (tabularDisplayType === void 0) { tabularDisplayType = ''; }
|
|
211
211
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
212
|
-
var
|
|
212
|
+
var modelCollection, query, initialQueryMatchCondition, sizes, divFields, queryMatchConditionLookup, queryGroup, queryProjection_1, res, err_1, tmpTotals, tmpRes;
|
|
213
213
|
var _this = this;
|
|
214
214
|
return __generator(this, function (_a) {
|
|
215
215
|
switch (_a.label) {
|
|
216
216
|
case 0:
|
|
217
|
-
uniqueSelectedFieldCollections = selectedFields.map(function (a) { return a.collection_name; }).filter(function (elem, index, self) {
|
|
218
|
-
return index === self.indexOf(elem);
|
|
219
|
-
});
|
|
220
217
|
modelCollection = index_1.ResolveIOServer.getMainDB().model(rootCollectionName);
|
|
221
218
|
query = [];
|
|
222
219
|
initialQueryMatchCondition = {
|
|
@@ -250,6 +247,34 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
250
247
|
// Add count
|
|
251
248
|
query.push({ $addFields: { count: { $sum: 1 } } });
|
|
252
249
|
sizes = [];
|
|
250
|
+
filterArrayFields.forEach(function (filterField) {
|
|
251
|
+
var _a, _b;
|
|
252
|
+
var fieldData = filterField.fieldPath.split('.$');
|
|
253
|
+
var fieldPath = '';
|
|
254
|
+
for (var i = 0; i < fieldData.length - 1; i++) {
|
|
255
|
+
fieldPath += fieldData[i];
|
|
256
|
+
if (fieldPath.split('.$')[fieldPath.split('.$').length - 1].includes('(Lookup)')) {
|
|
257
|
+
if (!query.some(function (a) { return a.$lookup && a.$lookup.as === filterField.lookup_as.replace(/\.\$/g, ''); })) {
|
|
258
|
+
query.push({ $lookup: {
|
|
259
|
+
from: filterField.lookup_collection,
|
|
260
|
+
localField: filterField.lookup_local_key,
|
|
261
|
+
foreignField: filterField.lookup_foreign_key,
|
|
262
|
+
as: filterField.lookup_as.replace(/\.\$/g, '')
|
|
263
|
+
} });
|
|
264
|
+
sizes.push(filterField.lookup_as.replace(/\.\$\./g, '_'));
|
|
265
|
+
query.push({ $addFields: (_a = {}, _a['size_' + filterField.lookup_as.replace(/\.\$\./g, '_')] = { $size: '$' + filterField.lookup_as.replace(/\.\$/g, '') }, _a) });
|
|
266
|
+
query.push({ '$unwind': { path: '$' + filterField.lookup_as.replace(/\.\$/g, ''), preserveNullAndEmptyArrays: true } });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
if (!query.some(function (a) { return a.$addFields && Object.keys(a.$addFields).includes('size_' + fieldPath.replace(/\./g, '_')); })) {
|
|
271
|
+
sizes.push(fieldPath.replace(/\./g, '_'));
|
|
272
|
+
query.push({ $addFields: (_b = {}, _b['size_' + fieldPath.replace(/\./g, '_')] = { $size: '$' + fieldPath }, _b) });
|
|
273
|
+
query.push({ '$unwind': { path: '$' + fieldPath, preserveNullAndEmptyArrays: true } });
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
253
278
|
// Groups - Lookups / Sizes / Unwinds
|
|
254
279
|
groupsRow.forEach(function (row) {
|
|
255
280
|
var _a, _b;
|
|
@@ -312,34 +337,6 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
312
337
|
}
|
|
313
338
|
}
|
|
314
339
|
});
|
|
315
|
-
filterArrayFields.forEach(function (filterField) {
|
|
316
|
-
var _a, _b;
|
|
317
|
-
var fieldData = filterField.fieldPath.split('.$');
|
|
318
|
-
var fieldPath = '';
|
|
319
|
-
for (var i = 0; i < fieldData.length - 1; i++) {
|
|
320
|
-
fieldPath += fieldData[i];
|
|
321
|
-
if (fieldPath.split('.$')[fieldPath.split('.$').length - 1].includes('(Lookup)')) {
|
|
322
|
-
if (!query.some(function (a) { return a.$lookup && a.$lookup.as === filterField.lookup_as.replace(/\.\$/g, ''); })) {
|
|
323
|
-
query.push({ $lookup: {
|
|
324
|
-
from: filterField.lookup_collection,
|
|
325
|
-
localField: filterField.lookup_local_key,
|
|
326
|
-
foreignField: filterField.lookup_foreign_key,
|
|
327
|
-
as: filterField.lookup_as.replace(/\.\$/g, '')
|
|
328
|
-
} });
|
|
329
|
-
sizes.push(filterField.lookup_as.replace(/\.\$\./g, '_'));
|
|
330
|
-
query.push({ $addFields: (_a = {}, _a['size_' + filterField.lookup_as.replace(/\.\$\./g, '_')] = { $size: '$' + filterField.lookup_as.replace(/\.\$/g, '') }, _a) });
|
|
331
|
-
query.push({ '$unwind': { path: '$' + filterField.lookup_as.replace(/\.\$/g, ''), preserveNullAndEmptyArrays: true } });
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
if (!query.some(function (a) { return a.$addFields && Object.keys(a.$addFields).includes('size_' + fieldPath.replace(/\./g, '_')); })) {
|
|
336
|
-
sizes.push(fieldPath.replace(/\./g, '_'));
|
|
337
|
-
query.push({ $addFields: (_b = {}, _b['size_' + fieldPath.replace(/\./g, '_')] = { $size: '$' + fieldPath }, _b) });
|
|
338
|
-
query.push({ '$unwind': { path: '$' + fieldPath, preserveNullAndEmptyArrays: true } });
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
340
|
divFields = { $addFields: {} };
|
|
344
341
|
fieldsTotal.filter(function (a) { return a.type === 'sum'; }).forEach(function (total) {
|
|
345
342
|
selectedFields.filter(function (a) { return a.fieldType === 'Number'; }).forEach(function (field) {
|
|
@@ -479,6 +476,12 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
479
476
|
else if (field.leafValueType === 'Last') {
|
|
480
477
|
queryGroup[field.id] = { '$last': '$' + field.fieldPath.replace(/\.\$/g, '') };
|
|
481
478
|
}
|
|
479
|
+
else if (field.leafValueType === 'Last') {
|
|
480
|
+
queryGroup[field.id] = { '$last': '$' + field.fieldPath.replace(/\.\$/g, '') };
|
|
481
|
+
}
|
|
482
|
+
else if (field.leafValueType === 'Unique') {
|
|
483
|
+
queryGroup[field.id] = { '$addToSet': '$' + field.fieldPath.replace(/\.\$/g, '') };
|
|
484
|
+
}
|
|
482
485
|
else {
|
|
483
486
|
queryGroup[field.id] = { '$push': '$' + field.fieldPath.replace(/\.\$/g, '') };
|
|
484
487
|
}
|