@resolveio/server-lib 20.7.120 → 20.7.122
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/client-server-app.js +51 -1
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +51 -1
- package/collections/app-status.collection.js.map +1 -1
- package/collections/counter.collection.js +55 -1
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +136 -1
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +87 -1
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +98 -1
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +60 -1
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +73 -1
- package/collections/file.collection.js.map +1 -1
- package/collections/flag-update.collection.js +56 -1
- package/collections/flag-update.collection.js.map +1 -1
- package/collections/flag.collection.js +56 -1
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +72 -1
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +75 -1
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +87 -1
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +66 -1
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +64 -1
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-function.collection.js +73 -1
- package/collections/monitor-function.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +76 -1
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +70 -1
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +56 -1
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +108 -1
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +86 -1
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +148 -1
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +88 -1
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +56 -1
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +265 -1
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +97 -1
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +95 -1
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +78 -1
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +869 -1
- package/http/auth.js.map +1 -1
- package/http/health.js +11 -1
- package/http/health.js.map +1 -1
- package/http/home.js +114 -1
- package/http/home.js.map +1 -1
- package/index.js +18 -1
- package/index.js.map +1 -1
- package/managers/cron.manager.js +461 -1
- package/managers/cron.manager.js.map +1 -1
- package/managers/local-log.manager.js +79 -1
- package/managers/local-log.manager.js.map +1 -1
- package/managers/method.manager.js +1025 -1
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +4231 -1
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +534 -1
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +1292 -1
- package/managers/subscription.manager.js.map +1 -1
- package/managers/websocket.manager.js +165 -1
- package/managers/websocket.manager.js.map +1 -1
- package/managers/worker-dispatcher.manager.js +335 -1
- package/managers/worker-dispatcher.manager.js.map +1 -1
- package/managers/worker-server.manager.js +292 -1
- package/managers/worker-server.manager.js.map +1 -1
- package/methods/accounts.js +302 -1
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +748 -1
- package/methods/aws.js.map +1 -1
- package/methods/collections.js +542 -1
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +111 -1
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +1476 -1
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flag-updates.js +8 -1
- package/methods/flag-updates.js.map +1 -1
- package/methods/flags.js +8 -1
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +417 -1
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +543 -1
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +742 -1
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +840 -1
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +232 -1
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +3 -1
- package/models/app-status.model.js.map +1 -1
- package/models/billing-logged-in-users.model.js +3 -1
- package/models/billing-logged-in-users.model.js.map +1 -1
- package/models/collection-document.model.js +3 -1
- package/models/collection-document.model.js.map +1 -1
- package/models/counter.model.js +3 -1
- package/models/counter.model.js.map +1 -1
- package/models/cron-job-history.model.js +3 -1
- package/models/cron-job-history.model.js.map +1 -1
- package/models/cron-job.model.js +3 -1
- package/models/cron-job.model.js.map +1 -1
- package/models/dialog.model.js +3 -1
- package/models/dialog.model.js.map +1 -1
- package/models/email-history.model.js +15 -1
- package/models/email-history.model.js.map +1 -1
- package/models/email-verified.model.js +3 -1
- package/models/email-verified.model.js.map +1 -1
- package/models/file.model.js +3 -1
- package/models/file.model.js.map +1 -1
- package/models/flag-update.model.js +3 -1
- package/models/flag-update.model.js.map +1 -1
- package/models/flag.model.js +3 -1
- package/models/flag.model.js.map +1 -1
- package/models/log-method-latency.model.js +3 -1
- package/models/log-method-latency.model.js.map +1 -1
- package/models/log-subscription.model.js +3 -1
- package/models/log-subscription.model.js.map +1 -1
- package/models/log.model.js +3 -1
- package/models/log.model.js.map +1 -1
- package/models/logged-in-users.model.js +3 -1
- package/models/logged-in-users.model.js.map +1 -1
- package/models/method-response.model.js +3 -1
- package/models/method-response.model.js.map +1 -1
- package/models/method.model.d.ts +0 -1
- package/models/method.model.js +3 -1
- package/models/method.model.js.map +1 -1
- package/models/monitor-cpu.model.js +3 -1
- package/models/monitor-cpu.model.js.map +1 -1
- package/models/monitor-function.model.js +3 -1
- package/models/monitor-function.model.js.map +1 -1
- package/models/monitor-memory.model.js +3 -1
- package/models/monitor-memory.model.js.map +1 -1
- package/models/monitor-mongo.model.js +3 -1
- package/models/monitor-mongo.model.js.map +1 -1
- package/models/notification.model.js +3 -1
- package/models/notification.model.js.map +1 -1
- package/models/pagination.model.js +23 -1
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +3 -1
- package/models/permission.model.js.map +1 -1
- package/models/report-builder-dashboard-builder.model.js +3 -1
- package/models/report-builder-dashboard-builder.model.js.map +1 -1
- package/models/report-builder-library.model.js +3 -1
- package/models/report-builder-library.model.js.map +1 -1
- package/models/report-builder-report.model.js +3 -1
- package/models/report-builder-report.model.js.map +1 -1
- package/models/report-builder.model.js +3 -1
- package/models/report-builder.model.js.map +1 -1
- package/models/select-data-label.model.js +3 -1
- package/models/select-data-label.model.js.map +1 -1
- package/models/server-message.model.js +3 -1
- package/models/server-message.model.js.map +1 -1
- package/models/subscription.model.js +3 -1
- package/models/subscription.model.js.map +1 -1
- package/models/support-ticket.model.js +3 -1
- package/models/support-ticket.model.js.map +1 -1
- package/models/user-group.model.js +3 -1
- package/models/user-group.model.js.map +1 -1
- package/models/user-guide.model.js +3 -1
- package/models/user-guide.model.js.map +1 -1
- package/models/user.model.js +3 -1
- package/models/user.model.js.map +1 -1
- package/package.json +1 -1
- package/public_api.js +77 -1
- package/public_api.js.map +1 -1
- package/publications/app-status.js +16 -1
- package/publications/app-status.js.map +1 -1
- package/publications/cron-jobs.js +32 -1
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +36 -1
- package/publications/files.js.map +1 -1
- package/publications/flags-update.js +22 -1
- package/publications/flags-update.js.map +1 -1
- package/publications/flags.js +22 -1
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +164 -1
- package/publications/logs.js.map +1 -1
- package/publications/notifications.js +16 -1
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +42 -1
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +90 -1
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +50 -1
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +16 -1
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +16 -1
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +16 -1
- package/publications/user-guides.js.map +1 -1
- package/resolveio-server-app.js +176 -1
- package/resolveio-server-app.js.map +1 -1
- package/server-app.js +1159 -1
- package/server-app.js.map +1 -1
- package/util/common.js +632 -1
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +454 -1
- package/util/schema-report-builder.js.map +1 -1
|
@@ -1,2 +1,455 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.mongoCommand = exports.getLeafFormatTypes = exports.getLeafValueTypes = exports.buildTree = exports.getReportLookupSchemas = void 0;
|
|
40
|
+
var resolveio_server_app_1 = require("../resolveio-server-app");
|
|
41
|
+
var common_1 = require("./common");
|
|
42
|
+
function getReportLookupSchemas(collection_root) {
|
|
43
|
+
var lookupTrees = [];
|
|
44
|
+
lookupTrees.push({ collection_name: collection_root, tree: resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(collection_root)['rbSchema'], is_root: true });
|
|
45
|
+
var schemaObj = resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(collection_root)['rbSchema'];
|
|
46
|
+
var modelKeys = Object.keys(schemaObj);
|
|
47
|
+
modelKeys.forEach(function (field) {
|
|
48
|
+
if (schemaObj[field].lookup_collection) {
|
|
49
|
+
var collectionName_1 = schemaObj[field].lookup_collection;
|
|
50
|
+
var collectionModel = resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(collectionName_1);
|
|
51
|
+
if (!lookupTrees.filter(function (a) { return a.collection_name === collectionName_1; }).length) {
|
|
52
|
+
lookupTrees.push({ collection_name: collectionName_1, tree: collectionModel['rbSchema'], is_root: false });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return lookupTrees;
|
|
57
|
+
}
|
|
58
|
+
exports.getReportLookupSchemas = getReportLookupSchemas;
|
|
59
|
+
function buildTree(current_root, schemaTree, lookup) {
|
|
60
|
+
var res = [];
|
|
61
|
+
Object.keys(schemaTree).filter(function (a) { return a !== '_id' && a !== 'id' && a !== '__v'; }).forEach(function (key) {
|
|
62
|
+
// Object.keys(schemaTree).filter(a => a !== '__v').forEach(key => {
|
|
63
|
+
if (!lookup || (lookup && !schemaTree[key].lookup_collection)) {
|
|
64
|
+
var treeItemSplit = key.split('.');
|
|
65
|
+
// debugger;
|
|
66
|
+
if (treeItemSplit.length === 1) {
|
|
67
|
+
if (schemaTree[key].rbType === 'String' || schemaTree[key].rbType === 'Number' || schemaTree[key].rbType === 'Boolean' || schemaTree[key].rbType === 'Date') {
|
|
68
|
+
res.push({
|
|
69
|
+
collection_name: current_root,
|
|
70
|
+
columnName: (0, common_1.toTitleCase)(key.replace(/\_/g, ' ')),
|
|
71
|
+
fieldName: key,
|
|
72
|
+
fieldType: schemaTree[key].rbType,
|
|
73
|
+
fieldTypeName: schemaTree[key].rbType === 'String' ? 'Text' : (schemaTree[key].rbType === 'Boolean' ? 'T/F' : schemaTree[key].rbType),
|
|
74
|
+
distinctFieldValues: [],
|
|
75
|
+
fieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,
|
|
76
|
+
fieldPathName: lookup ? ((0, common_1.toTitleCase)(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + ((0, common_1.toTitleCase)(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : (0, common_1.toTitleCase)(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> ')),
|
|
77
|
+
lookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),
|
|
78
|
+
lookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),
|
|
79
|
+
lookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),
|
|
80
|
+
lookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),
|
|
81
|
+
text: (0, common_1.toTitleCase)(key.replace(/\_/g, ' ')),
|
|
82
|
+
value: key,
|
|
83
|
+
isLeaf: true,
|
|
84
|
+
isActive: false,
|
|
85
|
+
isSelected: false,
|
|
86
|
+
depth: 0,
|
|
87
|
+
leafValueType: '',
|
|
88
|
+
leafValueTypes: getLeafValueTypes(schemaTree[key], key),
|
|
89
|
+
leafFormatType: '',
|
|
90
|
+
leafFormatTypes: getLeafFormatTypes(schemaTree[key], key)
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
res.push({
|
|
95
|
+
collection_name: current_root,
|
|
96
|
+
columnName: (0, common_1.toTitleCase)(key.replace(/\_/g, ' ')),
|
|
97
|
+
fieldName: key,
|
|
98
|
+
fieldType: schemaTree[key].lookup_collection ? 'Lookup' : schemaTree[key].rbType,
|
|
99
|
+
fieldTypeName: schemaTree[key].lookup_collection ? 'Lookup' : (schemaTree[key].rbType === 'Array' ? 'List' : 'Group'),
|
|
100
|
+
distinctFieldValues: [],
|
|
101
|
+
fieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,
|
|
102
|
+
fieldPathName: lookup ? ((0, common_1.toTitleCase)(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + ((0, common_1.toTitleCase)(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : (0, common_1.toTitleCase)(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> ')),
|
|
103
|
+
lookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),
|
|
104
|
+
lookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),
|
|
105
|
+
lookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),
|
|
106
|
+
lookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),
|
|
107
|
+
text: (0, common_1.toTitleCase)(key.replace(/\_/g, ' ')),
|
|
108
|
+
value: key,
|
|
109
|
+
isLeaf: false,
|
|
110
|
+
isActive: false,
|
|
111
|
+
isSelected: false,
|
|
112
|
+
depth: 0,
|
|
113
|
+
leafValueType: '',
|
|
114
|
+
leafFormatType: '',
|
|
115
|
+
children: []
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
res = res.sort(function (a, b) { return a.fieldName.localeCompare(b.fieldName); });
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
var child_1 = null;
|
|
122
|
+
treeItemSplit.forEach(function (layer, index) {
|
|
123
|
+
if (!child_1) {
|
|
124
|
+
child_1 = res.find(function (a) { return a.fieldName === layer; });
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
if (child_1.children.find(function (a) { return a.fieldName === layer; })) {
|
|
128
|
+
child_1 = child_1.children.find(function (a) { return a.fieldName === layer; });
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
if (schemaTree[key].rbType === 'String' || schemaTree[key].rbType === 'Number' || schemaTree[key].rbType === 'Boolean' || schemaTree[key].rbType === 'Date') {
|
|
132
|
+
child_1.children.push({
|
|
133
|
+
collection_name: current_root,
|
|
134
|
+
columnName: (0, common_1.toTitleCase)(key.replace(/\_/g, ' ')),
|
|
135
|
+
fieldName: layer,
|
|
136
|
+
fieldType: schemaTree[key].rbType,
|
|
137
|
+
fieldTypeName: schemaTree[key].rbType === 'String' ? 'Text' : (schemaTree[key].rbType === 'Boolean' ? 'T/F' : schemaTree[key].rbType),
|
|
138
|
+
distinctFieldValues: [],
|
|
139
|
+
fieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,
|
|
140
|
+
fieldPathName: lookup ? ((0, common_1.toTitleCase)(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + ((0, common_1.toTitleCase)(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : (0, common_1.toTitleCase)(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> ')),
|
|
141
|
+
lookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),
|
|
142
|
+
lookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),
|
|
143
|
+
lookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),
|
|
144
|
+
lookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),
|
|
145
|
+
text: (0, common_1.toTitleCase)(layer.replace(/\_/g, ' ')),
|
|
146
|
+
value: layer,
|
|
147
|
+
isLeaf: true,
|
|
148
|
+
isActive: false,
|
|
149
|
+
isSelected: false,
|
|
150
|
+
depth: index,
|
|
151
|
+
leafValueType: '',
|
|
152
|
+
leafValueTypes: getLeafValueTypes(schemaTree[key], key),
|
|
153
|
+
leafFormatType: '',
|
|
154
|
+
leafFormatTypes: getLeafFormatTypes(schemaTree[key], key)
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
child_1.children.push({
|
|
159
|
+
collection_name: current_root,
|
|
160
|
+
columnName: (0, common_1.toTitleCase)(key.replace(/\_/g, ' ')),
|
|
161
|
+
fieldName: layer,
|
|
162
|
+
fieldType: schemaTree[key].lookup_collection ? 'Lookup' : schemaTree[key].rbType,
|
|
163
|
+
fieldTypeName: schemaTree[key].lookup_collection ? 'Lookup' : (schemaTree[key].rbType === 'Array' ? 'List' : 'Group'),
|
|
164
|
+
distinctFieldValues: [],
|
|
165
|
+
fieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,
|
|
166
|
+
fieldPathName: lookup ? ((0, common_1.toTitleCase)(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + ((0, common_1.toTitleCase)(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : (0, common_1.toTitleCase)(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> ')),
|
|
167
|
+
lookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),
|
|
168
|
+
lookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),
|
|
169
|
+
lookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),
|
|
170
|
+
lookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),
|
|
171
|
+
text: (0, common_1.toTitleCase)(layer.replace(/\_/g, ' ')),
|
|
172
|
+
value: layer,
|
|
173
|
+
isLeaf: false,
|
|
174
|
+
isActive: false,
|
|
175
|
+
isSelected: false,
|
|
176
|
+
depth: index,
|
|
177
|
+
leafValueType: '',
|
|
178
|
+
leafFormatType: '',
|
|
179
|
+
children: []
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
child_1.children = child_1.children.sort(function (a, b) { return a.fieldName.localeCompare(b.fieldName); });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
return res;
|
|
190
|
+
}
|
|
191
|
+
exports.buildTree = buildTree;
|
|
192
|
+
// eslint-disable-next-line no-unused-vars
|
|
193
|
+
function getLeafValueTypes(schemaTree, fieldPath) {
|
|
194
|
+
var leafTypes = [];
|
|
195
|
+
if (schemaTree.rbType === 'String') {
|
|
196
|
+
leafTypes = [
|
|
197
|
+
{
|
|
198
|
+
text: 'As Value',
|
|
199
|
+
value: 'Value'
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
text: 'Unique',
|
|
203
|
+
value: 'Unique'
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
text: 'As Count',
|
|
207
|
+
value: 'Count'
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
text: 'First',
|
|
211
|
+
value: 'First'
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
text: 'Last',
|
|
215
|
+
value: 'Last'
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
}
|
|
219
|
+
else if (schemaTree.rbType === 'Number') {
|
|
220
|
+
leafTypes = [
|
|
221
|
+
{
|
|
222
|
+
text: 'As Value',
|
|
223
|
+
value: 'Value'
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
text: 'Unique',
|
|
227
|
+
value: 'Unique'
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
text: 'As Average',
|
|
231
|
+
value: 'Average'
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
text: 'As Count',
|
|
235
|
+
value: 'Count'
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
text: 'As Sum',
|
|
239
|
+
value: 'Sum'
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
text: 'Minimum',
|
|
243
|
+
value: 'Minimum'
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
text: 'Maximum',
|
|
247
|
+
value: 'Maximum'
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
text: 'First',
|
|
251
|
+
value: 'First'
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
text: 'Last',
|
|
255
|
+
value: 'Last'
|
|
256
|
+
}
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
else if (schemaTree.rbType === 'Boolean') {
|
|
260
|
+
leafTypes = [
|
|
261
|
+
{
|
|
262
|
+
text: 'As Value',
|
|
263
|
+
value: 'Value'
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
text: 'Unique',
|
|
267
|
+
value: 'Unique'
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
text: 'As Count',
|
|
271
|
+
value: 'Count'
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
text: 'First',
|
|
275
|
+
value: 'First'
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
text: 'Last',
|
|
279
|
+
value: 'Last'
|
|
280
|
+
}
|
|
281
|
+
];
|
|
282
|
+
}
|
|
283
|
+
else if (schemaTree.rbType === 'Date') {
|
|
284
|
+
leafTypes = [
|
|
285
|
+
{
|
|
286
|
+
text: 'As Value',
|
|
287
|
+
value: 'Value'
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
text: 'Unique',
|
|
291
|
+
value: 'Unique'
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
text: 'As Count',
|
|
295
|
+
value: 'Count'
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
text: 'Minimum',
|
|
299
|
+
value: 'Minimum'
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
text: 'Maximum',
|
|
303
|
+
value: 'Maximum'
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
text: 'First',
|
|
307
|
+
value: 'First'
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
text: 'Last',
|
|
311
|
+
value: 'Last'
|
|
312
|
+
}
|
|
313
|
+
];
|
|
314
|
+
}
|
|
315
|
+
return leafTypes;
|
|
316
|
+
}
|
|
317
|
+
exports.getLeafValueTypes = getLeafValueTypes;
|
|
318
|
+
// eslint-disable-next-line no-unused-vars
|
|
319
|
+
function getLeafFormatTypes(schemaTree, fieldPath) {
|
|
320
|
+
var leafTypes = [];
|
|
321
|
+
if (schemaTree.rbType === 'String') {
|
|
322
|
+
leafTypes = [
|
|
323
|
+
{
|
|
324
|
+
text: 'As Text',
|
|
325
|
+
value: 'String'
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
text: 'As Number',
|
|
329
|
+
value: 'Number'
|
|
330
|
+
}
|
|
331
|
+
];
|
|
332
|
+
}
|
|
333
|
+
else if (schemaTree.rbType === 'Number') {
|
|
334
|
+
leafTypes = [
|
|
335
|
+
{
|
|
336
|
+
text: 'As Number',
|
|
337
|
+
value: 'Number'
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
text: 'As Currency',
|
|
341
|
+
value: 'Currency'
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
text: 'As Text',
|
|
345
|
+
value: 'String'
|
|
346
|
+
}
|
|
347
|
+
];
|
|
348
|
+
}
|
|
349
|
+
else if (schemaTree.rbType === 'Boolean') {
|
|
350
|
+
leafTypes = [
|
|
351
|
+
{
|
|
352
|
+
text: 'As Number',
|
|
353
|
+
value: 'Number'
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
text: 'As Boolean (True/False)',
|
|
357
|
+
value: 'Boolean'
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
text: 'As Text (Yes/No)',
|
|
361
|
+
value: 'String'
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
text: 'As Number (1/0)',
|
|
365
|
+
value: 'Boolean_Number'
|
|
366
|
+
}
|
|
367
|
+
];
|
|
368
|
+
}
|
|
369
|
+
else if (schemaTree.rbType === 'Date') {
|
|
370
|
+
leafTypes = [
|
|
371
|
+
{
|
|
372
|
+
text: 'As Number',
|
|
373
|
+
value: 'Number'
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
text: 'As Date (Short Format)',
|
|
377
|
+
value: 'Date'
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
text: 'As Time (Short Format)',
|
|
381
|
+
value: 'Time'
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
text: 'As Date/Time (Short Format)',
|
|
385
|
+
value: 'DateTime'
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
text: 'As Date (Long Format)',
|
|
389
|
+
value: 'Date_long'
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
text: 'As Date/Time (Long Format)',
|
|
393
|
+
value: 'DateTime_long'
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
text: 'As Timestamp (MS since 1970)',
|
|
397
|
+
value: 'Timestamp'
|
|
398
|
+
}
|
|
399
|
+
];
|
|
400
|
+
}
|
|
401
|
+
return leafTypes;
|
|
402
|
+
}
|
|
403
|
+
exports.getLeafFormatTypes = getLeafFormatTypes;
|
|
404
|
+
function mongoCommand(commandstr, collection, field) {
|
|
405
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
406
|
+
var tmpObj, obj, obj, _a;
|
|
407
|
+
return __generator(this, function (_b) {
|
|
408
|
+
switch (_b.label) {
|
|
409
|
+
case 0:
|
|
410
|
+
_b.trys.push([0, 6, , 7]);
|
|
411
|
+
if (!(commandstr === 'count')) return [3 /*break*/, 2];
|
|
412
|
+
obj = {
|
|
413
|
+
count: collection,
|
|
414
|
+
query: {}
|
|
415
|
+
};
|
|
416
|
+
obj.query[field] = { $ne: null };
|
|
417
|
+
return [4 /*yield*/, resolveio_server_app_1.ResolveIOServer.getMainDB().command(obj)];
|
|
418
|
+
case 1:
|
|
419
|
+
tmpObj = _b.sent();
|
|
420
|
+
return [3 /*break*/, 5];
|
|
421
|
+
case 2:
|
|
422
|
+
if (!(commandstr === 'distinct')) return [3 /*break*/, 4];
|
|
423
|
+
obj = {
|
|
424
|
+
distinct: collection,
|
|
425
|
+
query: {},
|
|
426
|
+
key: field,
|
|
427
|
+
};
|
|
428
|
+
return [4 /*yield*/, resolveio_server_app_1.ResolveIOServer.getMainDB().command(obj)];
|
|
429
|
+
case 3:
|
|
430
|
+
tmpObj = _b.sent();
|
|
431
|
+
return [3 /*break*/, 5];
|
|
432
|
+
case 4:
|
|
433
|
+
if (commandstr === 'listIndexes') {
|
|
434
|
+
// tmpObj = await this.mainDb.db[collection].getIndexes();
|
|
435
|
+
// let obj = { 'listIndexes': collection };
|
|
436
|
+
// tmpObj = await this.mainDb.db.getIndexes(obj);
|
|
437
|
+
}
|
|
438
|
+
_b.label = 5;
|
|
439
|
+
case 5: return [3 /*break*/, 7];
|
|
440
|
+
case 6:
|
|
441
|
+
_a = _b.sent();
|
|
442
|
+
// console.log('----------- mongoCommand err: ', err);
|
|
443
|
+
return [2 /*return*/, -1];
|
|
444
|
+
case 7:
|
|
445
|
+
if (tmpObj) {
|
|
446
|
+
return [2 /*return*/, tmpObj.values];
|
|
447
|
+
}
|
|
448
|
+
return [2 /*return*/];
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
exports.mongoCommand = mongoCommand;
|
|
454
|
+
|
|
2
455
|
//# sourceMappingURL=schema-report-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/schema-report-builder.ts"],"names":["resolveio_server_app_1","require","common_1","getReportLookupSchemas","collection_root","lookupTrees","schemaObj","push","collection_name","tree","ResolveIOServer","getMongoManager","collection","is_root","Object","keys","forEach","field","collectionName_1","lookup_collection","collectionModel","filter","a","length","buildTree","current_root","schemaTree","lookup","res","key","treeItemSplit","child_1","split","rbType","columnName","toTitleCase","replace","fieldName","fieldType","fieldTypeName","distinctFieldValues","fieldPath","lookup_as","fieldPathName","lookup_local_key","local_key","lookup_foreign_key","lookup_key","text","value","isLeaf","isActive","isSelected","depth","leafValueType","leafValueTypes","getLeafValueTypes","leafFormatType","leafFormatTypes","getLeafFormatTypes","children","sort","b","localeCompare","layer","index","find","leafTypes","mongoCommand","commandstr","obj","count","query","$ne","getMainDB","command","tmpObj","_b","sent","distinct","values","exports"],"mappings":"k8CACAA,wB,yLAAAC,QAAA,yBAAA,GACAC,SAAAD,QAAA,UAAA,EAEA,SAAgBE,uBAAuBC,GACtC,IAAIC,EAAgC,GAEhCC,GADJD,EAAYE,KAAK,CAAEC,gBAAiBJ,EAAiBK,KAAMT,uBAAAU,gBAAgBC,gBAAe,EAAGC,WAAWR,CAAe,EAAY,SAAGS,QAAS,CAAA,CAAI,CAAE,EACrIb,uBAAAU,gBAAgBC,gBAAe,EAAGC,WAAWR,CAAe,EAAY,UAaxF,OAZgBU,OAAOC,KAAKT,CAAS,EAC3BU,QAAQ,SAAAC,GACjB,IACKC,EADDZ,EAAUW,GAAOE,oBAChBD,EAAiBZ,EAAUW,GAAOE,kBAClCC,EAAkBpB,uBAAAU,gBAAgBC,gBAAe,EAAGC,WAAWM,CAAc,EAE5Eb,EAAYgB,OAAO,SAAAC,GAAK,OAAAA,EAAEd,kBAAoBU,CAAtB,CAAoC,EAAEK,QAClElB,EAAYE,KAAK,CAAEC,gBAAiBU,EAAgBT,KAAMW,EAA0B,SAAGP,QAAS,CAAA,CAAK,CAAE,EAG1G,CAAC,EAEMR,CACR,CAEA,SAAgBmB,UAAUC,EAAcC,EAAYC,GACnD,IAAIC,EAAM,GAwIV,OAtIAd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,SACnBkC,EAAY,CACX,CACCnB,KAAM,YACNC,MAAO,Q,EAER,CACCD,KAAM,yBACNC,MAAO,M,EAER,CACCD,KAAM,yBACNC,MAAO,M,EAER,CACCD,KAAM,8BACNC,MAAO,U,EAER,CACCD,KAAM,wBACNC,MAAO,W,EAER,CACCD,KAAM,6BACNC,MAAO,e,EAER,CACCD,KAAM,+BACNC,MAAO,W,IAIHkB,CACR,CAMA,SAAsBC,aAAaC,EAAoBzD,EAAoBK,G,+IAItD,UAAfoD,GAAA,CAAA,EAAA,KACCC,EAAM,CACTC,MAAO3D,EACP4D,MAAO,E,GAEJA,MAAMvD,GAAS,CAACwD,IAAK,IAAI,EACpB,CAAA,EAAMzE,uBAAAU,gBAAgBgE,UAAS,EAAGC,QAAQL,CAAG,I,cAAtDM,EAASC,EAAAC,KAAA,E,mBAGc,aAAfT,EAAA,CAAA,EAAA,IACJC,EAAM,CACTS,SAAUnE,EACV4D,MAAO,GACP3C,IAAKZ,C,EAEG,CAAA,EAAMjB,uBAAAU,gBAAgBgE,UAAS,EAAGC,QAAQL,CAAG,I,cAAtDM,EAASC,EAAAC,KAAA,E,iDASV,O,SAAA,CAAA,EAAO,CAAC,G,OAET,OAAIF,EACH,CAAA,EAAOA,EAAOI,Q,SAxZhBC,QAAA9E,uBAAAA,uBAmBA8E,QAAAzD,UAAAA,UA6IAyD,QAAAzB,kBAAAA,kBA+HAyB,QAAAtB,mBAAAA,mBA0FAsB,QAAAb,aAAAA","file":"schema-report-builder.js","sourcesContent":["import { CollectionTree } from '../models/report-builder.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { toTitleCase } from './common';\n\nexport function getReportLookupSchemas(collection_root: string) {\n\tlet lookupTrees: CollectionTree[] = [];\n\tlookupTrees.push({ collection_name: collection_root, tree: ResolveIOServer.getMongoManager().collection(collection_root)['rbSchema'], is_root: true });\n\tlet schemaObj = ResolveIOServer.getMongoManager().collection(collection_root)['rbSchema'];\n\tlet modelKeys = Object.keys(schemaObj);\n\tmodelKeys.forEach(field => {\n\t\tif (schemaObj[field].lookup_collection) {\n\t\t\tlet collectionName = schemaObj[field].lookup_collection;\n\t\t\tlet collectionModel = ResolveIOServer.getMongoManager().collection(collectionName);\n\n\t\t\tif (!lookupTrees.filter(a => a.collection_name === collectionName).length) {\n\t\t\t\tlookupTrees.push({ collection_name: collectionName, tree: collectionModel['rbSchema'], is_root: false });\n\t\t\t}\n\t\t}\n\t});\n\n\treturn lookupTrees;\n}\n\nexport function buildTree(current_root, schemaTree, lookup?) {\n\tlet res = [];\n\n\tObject.keys(schemaTree).filter(a => a !== '_id' && a !== 'id' && a !== '__v').forEach(key => {\n\t// Object.keys(schemaTree).filter(a => a !== '__v').forEach(key => {\n\t\tif (!lookup || (lookup && !schemaTree[key].lookup_collection)) {\n\t\t\tlet treeItemSplit = key.split('.');\n\t\t\n\t\t\t// debugger;\n\n\t\t\tif (treeItemSplit.length === 1) {\n\t\t\t\tif (schemaTree[key].rbType === 'String' || schemaTree[key].rbType === 'Number' || schemaTree[key].rbType === 'Boolean' || schemaTree[key].rbType === 'Date') {\n\t\t\t\t\tres.push({\n\t\t\t\t\t\tcollection_name: current_root,\n\t\t\t\t\t\tcolumnName: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\tfieldName: key,\n\t\t\t\t\t\tfieldType: schemaTree[key].rbType,\n\t\t\t\t\t\tfieldTypeName: schemaTree[key].rbType === 'String' ? 'Text' : (schemaTree[key].rbType === 'Boolean' ? 'T/F' : schemaTree[key].rbType),\n\t\t\t\t\t\tdistinctFieldValues: [],\n\t\t\t\t\t\tfieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,\n\t\t\t\t\t\tfieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> ')),\n\t\t\t\t\t\tlookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),\n\t\t\t\t\t\tlookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),\n\t\t\t\t\t\tlookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),\n\t\t\t\t\t\tlookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),\n\t\t\t\t\t\ttext: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\tisLeaf: true,\n\t\t\t\t\t\tisActive: false,\n\t\t\t\t\t\tisSelected: false,\n\t\t\t\t\t\tdepth: 0,\n\t\t\t\t\t\tleafValueType: '',\n\t\t\t\t\t\tleafValueTypes: getLeafValueTypes(schemaTree[key], key),\n\t\t\t\t\t\tleafFormatType: '',\n\t\t\t\t\t\tleafFormatTypes: getLeafFormatTypes(schemaTree[key], key)\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tres.push({\n\t\t\t\t\t\tcollection_name: current_root,\n\t\t\t\t\t\tcolumnName: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\tfieldName: key,\n\t\t\t\t\t\tfieldType: schemaTree[key].lookup_collection ? 'Lookup' : schemaTree[key].rbType,\n\t\t\t\t\t\tfieldTypeName: schemaTree[key].lookup_collection ? 'Lookup' : (schemaTree[key].rbType === 'Array' ? 'List' : 'Group'),\n\t\t\t\t\t\tdistinctFieldValues: [],\n\t\t\t\t\t\tfieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,\n\t\t\t\t\t\tfieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> ')),\n\t\t\t\t\t\tlookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),\n\t\t\t\t\t\tlookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),\n\t\t\t\t\t\tlookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),\n\t\t\t\t\t\tlookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),\n\t\t\t\t\t\ttext: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\tisLeaf: false,\n\t\t\t\t\t\tisActive: false,\n\t\t\t\t\t\tisSelected: false,\n\t\t\t\t\t\tdepth: 0,\n\t\t\t\t\t\tleafValueType: '',\n\t\t\t\t\t\tleafFormatType: '',\n\t\t\t\t\t\tchildren: []\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tres = res.sort((a, b) => a.fieldName.localeCompare(b.fieldName));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet child = null;\n\n\t\t\t\ttreeItemSplit.forEach((layer, index) => {\n\t\t\t\t\tif (!child) {\n\t\t\t\t\t\tchild = res.find(a => a.fieldName === layer);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (child.children.find(a => a.fieldName === layer)) {\n\t\t\t\t\t\t\tchild = child.children.find(a => a.fieldName === layer);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif (schemaTree[key].rbType === 'String' || schemaTree[key].rbType === 'Number' || schemaTree[key].rbType === 'Boolean' || schemaTree[key].rbType === 'Date') {\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tchild.children.push({\n\t\t\t\t\t\t\t\t\tcollection_name: current_root,\n\t\t\t\t\t\t\t\t\tcolumnName: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\t\t\t\tfieldName: layer,\n\t\t\t\t\t\t\t\t\tfieldType: schemaTree[key].rbType,\n\t\t\t\t\t\t\t\t\tfieldTypeName: schemaTree[key].rbType === 'String' ? 'Text' : (schemaTree[key].rbType === 'Boolean' ? 'T/F' : schemaTree[key].rbType),\n\t\t\t\t\t\t\t\t\tdistinctFieldValues: [],\n\t\t\t\t\t\t\t\t\tfieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,\n\t\t\t\t\t\t\t\t\tfieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> ')),\n\t\t\t\t\t\t\t\t\tlookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),\n\t\t\t\t\t\t\t\t\tlookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),\n\t\t\t\t\t\t\t\t\tlookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),\n\t\t\t\t\t\t\t\t\tlookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),\n\t\t\t\t\t\t\t\t\ttext: toTitleCase(layer.replace(/\\_/g, ' ')),\n\t\t\t\t\t\t\t\t\tvalue: layer,\n\t\t\t\t\t\t\t\t\tisLeaf: true,\n\t\t\t\t\t\t\t\t\tisActive: false,\n\t\t\t\t\t\t\t\t\tisSelected: false,\n\t\t\t\t\t\t\t\t\tdepth: index,\n\t\t\t\t\t\t\t\t\tleafValueType: '',\n\t\t\t\t\t\t\t\t\tleafValueTypes: getLeafValueTypes(schemaTree[key], key),\n\t\t\t\t\t\t\t\t\tleafFormatType: '',\n\t\t\t\t\t\t\t\t\tleafFormatTypes: getLeafFormatTypes(schemaTree[key], key)\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tchild.children.push({\n\t\t\t\t\t\t\t\t\tcollection_name: current_root,\n\t\t\t\t\t\t\t\t\tcolumnName: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\t\t\t\tfieldName: layer,\n\t\t\t\t\t\t\t\t\tfieldType: schemaTree[key].lookup_collection ? 'Lookup' : schemaTree[key].rbType,\n\t\t\t\t\t\t\t\t\tfieldTypeName: schemaTree[key].lookup_collection ? 'Lookup' : (schemaTree[key].rbType === 'Array' ? 'List' : 'Group'),\n\t\t\t\t\t\t\t\t\tdistinctFieldValues: [],\n\t\t\t\t\t\t\t\t\tfieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,\n\t\t\t\t\t\t\t\t\tfieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> ')),\n\t\t\t\t\t\t\t\t\tlookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),\n\t\t\t\t\t\t\t\t\tlookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),\n\t\t\t\t\t\t\t\t\tlookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),\n\t\t\t\t\t\t\t\t\tlookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),\n\t\t\t\t\t\t\t\t\ttext: toTitleCase(layer.replace(/\\_/g, ' ')),\n\t\t\t\t\t\t\t\t\tvalue: layer,\n\t\t\t\t\t\t\t\t\tisLeaf: false,\n\t\t\t\t\t\t\t\t\tisActive: false,\n\t\t\t\t\t\t\t\t\tisSelected: false,\n\t\t\t\t\t\t\t\t\tdepth: index,\n\t\t\t\t\t\t\t\t\tleafValueType: '',\n\t\t\t\t\t\t\t\t\tleafFormatType: '',\n\t\t\t\t\t\t\t\t\tchildren: []\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tchild.children = child.children.sort((a, b) => a.fieldName.localeCompare(b.fieldName));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n\treturn res;\n}\n\n// eslint-disable-next-line no-unused-vars\nexport function getLeafValueTypes(schemaTree, fieldPath) {\n\tlet leafTypes = [];\n\n\tif (schemaTree.rbType === 'String') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Value',\n\t\t\t\tvalue: 'Value'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Unique',\n\t\t\t\tvalue: 'Unique'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Count',\n\t\t\t\tvalue: 'Count'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'First',\n\t\t\t\tvalue: 'First'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Last',\n\t\t\t\tvalue: 'Last'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Number') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Value',\n\t\t\t\tvalue: 'Value'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Unique',\n\t\t\t\tvalue: 'Unique'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Average',\n\t\t\t\tvalue: 'Average'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Count',\n\t\t\t\tvalue: 'Count'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Sum',\n\t\t\t\tvalue: 'Sum'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Minimum',\n\t\t\t\tvalue: 'Minimum'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Maximum',\n\t\t\t\tvalue: 'Maximum'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'First',\n\t\t\t\tvalue: 'First'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Last',\n\t\t\t\tvalue: 'Last'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Boolean') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Value',\n\t\t\t\tvalue: 'Value'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Unique',\n\t\t\t\tvalue: 'Unique'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Count',\n\t\t\t\tvalue: 'Count'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'First',\n\t\t\t\tvalue: 'First'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Last',\n\t\t\t\tvalue: 'Last'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Date') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Value',\n\t\t\t\tvalue: 'Value'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Unique',\n\t\t\t\tvalue: 'Unique'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Count',\n\t\t\t\tvalue: 'Count'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Minimum',\n\t\t\t\tvalue: 'Minimum'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Maximum',\n\t\t\t\tvalue: 'Maximum'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'First',\n\t\t\t\tvalue: 'First'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Last',\n\t\t\t\tvalue: 'Last'\n\t\t\t}\n\t\t];\n\t}\n\treturn leafTypes;\n}\n\n// eslint-disable-next-line no-unused-vars\nexport function getLeafFormatTypes(schemaTree, fieldPath) {\n\tlet leafTypes = [];\n\n\tif (schemaTree.rbType === 'String') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Text',\n\t\t\t\tvalue: 'String'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Number',\n\t\t\t\tvalue: 'Number'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Number') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Number',\n\t\t\t\tvalue: 'Number'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Currency',\n\t\t\t\tvalue: 'Currency'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Text',\n\t\t\t\tvalue: 'String'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Boolean') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Number',\n\t\t\t\tvalue: 'Number'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Boolean (True/False)',\n\t\t\t\tvalue: 'Boolean'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Text (Yes/No)',\n\t\t\t\tvalue: 'String'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Number (1/0)',\n\t\t\t\tvalue: 'Boolean_Number'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Date') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Number',\n\t\t\t\tvalue: 'Number'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Date (Short Format)',\n\t\t\t\tvalue: 'Date'\n\t\t\t}, \n\t\t\t{\n\t\t\t\ttext: 'As Time (Short Format)',\n\t\t\t\tvalue: 'Time'\n\t\t\t}, \n\t\t\t{\n\t\t\t\ttext: 'As Date/Time (Short Format)',\n\t\t\t\tvalue: 'DateTime'\n\t\t\t}, \n\t\t\t{\n\t\t\t\ttext: 'As Date (Long Format)',\n\t\t\t\tvalue: 'Date_long'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Date/Time (Long Format)',\n\t\t\t\tvalue: 'DateTime_long'\n\t\t\t}, \n\t\t\t{\n\t\t\t\ttext: 'As Timestamp (MS since 1970)',\n\t\t\t\tvalue: 'Timestamp'\n\t\t\t}\n\t\t];\n\t}\n\treturn leafTypes;\n}\n\n\n\n\n\nexport async function mongoCommand(commandstr: string, collection: string, field?: any) {\n\tlet tmpObj;\n\ttry {\n\t\t// Count the number of non-empty fields in a given collection:\n\t\tif (commandstr === 'count') {\n\t\t\tlet obj = {\n\t\t\t\tcount: collection,\n\t\t\t\tquery: {}\n\t\t\t};\n\t\t\tobj.query[field] = {$ne: null};\n\t\t\ttmpObj = await ResolveIOServer.getMainDB().command(obj);\n\t\t}\n\t\t// Get all distinct values in a given field.\n\t\telse if (commandstr === 'distinct') {\n\t\t\tlet obj = {\n\t\t\t\tdistinct: collection,\n\t\t\t\tquery: {},\n\t\t\t\tkey: field,\n\t\t\t};\n\t\t\ttmpObj = await ResolveIOServer.getMainDB().command(obj);\n\t\t}\n\t\telse if (commandstr === 'listIndexes') {\n\t\t\t// tmpObj = await this.mainDb.db[collection].getIndexes();\n\t\t\t// let obj = { 'listIndexes': collection };\n\t\t\t// tmpObj = await this.mainDb.db.getIndexes(obj);\n\t\t}\n\t} catch {\n\t\t// console.log('----------- mongoCommand err: ', err);\n\t\treturn -1;\n\t}\n\tif (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gBACpC,KAAK,EAAE,WAAW;aAClB;SACD,CAAC;KACF;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AApFD,gDAoFC;AAMD,SAAsB,YAAY,CAAC,UAAkB,EAAE,UAAkB,EAAE,KAAW;;;;;;;yBAIhF,CAAA,UAAU,KAAK,OAAO,CAAA,EAAtB,wBAAsB;oBACrB,GAAG,GAAG;wBACT,KAAK,EAAE,UAAU;wBACjB,KAAK,EAAE,EAAE;qBACT,CAAC;oBACF,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAC,GAAG,EAAE,IAAI,EAAC,CAAC;oBACtB,qBAAM,sCAAe,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAA;;oBAAvD,MAAM,GAAG,SAA8C,CAAC;;;yBAGhD,CAAA,UAAU,KAAK,UAAU,CAAA,EAAzB,wBAAyB;oBAC7B,GAAG,GAAG;wBACT,QAAQ,EAAE,UAAU;wBACpB,KAAK,EAAE,EAAE;wBACT,GAAG,EAAE,KAAK;qBACV,CAAC;oBACO,qBAAM,sCAAe,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAA;;oBAAvD,MAAM,GAAG,SAA8C,CAAC;;;oBAEpD,IAAI,UAAU,KAAK,aAAa,EAAE;wBACtC,0DAA0D;wBAC1D,2CAA2C;wBAC3C,iDAAiD;qBACjD;;;;;oBAED,sDAAsD;oBACtD,sBAAO,CAAC,CAAC,EAAC;;oBAEX,IAAI,MAAM,EAAE;wBACX,sBAAO,MAAM,CAAC,MAAM,EAAC;qBACrB;;;;;CACD;AAjCD,oCAiCC","file":"schema-report-builder.js","sourcesContent":["import { CollectionTree } from '../models/report-builder.model';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { toTitleCase } from './common';\n\nexport function getReportLookupSchemas(collection_root: string) {\n\tlet lookupTrees: CollectionTree[] = [];\n\tlookupTrees.push({ collection_name: collection_root, tree: ResolveIOServer.getMongoManager().collection(collection_root)['rbSchema'], is_root: true });\n\tlet schemaObj = ResolveIOServer.getMongoManager().collection(collection_root)['rbSchema'];\n\tlet modelKeys = Object.keys(schemaObj);\n\tmodelKeys.forEach(field => {\n\t\tif (schemaObj[field].lookup_collection) {\n\t\t\tlet collectionName = schemaObj[field].lookup_collection;\n\t\t\tlet collectionModel = ResolveIOServer.getMongoManager().collection(collectionName);\n\n\t\t\tif (!lookupTrees.filter(a => a.collection_name === collectionName).length) {\n\t\t\t\tlookupTrees.push({ collection_name: collectionName, tree: collectionModel['rbSchema'], is_root: false });\n\t\t\t}\n\t\t}\n\t});\n\n\treturn lookupTrees;\n}\n\nexport function buildTree(current_root, schemaTree, lookup?) {\n\tlet res = [];\n\n\tObject.keys(schemaTree).filter(a => a !== '_id' && a !== 'id' && a !== '__v').forEach(key => {\n\t// Object.keys(schemaTree).filter(a => a !== '__v').forEach(key => {\n\t\tif (!lookup || (lookup && !schemaTree[key].lookup_collection)) {\n\t\t\tlet treeItemSplit = key.split('.');\n\t\t\n\t\t\t// debugger;\n\n\t\t\tif (treeItemSplit.length === 1) {\n\t\t\t\tif (schemaTree[key].rbType === 'String' || schemaTree[key].rbType === 'Number' || schemaTree[key].rbType === 'Boolean' || schemaTree[key].rbType === 'Date') {\n\t\t\t\t\tres.push({\n\t\t\t\t\t\tcollection_name: current_root,\n\t\t\t\t\t\tcolumnName: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\tfieldName: key,\n\t\t\t\t\t\tfieldType: schemaTree[key].rbType,\n\t\t\t\t\t\tfieldTypeName: schemaTree[key].rbType === 'String' ? 'Text' : (schemaTree[key].rbType === 'Boolean' ? 'T/F' : schemaTree[key].rbType),\n\t\t\t\t\t\tdistinctFieldValues: [],\n\t\t\t\t\t\tfieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,\n\t\t\t\t\t\tfieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> ')),\n\t\t\t\t\t\tlookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),\n\t\t\t\t\t\tlookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),\n\t\t\t\t\t\tlookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),\n\t\t\t\t\t\tlookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),\n\t\t\t\t\t\ttext: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\tisLeaf: true,\n\t\t\t\t\t\tisActive: false,\n\t\t\t\t\t\tisSelected: false,\n\t\t\t\t\t\tdepth: 0,\n\t\t\t\t\t\tleafValueType: '',\n\t\t\t\t\t\tleafValueTypes: getLeafValueTypes(schemaTree[key], key),\n\t\t\t\t\t\tleafFormatType: '',\n\t\t\t\t\t\tleafFormatTypes: getLeafFormatTypes(schemaTree[key], key)\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tres.push({\n\t\t\t\t\t\tcollection_name: current_root,\n\t\t\t\t\t\tcolumnName: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\tfieldName: key,\n\t\t\t\t\t\tfieldType: schemaTree[key].lookup_collection ? 'Lookup' : schemaTree[key].rbType,\n\t\t\t\t\t\tfieldTypeName: schemaTree[key].lookup_collection ? 'Lookup' : (schemaTree[key].rbType === 'Array' ? 'List' : 'Group'),\n\t\t\t\t\t\tdistinctFieldValues: [],\n\t\t\t\t\t\tfieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,\n\t\t\t\t\t\tfieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> ')),\n\t\t\t\t\t\tlookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),\n\t\t\t\t\t\tlookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),\n\t\t\t\t\t\tlookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),\n\t\t\t\t\t\tlookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),\n\t\t\t\t\t\ttext: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\tisLeaf: false,\n\t\t\t\t\t\tisActive: false,\n\t\t\t\t\t\tisSelected: false,\n\t\t\t\t\t\tdepth: 0,\n\t\t\t\t\t\tleafValueType: '',\n\t\t\t\t\t\tleafFormatType: '',\n\t\t\t\t\t\tchildren: []\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tres = res.sort((a, b) => a.fieldName.localeCompare(b.fieldName));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet child = null;\n\n\t\t\t\ttreeItemSplit.forEach((layer, index) => {\n\t\t\t\t\tif (!child) {\n\t\t\t\t\t\tchild = res.find(a => a.fieldName === layer);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (child.children.find(a => a.fieldName === layer)) {\n\t\t\t\t\t\t\tchild = child.children.find(a => a.fieldName === layer);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif (schemaTree[key].rbType === 'String' || schemaTree[key].rbType === 'Number' || schemaTree[key].rbType === 'Boolean' || schemaTree[key].rbType === 'Date') {\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tchild.children.push({\n\t\t\t\t\t\t\t\t\tcollection_name: current_root,\n\t\t\t\t\t\t\t\t\tcolumnName: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\t\t\t\tfieldName: layer,\n\t\t\t\t\t\t\t\t\tfieldType: schemaTree[key].rbType,\n\t\t\t\t\t\t\t\t\tfieldTypeName: schemaTree[key].rbType === 'String' ? 'Text' : (schemaTree[key].rbType === 'Boolean' ? 'T/F' : schemaTree[key].rbType),\n\t\t\t\t\t\t\t\t\tdistinctFieldValues: [],\n\t\t\t\t\t\t\t\t\tfieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,\n\t\t\t\t\t\t\t\t\tfieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> ')),\n\t\t\t\t\t\t\t\t\tlookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),\n\t\t\t\t\t\t\t\t\tlookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),\n\t\t\t\t\t\t\t\t\tlookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),\n\t\t\t\t\t\t\t\t\tlookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),\n\t\t\t\t\t\t\t\t\ttext: toTitleCase(layer.replace(/\\_/g, ' ')),\n\t\t\t\t\t\t\t\t\tvalue: layer,\n\t\t\t\t\t\t\t\t\tisLeaf: true,\n\t\t\t\t\t\t\t\t\tisActive: false,\n\t\t\t\t\t\t\t\t\tisSelected: false,\n\t\t\t\t\t\t\t\t\tdepth: index,\n\t\t\t\t\t\t\t\t\tleafValueType: '',\n\t\t\t\t\t\t\t\t\tleafValueTypes: getLeafValueTypes(schemaTree[key], key),\n\t\t\t\t\t\t\t\t\tleafFormatType: '',\n\t\t\t\t\t\t\t\t\tleafFormatTypes: getLeafFormatTypes(schemaTree[key], key)\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tchild.children.push({\n\t\t\t\t\t\t\t\t\tcollection_name: current_root,\n\t\t\t\t\t\t\t\t\tcolumnName: toTitleCase(key.replace(/\\_/g, ' ')),\n\t\t\t\t\t\t\t\t\tfieldName: layer,\n\t\t\t\t\t\t\t\t\tfieldType: schemaTree[key].lookup_collection ? 'Lookup' : schemaTree[key].rbType,\n\t\t\t\t\t\t\t\t\tfieldTypeName: schemaTree[key].lookup_collection ? 'Lookup' : (schemaTree[key].rbType === 'Array' ? 'List' : 'Group'),\n\t\t\t\t\t\t\t\t\tdistinctFieldValues: [],\n\t\t\t\t\t\t\t\t\tfieldPath: lookup ? lookup.lookup_as + '.$.' + key : key,\n\t\t\t\t\t\t\t\t\tfieldPathName: lookup ? (toTitleCase(lookup.lookup_as.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) + ' (List) -> ' + (toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> '))) : toTitleCase(key.replace(/\\.\\$\\./g, ' (List) -> ').replace(/\\./g, ' (Group) -> ')),\n\t\t\t\t\t\t\t\t\tlookup_collection: lookup ? lookup.lookup_collection : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_collection : ''),\n\t\t\t\t\t\t\t\t\tlookup_local_key: lookup ? lookup.lookup_local_key : (schemaTree[key].lookup_collection ? schemaTree[key].local_key : ''),\n\t\t\t\t\t\t\t\t\tlookup_foreign_key: lookup ? lookup.lookup_foreign_key : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_key : ''),\n\t\t\t\t\t\t\t\t\tlookup_as: lookup ? lookup.lookup_as : (schemaTree[key].lookup_collection ? schemaTree[key].lookup_as : ''),\n\t\t\t\t\t\t\t\t\ttext: toTitleCase(layer.replace(/\\_/g, ' ')),\n\t\t\t\t\t\t\t\t\tvalue: layer,\n\t\t\t\t\t\t\t\t\tisLeaf: false,\n\t\t\t\t\t\t\t\t\tisActive: false,\n\t\t\t\t\t\t\t\t\tisSelected: false,\n\t\t\t\t\t\t\t\t\tdepth: index,\n\t\t\t\t\t\t\t\t\tleafValueType: '',\n\t\t\t\t\t\t\t\t\tleafFormatType: '',\n\t\t\t\t\t\t\t\t\tchildren: []\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tchild.children = child.children.sort((a, b) => a.fieldName.localeCompare(b.fieldName));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n\treturn res;\n}\n\n// eslint-disable-next-line no-unused-vars\nexport function getLeafValueTypes(schemaTree, fieldPath) {\n\tlet leafTypes = [];\n\n\tif (schemaTree.rbType === 'String') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Value',\n\t\t\t\tvalue: 'Value'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Unique',\n\t\t\t\tvalue: 'Unique'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Count',\n\t\t\t\tvalue: 'Count'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'First',\n\t\t\t\tvalue: 'First'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Last',\n\t\t\t\tvalue: 'Last'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Number') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Value',\n\t\t\t\tvalue: 'Value'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Unique',\n\t\t\t\tvalue: 'Unique'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Average',\n\t\t\t\tvalue: 'Average'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Count',\n\t\t\t\tvalue: 'Count'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Sum',\n\t\t\t\tvalue: 'Sum'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Minimum',\n\t\t\t\tvalue: 'Minimum'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Maximum',\n\t\t\t\tvalue: 'Maximum'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'First',\n\t\t\t\tvalue: 'First'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Last',\n\t\t\t\tvalue: 'Last'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Boolean') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Value',\n\t\t\t\tvalue: 'Value'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Unique',\n\t\t\t\tvalue: 'Unique'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Count',\n\t\t\t\tvalue: 'Count'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'First',\n\t\t\t\tvalue: 'First'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Last',\n\t\t\t\tvalue: 'Last'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Date') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Value',\n\t\t\t\tvalue: 'Value'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Unique',\n\t\t\t\tvalue: 'Unique'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Count',\n\t\t\t\tvalue: 'Count'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Minimum',\n\t\t\t\tvalue: 'Minimum'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Maximum',\n\t\t\t\tvalue: 'Maximum'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'First',\n\t\t\t\tvalue: 'First'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'Last',\n\t\t\t\tvalue: 'Last'\n\t\t\t}\n\t\t];\n\t}\n\treturn leafTypes;\n}\n\n// eslint-disable-next-line no-unused-vars\nexport function getLeafFormatTypes(schemaTree, fieldPath) {\n\tlet leafTypes = [];\n\n\tif (schemaTree.rbType === 'String') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Text',\n\t\t\t\tvalue: 'String'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Number',\n\t\t\t\tvalue: 'Number'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Number') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Number',\n\t\t\t\tvalue: 'Number'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Currency',\n\t\t\t\tvalue: 'Currency'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Text',\n\t\t\t\tvalue: 'String'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Boolean') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Number',\n\t\t\t\tvalue: 'Number'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Boolean (True/False)',\n\t\t\t\tvalue: 'Boolean'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Text (Yes/No)',\n\t\t\t\tvalue: 'String'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Number (1/0)',\n\t\t\t\tvalue: 'Boolean_Number'\n\t\t\t}\n\t\t];\n\t}\n\telse if (schemaTree.rbType === 'Date') {\n\t\tleafTypes = [\n\t\t\t{\n\t\t\t\ttext: 'As Number',\n\t\t\t\tvalue: 'Number'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Date (Short Format)',\n\t\t\t\tvalue: 'Date'\n\t\t\t}, \n\t\t\t{\n\t\t\t\ttext: 'As Time (Short Format)',\n\t\t\t\tvalue: 'Time'\n\t\t\t}, \n\t\t\t{\n\t\t\t\ttext: 'As Date/Time (Short Format)',\n\t\t\t\tvalue: 'DateTime'\n\t\t\t}, \n\t\t\t{\n\t\t\t\ttext: 'As Date (Long Format)',\n\t\t\t\tvalue: 'Date_long'\n\t\t\t},\n\t\t\t{\n\t\t\t\ttext: 'As Date/Time (Long Format)',\n\t\t\t\tvalue: 'DateTime_long'\n\t\t\t}, \n\t\t\t{\n\t\t\t\ttext: 'As Timestamp (MS since 1970)',\n\t\t\t\tvalue: 'Timestamp'\n\t\t\t}\n\t\t];\n\t}\n\treturn leafTypes;\n}\n\n\n\n\n\nexport async function mongoCommand(commandstr: string, collection: string, field?: any) {\n\tlet tmpObj;\n\ttry {\n\t\t// Count the number of non-empty fields in a given collection:\n\t\tif (commandstr === 'count') {\n\t\t\tlet obj = {\n\t\t\t\tcount: collection,\n\t\t\t\tquery: {}\n\t\t\t};\n\t\t\tobj.query[field] = {$ne: null};\n\t\t\ttmpObj = await ResolveIOServer.getMainDB().command(obj);\n\t\t}\n\t\t// Get all distinct values in a given field.\n\t\telse if (commandstr === 'distinct') {\n\t\t\tlet obj = {\n\t\t\t\tdistinct: collection,\n\t\t\t\tquery: {},\n\t\t\t\tkey: field,\n\t\t\t};\n\t\t\ttmpObj = await ResolveIOServer.getMainDB().command(obj);\n\t\t}\n\t\telse if (commandstr === 'listIndexes') {\n\t\t\t// tmpObj = await this.mainDb.db[collection].getIndexes();\n\t\t\t// let obj = { 'listIndexes': collection };\n\t\t\t// tmpObj = await this.mainDb.db.getIndexes(obj);\n\t\t}\n\t} catch {\n\t\t// console.log('----------- mongoCommand err: ', err);\n\t\treturn -1;\n\t}\n\tif (tmpObj) {\n\t\treturn tmpObj.values;\n\t}\n}"]}
|