@resolveio/server-lib 9.2.17 → 9.2.19
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 +1 -55
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +1 -40
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +1 -40
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +1 -43
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +1 -71
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +1 -74
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +1 -55
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +1 -50
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +1 -62
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +1 -44
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +1 -53
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +1 -57
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +1 -72
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +1 -58
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +1 -51
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +1 -55
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +1 -57
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +1 -66
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +1 -74
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +1 -68
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +1 -62
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +1 -40
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +1 -93
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +1 -76
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +1 -138
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +1 -79
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +1 -46
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +1 -248
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +1 -161
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +1 -72
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +1 -62
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +1 -697
- package/http/auth.js.map +1 -1
- package/http/health.js +1 -10
- package/http/health.js.map +1 -1
- package/http/home.js +1 -64
- package/http/home.js.map +1 -1
- package/index.js +1 -123
- package/index.js.map +1 -1
- package/managers/cron.manager.js +1 -205
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +1 -599
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +1 -1682
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +1 -334
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +1 -867
- package/managers/subscription.manager.js.map +1 -1
- package/managers/subscription.performance.js +1 -100
- package/managers/subscription.performance.js.map +1 -1
- package/methods/accounts.js +1 -224
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +1 -449
- package/methods/aws.js.map +1 -1
- package/methods/cloudconvert.js +1 -214
- package/methods/cloudconvert.js.map +1 -1
- package/methods/collections.js +1 -526
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +1 -121
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +1 -1284
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +1 -8
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +1 -370
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +1 -384
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +1 -685
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +1 -826
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +1 -263
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +1 -3
- package/models/app-status.model.js.map +1 -1
- package/models/app-version.model.js +1 -3
- package/models/app-version.model.js.map +1 -1
- package/models/billing-logged-in-users.model.js +1 -3
- package/models/billing-logged-in-users.model.js.map +1 -1
- package/models/collection-document.model.js +1 -3
- package/models/collection-document.model.js.map +1 -1
- package/models/counter.model.js +1 -3
- package/models/counter.model.js.map +1 -1
- package/models/cron-job-history.model.js +1 -3
- package/models/cron-job-history.model.js.map +1 -1
- package/models/cron-job.model.js +1 -3
- package/models/cron-job.model.js.map +1 -1
- package/models/dialog.model.js +1 -3
- package/models/dialog.model.js.map +1 -1
- package/models/email-history.model.js +1 -3
- package/models/email-history.model.js.map +1 -1
- package/models/email-verified.model.js +1 -3
- package/models/email-verified.model.js.map +1 -1
- package/models/file.model.js +1 -3
- package/models/file.model.js.map +1 -1
- package/models/flag.model.js +1 -3
- package/models/flag.model.js.map +1 -1
- package/models/log-method-latency.model.js +1 -3
- package/models/log-method-latency.model.js.map +1 -1
- package/models/log-subscription.model.js +1 -3
- package/models/log-subscription.model.js.map +1 -1
- package/models/log.model.js +1 -3
- package/models/log.model.js.map +1 -1
- package/models/logged-in-users.model.js +1 -3
- package/models/logged-in-users.model.js.map +1 -1
- package/models/method-call.model.js +1 -3
- package/models/method-call.model.js.map +1 -1
- package/models/method-response.model.js +1 -3
- package/models/method-response.model.js.map +1 -1
- package/models/method.model.js +1 -3
- package/models/method.model.js.map +1 -1
- package/models/monitor-cpu.model.js +1 -3
- package/models/monitor-cpu.model.js.map +1 -1
- package/models/monitor-https-inbound.model.js +1 -3
- package/models/monitor-https-inbound.model.js.map +1 -1
- package/models/monitor-https-outbound.model.js +1 -3
- package/models/monitor-https-outbound.model.js.map +1 -1
- package/models/monitor-memory.model.js +1 -3
- package/models/monitor-memory.model.js.map +1 -1
- package/models/monitor-mongo.model.js +1 -3
- package/models/monitor-mongo.model.js.map +1 -1
- package/models/notification.model.js +1 -3
- package/models/notification.model.js.map +1 -1
- package/models/pagination.model.js +1 -23
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +1 -3
- package/models/permission.model.js.map +1 -1
- package/models/report-builder-dashboard-builder.model.js +1 -3
- package/models/report-builder-dashboard-builder.model.js.map +1 -1
- package/models/report-builder-library.model.js +1 -3
- package/models/report-builder-library.model.js.map +1 -1
- package/models/report-builder-report.model.js +1 -3
- package/models/report-builder-report.model.js.map +1 -1
- package/models/report-builder.model.js +1 -3
- package/models/report-builder.model.js.map +1 -1
- package/models/select-data-label.model.js +1 -3
- package/models/select-data-label.model.js.map +1 -1
- package/models/server-response.model.js +1 -3
- package/models/server-response.model.js.map +1 -1
- package/models/subscription.model.js +1 -3
- package/models/subscription.model.js.map +1 -1
- package/models/support-ticket.model.js +1 -3
- package/models/support-ticket.model.js.map +1 -1
- package/models/user-group.model.js +1 -3
- package/models/user-group.model.js.map +1 -1
- package/models/user-guide.model.js +1 -3
- package/models/user-guide.model.js.map +1 -1
- package/models/user.model.js +1 -3
- package/models/user.model.js.map +1 -1
- package/package.json +2 -2
- package/public_api.js +1 -78
- package/public_api.js.map +1 -1
- package/publications/app-status.js +1 -16
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +1 -16
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +1 -32
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +1 -36
- package/publications/files.js.map +1 -1
- package/publications/flags.js +1 -22
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +1 -90
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +1 -16
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +1 -16
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +1 -16
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +1 -42
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +1 -89
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +1 -50
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +1 -16
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +1 -16
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +1 -16
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +1 -682
- package/server-app.js.map +1 -1
- package/util/common.js +1 -498
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +1 -452
- package/util/schema-report-builder.js.map +1 -1
|
@@ -1,453 +1,2 @@
|
|
|
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 (_) 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 index_1 = require("../index");
|
|
41
|
-
var common_1 = require("./common");
|
|
42
|
-
function getReportLookupSchemas(collection_root) {
|
|
43
|
-
var lookupTrees = [];
|
|
44
|
-
lookupTrees.push({ collection_name: collection_root, tree: index_1.ResolveIOServer.getMongoManager().collection(collection_root)['rbSchema'], is_root: true });
|
|
45
|
-
var schemaObj = index_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 = index_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' && !a.startsWith('id_') && a !== 'id' && !a.match(/.*\.id_/); }).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: 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 ? (common_1.toTitleCase(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + (common_1.toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : 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: 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: 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 ? (common_1.toTitleCase(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + (common_1.toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : 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: 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.filter(function (a) { return a.fieldName === layer; })[0];
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
if (child_1.children.filter(function (a) { return a.fieldName === layer; })[0]) {
|
|
128
|
-
child_1 = child_1.children.filter(function (a) { return a.fieldName === layer; })[0];
|
|
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: 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 ? (common_1.toTitleCase(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + (common_1.toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : 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: 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: 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 ? (common_1.toTitleCase(lookup.lookup_as.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) + ' (List) -> ' + (common_1.toTitleCase(key.replace(/\.\$\./g, ' (List) -> ').replace(/\./g, ' (Group) -> '))) : 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: 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
|
-
function getLeafValueTypes(schemaTree, fieldPath) {
|
|
193
|
-
var leafTypes = [];
|
|
194
|
-
if (schemaTree.rbType === 'String') {
|
|
195
|
-
leafTypes = [
|
|
196
|
-
{
|
|
197
|
-
text: 'As Value',
|
|
198
|
-
value: 'Value'
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
text: 'Unique',
|
|
202
|
-
value: 'Unique'
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
text: 'As Count',
|
|
206
|
-
value: 'Count'
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
text: 'First',
|
|
210
|
-
value: 'First'
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
text: 'Last',
|
|
214
|
-
value: 'Last'
|
|
215
|
-
}
|
|
216
|
-
];
|
|
217
|
-
}
|
|
218
|
-
else if (schemaTree.rbType === 'Number') {
|
|
219
|
-
leafTypes = [
|
|
220
|
-
{
|
|
221
|
-
text: 'As Value',
|
|
222
|
-
value: 'Value'
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
text: 'Unique',
|
|
226
|
-
value: 'Unique'
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
text: 'As Average',
|
|
230
|
-
value: 'Average'
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
text: 'As Count',
|
|
234
|
-
value: 'Count'
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
text: 'As Sum',
|
|
238
|
-
value: 'Sum'
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
text: 'Minimum',
|
|
242
|
-
value: 'Minimum'
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
text: 'Maximum',
|
|
246
|
-
value: 'Maximum'
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
text: 'First',
|
|
250
|
-
value: 'First'
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
text: 'Last',
|
|
254
|
-
value: 'Last'
|
|
255
|
-
}
|
|
256
|
-
];
|
|
257
|
-
}
|
|
258
|
-
else if (schemaTree.rbType === 'Boolean') {
|
|
259
|
-
leafTypes = [
|
|
260
|
-
{
|
|
261
|
-
text: 'As Value',
|
|
262
|
-
value: 'Value'
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
text: 'Unique',
|
|
266
|
-
value: 'Unique'
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
text: 'As Count',
|
|
270
|
-
value: 'Count'
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
text: 'First',
|
|
274
|
-
value: 'First'
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
text: 'Last',
|
|
278
|
-
value: 'Last'
|
|
279
|
-
}
|
|
280
|
-
];
|
|
281
|
-
}
|
|
282
|
-
else if (schemaTree.rbType === 'Date') {
|
|
283
|
-
leafTypes = [
|
|
284
|
-
{
|
|
285
|
-
text: 'As Value',
|
|
286
|
-
value: 'Value'
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
text: 'Unique',
|
|
290
|
-
value: 'Unique'
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
text: 'As Count',
|
|
294
|
-
value: 'Count'
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
text: 'Minimum',
|
|
298
|
-
value: 'Minimum'
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
text: 'Maximum',
|
|
302
|
-
value: 'Maximum'
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
text: 'First',
|
|
306
|
-
value: 'First'
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
text: 'Last',
|
|
310
|
-
value: 'Last'
|
|
311
|
-
}
|
|
312
|
-
];
|
|
313
|
-
}
|
|
314
|
-
return leafTypes;
|
|
315
|
-
}
|
|
316
|
-
exports.getLeafValueTypes = getLeafValueTypes;
|
|
317
|
-
function getLeafFormatTypes(schemaTree, fieldPath) {
|
|
318
|
-
var leafTypes = [];
|
|
319
|
-
if (schemaTree.rbType === 'String') {
|
|
320
|
-
leafTypes = [
|
|
321
|
-
{
|
|
322
|
-
text: 'As Text',
|
|
323
|
-
value: 'String'
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
text: 'As Number',
|
|
327
|
-
value: 'Number'
|
|
328
|
-
}
|
|
329
|
-
];
|
|
330
|
-
}
|
|
331
|
-
else if (schemaTree.rbType === 'Number') {
|
|
332
|
-
leafTypes = [
|
|
333
|
-
{
|
|
334
|
-
text: 'As Number',
|
|
335
|
-
value: 'Number'
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
text: 'As Currency',
|
|
339
|
-
value: 'Currency'
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
text: 'As Text',
|
|
343
|
-
value: 'String'
|
|
344
|
-
}
|
|
345
|
-
];
|
|
346
|
-
}
|
|
347
|
-
else if (schemaTree.rbType === 'Boolean') {
|
|
348
|
-
leafTypes = [
|
|
349
|
-
{
|
|
350
|
-
text: 'As Number',
|
|
351
|
-
value: 'Number'
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
text: 'As Boolean (True/False)',
|
|
355
|
-
value: 'Boolean'
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
text: 'As Text (Yes/No)',
|
|
359
|
-
value: 'String'
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
text: 'As Number (1/0)',
|
|
363
|
-
value: 'Boolean_Number'
|
|
364
|
-
}
|
|
365
|
-
];
|
|
366
|
-
}
|
|
367
|
-
else if (schemaTree.rbType === 'Date') {
|
|
368
|
-
leafTypes = [
|
|
369
|
-
{
|
|
370
|
-
text: 'As Number',
|
|
371
|
-
value: 'Number'
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
text: 'As Date (Short Format)',
|
|
375
|
-
value: 'Date'
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
text: 'As Time (Short Format)',
|
|
379
|
-
value: 'Time'
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
text: 'As Date/Time (Short Format)',
|
|
383
|
-
value: 'DateTime'
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
text: 'As Date (Long Format)',
|
|
387
|
-
value: 'Date_long'
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
text: 'As Date/Time (Long Format)',
|
|
391
|
-
value: 'DateTime_long'
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
text: 'As Timestamp (MS since 1970)',
|
|
395
|
-
value: 'Timestamp'
|
|
396
|
-
}
|
|
397
|
-
];
|
|
398
|
-
}
|
|
399
|
-
return leafTypes;
|
|
400
|
-
}
|
|
401
|
-
exports.getLeafFormatTypes = getLeafFormatTypes;
|
|
402
|
-
function mongoCommand(commandstr, collection, field) {
|
|
403
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
404
|
-
var tmpObj, obj, obj, err_1;
|
|
405
|
-
return __generator(this, function (_a) {
|
|
406
|
-
switch (_a.label) {
|
|
407
|
-
case 0:
|
|
408
|
-
_a.trys.push([0, 6, , 7]);
|
|
409
|
-
if (!(commandstr === 'count')) return [3 /*break*/, 2];
|
|
410
|
-
obj = {
|
|
411
|
-
count: collection,
|
|
412
|
-
query: {}
|
|
413
|
-
};
|
|
414
|
-
obj.query[field] = { $ne: null };
|
|
415
|
-
return [4 /*yield*/, index_1.ResolveIOServer.getMainDB().command(obj)];
|
|
416
|
-
case 1:
|
|
417
|
-
tmpObj = _a.sent();
|
|
418
|
-
return [3 /*break*/, 5];
|
|
419
|
-
case 2:
|
|
420
|
-
if (!(commandstr === 'distinct')) return [3 /*break*/, 4];
|
|
421
|
-
obj = {
|
|
422
|
-
distinct: collection,
|
|
423
|
-
query: {},
|
|
424
|
-
key: field,
|
|
425
|
-
};
|
|
426
|
-
return [4 /*yield*/, index_1.ResolveIOServer.getMainDB().command(obj)];
|
|
427
|
-
case 3:
|
|
428
|
-
tmpObj = _a.sent();
|
|
429
|
-
return [3 /*break*/, 5];
|
|
430
|
-
case 4:
|
|
431
|
-
if (commandstr === 'listIndexes') {
|
|
432
|
-
// tmpObj = await this.mainDb.db[collection].getIndexes();
|
|
433
|
-
// let obj = { 'listIndexes': collection };
|
|
434
|
-
// tmpObj = await this.mainDb.db.getIndexes(obj);
|
|
435
|
-
}
|
|
436
|
-
_a.label = 5;
|
|
437
|
-
case 5: return [3 /*break*/, 7];
|
|
438
|
-
case 6:
|
|
439
|
-
err_1 = _a.sent();
|
|
440
|
-
// console.log('----------- mongoCommand err: ', err);
|
|
441
|
-
return [2 /*return*/, -1];
|
|
442
|
-
case 7:
|
|
443
|
-
if (tmpObj) {
|
|
444
|
-
return [2 /*return*/, tmpObj.values];
|
|
445
|
-
}
|
|
446
|
-
return [2 /*return*/];
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
exports.mongoCommand = mongoCommand;
|
|
452
|
-
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,o,t,l){return new(t||(t=Promise))((function(a,r){function fulfilled(e){try{step(l.next(e))}catch(e){r(e)}}function rejected(e){try{step(l.throw(e))}catch(e){r(e)}}function step(e){e.done?a(e.value):function adopt(e){return e instanceof t?e:new t((function(o){o(e)}))}(e.value).then(fulfilled,rejected)}step((l=l.apply(e,o||[])).next())}))},__generator=this&&this.__generator||function(e,o){var t,l,a,r,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return r={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function verb(r){return function(n){return function step(r){if(t)throw new TypeError("Generator is already executing.");for(;u;)try{if(t=1,l&&(a=2&r[0]?l.return:r[0]?l.throw||((a=l.return)&&a.call(l),0):l.next)&&!(a=a.call(l,r[1])).done)return a;switch(l=0,a&&(r=[2&r[0],a.value]),r[0]){case 0:case 1:a=r;break;case 4:return u.label++,{value:r[1],done:!1};case 5:u.label++,l=r[1],r=[0];continue;case 7:r=u.ops.pop(),u.trys.pop();continue;default:if(!(a=u.trys,(a=a.length>0&&a[a.length-1])||6!==r[0]&&2!==r[0])){u=0;continue}if(3===r[0]&&(!a||r[1]>a[0]&&r[1]<a[3])){u.label=r[1];break}if(6===r[0]&&u.label<a[1]){u.label=a[1],a=r;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(r);break}a[2]&&u.ops.pop(),u.trys.pop();continue}r=o.call(e,u)}catch(e){r=[6,e],l=0}finally{t=a=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,n])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.mongoCommand=exports.getLeafFormatTypes=exports.getLeafValueTypes=exports.buildTree=exports.getReportLookupSchemas=void 0;var index_1=require("../index"),common_1=require("./common");function getReportLookupSchemas(e){var o=[];o.push({collection_name:e,tree:index_1.ResolveIOServer.getMongoManager().collection(e).rbSchema,is_root:!0});var t=index_1.ResolveIOServer.getMongoManager().collection(e).rbSchema;return Object.keys(t).forEach((function(e){if(t[e].lookup_collection){var l=t[e].lookup_collection,a=index_1.ResolveIOServer.getMongoManager().collection(l);o.filter((function(e){return e.collection_name===l})).length||o.push({collection_name:l,tree:a.rbSchema,is_root:!1})}})),o}function buildTree(e,o,t){var l=[];return Object.keys(o).filter((function(e){return"_id"!==e&&"id"!==e&&"__v"!==e&&!e.startsWith("id_")&&"id"!==e&&!e.match(/.*\.id_/)})).forEach((function(a){if(!t||t&&!o[a].lookup_collection){var r=a.split(".");if(1===r.length)"String"===o[a].rbType||"Number"===o[a].rbType||"Boolean"===o[a].rbType||"Date"===o[a].rbType?l.push({collection_name:e,columnName:common_1.toTitleCase(a.replace(/\_/g," ")),fieldName:a,fieldType:o[a].rbType,fieldTypeName:"String"===o[a].rbType?"Text":"Boolean"===o[a].rbType?"T/F":o[a].rbType,distinctFieldValues:[],fieldPath:t?t.lookup_as+".$."+a:a,fieldPathName:t?common_1.toTitleCase(t.lookup_as.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> "))+" (List) -> "+common_1.toTitleCase(a.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> ")):common_1.toTitleCase(a.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> ")),lookup_collection:t?t.lookup_collection:o[a].lookup_collection?o[a].lookup_collection:"",lookup_local_key:t?t.lookup_local_key:o[a].lookup_collection?o[a].local_key:"",lookup_foreign_key:t?t.lookup_foreign_key:o[a].lookup_collection?o[a].lookup_key:"",lookup_as:t?t.lookup_as:o[a].lookup_collection?o[a].lookup_as:"",text:common_1.toTitleCase(a.replace(/\_/g," ")),value:a,isLeaf:!0,isActive:!1,isSelected:!1,depth:0,leafValueType:"",leafValueTypes:getLeafValueTypes(o[a],a),leafFormatType:"",leafFormatTypes:getLeafFormatTypes(o[a],a)}):l.push({collection_name:e,columnName:common_1.toTitleCase(a.replace(/\_/g," ")),fieldName:a,fieldType:o[a].lookup_collection?"Lookup":o[a].rbType,fieldTypeName:o[a].lookup_collection?"Lookup":"Array"===o[a].rbType?"List":"Group",distinctFieldValues:[],fieldPath:t?t.lookup_as+".$."+a:a,fieldPathName:t?common_1.toTitleCase(t.lookup_as.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> "))+" (List) -> "+common_1.toTitleCase(a.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> ")):common_1.toTitleCase(a.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> ")),lookup_collection:t?t.lookup_collection:o[a].lookup_collection?o[a].lookup_collection:"",lookup_local_key:t?t.lookup_local_key:o[a].lookup_collection?o[a].local_key:"",lookup_foreign_key:t?t.lookup_foreign_key:o[a].lookup_collection?o[a].lookup_key:"",lookup_as:t?t.lookup_as:o[a].lookup_collection?o[a].lookup_as:"",text:common_1.toTitleCase(a.replace(/\_/g," ")),value:a,isLeaf:!1,isActive:!1,isSelected:!1,depth:0,leafValueType:"",leafFormatType:"",children:[]}),l=l.sort((function(e,o){return e.fieldName.localeCompare(o.fieldName)}));else{var u=null;r.forEach((function(r,n){u?u.children.filter((function(e){return e.fieldName===r}))[0]?u=u.children.filter((function(e){return e.fieldName===r}))[0]:("String"===o[a].rbType||"Number"===o[a].rbType||"Boolean"===o[a].rbType||"Date"===o[a].rbType?u.children.push({collection_name:e,columnName:common_1.toTitleCase(a.replace(/\_/g," ")),fieldName:r,fieldType:o[a].rbType,fieldTypeName:"String"===o[a].rbType?"Text":"Boolean"===o[a].rbType?"T/F":o[a].rbType,distinctFieldValues:[],fieldPath:t?t.lookup_as+".$."+a:a,fieldPathName:t?common_1.toTitleCase(t.lookup_as.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> "))+" (List) -> "+common_1.toTitleCase(a.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> ")):common_1.toTitleCase(a.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> ")),lookup_collection:t?t.lookup_collection:o[a].lookup_collection?o[a].lookup_collection:"",lookup_local_key:t?t.lookup_local_key:o[a].lookup_collection?o[a].local_key:"",lookup_foreign_key:t?t.lookup_foreign_key:o[a].lookup_collection?o[a].lookup_key:"",lookup_as:t?t.lookup_as:o[a].lookup_collection?o[a].lookup_as:"",text:common_1.toTitleCase(r.replace(/\_/g," ")),value:r,isLeaf:!0,isActive:!1,isSelected:!1,depth:n,leafValueType:"",leafValueTypes:getLeafValueTypes(o[a],a),leafFormatType:"",leafFormatTypes:getLeafFormatTypes(o[a],a)}):u.children.push({collection_name:e,columnName:common_1.toTitleCase(a.replace(/\_/g," ")),fieldName:r,fieldType:o[a].lookup_collection?"Lookup":o[a].rbType,fieldTypeName:o[a].lookup_collection?"Lookup":"Array"===o[a].rbType?"List":"Group",distinctFieldValues:[],fieldPath:t?t.lookup_as+".$."+a:a,fieldPathName:t?common_1.toTitleCase(t.lookup_as.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> "))+" (List) -> "+common_1.toTitleCase(a.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> ")):common_1.toTitleCase(a.replace(/\.\$\./g," (List) -> ").replace(/\./g," (Group) -> ")),lookup_collection:t?t.lookup_collection:o[a].lookup_collection?o[a].lookup_collection:"",lookup_local_key:t?t.lookup_local_key:o[a].lookup_collection?o[a].local_key:"",lookup_foreign_key:t?t.lookup_foreign_key:o[a].lookup_collection?o[a].lookup_key:"",lookup_as:t?t.lookup_as:o[a].lookup_collection?o[a].lookup_as:"",text:common_1.toTitleCase(r.replace(/\_/g," ")),value:r,isLeaf:!1,isActive:!1,isSelected:!1,depth:n,leafValueType:"",leafFormatType:"",children:[]}),u.children=u.children.sort((function(e,o){return e.fieldName.localeCompare(o.fieldName)}))):u=l.filter((function(e){return e.fieldName===r}))[0]}))}}})),l}function getLeafValueTypes(e,o){var t=[];return"String"===e.rbType?t=[{text:"As Value",value:"Value"},{text:"Unique",value:"Unique"},{text:"As Count",value:"Count"},{text:"First",value:"First"},{text:"Last",value:"Last"}]:"Number"===e.rbType?t=[{text:"As Value",value:"Value"},{text:"Unique",value:"Unique"},{text:"As Average",value:"Average"},{text:"As Count",value:"Count"},{text:"As Sum",value:"Sum"},{text:"Minimum",value:"Minimum"},{text:"Maximum",value:"Maximum"},{text:"First",value:"First"},{text:"Last",value:"Last"}]:"Boolean"===e.rbType?t=[{text:"As Value",value:"Value"},{text:"Unique",value:"Unique"},{text:"As Count",value:"Count"},{text:"First",value:"First"},{text:"Last",value:"Last"}]:"Date"===e.rbType&&(t=[{text:"As Value",value:"Value"},{text:"Unique",value:"Unique"},{text:"As Count",value:"Count"},{text:"Minimum",value:"Minimum"},{text:"Maximum",value:"Maximum"},{text:"First",value:"First"},{text:"Last",value:"Last"}]),t}function getLeafFormatTypes(e,o){var t=[];return"String"===e.rbType?t=[{text:"As Text",value:"String"},{text:"As Number",value:"Number"}]:"Number"===e.rbType?t=[{text:"As Number",value:"Number"},{text:"As Currency",value:"Currency"},{text:"As Text",value:"String"}]:"Boolean"===e.rbType?t=[{text:"As Number",value:"Number"},{text:"As Boolean (True/False)",value:"Boolean"},{text:"As Text (Yes/No)",value:"String"},{text:"As Number (1/0)",value:"Boolean_Number"}]:"Date"===e.rbType&&(t=[{text:"As Number",value:"Number"},{text:"As Date (Short Format)",value:"Date"},{text:"As Time (Short Format)",value:"Time"},{text:"As Date/Time (Short Format)",value:"DateTime"},{text:"As Date (Long Format)",value:"Date_long"},{text:"As Date/Time (Long Format)",value:"DateTime_long"},{text:"As Timestamp (MS since 1970)",value:"Timestamp"}]),t}function mongoCommand(e,o,t){return __awaiter(this,void 0,void 0,(function(){var l,a;return __generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,6,,7]),"count"!==e?[3,2]:((a={count:o,query:{}}).query[t]={$ne:null},[4,index_1.ResolveIOServer.getMainDB().command(a)]);case 1:return l=r.sent(),[3,5];case 2:return"distinct"!==e?[3,4]:(a={distinct:o,query:{},key:t},[4,index_1.ResolveIOServer.getMainDB().command(a)]);case 3:return l=r.sent(),[3,5];case 4:r.label=5;case 5:return[3,7];case 6:return r.sent(),[2,-1];case 7:return l?[2,l.values]:[2]}}))}))}exports.getReportLookupSchemas=getReportLookupSchemas,exports.buildTree=buildTree,exports.getLeafValueTypes=getLeafValueTypes,exports.getLeafFormatTypes=getLeafFormatTypes,exports.mongoCommand=mongoCommand;
|
|
453
2
|
//# sourceMappingURL=schema-report-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/schema-report-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kCAA2C;AAE3C,mCAAuC;AAEvC,SAAgB,sBAAsB,CAAC,eAAuB;IAC7D,IAAI,WAAW,GAAqB,EAAE,CAAC;IACvC,WAAW,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACvJ,IAAI,SAAS,GAAG,uBAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,UAAU,CAAC,CAAC;IAC1F,IAAI,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACvC,SAAS,CAAC,OAAO,CAAC,UAAA,KAAK;QACtB,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE;YACvC,IAAI,gBAAc,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC;YACxD,IAAI,eAAe,GAAG,uBAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,gBAAc,CAAC,CAAC;YAEnF,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,eAAe,KAAK,gBAAc,EAApC,CAAoC,CAAC,CAAC,MAAM,EAAE;gBAC1E,WAAW,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,gBAAc,EAAE,IAAI,EAAE,eAAe,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;aACzG;SACD;IACF,CAAC,CAAC,CAA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I,EAAE,4BAA4B;gBAClC,KAAK,EAAE,eAAe;aACtB;YACD;gBACC,IAAI,EAAE,8BAA8B;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,uBAAe,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,uBAAe,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 { ResolveIOServer } from '../index';\nimport { CollectionTree } from '../models/report-builder.model';\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' && !a.startsWith('id_') && a !== 'id' && !a.match(/.*\\.id_/)).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.filter(a => a.fieldName === layer)[0];\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (child.children.filter(a => a.fieldName === layer)[0]) {\n\t\t\t\t\t\t\tchild = child.children.filter(a => a.fieldName === layer)[0];\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\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\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 (err) {\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}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/util/schema-report-builder.ts"],"names":["index_1","require","common_1","getReportLookupSchemas","collection_root","lookupTrees","push","collection_name","tree","ResolveIOServer","getMongoManager","collection","is_root","schemaObj","Object","keys","forEach","field","lookup_collection","collectionName_1","collectionModel","filter","a","length","buildTree","current_root","schemaTree","lookup","res","startsWith","match","key","treeItemSplit","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","child_1","layer","index","leafTypes","mongoCommand","commandstr","obj","count","query","$ne","getMainDB","command","tmpObj","_a","sent","distinct","values","exports"],"mappings":"mqDAAA,IAAAA,QAAAC,QAAA,YAEAC,SAAAD,QAAA,YAEA,SAAgBE,uBAAuBC,GACtC,IAAIC,EAAgC,GACpCA,EAAYC,KAAK,CAAEC,gBAAiBH,EAAiBI,KAAMR,QAAAS,gBAAgBC,kBAAkBC,WAAWP,GAA2B,SAAGQ,SAAS,IAC/I,IAAIC,EAAYb,QAAAS,gBAAgBC,kBAAkBC,WAAWP,GAA2B,SAaxF,OAZgBU,OAAOC,KAAKF,GAClBG,SAAQ,SAAAC,GACjB,GAAIJ,EAAUI,GAAOC,kBAAmB,CACvC,IAAIC,EAAiBN,EAAUI,GAAOC,kBAClCE,EAAkBpB,QAAAS,gBAAgBC,kBAAkBC,WAAWQ,GAE9Dd,EAAYgB,QAAO,SAA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CACTC,MAAO7D,EACP8D,MAAO,KAEJA,MAAMxD,GAAS,CAACyD,IAAK,MAChB,CAAA,EAAM1E,QAAAS,gBAAgBkE,YAAYC,QAAQL,mBAAnDM,EAASC,EAAAC,0BAGc,aAAfT,EAAA,CAAA,EAAA,IACJC,EAAM,CACTS,SAAUrE,EACV8D,MAAO,GACP1C,IAAKd,GAEG,CAAA,EAAMjB,QAAAS,gBAAgBkE,YAAYC,QAAQL,mBAAnDM,EAASC,EAAAC,wDASV,gBAAA,CAAA,GAAQ,UAET,OAAIF,EACH,CAAA,EAAOA,EAAOI,mBAtZhBC,QAAA/E,uBAAAA,uBAmBA+E,QAAA1D,UAAAA,UA4IA0D,QAAAzB,kBAAAA,kBA8HAyB,QAAAtB,mBAAAA,mBA0FAsB,QAAAb,aAAAA","file":"schema-report-builder.js","sourcesContent":["import { ResolveIOServer } from '../index';\nimport { CollectionTree } from '../models/report-builder.model';\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' && !a.startsWith('id_') && a !== 'id' && !a.match(/.*\\.id_/)).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.filter(a => a.fieldName === layer)[0];\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (child.children.filter(a => a.fieldName === layer)[0]) {\n\t\t\t\t\t\t\tchild = child.children.filter(a => a.fieldName === layer)[0];\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\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\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 (err) {\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}"]}
|