@resolveio/server-lib 20.10.8 → 20.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/collections/report-builder-report.collection.js +0 -44
- package/collections/report-builder-report.collection.js.map +1 -1
- package/http/auth.js +42 -8
- package/http/auth.js.map +1 -1
- package/http/home.js +21 -2
- package/http/home.js.map +1 -1
- package/managers/method.manager.d.ts +2 -1
- package/managers/method.manager.js +59 -50
- package/managers/method.manager.js.map +1 -1
- package/managers/subscription.manager.js +60 -41
- package/managers/subscription.manager.js.map +1 -1
- package/methods/accounts.js +29 -6
- package/methods/accounts.js.map +1 -1
- package/methods/cron-jobs.js +1 -1
- package/methods/cron-jobs.js.map +1 -1
- package/methods/logs.js +20 -10
- package/methods/logs.js.map +1 -1
- package/methods/report-builder.js +5 -257
- package/methods/report-builder.js.map +1 -1
- package/methods.ts +4 -4
- package/models/report-builder-report.model.d.ts +0 -2
- package/models/report-builder-report.model.js.map +1 -1
- package/models/report-builder.model.d.ts +0 -14
- package/models/report-builder.model.js.map +1 -1
- package/package.json +9 -8
- package/server-app.d.ts +1 -0
- package/server-app.js +54 -33
- package/server-app.js.map +1 -1
- package/util/error-reporter.d.ts +52 -0
- package/util/error-reporter.js +356 -0
- package/util/error-reporter.js.map +1 -0
- package/util/schema-report-builder.js +2 -9
- package/util/schema-report-builder.js.map +1 -1
|
@@ -0,0 +1,356 @@
|
|
|
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
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
+
if (!m) return o;
|
|
52
|
+
var i = m.call(o), r, ar = [], e;
|
|
53
|
+
try {
|
|
54
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) { e = { error: error }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e) throw e.error; }
|
|
62
|
+
}
|
|
63
|
+
return ar;
|
|
64
|
+
};
|
|
65
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
+
exports.ErrorReporter = void 0;
|
|
67
|
+
var crypto_1 = require("crypto");
|
|
68
|
+
var resolveio_server_app_1 = require("../resolveio-server-app");
|
|
69
|
+
var DEFAULT_ERROR_API_URL = 'https://backend.resolveio.com/api/errors/report';
|
|
70
|
+
var LOCAL_HOSTNAMES = new Set(['localhost', '127.0.0.1', '0.0.0.0', '::1']);
|
|
71
|
+
var ErrorReporter = /** @class */ (function () {
|
|
72
|
+
function ErrorReporter() {
|
|
73
|
+
}
|
|
74
|
+
ErrorReporter.report = function (options) {
|
|
75
|
+
var _a;
|
|
76
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
+
var logger, config, normalizedApiUrl, clientName, sourceApp, environment, message, severity, stack, context, metadata, attachments, fingerprint, idempotencyKey, reportedAt, normalizedReportedSourceEnv, payload, transport, response, err_1;
|
|
78
|
+
return __generator(this, function (_b) {
|
|
79
|
+
switch (_b.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
logger = options.logger || console;
|
|
82
|
+
config = getServerConfig();
|
|
83
|
+
normalizedApiUrl = options.apiUrl || DEFAULT_ERROR_API_URL;
|
|
84
|
+
clientName = options.clientName || (config === null || config === void 0 ? void 0 : config.CLIENT_NAME) || ((_a = resolveio_server_app_1.ResolveIOServer.getClientName) === null || _a === void 0 ? void 0 : _a.call(resolveio_server_app_1.ResolveIOServer)) || 'resolveio';
|
|
85
|
+
sourceApp = options.sourceApp || clientName || 'resolveio-server-lib';
|
|
86
|
+
environment = options.environment || process.env.RESOLVEIO_ENV || (config === null || config === void 0 ? void 0 : config.RESOLVEIO_ENV) || (config === null || config === void 0 ? void 0 : config.ENVIRONMENT) || (config === null || config === void 0 ? void 0 : config.ROOT_URL) || process.env.NODE_ENV || 'unknown';
|
|
87
|
+
message = options.message || options.subject || 'ResolveIO Error Detected';
|
|
88
|
+
severity = options.severity || 'error';
|
|
89
|
+
stack = normalizeStack(options.stack || options.error);
|
|
90
|
+
context = normalizeStructured(options.context, options.correlationId);
|
|
91
|
+
metadata = normalizeStructured(mergeMetadata(options.metadata, options.correlationId));
|
|
92
|
+
attachments = Array.isArray(options.attachments) ? normalizeAttachments(options.attachments) : undefined;
|
|
93
|
+
fingerprint = options.fingerprint || computeFingerprint(sourceApp, environment, message, stack);
|
|
94
|
+
idempotencyKey = options.idempotencyKey;
|
|
95
|
+
reportedAt = normalizeReportedAt(options.reportedAt);
|
|
96
|
+
normalizedReportedSourceEnv = normalizeStructured(options.reportedSourceEnv);
|
|
97
|
+
payload = removeEmptyFields({
|
|
98
|
+
sourceApp: sourceApp,
|
|
99
|
+
message: message,
|
|
100
|
+
environment: environment,
|
|
101
|
+
clientId: options.clientId,
|
|
102
|
+
clientSlug: options.clientSlug,
|
|
103
|
+
clientName: clientName,
|
|
104
|
+
clientRepo: options.clientRepo,
|
|
105
|
+
clientEmail: options.clientEmail,
|
|
106
|
+
severity: severity,
|
|
107
|
+
stack: stack,
|
|
108
|
+
context: context,
|
|
109
|
+
metadata: metadata,
|
|
110
|
+
attachments: attachments,
|
|
111
|
+
fingerprint: fingerprint,
|
|
112
|
+
idempotencyKey: idempotencyKey,
|
|
113
|
+
reportedBy: options.reportedBy,
|
|
114
|
+
reportedAt: reportedAt,
|
|
115
|
+
reportedFor: options.reportedFor,
|
|
116
|
+
reportedCount: options.reportedCount,
|
|
117
|
+
reportedSourceHost: options.reportedSourceHost,
|
|
118
|
+
reportedSourceIp: options.reportedSourceIp,
|
|
119
|
+
reportedSourceVersion: options.reportedSourceVersion,
|
|
120
|
+
reportedSourcePid: options.reportedSourcePid,
|
|
121
|
+
reportedSourceInstance: options.reportedSourceInstance,
|
|
122
|
+
reportedSourceRegion: options.reportedSourceRegion,
|
|
123
|
+
reportedSourceCluster: options.reportedSourceCluster,
|
|
124
|
+
reportedSourceProcess: options.reportedSourceProcess,
|
|
125
|
+
reportedSourceEnv: typeof normalizedReportedSourceEnv === 'string' ? undefined : normalizedReportedSourceEnv
|
|
126
|
+
});
|
|
127
|
+
if (shouldSuppressForLocalEnvironment(config, normalizedApiUrl)) {
|
|
128
|
+
logger.info('ErrorReporter suppressed: local environment detected');
|
|
129
|
+
logger.error('ErrorReporter payload (suppressed):', payload);
|
|
130
|
+
return [2 /*return*/, { delivered: false, reason: 'local-environment' }];
|
|
131
|
+
}
|
|
132
|
+
transport = options.fetch || globalThis.fetch;
|
|
133
|
+
if (typeof transport !== 'function') {
|
|
134
|
+
logger.error('ErrorReporter failed: fetch is not available in this runtime');
|
|
135
|
+
logger.error('ErrorReporter payload (not sent):', payload);
|
|
136
|
+
return [2 /*return*/, { delivered: false, reason: 'missing-fetch' }];
|
|
137
|
+
}
|
|
138
|
+
_b.label = 1;
|
|
139
|
+
case 1:
|
|
140
|
+
_b.trys.push([1, 3, , 4]);
|
|
141
|
+
return [4 /*yield*/, transport(normalizedApiUrl, {
|
|
142
|
+
method: 'POST',
|
|
143
|
+
headers: removeEmptyFields({
|
|
144
|
+
'Content-Type': 'application/json',
|
|
145
|
+
'X-ResolveIO-Error-Key': clientName,
|
|
146
|
+
'X-ResolveIO-Error-Hash': fingerprint,
|
|
147
|
+
'X-ResolveIO-Idempotency-Key': idempotencyKey
|
|
148
|
+
}),
|
|
149
|
+
body: JSON.stringify(payload)
|
|
150
|
+
})];
|
|
151
|
+
case 2:
|
|
152
|
+
response = _b.sent();
|
|
153
|
+
if (!response.ok) {
|
|
154
|
+
logger.error('ErrorReporter failed to deliver payload', { status: response.status, statusText: response.statusText });
|
|
155
|
+
return [2 /*return*/, { delivered: false, status: response.status, reason: 'http-error' }];
|
|
156
|
+
}
|
|
157
|
+
return [2 /*return*/, { delivered: true, status: response.status }];
|
|
158
|
+
case 3:
|
|
159
|
+
err_1 = _b.sent();
|
|
160
|
+
logger.error('ErrorReporter exception while delivering payload', err_1);
|
|
161
|
+
logger.error('ErrorReporter payload (not sent):', payload);
|
|
162
|
+
return [2 /*return*/, { delivered: false, reason: 'network-error' }];
|
|
163
|
+
case 4: return [2 /*return*/];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
return ErrorReporter;
|
|
169
|
+
}());
|
|
170
|
+
exports.ErrorReporter = ErrorReporter;
|
|
171
|
+
function getServerConfig() {
|
|
172
|
+
var _a;
|
|
173
|
+
try {
|
|
174
|
+
return ((_a = resolveio_server_app_1.ResolveIOServer.getServerConfig) === null || _a === void 0 ? void 0 : _a.call(resolveio_server_app_1.ResolveIOServer)) || null;
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
console.error('Failed to read ResolveIO server config', err);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function normalizeStack(stack) {
|
|
182
|
+
if (!stack) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
if (typeof stack === 'string') {
|
|
186
|
+
return stack;
|
|
187
|
+
}
|
|
188
|
+
if (stack instanceof Error) {
|
|
189
|
+
return stack.stack || stack.message;
|
|
190
|
+
}
|
|
191
|
+
if (typeof stack === 'object' && stack !== null && typeof stack.stack === 'string') {
|
|
192
|
+
return stack.stack;
|
|
193
|
+
}
|
|
194
|
+
if (typeof stack === 'object' && stack !== null && typeof stack.message === 'string') {
|
|
195
|
+
return stack.message;
|
|
196
|
+
}
|
|
197
|
+
return JSON.stringify(stack);
|
|
198
|
+
}
|
|
199
|
+
function normalizeStructured(value, correlationId) {
|
|
200
|
+
if (value === null || value === undefined) {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
if (typeof value === 'string') {
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
var serialized = serializeValue(value);
|
|
207
|
+
if (correlationId && typeof serialized === 'object' && serialized !== null && !serialized.correlationId) {
|
|
208
|
+
serialized.correlationId = correlationId;
|
|
209
|
+
}
|
|
210
|
+
return serialized;
|
|
211
|
+
}
|
|
212
|
+
function serializeValue(value, seen) {
|
|
213
|
+
var e_1, _a;
|
|
214
|
+
if (seen === void 0) { seen = new WeakSet(); }
|
|
215
|
+
if (value === null || value === undefined) {
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
if (typeof value === 'bigint') {
|
|
222
|
+
return value.toString();
|
|
223
|
+
}
|
|
224
|
+
if (value instanceof Date) {
|
|
225
|
+
return value.toISOString();
|
|
226
|
+
}
|
|
227
|
+
if (value instanceof Error) {
|
|
228
|
+
var base = {
|
|
229
|
+
name: value.name,
|
|
230
|
+
message: value.message,
|
|
231
|
+
stack: value.stack
|
|
232
|
+
};
|
|
233
|
+
return Object.assign({}, base, serializeValue(Object.assign({}, value), seen));
|
|
234
|
+
}
|
|
235
|
+
if (Array.isArray(value)) {
|
|
236
|
+
if (seen.has(value)) {
|
|
237
|
+
return '[Circular]';
|
|
238
|
+
}
|
|
239
|
+
seen.add(value);
|
|
240
|
+
var arr = value.map(function (item) { return serializeValue(item, seen); });
|
|
241
|
+
seen.delete(value);
|
|
242
|
+
return arr;
|
|
243
|
+
}
|
|
244
|
+
if (typeof value === 'object') {
|
|
245
|
+
if (seen.has(value)) {
|
|
246
|
+
return '[Circular]';
|
|
247
|
+
}
|
|
248
|
+
seen.add(value);
|
|
249
|
+
var obj = {};
|
|
250
|
+
try {
|
|
251
|
+
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
252
|
+
var _d = __read(_c.value, 2), key = _d[0], val = _d[1];
|
|
253
|
+
obj[key] = serializeValue(val, seen);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
257
|
+
finally {
|
|
258
|
+
try {
|
|
259
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
260
|
+
}
|
|
261
|
+
finally { if (e_1) throw e_1.error; }
|
|
262
|
+
}
|
|
263
|
+
seen.delete(value);
|
|
264
|
+
return obj;
|
|
265
|
+
}
|
|
266
|
+
return String(value);
|
|
267
|
+
}
|
|
268
|
+
function normalizeAttachments(attachments) {
|
|
269
|
+
return attachments
|
|
270
|
+
.filter(function (att) { return !!att && typeof att === 'object'; })
|
|
271
|
+
.map(function (att) { return removeEmptyFields({
|
|
272
|
+
name: att.name,
|
|
273
|
+
url: att.url,
|
|
274
|
+
contentType: att.contentType,
|
|
275
|
+
size: typeof att.size === 'number' ? att.size : undefined
|
|
276
|
+
}); })
|
|
277
|
+
.filter(function (att) { return !!att.name; });
|
|
278
|
+
}
|
|
279
|
+
function normalizeReportedAt(value) {
|
|
280
|
+
if (!value) {
|
|
281
|
+
return new Date().toISOString();
|
|
282
|
+
}
|
|
283
|
+
if (value instanceof Date) {
|
|
284
|
+
return value.toISOString();
|
|
285
|
+
}
|
|
286
|
+
var date = new Date(value);
|
|
287
|
+
if (!isNaN(date.getTime())) {
|
|
288
|
+
return date.toISOString();
|
|
289
|
+
}
|
|
290
|
+
return new Date().toISOString();
|
|
291
|
+
}
|
|
292
|
+
function computeFingerprint(sourceApp, environment, message, stack) {
|
|
293
|
+
var signature = "".concat(sourceApp || '', ":").concat(environment || '', ":").concat(message || '', ":").concat(stack ? stack.split('\n').slice(0, 5).join('|') : '');
|
|
294
|
+
return (0, crypto_1.createHash)('sha256').update(signature).digest('hex');
|
|
295
|
+
}
|
|
296
|
+
function removeEmptyFields(obj) {
|
|
297
|
+
var e_2, _a;
|
|
298
|
+
var cleaned = {};
|
|
299
|
+
try {
|
|
300
|
+
for (var _b = __values(Object.entries(obj || {})), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
301
|
+
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
302
|
+
if (value === undefined || value === null || value === '') {
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
cleaned[key] = value;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
309
|
+
finally {
|
|
310
|
+
try {
|
|
311
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
312
|
+
}
|
|
313
|
+
finally { if (e_2) throw e_2.error; }
|
|
314
|
+
}
|
|
315
|
+
return cleaned;
|
|
316
|
+
}
|
|
317
|
+
function mergeMetadata(metadata, correlationId) {
|
|
318
|
+
if (!metadata && !correlationId) {
|
|
319
|
+
return undefined;
|
|
320
|
+
}
|
|
321
|
+
var base = metadata ? normalizeStructured(metadata) : undefined;
|
|
322
|
+
if (!correlationId) {
|
|
323
|
+
return base;
|
|
324
|
+
}
|
|
325
|
+
if (typeof base === 'string') {
|
|
326
|
+
return {
|
|
327
|
+
correlationId: correlationId,
|
|
328
|
+
message: base
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
var metadataObj = (base || {});
|
|
332
|
+
if (!metadataObj.correlationId) {
|
|
333
|
+
metadataObj.correlationId = correlationId;
|
|
334
|
+
}
|
|
335
|
+
return metadataObj;
|
|
336
|
+
}
|
|
337
|
+
function shouldSuppressForLocalEnvironment(config, apiUrl) {
|
|
338
|
+
if (isLocalUrl(config === null || config === void 0 ? void 0 : config.ROOT_URL) || isLocalUrl(config === null || config === void 0 ? void 0 : config.SERVER_URL) || process.env.NODE_ENV === 'development') {
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
return isLocalUrl(apiUrl);
|
|
342
|
+
}
|
|
343
|
+
function isLocalUrl(url) {
|
|
344
|
+
if (!url || typeof url !== 'string') {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
try {
|
|
348
|
+
var parsed = new URL(url);
|
|
349
|
+
return LOCAL_HOSTNAMES.has(parsed.hostname.toLowerCase());
|
|
350
|
+
}
|
|
351
|
+
catch (_a) {
|
|
352
|
+
return /localhost|127\.0\.0\.1|0\.0\.0\.0|::1/.test(url);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
//# sourceMappingURL=error-reporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/error-reporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAoC;AACpC,gEAA0D;AAE1D,IAAM,qBAAqB,GAAG,iDAAiD,CAAC;AAChF,IAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAA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EAAE,MAAc;IAC5F,IAAI,UAAU,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAC,IAAI,UAAU,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QAC7G,OAAO,IAAI,CAAC;KACZ;IAED,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,UAAU,CAAC,GAAY;IAC/B,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QACpC,OAAO,KAAK,CAAC;KACb;IAED,IAAI;QACH,IAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;KAC1D;IACD,WAAM;QACL,OAAO,uCAAuC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACzD;AACF,CAAC","file":"error-reporter.js","sourcesContent":["import { createHash } from 'crypto';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nconst DEFAULT_ERROR_API_URL = 'https://backend.resolveio.com/api/errors/report';\nconst LOCAL_HOSTNAMES = new Set(['localhost', '127.0.0.1', '0.0.0.0', '::1']);\n\n// eslint-disable-next-line no-unused-vars\ntype FetchLike = (input: RequestInfo, init?: RequestInit) => Promise<Response>;\n\nexport interface ErrorReportAttachment {\n\tname: string;\n\turl?: string;\n\tcontentType?: string;\n\tsize?: number;\n}\n\nexport interface ErrorReportOptions {\n\tsourceApp?: string;\n\tmessage?: string;\n\tsubject?: string;\n\tenvironment?: string;\n\tclientId?: string;\n\tclientSlug?: string;\n\tclientName?: string;\n\tclientRepo?: string;\n\tclientEmail?: string;\n\tseverity?: string;\n\tstack?: string | Error;\n\terror?: unknown;\n\tcontext?: Record<string, any> | string | null;\n\tmetadata?: Record<string, any> | string | null;\n\tattachments?: ErrorReportAttachment[];\n\tfingerprint?: string;\n\tidempotencyKey?: string;\n\treportedBy?: string;\n\treportedAt?: string | Date;\n\treportedFor?: string;\n\treportedCount?: number;\n\treportedSourceHost?: string;\n\treportedSourceIp?: string;\n\treportedSourceVersion?: string;\n\treportedSourcePid?: number;\n\treportedSourceInstance?: string;\n\treportedSourceRegion?: string;\n\treportedSourceCluster?: string;\n\treportedSourceProcess?: string;\n\treportedSourceEnv?: Record<string, any>;\n\tcorrelationId?: string;\n\tapiUrl?: string;\n\tfetch?: FetchLike;\n\tlogger?: Pick<typeof console, 'error' | 'warn' | 'info' | 'log'>;\n}\n\nexport interface ErrorReportResult {\n\tdelivered: boolean;\n\tstatus?: number;\n\treason?: string;\n}\n\ninterface ErrorReportPayload {\n\tsourceApp: string;\n\tmessage: string;\n\tenvironment?: string;\n\tclientId?: string;\n\tclientSlug?: string;\n\tclientName?: string;\n\tclientRepo?: string;\n\tclientEmail?: string;\n\tseverity: string;\n\tstack?: string;\n\tcontext?: Record<string, any> | string;\n\tmetadata?: Record<string, any> | string;\n\tattachments?: ErrorReportAttachment[];\n\tfingerprint?: string;\n\tidempotencyKey?: string;\n\treportedBy?: string;\n\treportedAt?: string;\n\treportedFor?: string;\n\treportedCount?: number;\n\treportedSourceHost?: string;\n\treportedSourceIp?: string;\n\treportedSourceVersion?: string;\n\treportedSourcePid?: number;\n\treportedSourceInstance?: string;\n\treportedSourceRegion?: string;\n\treportedSourceCluster?: string;\n\treportedSourceProcess?: string;\n\treportedSourceEnv?: Record<string, any>;\n}\n\nexport class ErrorReporter {\n\tpublic static async report(options: ErrorReportOptions): Promise<ErrorReportResult> {\n\t\tconst logger = options.logger || console;\n\t\tconst config = getServerConfig();\n\t\tconst normalizedApiUrl = options.apiUrl || DEFAULT_ERROR_API_URL;\n\t\tconst clientName = options.clientName || config?.CLIENT_NAME || ResolveIOServer.getClientName?.() || 'resolveio';\n\t\tconst sourceApp = options.sourceApp || clientName || 'resolveio-server-lib';\n\t\tconst environment = options.environment || process.env.RESOLVEIO_ENV || config?.RESOLVEIO_ENV || config?.ENVIRONMENT || config?.ROOT_URL || process.env.NODE_ENV || 'unknown';\n\t\tconst message = options.message || options.subject || 'ResolveIO Error Detected';\n\t\tconst severity = options.severity || 'error';\n\t\tconst stack = normalizeStack(options.stack || options.error);\n\t\tconst context = normalizeStructured(options.context, options.correlationId);\n\t\tconst metadata = normalizeStructured(mergeMetadata(options.metadata, options.correlationId));\n\t\tconst attachments = Array.isArray(options.attachments) ? normalizeAttachments(options.attachments) : undefined;\n\t\tconst fingerprint = options.fingerprint || computeFingerprint(sourceApp, environment, message, stack);\n\t\tconst idempotencyKey = options.idempotencyKey;\n\t\tconst reportedAt = normalizeReportedAt(options.reportedAt);\n\t\tconst normalizedReportedSourceEnv = normalizeStructured(options.reportedSourceEnv);\n\t\tconst payload: ErrorReportPayload = removeEmptyFields({\n\t\t\tsourceApp,\n\t\t\tmessage,\n\t\t\tenvironment,\n\t\t\tclientId: options.clientId,\n\t\t\tclientSlug: options.clientSlug,\n\t\t\tclientName,\n\t\t\tclientRepo: options.clientRepo,\n\t\t\tclientEmail: options.clientEmail,\n\t\t\tseverity,\n\t\t\tstack,\n\t\t\tcontext,\n\t\t\tmetadata,\n\t\t\tattachments,\n\t\t\tfingerprint,\n\t\t\tidempotencyKey,\n\t\t\treportedBy: options.reportedBy,\n\t\t\treportedAt,\n\t\t\treportedFor: options.reportedFor,\n\t\t\treportedCount: options.reportedCount,\n\t\t\treportedSourceHost: options.reportedSourceHost,\n\t\t\treportedSourceIp: options.reportedSourceIp,\n\t\t\treportedSourceVersion: options.reportedSourceVersion,\n\t\t\treportedSourcePid: options.reportedSourcePid,\n\t\t\treportedSourceInstance: options.reportedSourceInstance,\n\t\t\treportedSourceRegion: options.reportedSourceRegion,\n\t\t\treportedSourceCluster: options.reportedSourceCluster,\n\t\t\treportedSourceProcess: options.reportedSourceProcess,\n\t\t\treportedSourceEnv: typeof normalizedReportedSourceEnv === 'string' ? undefined : normalizedReportedSourceEnv as Record<string, any>\n\t\t});\n\n\t\tif (shouldSuppressForLocalEnvironment(config, normalizedApiUrl)) {\n\t\t\tlogger.info('ErrorReporter suppressed: local environment detected');\n\t\t\tlogger.error('ErrorReporter payload (suppressed):', payload);\n\t\t\treturn { delivered: false, reason: 'local-environment' };\n\t\t}\n\n\t\tconst transport = options.fetch || globalThis.fetch;\n\t\tif (typeof transport !== 'function') {\n\t\t\tlogger.error('ErrorReporter failed: fetch is not available in this runtime');\n\t\t\tlogger.error('ErrorReporter payload (not sent):', payload);\n\t\t\treturn { delivered: false, reason: 'missing-fetch' };\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await transport(normalizedApiUrl, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: removeEmptyFields({\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t'X-ResolveIO-Error-Key': clientName,\n\t\t\t\t\t'X-ResolveIO-Error-Hash': fingerprint,\n\t\t\t\t\t'X-ResolveIO-Idempotency-Key': idempotencyKey\n\t\t\t\t}),\n\t\t\t\tbody: JSON.stringify(payload)\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tlogger.error('ErrorReporter failed to deliver payload', { status: response.status, statusText: response.statusText });\n\t\t\t\treturn { delivered: false, status: response.status, reason: 'http-error' };\n\t\t\t}\n\n\t\t\treturn { delivered: true, status: response.status };\n\t\t}\n\t\tcatch (err) {\n\t\t\tlogger.error('ErrorReporter exception while delivering payload', err);\n\t\t\tlogger.error('ErrorReporter payload (not sent):', payload);\n\t\t\treturn { delivered: false, reason: 'network-error' };\n\t\t}\n\t}\n}\n\nfunction getServerConfig(): Record<string, any> | null {\n\ttry {\n\t\treturn ResolveIOServer.getServerConfig?.() || null;\n\t}\n\tcatch (err) {\n\t\tconsole.error('Failed to read ResolveIO server config', err);\n\t\treturn null;\n\t}\n}\n\nfunction normalizeStack(stack?: string | Error | unknown): string | undefined {\n\tif (!stack) {\n\t\treturn undefined;\n\t}\n\n\tif (typeof stack === 'string') {\n\t\treturn stack;\n\t}\n\n\tif (stack instanceof Error) {\n\t\treturn stack.stack || stack.message;\n\t}\n\n\tif (typeof stack === 'object' && stack !== null && typeof (stack as Record<string, any>).stack === 'string') {\n\t\treturn (stack as Record<string, any>).stack;\n\t}\n\n\tif (typeof stack === 'object' && stack !== null && typeof (stack as Record<string, any>).message === 'string') {\n\t\treturn (stack as Record<string, any>).message;\n\t}\n\n\treturn JSON.stringify(stack);\n}\n\nfunction normalizeStructured(value: any, correlationId?: string): Record<string, any> | string | undefined {\n\tif (value === null || value === undefined) {\n\t\treturn undefined;\n\t}\n\n\tif (typeof value === 'string') {\n\t\treturn value;\n\t}\n\n\tconst serialized = serializeValue(value);\n\tif (correlationId && typeof serialized === 'object' && serialized !== null && !serialized.correlationId) {\n\t\tserialized.correlationId = correlationId;\n\t}\n\treturn serialized;\n}\n\nfunction serializeValue(value: any, seen: WeakSet<object> = new WeakSet()): any {\n\tif (value === null || value === undefined) {\n\t\treturn value;\n\t}\n\n\tif (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n\t\treturn value;\n\t}\n\n\tif (typeof value === 'bigint') {\n\t\treturn value.toString();\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn value.toISOString();\n\t}\n\n\tif (value instanceof Error) {\n\t\tconst base = {\n\t\t\tname: value.name,\n\t\t\tmessage: value.message,\n\t\t\tstack: value.stack\n\t\t};\n\t\treturn Object.assign({}, base, serializeValue(Object.assign({}, value), seen));\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tif (seen.has(value)) {\n\t\t\treturn '[Circular]';\n\t\t}\n\t\tseen.add(value);\n\t\tconst arr = value.map(item => serializeValue(item, seen));\n\t\tseen.delete(value);\n\t\treturn arr;\n\t}\n\n\tif (typeof value === 'object') {\n\t\tif (seen.has(value)) {\n\t\t\treturn '[Circular]';\n\t\t}\n\t\tseen.add(value);\n\t\tconst obj: Record<string, any> = {};\n\t\tfor (const [key, val] of Object.entries(value)) {\n\t\t\tobj[key] = serializeValue(val, seen);\n\t\t}\n\t\tseen.delete(value);\n\t\treturn obj;\n\t}\n\n\treturn String(value);\n}\n\nfunction normalizeAttachments(attachments: ErrorReportAttachment[]): ErrorReportAttachment[] {\n\treturn attachments\n\t\t.filter(att => !!att && typeof att === 'object')\n\t\t.map(att => removeEmptyFields({\n\t\t\tname: att.name,\n\t\t\turl: att.url,\n\t\t\tcontentType: att.contentType,\n\t\t\tsize: typeof att.size === 'number' ? att.size : undefined\n\t\t}))\n\t\t.filter(att => !!att.name);\n}\n\nfunction normalizeReportedAt(value?: string | Date): string | undefined {\n\tif (!value) {\n\t\treturn new Date().toISOString();\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn value.toISOString();\n\t}\n\n\tconst date = new Date(value);\n\tif (!isNaN(date.getTime())) {\n\t\treturn date.toISOString();\n\t}\n\n\treturn new Date().toISOString();\n}\n\nfunction computeFingerprint(sourceApp: string, environment: string | undefined, message: string, stack?: string): string | undefined {\n\tconst signature = `${sourceApp || ''}:${environment || ''}:${message || ''}:${stack ? stack.split('\\n').slice(0, 5).join('|') : ''}`;\n\treturn createHash('sha256').update(signature).digest('hex');\n}\n\nfunction removeEmptyFields<T extends Record<string, any>>(obj: T): T {\n\tconst cleaned: Record<string, any> = {};\n\tfor (const [key, value] of Object.entries(obj || {})) {\n\t\tif (value === undefined || value === null || value === '') {\n\t\t\tcontinue;\n\t\t}\n\t\tcleaned[key] = value;\n\t}\n\treturn cleaned as T;\n}\n\nfunction mergeMetadata(metadata: Record<string, any> | string | null | undefined, correlationId?: string) {\n\tif (!metadata && !correlationId) {\n\t\treturn undefined;\n\t}\n\n\tconst base = metadata ? normalizeStructured(metadata) : undefined;\n\tif (!correlationId) {\n\t\treturn base;\n\t}\n\n\tif (typeof base === 'string') {\n\t\treturn {\n\t\t\tcorrelationId,\n\t\t\tmessage: base\n\t\t};\n\t}\n\n\tconst metadataObj = (base || {}) as Record<string, any>;\n\tif (!metadataObj.correlationId) {\n\t\tmetadataObj.correlationId = correlationId;\n\t}\n\treturn metadataObj;\n}\n\nfunction shouldSuppressForLocalEnvironment(config: Record<string, any> | null, apiUrl: string): boolean {\n\tif (isLocalUrl(config?.ROOT_URL) || isLocalUrl(config?.SERVER_URL) || process.env.NODE_ENV === 'development') {\n\t\treturn true;\n\t}\n\n\treturn isLocalUrl(apiUrl);\n}\n\nfunction isLocalUrl(url?: string): boolean {\n\tif (!url || typeof url !== 'string') {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\treturn LOCAL_HOSTNAMES.has(parsed.hostname.toLowerCase());\n\t}\n\tcatch {\n\t\treturn /localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|::1/.test(url);\n\t}\n}\n"]}
|
|
@@ -40,21 +40,14 @@ exports.mongoCommand = exports.getLeafFormatTypes = exports.getLeafValueTypes =
|
|
|
40
40
|
var resolveio_server_app_1 = require("../resolveio-server-app");
|
|
41
41
|
var common_1 = require("./common");
|
|
42
42
|
function getReportLookupSchemas(collection_root) {
|
|
43
|
-
var rootCollection = resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(collection_root);
|
|
44
|
-
if (!rootCollection || !rootCollection['rbSchema']) {
|
|
45
|
-
throw new Error('Report builder schema not available for collection ' + String(collection_root) + '. Ensure useReportBuilder is enabled.');
|
|
46
|
-
}
|
|
47
43
|
var lookupTrees = [];
|
|
48
|
-
lookupTrees.push({ collection_name: collection_root, tree:
|
|
49
|
-
var schemaObj =
|
|
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'];
|
|
50
46
|
var modelKeys = Object.keys(schemaObj);
|
|
51
47
|
modelKeys.forEach(function (field) {
|
|
52
48
|
if (schemaObj[field].lookup_collection) {
|
|
53
49
|
var collectionName_1 = schemaObj[field].lookup_collection;
|
|
54
50
|
var collectionModel = resolveio_server_app_1.ResolveIOServer.getMongoManager().collection(collectionName_1);
|
|
55
|
-
if (!collectionModel || !collectionModel['rbSchema']) {
|
|
56
|
-
throw new Error('Report builder lookup schema missing for collection ' + collectionName_1 + ' referenced from ' + String(collection_root) + '.');
|
|
57
|
-
}
|
|
58
51
|
if (!lookupTrees.filter(function (a) { return a.collection_name === collectionName_1; }).length) {
|
|
59
52
|
lookupTrees.push({ collection_name: collectionName_1, tree: collectionModel['rbSchema'], is_root: false });
|
|
60
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/schema-report-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gEAA0D;AAC1D,mCAAuC;AAEvC,SAAgB,sBAAsB,CAAC,eAAuB;IAC7D,IAAI,cAAc,GAAG,sCAAe,CAAC,eAAe,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IACnF,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;QACnD,MAAM,IAAI,KAAK,CAAC,qDAAqD,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,uCAAuC,CAAC,CAAC;KAC3I;IAED,IAAI,WAAW,GAAqB,EAAE,CAAC;IACvC,WAAW,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACxG,IAAI,SAAS,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3C,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,gBA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AAzB,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 rootCollection = ResolveIOServer.getMongoManager().collection(collection_root);\n\tif (!rootCollection || !rootCollection['rbSchema']) {\n\t\tthrow new Error('Report builder schema not available for collection ' + String(collection_root) + '. Ensure useReportBuilder is enabled.');\n\t}\n\n\tlet lookupTrees: CollectionTree[] = [];\n\tlookupTrees.push({ collection_name: collection_root, tree: rootCollection['rbSchema'], is_root: true });\n\tlet schemaObj = rootCollection['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\t\t\tif (!collectionModel || !collectionModel['rbSchema']) {\n\t\t\t\tthrow new Error('Report builder lookup schema missing for collection ' + collectionName + ' referenced from ' + String(collection_root) + '.');\n\t\t\t}\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}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/util/schema-report-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gEAA0D;AAC1D,mCAAuC;AAEvC,SAAgB,sBAAsB,CAAC,eA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BAAsB;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}"]}
|