@resolveio/server-lib 20.12.29 → 20.12.31

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.
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -112,7 +123,7 @@ function loadCronJobMethods(methodManager) {
112
123
  }),
113
124
  function: function (data) {
114
125
  return __awaiter(this, void 0, void 0, function () {
115
- var report, fieldsObj_1, count_1, sortObj_1, rootOptions, filters_1, collectionTree, treeLeaves, allLeaves_1, filterArrayFields_1, filterArrays_1, res, results_1, reportTotals, lines_1, tmpHeaders_1, wb, ws, wbout, _a, _b, email, e_1_1, wb, ws_1, currentRow_1, row, copy, widths_1, i, now, buffer, _c, _d, email, e_2_1, err_1, datedUniqueDates_1, datedUniqueGroups_1, datedData_1, reportTotalGroups_1, reportTotalDates_1, _loop_1, i, tmpResults, wb, ws, currentRow, currentCol_1, row_1, _loop_2, i, i, total, j, field, buffer, _e, _f, email, e_3_1, err_2, err_3, err_4;
126
+ var report, fieldsObj_1, count_1, sortObj_1, rootOptions, filters_1, collectionTree, treeLeaves, allLeaves_1, filterArrayFields_1, filterArrays_1, res, results_1, reportTotals, customFields, exportFields_1, lines_1, tmpHeaders_1, wb, ws, wbout, _a, _b, email, e_1_1, wb, ws_1, currentRow_1, row, copy, widths_1, i, now, buffer, _c, _d, email, e_2_1, err_1, datedUniqueDates_1, datedUniqueGroups_1, datedData_1, reportTotalGroups_1, reportTotalDates_1, _loop_1, i, tmpResults, wb, ws, currentRow, currentCol_1, row_1, _loop_2, i, i, total, j, field, buffer, _e, _f, email, e_3_1, err_2, err_3, err_4;
116
127
  var e_1, _g, e_2, _h, e_3, _j;
117
128
  return __generator(this, function (_k) {
118
129
  switch (_k.label) {
@@ -463,8 +474,10 @@ function loadCronJobMethods(methodManager) {
463
474
  if (!(res && res[0])) return [3 /*break*/, 40];
464
475
  results_1 = res[0].results;
465
476
  reportTotals = res[0].totals;
477
+ customFields = (report.fields_custom || []).map(function (cust) { return (__assign(__assign({}, cust), { id: cust.selFieldId, fieldType: 'Number', leafValueType: cust.leafValueType || 'Value', leafFormatType: 'Number', columnName: cust.columnName || cust.id, show: true })); });
478
+ exportFields_1 = report.fields_selected.filter(function (a) { return a.show; }).concat(customFields);
466
479
  if (!(report.type === 'List')) return [3 /*break*/, 14];
467
- report.fields_selected.filter(function (a) { return a.show; }).forEach(function (field) {
480
+ exportFields_1.forEach(function (field) {
468
481
  if ((field.fieldType === 'Number' || field.leafValueType === 'Count') && field.leafFormatType === 'Number') {
469
482
  results_1.filter(function (a) { return a[field.id] !== null && a[field.id] !== undefined; }).forEach(function (result) {
470
483
  result[field.id] = result[field.id].toLocaleString();
@@ -531,7 +544,7 @@ function loadCronJobMethods(methodManager) {
531
544
  report.groups_row.forEach(function (group) {
532
545
  tmpHeaders_1[group.id] = group.columnName;
533
546
  });
534
- report.fields_selected.filter(function (a) { return a.show; }).forEach(function (header) {
547
+ exportFields_1.forEach(function (header) {
535
548
  tmpHeaders_1[header.columnName] = header.columnName;
536
549
  });
537
550
  wb = XLSX.utils.book_new();
@@ -550,7 +563,7 @@ function loadCronJobMethods(methodManager) {
550
563
  }
551
564
  }
552
565
  });
553
- report.fields_selected.filter(function (a) { return a.show; }).forEach(function (header) {
566
+ exportFields_1.forEach(function (header) {
554
567
  if (Array.isArray(result[header.id])) {
555
568
  tmp[header.columnName] = result[header.id].join(',');
556
569
  }
@@ -603,7 +616,7 @@ function loadCronJobMethods(methodManager) {
603
616
  case 13: return [3 /*break*/, 40];
604
617
  case 14:
605
618
  if (!(report.type === 'Group')) return [3 /*break*/, 27];
606
- report.fields_selected.filter(function (a) { return a.show; }).forEach(function (field) {
619
+ exportFields_1.forEach(function (field) {
607
620
  results_1.forEach(function (result) {
608
621
  modifyDataTypeField(report, result, field, 1);
609
622
  });
@@ -642,8 +655,8 @@ function loadCronJobMethods(methodManager) {
642
655
  copy = (0, common_1.deepCopy)(results_1);
643
656
  widths_1 = [];
644
657
  copy.forEach(function (res) {
645
- currentRow_1 = tabGroupExcelRecursive(report, ws_1, currentRow_1, 1, res);
646
- tabGroupExcelWidthRecursive(report, 1, res, widths_1);
658
+ currentRow_1 = tabGroupExcelRecursive(report, ws_1, currentRow_1, 1, res, exportFields_1);
659
+ tabGroupExcelWidthRecursive(report, 1, res, widths_1, exportFields_1);
647
660
  });
648
661
  for (i = 1; i < ws_1.columns.length; i++) {
649
662
  ws_1.columns[i].width = widths_1[i - 1];
@@ -1210,7 +1223,7 @@ function modifyDataTypeField(report, result, field, index) {
1210
1223
  }
1211
1224
  }
1212
1225
  }
1213
- function tabGroupExcelRecursive(report, ws, currentRow, level, result) {
1226
+ function tabGroupExcelRecursive(report, ws, currentRow, level, result, fields) {
1214
1227
  var row = ws.getRow(currentRow);
1215
1228
  if (level < report.groups_row.length) {
1216
1229
  row.getCell(2).fill = {
@@ -1236,7 +1249,7 @@ function tabGroupExcelRecursive(report, ws, currentRow, level, result) {
1236
1249
  report.fields_total.forEach(function (total) {
1237
1250
  currentRow += 1;
1238
1251
  row = ws.getRow(currentRow);
1239
- report.fields_selected.filter(function (a) { return a.show; }).forEach(function (field, fieldIndex) {
1252
+ fields.forEach(function (field, fieldIndex) {
1240
1253
  if (total.fields.includes(field.id)) {
1241
1254
  row.getCell(fieldIndex + 2).value = field.columnName;
1242
1255
  row.getCell(fieldIndex + 2).font = {
@@ -1268,7 +1281,7 @@ function tabGroupExcelRecursive(report, ws, currentRow, level, result) {
1268
1281
  report.fields_total.forEach(function (total) {
1269
1282
  currentRow += 1;
1270
1283
  row = ws.getRow(currentRow);
1271
- report.fields_selected.filter(function (a) { return a.show; }).forEach(function (field, fieldIndex) {
1284
+ fields.forEach(function (field, fieldIndex) {
1272
1285
  if (total.fields.includes(field.id)) {
1273
1286
  row.getCell(fieldIndex + 2).value = result[total.id + '_' + field.id];
1274
1287
  row.getCell(fieldIndex + 2).font = {
@@ -1311,7 +1324,7 @@ function tabGroupExcelRecursive(report, ws, currentRow, level, result) {
1311
1324
  var nextResults = result[nextGroup.id];
1312
1325
  if (Array.isArray(nextResults)) {
1313
1326
  nextResults.forEach(function (tDataRes) {
1314
- currentRow = tabGroupExcelRecursive(report, ws, currentRow, level + 1, tDataRes);
1327
+ currentRow = tabGroupExcelRecursive(report, ws, currentRow, level + 1, tDataRes, fields);
1315
1328
  });
1316
1329
  }
1317
1330
  }
@@ -1339,7 +1352,7 @@ function tabGroupExcelRecursive(report, ws, currentRow, level, result) {
1339
1352
  currentRow += 1;
1340
1353
  row = ws.getRow(currentRow);
1341
1354
  // Headers
1342
- report.fields_selected.filter(function (a) { return a.show; }).forEach(function (field, fieldIndex) {
1355
+ fields.forEach(function (field, fieldIndex) {
1343
1356
  row.getCell(fieldIndex + 2).value = field.columnName;
1344
1357
  row.getCell(fieldIndex + 2).font = {
1345
1358
  name: 'Arial',
@@ -1367,7 +1380,7 @@ function tabGroupExcelRecursive(report, ws, currentRow, level, result) {
1367
1380
  result['f_0'].forEach(function (res, resIndex) {
1368
1381
  currentRow += 1;
1369
1382
  row = ws.getRow(currentRow);
1370
- report.fields_selected.filter(function (a) { return a.show; }).forEach(function (field, fieldIndex) {
1383
+ fields.forEach(function (field, fieldIndex) {
1371
1384
  if (field.fieldType === 'Number' && typeof (result[field.id][resIndex]) === 'string' && result[field.id][resIndex]) {
1372
1385
  row.getCell(fieldIndex + 2).value = parseFloat(result[field.id][resIndex].replace(new RegExp(/\,/g), '').replace(new RegExp(/\$/g), ''));
1373
1386
  }
@@ -1400,7 +1413,7 @@ function tabGroupExcelRecursive(report, ws, currentRow, level, result) {
1400
1413
  report.fields_total.forEach(function (total) {
1401
1414
  currentRow += 1;
1402
1415
  row = ws.getRow(currentRow);
1403
- report.fields_selected.filter(function (a) { return a.show; }).forEach(function (field, fieldIndex) {
1416
+ fields.forEach(function (field, fieldIndex) {
1404
1417
  if (total.fields.includes(field.id)) {
1405
1418
  row.getCell(fieldIndex + 2).value = result[total.id + '_' + field.id];
1406
1419
  row.getCell(fieldIndex + 2).font = {
@@ -1440,20 +1453,20 @@ function tabGroupExcelRecursive(report, ws, currentRow, level, result) {
1440
1453
  }
1441
1454
  return currentRow + 1;
1442
1455
  }
1443
- function tabGroupExcelWidthRecursive(report, level, result, cols) {
1456
+ function tabGroupExcelWidthRecursive(report, level, result, cols, fields) {
1444
1457
  if (level < report.groups_row.length) {
1445
1458
  var nextGroup = report.groups_row[level];
1446
1459
  if (nextGroup) {
1447
1460
  var nextResults = result[nextGroup.id];
1448
1461
  if (Array.isArray(nextResults)) {
1449
1462
  nextResults.forEach(function (tDataRes) {
1450
- cols = tabGroupExcelWidthRecursive(report, level + 1, tDataRes, cols);
1463
+ cols = tabGroupExcelWidthRecursive(report, level + 1, tDataRes, cols, fields);
1451
1464
  });
1452
1465
  }
1453
1466
  }
1454
1467
  }
1455
1468
  else {
1456
- report.fields_selected.filter(function (a) { return a.show; }).forEach(function (field, fieldIndex) {
1469
+ fields.forEach(function (field, fieldIndex) {
1457
1470
  if (Array.isArray(result[field.id])) {
1458
1471
  result[field.id].forEach(function (res) {
1459
1472
  var length = 10;