@servicelabsco/slabs-access-manager 0.1.74 → 0.1.75
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/dist/access/es6.classes.d.ts +1 -1
- package/dist/access/libraries/process.common.list.d.ts +19 -7
- package/dist/access/libraries/process.common.list.js +32 -7
- package/dist/access/libraries/process.common.list.js.map +1 -1
- package/dist/access/services/listing.service.d.ts +9 -12
- package/dist/access/services/listing.service.js +49 -47
- package/dist/access/services/listing.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -186,7 +186,7 @@ import { UserRoleSubscriber } from './subscribers/user.role.subscriber';
|
|
|
186
186
|
import { WatchlistAssignmentSubscriber } from './subscribers/watchlist.assignment.subscriber';
|
|
187
187
|
declare const es6Classes: {
|
|
188
188
|
controllers: (typeof AccessMenuController | typeof BulkUploadController | typeof BulkUploadItemController | typeof BusinessPreferenceController | typeof BusinessUserGroupController | typeof ChoiceListController | typeof ChoiceTypeController | typeof CustomFieldController | typeof DashboardController | typeof DownloadLogController | typeof GroupMemberController | typeof GroupRoleController | typeof ListingController | typeof ListingPreferenceController | typeof ScheduledReportController | typeof UserPreferenceController)[];
|
|
189
|
-
dtos: (typeof GroupRoleAttributesDto | typeof AccessBusinessParamDto | typeof AddListingPreferenceDto | typeof ListResponseDto | typeof
|
|
189
|
+
dtos: (typeof GroupRoleAttributesDto | typeof AccessBusinessParamDto | typeof AddListingPreferenceDto | typeof ListResponseDto | typeof DateRangeFilterDto | typeof DateFilterDto | typeof ListResponseFormatDto | typeof NumberRangeFilterDto | typeof CommonListFilterDto | typeof ProcessCommonListConfigDto | typeof AddBusinessPreferenceDto | typeof DbFindDto | typeof AddChoiceListDto | typeof ModifyCustomFieldStatusDto | typeof StringSearchDto | typeof AddGroupMemberDto | typeof AddRoleDto | typeof AddScheduledReportDto | typeof AddConversationDto | typeof ProcessListingPayloadDto)[];
|
|
190
190
|
entities: (typeof AccessBusinessEntity | typeof BusinessEmailEntity | typeof BusinessGroupRoleEntity | typeof BusinessUserEntity | typeof ProductEntity | typeof GroupRoleEntity | typeof BusinessUserRoleEntity | typeof MenuRoleEntity | typeof MenuEntity | typeof UiActionRoleEntity | typeof MenuActionEntity | typeof ChildMenuEntity | typeof ConversationEntity | typeof DashboardComponentEntity | typeof DownloadLogEntity | typeof EmailRecipientEntity | typeof EmailMessageEntity | typeof GroupMemberEntity | typeof PreferenceUserEntity | typeof ListingPreferenceEntity | typeof PreferenceUserGroupEntity | typeof ModuleMenuEntity | typeof ScheduledReportEntity | typeof UserRoleEntity | typeof WatchlistAssignmentEntity)[];
|
|
191
191
|
enums: (typeof CustomColumnTypeEnum)[];
|
|
192
192
|
jobs: (typeof BusinessEmailJob | typeof BusinessGroupRoleJob | typeof BusinessPreferenceJob | typeof BusinessUserGroupJob | typeof BusinessUserJob | typeof BusinessUserRoleJob | typeof ChildMenuJob | typeof ChoiceListJob | typeof ChoiceTypeJob | typeof ConversationJob | typeof CustomFieldJob | typeof CustomReportJob | typeof DashboardComponentJob | typeof DashboardJob | typeof DownloadLogJob | typeof EmailAttachmentJob | typeof EmailMessageJob | typeof EmailRecipientJob | typeof GroupMemberJob | typeof GroupRoleJob | typeof ListPreferenceJob | typeof ListingColumnJob | typeof ListingPageJob | typeof ListingPreferenceJob | typeof MenuActionJob | typeof MenuJob | typeof MenuRoleJob | typeof ModuleJob | typeof ModuleMenuJob | typeof PreferenceUserGroupJob | typeof PreferenceUsersJob | typeof ProductJob | typeof RoleGroupJob | typeof ScheduledReportProcessingJob | typeof ScheduledReportJob | typeof SyncBURoleJob | typeof UiActionJob | typeof UiActionRoleJob | typeof UserPreferenceJob | typeof UserRoleJob | typeof WatchlistAssignmentJob)[];
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { CommonListFilterDto } from
|
|
2
|
-
import { DateFilterDto } from
|
|
3
|
-
import { ListResponseDto } from
|
|
4
|
-
import { ProcessCommonListConfigDto } from
|
|
5
|
-
import { AccessBusinessEntity } from
|
|
6
|
-
import { ListingPageEntity } from
|
|
7
|
-
import { ListingService } from
|
|
1
|
+
import { CommonListFilterDto } from "../dtos/common.list.filter.dto";
|
|
2
|
+
import { DateFilterDto } from "../dtos/date.filter.dto";
|
|
3
|
+
import { ListResponseDto } from "../dtos/list.response.dto";
|
|
4
|
+
import { ProcessCommonListConfigDto } from "../dtos/process.common.list.config.dto";
|
|
5
|
+
import { AccessBusinessEntity } from "../entities/access.business.entity";
|
|
6
|
+
import { ListingPageEntity } from "../entities/listing.page.entity";
|
|
7
|
+
import { ListingService } from "../services/listing.service";
|
|
8
8
|
export declare class ProcessCommonList {
|
|
9
9
|
protected config: ProcessCommonListConfigDto;
|
|
10
|
+
protected query: string;
|
|
11
|
+
protected response: ListResponseDto;
|
|
10
12
|
protected filter: CommonListFilterDto;
|
|
11
13
|
protected restrictions: string[];
|
|
12
14
|
protected listingService: ListingService;
|
|
@@ -20,4 +22,14 @@ export declare class ProcessCommonList {
|
|
|
20
22
|
protected getScripts(): Promise<ListingPageEntity>;
|
|
21
23
|
protected getColumns(listing_id: number): Promise<string[]>;
|
|
22
24
|
protected filterBooleanColumn(field: string, column: string): void;
|
|
25
|
+
setQuery(query: string): void;
|
|
26
|
+
setFilter(filter: CommonListFilterDto): void;
|
|
27
|
+
getFilter(): CommonListFilterDto;
|
|
28
|
+
getConfig(): ProcessCommonListConfigDto;
|
|
29
|
+
getQuery(): string;
|
|
30
|
+
getBusiness(): AccessBusinessEntity;
|
|
31
|
+
getResponse(): ListResponseDto;
|
|
32
|
+
setResponse(response: ListResponseDto): void;
|
|
33
|
+
getRestrictions(): string[];
|
|
34
|
+
setRestrictions(restrictions: string[]): void;
|
|
23
35
|
}
|
|
@@ -8,17 +8,12 @@ const process_date_filter_1 = require("./process.date.filter");
|
|
|
8
8
|
class ProcessCommonList {
|
|
9
9
|
constructor() {
|
|
10
10
|
this.config = {};
|
|
11
|
+
this.response = { stats: {}, metrics: {}, records: [] };
|
|
11
12
|
this.restrictions = [];
|
|
12
13
|
}
|
|
13
14
|
async handle() {
|
|
14
|
-
const payload = {
|
|
15
|
-
config: this.config,
|
|
16
|
-
restrictions: this.restrictions,
|
|
17
|
-
filter: this.filter,
|
|
18
|
-
business_id: this.business.id,
|
|
19
|
-
};
|
|
20
15
|
this.filter.order = this.getOrder();
|
|
21
|
-
return this.listingService.handle(
|
|
16
|
+
return this.listingService.handle(this);
|
|
22
17
|
}
|
|
23
18
|
processDate(date, column) {
|
|
24
19
|
const range = new process_date_filter_1.ProcessDateFilter().process(date);
|
|
@@ -79,6 +74,36 @@ class ProcessCommonList {
|
|
|
79
74
|
return;
|
|
80
75
|
this.restrictions.push(`${column} = ${this.filter[field]}`);
|
|
81
76
|
}
|
|
77
|
+
setQuery(query) {
|
|
78
|
+
this.query = query;
|
|
79
|
+
}
|
|
80
|
+
setFilter(filter) {
|
|
81
|
+
this.filter = filter;
|
|
82
|
+
}
|
|
83
|
+
getFilter() {
|
|
84
|
+
return this.filter;
|
|
85
|
+
}
|
|
86
|
+
getConfig() {
|
|
87
|
+
return this.config;
|
|
88
|
+
}
|
|
89
|
+
getQuery() {
|
|
90
|
+
return this.query;
|
|
91
|
+
}
|
|
92
|
+
getBusiness() {
|
|
93
|
+
return this.business;
|
|
94
|
+
}
|
|
95
|
+
getResponse() {
|
|
96
|
+
return this.response;
|
|
97
|
+
}
|
|
98
|
+
setResponse(response) {
|
|
99
|
+
this.response = response;
|
|
100
|
+
}
|
|
101
|
+
getRestrictions() {
|
|
102
|
+
return this.restrictions;
|
|
103
|
+
}
|
|
104
|
+
setRestrictions(restrictions) {
|
|
105
|
+
this.restrictions = restrictions;
|
|
106
|
+
}
|
|
82
107
|
}
|
|
83
108
|
exports.ProcessCommonList = ProcessCommonList;
|
|
84
109
|
//# sourceMappingURL=process.common.list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.common.list.js","sourceRoot":"","sources":["../../../src/access/libraries/process.common.list.ts"],"names":[],"mappings":";;;A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,CAAC;IACzB,CAAC;IAED,WAAW,CAAC,QAAyB;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,eAAe,CAAC,YAAsB;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;CACJ;AAxKD,8CAwKC"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { AccessService, CacheService, PropertyService, SqlService, UploadService } from '@servicelabsco/nestjs-utility-services';
|
|
2
2
|
import { AddListingPreferenceDto } from '../dtos/add.listing.preference.dto';
|
|
3
3
|
import { ListResponseDto } from '../dtos/list.response.dto';
|
|
4
|
-
import { ProcessListingPayloadDto } from '../dtos/process.listing.payload.dto';
|
|
5
4
|
import { AccessBusinessEntity } from '../entities/access.business.entity';
|
|
6
5
|
import { ListingColumnEntity } from '../entities/listing.column.entity';
|
|
7
6
|
import { ListingPageEntity } from '../entities/listing.page.entity';
|
|
8
7
|
import { ListingPreferenceEntity } from '../entities/listing.preference.entity';
|
|
8
|
+
import { ProcessCommonList } from '../libraries/process.common.list';
|
|
9
9
|
export declare class ListingService {
|
|
10
10
|
private readonly accessService;
|
|
11
11
|
private readonly sqlService;
|
|
12
12
|
private readonly uploadService;
|
|
13
13
|
private readonly propertyService;
|
|
14
14
|
private readonly cacheService;
|
|
15
|
-
private payload;
|
|
16
|
-
private query;
|
|
17
|
-
private response;
|
|
18
15
|
constructor(accessService: AccessService, sqlService: SqlService, uploadService: UploadService, propertyService: PropertyService, cacheService: CacheService);
|
|
19
16
|
savePreference(listing: ListingPageEntity, business: AccessBusinessEntity, payload: AddListingPreferenceDto): Promise<ListingPreferenceEntity>;
|
|
20
17
|
private saveGlobalPreference;
|
|
@@ -26,16 +23,16 @@ export declare class ListingService {
|
|
|
26
23
|
private canSetGlobal;
|
|
27
24
|
getDownloadLimit(businessId: number): Promise<number>;
|
|
28
25
|
private getDbDownloadLimit;
|
|
29
|
-
handle(
|
|
30
|
-
getListRecords(): Promise<ListResponseDto>;
|
|
31
|
-
getTotalRecords(): Promise<void>;
|
|
32
|
-
getQueryRestrictions(): string;
|
|
33
|
-
getQuery(): string;
|
|
34
|
-
getRecords(): Promise<void>;
|
|
35
|
-
aggregate(): Promise<{
|
|
26
|
+
handle(listing: ProcessCommonList): Promise<ListResponseDto>;
|
|
27
|
+
getListRecords(listing: ProcessCommonList): Promise<ListResponseDto>;
|
|
28
|
+
getTotalRecords(listing: ProcessCommonList): Promise<void>;
|
|
29
|
+
getQueryRestrictions(listing: ProcessCommonList): string;
|
|
30
|
+
getQuery(listing: ProcessCommonList): string;
|
|
31
|
+
getRecords(listing: ProcessCommonList): Promise<void>;
|
|
32
|
+
aggregate(listing: ProcessCommonList): Promise<{
|
|
36
33
|
aggregate: any;
|
|
37
34
|
}>;
|
|
38
|
-
generateCsv(
|
|
35
|
+
generateCsv(listing: ProcessCommonList): Promise<{
|
|
39
36
|
url: string;
|
|
40
37
|
}>;
|
|
41
38
|
}
|
|
@@ -25,7 +25,6 @@ let ListingService = class ListingService {
|
|
|
25
25
|
this.uploadService = uploadService;
|
|
26
26
|
this.propertyService = propertyService;
|
|
27
27
|
this.cacheService = cacheService;
|
|
28
|
-
this.response = { stats: {}, metrics: {}, records: [] };
|
|
29
28
|
}
|
|
30
29
|
async savePreference(listing, business, payload) {
|
|
31
30
|
if (payload.is_global && this.canSetGlobal())
|
|
@@ -95,83 +94,86 @@ let ListingService = class ListingService {
|
|
|
95
94
|
return +businessPreference.preference['csv_download_limit'];
|
|
96
95
|
return +(await this.propertyService.get('csv.download.limit'));
|
|
97
96
|
}
|
|
98
|
-
async handle(
|
|
99
|
-
this.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
await this.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (this.payload.filter?.no_metrics || this.payload.filter?.format?.csv)
|
|
97
|
+
async handle(listing) {
|
|
98
|
+
listing.setQuery(this.getQuery(listing));
|
|
99
|
+
if (listing.getFilter().aggregate)
|
|
100
|
+
return this.aggregate(listing);
|
|
101
|
+
if (listing.getFilter().format?.csv)
|
|
102
|
+
return this.generateCsv(listing);
|
|
103
|
+
return this.getListRecords(listing);
|
|
104
|
+
}
|
|
105
|
+
async getListRecords(listing) {
|
|
106
|
+
await this.getRecords(listing);
|
|
107
|
+
await this.getTotalRecords(listing);
|
|
108
|
+
return listing.getResponse();
|
|
109
|
+
}
|
|
110
|
+
async getTotalRecords(listing) {
|
|
111
|
+
if (listing.getFilter()?.no_metrics || listing.getFilter()?.format?.csv)
|
|
114
112
|
return;
|
|
115
|
-
const metrics =
|
|
113
|
+
const metrics = listing.getConfig()?.metrics || [];
|
|
116
114
|
metrics.push(`count(1) count`);
|
|
117
|
-
const sql = `select ${metrics.join(',')} from ${
|
|
115
|
+
const sql = `select ${metrics.join(',')} from ${listing.getQuery()}`;
|
|
118
116
|
const record = await this.sqlService.readFirst(sql);
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
let response = listing.getResponse();
|
|
118
|
+
response.stats.total = record.count;
|
|
119
|
+
response.metrics = {};
|
|
121
120
|
for (const [key, value] of Object.entries(record)) {
|
|
122
121
|
if (key === 'count')
|
|
123
122
|
continue;
|
|
124
|
-
|
|
123
|
+
response.metrics[key] = value;
|
|
125
124
|
}
|
|
125
|
+
listing.setResponse(response);
|
|
126
126
|
}
|
|
127
|
-
getQueryRestrictions() {
|
|
128
|
-
if (!
|
|
127
|
+
getQueryRestrictions(listing) {
|
|
128
|
+
if (!listing.getRestrictions().length)
|
|
129
129
|
return;
|
|
130
130
|
const record = [];
|
|
131
|
-
|
|
131
|
+
listing.getRestrictions().forEach((restriction) => {
|
|
132
132
|
record.push(` ( ${restriction} ) `);
|
|
133
133
|
});
|
|
134
134
|
return record.join('and');
|
|
135
135
|
}
|
|
136
|
-
getQuery() {
|
|
137
|
-
const restrictions = this.getQueryRestrictions();
|
|
138
|
-
const columns =
|
|
139
|
-
let sql = `select ${columns} from ${
|
|
136
|
+
getQuery(listing) {
|
|
137
|
+
const restrictions = this.getQueryRestrictions(listing);
|
|
138
|
+
const columns = listing.getConfig().columns.join(',');
|
|
139
|
+
let sql = `select ${columns} from ${listing.getConfig().sql}`;
|
|
140
140
|
if (restrictions)
|
|
141
141
|
sql = `${sql} and ${restrictions} `;
|
|
142
|
-
if (
|
|
143
|
-
return `(${sql}) sq where ${
|
|
142
|
+
if (listing.getFilter().filter_query)
|
|
143
|
+
return `(${sql}) sq where ${listing.getFilter().filter_query}`;
|
|
144
144
|
return `(${sql}) sq`;
|
|
145
145
|
}
|
|
146
|
-
async getRecords() {
|
|
147
|
-
const filter =
|
|
146
|
+
async getRecords(listing) {
|
|
147
|
+
const filter = listing.getFilter();
|
|
148
148
|
const limit = filter.limit ?? 20;
|
|
149
149
|
const page = filter.page || 1;
|
|
150
150
|
const offset = (page - 1) * limit;
|
|
151
|
-
const order =
|
|
152
|
-
const sql = `select sq.* from ${
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
151
|
+
const order = listing.getFilter().order || listing.getConfig().order || 'sq.created_at desc';
|
|
152
|
+
const sql = `select sq.* from ${listing.getQuery()} order by ${order} limit ${limit} offset ${offset}`;
|
|
153
|
+
let response = listing.getResponse();
|
|
154
|
+
response.stats.limit = limit;
|
|
155
|
+
response.stats.page = page;
|
|
156
|
+
response.records = await this.sqlService.read(sql);
|
|
157
|
+
listing.setResponse(response);
|
|
158
|
+
}
|
|
159
|
+
async aggregate(listing) {
|
|
160
|
+
const aggregate = listing.getFilter().aggregate;
|
|
159
161
|
const supportedOperations = ['avg', 'sum', 'max', 'min'];
|
|
160
162
|
const key = Object.keys(aggregate)[0];
|
|
161
163
|
if (supportedOperations.indexOf(key) === -1)
|
|
162
164
|
throw new nestjs_utility_services_1.OperationException(`Given aggregate function ${key} is not supported`);
|
|
163
165
|
const value = Object.values(aggregate)[0];
|
|
164
|
-
const sql = `select ${key}(sq.${value}) aggregate from ${
|
|
166
|
+
const sql = `select ${key}(sq.${value}) aggregate from ${listing.getQuery()}`;
|
|
165
167
|
const response = await this.sqlService.readFirst(sql);
|
|
166
168
|
return { aggregate: response.aggregate };
|
|
167
169
|
}
|
|
168
|
-
async generateCsv(
|
|
169
|
-
if (!
|
|
170
|
+
async generateCsv(listing) {
|
|
171
|
+
if (!listing.getFilter()?.listing_slug)
|
|
170
172
|
throw new nestjs_utility_services_1.OperationException(`listing slug is mandatory for csv exports`);
|
|
171
|
-
const limit = await this.getDownloadLimit(
|
|
172
|
-
const dataSql = `select sq.* from ${
|
|
173
|
+
const limit = await this.getDownloadLimit(listing.getBusiness().id);
|
|
174
|
+
const dataSql = `select sq.* from ${listing.getQuery()} limit ${limit}`;
|
|
173
175
|
const records = await this.sqlService.read(dataSql);
|
|
174
|
-
return new process_listing_csv_file_1.ProcessListingCsvFile(this.uploadService, this.sqlService).process(
|
|
176
|
+
return new process_listing_csv_file_1.ProcessListingCsvFile(this.uploadService, this.sqlService).process(listing.getFilter().listing_slug, records);
|
|
175
177
|
}
|
|
176
178
|
};
|
|
177
179
|
exports.ListingService = ListingService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listing.service.js","sourceRoot":"","sources":["../../../src/access/services/listing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,oFASgD;AAChD,uCAAoC;AACpC,qCAAiC;
|
|
1
|
+
{"version":3,"file":"listing.service.js","sourceRoot":"","sources":["../../../src/access/services/listing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,oFASgD;AAChD,uCAAoC;AACpC,qCAAiC;AAIjC,uFAAkF;AAClF,6EAAwE;AAExE,qFAAgF;AAChF,oFAA8E;AAIvE,I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