@resolveio/server-lib 4.3.15 → 4.4.0

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.
@@ -0,0 +1,72 @@
1
+ import { CollectionDocument } from '../models/collection-document.model';
2
+ export interface ReportBuilderReportModel extends CollectionDocument {
3
+ collection_root: string;
4
+ report_name: string;
5
+ fields_sort: ReportBuilderReportFieldsSort[];
6
+ fields_filter: ReportBuilderReportFieldsFilter[];
7
+ fields_selected: ReportBuilderReportFieldsSelected[];
8
+ fields_total: ReportBuilderReportFieldsTotal[];
9
+ fields_link: ReportBuilderReportFieldsLink[];
10
+ id_user: string;
11
+ user: string;
12
+ date_created: Date;
13
+ shared_users: string[];
14
+ type: ReportBuilderReportType;
15
+ groups_row: ReportBuilderGroupsRow[];
16
+ groups_column: ReportBuilderGroupsRow[];
17
+ id_date_field?: string;
18
+ date_interval?: string;
19
+ }
20
+ export interface ReportBuilderReportFieldsLink {
21
+ field_first: string;
22
+ field_second: string;
23
+ id: number;
24
+ }
25
+ export interface ReportBuilderReportFieldsTotal {
26
+ type: string;
27
+ fields: string[];
28
+ id: number;
29
+ }
30
+ export interface ReportBuilderGroupsRow {
31
+ field: string;
32
+ id: string;
33
+ columnName: string;
34
+ }
35
+ export declare type ReportBuilderReportType = 'Tabular' | 'Dated';
36
+ export interface ReportBuilderReportFieldsSort {
37
+ field: string;
38
+ order: string;
39
+ }
40
+ export interface ReportBuilderReportFieldsFilter {
41
+ field: string;
42
+ fieldType: string;
43
+ condition: string;
44
+ value: any;
45
+ highValue: any;
46
+ dateValue: any;
47
+ highDateValue: any;
48
+ booleanValue: string;
49
+ is_rolling: boolean;
50
+ rolling_interval: string;
51
+ }
52
+ export interface ReportBuilderReportFieldsSelected {
53
+ collection_name: string;
54
+ columnName: string;
55
+ fieldName: string;
56
+ fieldType: string;
57
+ distinctFieldValues: string[];
58
+ fieldPath: string;
59
+ lookup_collection: string;
60
+ lookup_local_key: string;
61
+ lookup_foreign_key: string;
62
+ lookup_as: string;
63
+ text: string;
64
+ value: string;
65
+ isLeaf: boolean;
66
+ isActive: boolean;
67
+ isSelected: boolean;
68
+ depth: number;
69
+ leafType: string;
70
+ leafTypes: string[];
71
+ id?: string;
72
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,61 @@
1
+ import { Schema } from 'mongoose';
2
+ export interface ReportBuilderQueryOptionsModel {
3
+ rootCollection: string;
4
+ searchString: string;
5
+ entriesPerPage: string;
6
+ pageNum: number;
7
+ sortColumn: string;
8
+ sortOrder: string;
9
+ filters?: Object;
10
+ }
11
+ export interface CollectionTree {
12
+ collection_name: string;
13
+ tree: Schema;
14
+ is_root: boolean;
15
+ }
16
+ export interface LookupTables {
17
+ lookup: string;
18
+ local_key: string;
19
+ }
20
+ export interface TreeItemLeafType {
21
+ text: string;
22
+ value: any;
23
+ }
24
+ export interface TreeItem {
25
+ text: string;
26
+ isLeaf: boolean;
27
+ children?: TreeItem[];
28
+ parent?: TreeItem;
29
+ isSelected?: boolean;
30
+ isActive?: boolean;
31
+ isVisible: boolean;
32
+ value: string;
33
+ depth?: number;
34
+ rowNumber?: number;
35
+ disabled?: boolean;
36
+ layers?: any[];
37
+ leafTypeValue?: string;
38
+ }
39
+ export interface ReportTableColumn {
40
+ collection: string;
41
+ collectionAlias?: string;
42
+ lookupIsRootNode?: boolean;
43
+ columnName: string;
44
+ fieldPath: String;
45
+ localKey?: string;
46
+ lookupKey?: string;
47
+ }
48
+ export interface ReportTableModel {
49
+ rootCollection: string;
50
+ searchString: string;
51
+ entriesPerPage: string;
52
+ pageNum: number;
53
+ sortColumn: string;
54
+ sortOrder: string;
55
+ filters?: Object;
56
+ }
57
+ export interface UnwindPaths {
58
+ collectionName: string;
59
+ collectionNameAlias?: string;
60
+ paths: string[];
61
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "4.3.15",
3
+ "version": "4.4.0",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -20,6 +20,7 @@
20
20
  "forever": "0.15.3",
21
21
  "handlebars": "4.1.2",
22
22
  "imap": "0.8.19",
23
+ "json2csv": "^4.5.2",
23
24
  "jsonwebtoken": "8.5.1",
24
25
  "moment": "2.24.0",
25
26
  "moment-timezone": "0.5.25",
@@ -49,7 +50,7 @@
49
50
  "@types/imap": "0.8.29",
50
51
  "@types/jsonwebtoken": "8.3.2",
51
52
  "@types/mongodb": "3.1.28",
52
- "@types/mongoose": "5.5.6",
53
+ "@types/mongoose": "5.5.13",
53
54
  "@types/nodemailer": "6.2.0",
54
55
  "@types/passport": "1.0.0",
55
56
  "@types/passport-local": "1.0.33",
@@ -0,0 +1,2 @@
1
+ import { SubscriptionManager } from '../managers/subscription.manager';
2
+ export declare function loadReportBuilderReportPublications(subscriptionManager: SubscriptionManager): void;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var simpl_schema_1 = require("simpl-schema");
4
+ var report_builder_report_collection_1 = require("../collections/report-builder-report.collection");
5
+ function loadReportBuilderReportPublications(subscriptionManager) {
6
+ subscriptionManager.publications({
7
+ reportbuilderreports: {
8
+ ws_specific: true,
9
+ function: function (id_user) {
10
+ return report_builder_report_collection_1.ReportBuilderReports.find({ $or: [{ id_user: id_user }, { shared_users: id_user }] }).sort({ report_name: 1 }).exec();
11
+ },
12
+ collections: ['report-builder-reports']
13
+ },
14
+ reportbuilderreportWithId: {
15
+ check: new simpl_schema_1.default({
16
+ id: {
17
+ type: String
18
+ }
19
+ }),
20
+ function: function (id) {
21
+ return report_builder_report_collection_1.ReportBuilderReports.findOne({ _id: id }).exec();
22
+ },
23
+ collections: ['report-builder-reports'],
24
+ fetchFunction: function (document, id) {
25
+ return document._id === id;
26
+ }
27
+ },
28
+ reportbuilderreportsWithCustomerId: {
29
+ check: new simpl_schema_1.default({
30
+ id: {
31
+ type: String
32
+ }
33
+ }),
34
+ function: function (id) {
35
+ return report_builder_report_collection_1.ReportBuilderReports.find({ shared_users: id }).exec();
36
+ },
37
+ collections: ['report-builder-reports'],
38
+ fetchFunction: function (document, id) {
39
+ return document['shared_users'].includes(id);
40
+ }
41
+ }
42
+ });
43
+ }
44
+ exports.loadReportBuilderReportPublications = loadReportBuilderReportPublications;
package/util/common.d.ts CHANGED
@@ -12,3 +12,8 @@ export declare function mergeUpdates(...updatesToMerge: any[]): {
12
12
  export declare function getDeepDiff(doc1: any, doc2: any): any;
13
13
  export declare function applyMongoUpdate(uDoc: any, delta: any): any;
14
14
  export declare function getBinarySize(string: any): number;
15
+ export declare function pad(num: any, size: any): string;
16
+ export declare function randomString(length: any, chars: any): string;
17
+ export declare function toTitleCase(str: any): any;
18
+ export declare function isObject(item: any): boolean;
19
+ export declare function mergeDeep(target: any, ...sources: any[]): any;
package/util/common.js CHANGED
@@ -339,3 +339,55 @@ function getBinarySize(string) {
339
339
  }
340
340
  }
341
341
  exports.getBinarySize = getBinarySize;
342
+ function pad(num, size) {
343
+ var s = num + '';
344
+ while (s.length < size) {
345
+ s = '0' + s;
346
+ }
347
+ return s;
348
+ }
349
+ exports.pad = pad;
350
+ function randomString(length, chars) {
351
+ var result = '';
352
+ for (var i = length; i > 0; --i) {
353
+ result += chars[Math.floor(Math.random() * chars.length)];
354
+ }
355
+ return result;
356
+ }
357
+ exports.randomString = randomString;
358
+ function toTitleCase(str) {
359
+ return str.replace(/\w\S*/g, function (txt) {
360
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
361
+ });
362
+ }
363
+ exports.toTitleCase = toTitleCase;
364
+ function isObject(item) {
365
+ return (item && typeof item === 'object' && !Array.isArray(item));
366
+ }
367
+ exports.isObject = isObject;
368
+ function mergeDeep(target) {
369
+ var _a, _b;
370
+ var sources = [];
371
+ for (var _i = 1; _i < arguments.length; _i++) {
372
+ sources[_i - 1] = arguments[_i];
373
+ }
374
+ if (!sources.length) {
375
+ return target;
376
+ }
377
+ var source = sources.shift();
378
+ if (isObject(target) && isObject(source)) {
379
+ for (var key in source) {
380
+ if (isObject(source[key])) {
381
+ if (!target[key]) {
382
+ Object.assign(target, (_a = {}, _a[key] = {}, _a));
383
+ }
384
+ mergeDeep(target[key], source[key]);
385
+ }
386
+ else {
387
+ Object.assign(target, (_b = {}, _b[key] = source[key], _b));
388
+ }
389
+ }
390
+ }
391
+ return mergeDeep.apply(void 0, [target].concat(sources));
392
+ }
393
+ exports.mergeDeep = mergeDeep;
@@ -0,0 +1,16 @@
1
+ import { CollectionTree, LookupTables } from '../models/report-builder.model';
2
+ import { Schema } from 'mongoose';
3
+ export declare function getReportLookupSchemas(collection_root: string): CollectionTree[];
4
+ export declare function buildRbSchema(rbSchema: any): any;
5
+ /*** ye old regex pairs:
6
+ TEMP, PER FILE:
7
+ (['\s][^'\s]*id_[^'\s]+'?):\s*{
8
+ rbLookups.push({ lookup: 'AAA', local_key: $1 });
9
+ \s*rbLookups.push\s*\((\s*\{\s*lookup\:\s*'[^']*'\s*?\,?\s*)(local_key\:\s*'[^']*')\s*?\,?(\s*\})\)\;
10
+ $1$2,$3,\n
11
+ ***/
12
+ export declare function buildRbLookups(rbLookups: LookupTables[], defaultSchema: Schema<any>, default_checked_array?: string[]): any;
13
+ export declare function throwErr(err: any, lkp: any, lookupNode: any, newPropertyName?: string): void;
14
+ export declare function buildTree(current_root: any, schemaTree: any, lookup?: any): any[];
15
+ export declare function getLeafTypes(schemaTree: any, fieldPath: any): any[];
16
+ export declare function mongoCommand(commandstr: string, collection: string, field?: any): Promise<any>;