rez_core 1.1.5 → 1.1.7
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/module/filter/service/filter.service.js +17 -12
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/meta/controller/meta.controller.js.map +1 -1
- package/dist/module/meta/repository/entity-table.repository.d.ts +1 -0
- package/dist/module/meta/repository/entity-table.repository.js +5 -0
- package/dist/module/meta/repository/entity-table.repository.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.d.ts +1 -0
- package/dist/module/meta/service/entity-table.service.js +21 -7
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/service/filter.service.ts +44 -40
- package/src/module/meta/controller/meta.controller.ts +0 -1
- package/src/module/meta/repository/entity-table.repository.ts +7 -1
- package/src/module/meta/service/entity-table.service.ts +54 -22
package/package.json
CHANGED
|
@@ -79,9 +79,8 @@ export class FilterService {
|
|
|
79
79
|
} = dto;
|
|
80
80
|
|
|
81
81
|
// Fetch meta
|
|
82
|
-
const entityMeta =
|
|
83
|
-
|
|
84
|
-
const tableName = entityMeta?.db_table_name;
|
|
82
|
+
const entityMeta = await this.entityTableService.getEntityData(entity_type);
|
|
83
|
+
const tableName = entityMeta?.data_source; // data_souce is the table name
|
|
85
84
|
if (!tableName)
|
|
86
85
|
throw new BadRequestException(`Invalid entity_type: ${entity_type}`);
|
|
87
86
|
|
|
@@ -128,7 +127,7 @@ export class FilterService {
|
|
|
128
127
|
|
|
129
128
|
// Build query for tab counts (no tab.value filter here)
|
|
130
129
|
const allTabs = await this.gettab_value_counts(
|
|
131
|
-
|
|
130
|
+
getTableMeta.data_source,
|
|
132
131
|
tabs?.columnName,
|
|
133
132
|
baseWhere,
|
|
134
133
|
);
|
|
@@ -249,11 +248,13 @@ export class FilterService {
|
|
|
249
248
|
): { query: string; params: any } | null {
|
|
250
249
|
if (!meta) return null;
|
|
251
250
|
|
|
252
|
-
|
|
251
|
+
let attr = filter.filter_attribute;
|
|
253
252
|
const val = filter.filter_value;
|
|
254
253
|
const op = filter.filter_operator;
|
|
255
254
|
const key = `param_${attr}_${Math.random().toString(36).substring(2, 8)}`;
|
|
256
255
|
|
|
256
|
+
if (meta.data_source_type === 'entity') attr = `${attr}_id`;
|
|
257
|
+
|
|
257
258
|
switch (meta.data_type) {
|
|
258
259
|
case 'text':
|
|
259
260
|
return this.buildTextCondition(attr, op, val, key);
|
|
@@ -344,16 +345,16 @@ export class FilterService {
|
|
|
344
345
|
) {
|
|
345
346
|
switch (op) {
|
|
346
347
|
case 'equal':
|
|
347
|
-
return { query: `e.${attr}
|
|
348
|
+
return { query: `e.${attr} = :${key}`, params: { [key]: val } };
|
|
348
349
|
|
|
349
350
|
case 'not_equal':
|
|
350
|
-
return { query: `e.${attr}
|
|
351
|
+
return { query: `e.${attr} != :${key}`, params: { [key]: val } };
|
|
351
352
|
|
|
352
353
|
case 'empty':
|
|
353
|
-
return { query: `e.${attr}
|
|
354
|
+
return { query: `e.${attr} IS NULL`, params: {} };
|
|
354
355
|
|
|
355
356
|
case 'not_empty':
|
|
356
|
-
return { query: `e.${attr}
|
|
357
|
+
return { query: `e.${attr} IS NOT NULL`, params: {} };
|
|
357
358
|
|
|
358
359
|
default:
|
|
359
360
|
throw new BadRequestException(`Unsupported operator for select: ${op}`);
|
|
@@ -361,41 +362,44 @@ export class FilterService {
|
|
|
361
362
|
}
|
|
362
363
|
|
|
363
364
|
private buildMultiSelectCondition(
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
);
|
|
373
|
-
}
|
|
365
|
+
attr: string,
|
|
366
|
+
op: string,
|
|
367
|
+
val: any,
|
|
368
|
+
key: string,
|
|
369
|
+
) {
|
|
370
|
+
if (Array.isArray(val) && val.length === 0) {
|
|
371
|
+
return { query: `e.${attr}`, params: {} };
|
|
372
|
+
}
|
|
374
373
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
};
|
|
374
|
+
if ((op === 'equal' || op === 'not_equal') && !Array.isArray(val)) {
|
|
375
|
+
throw new BadRequestException(
|
|
376
|
+
`Value for multi-select must be an array for operator: ${op}`,
|
|
377
|
+
);
|
|
378
|
+
}
|
|
381
379
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
380
|
+
switch (op) {
|
|
381
|
+
case 'equal':
|
|
382
|
+
return {
|
|
383
|
+
query: `e.${attr} IN (:${key})`, // ✅ use (:key)
|
|
384
|
+
params: { [key]: val },
|
|
385
|
+
};
|
|
387
386
|
|
|
388
|
-
|
|
389
|
-
|
|
387
|
+
case 'not_equal':
|
|
388
|
+
return {
|
|
389
|
+
query: `e.${attr} NOT IN (:${key})`, // ✅ use (:key)
|
|
390
|
+
params: { [key]: val },
|
|
391
|
+
};
|
|
390
392
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
+
case 'empty':
|
|
394
|
+
return { query: `e.${attr} IS NULL`, params: {} };
|
|
393
395
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
`Unsupported operator for multiselect: ${op}`,
|
|
397
|
-
);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
396
|
+
case 'not_empty':
|
|
397
|
+
return { query: `e.${attr} IS NOT NULL`, params: {} };
|
|
400
398
|
|
|
399
|
+
default:
|
|
400
|
+
throw new BadRequestException(
|
|
401
|
+
`Unsupported operator for multiselect: ${op}`,
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
401
405
|
}
|
|
@@ -11,12 +11,18 @@ export class EntityTableRepository {
|
|
|
11
11
|
) {}
|
|
12
12
|
|
|
13
13
|
async findByEntityTypeAndListType(entityType: string, listType: string) {
|
|
14
|
-
const temp =
|
|
14
|
+
const temp = await this.entityTableRepository.findOne({
|
|
15
15
|
where: { mapped_entity_type: entityType, list_type: listType },
|
|
16
16
|
});
|
|
17
17
|
return temp;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
async findByMappedEntityType(mappedEntityType: string) {
|
|
21
|
+
return await this.entityTableRepository.findOne({
|
|
22
|
+
where: { mapped_entity_type: mappedEntityType, display_type: 'LIST' },
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
async findByEntityTypeAndListTypeAndDisplayType(
|
|
21
27
|
entityType: string,
|
|
22
28
|
listType: string,
|
|
@@ -12,11 +12,29 @@ export class EntityTableService {
|
|
|
12
12
|
constructor(
|
|
13
13
|
private entityTableRepository: EntityTableRepository,
|
|
14
14
|
private readonly entityTableColumnRepository: EntityTableColumnRepository,
|
|
15
|
-
@Inject(forwardRef(() => ListMasterService))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
) {
|
|
15
|
+
@Inject(forwardRef(() => ListMasterService))
|
|
16
|
+
private readonly listMasterService: ListMasterService,
|
|
17
|
+
|
|
18
|
+
private readonly savedFilterRepoService: SavedFilterRepositoryService,
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
async getEntityData(mappedEntityType: string | null) {
|
|
22
|
+
if (mappedEntityType) {
|
|
23
|
+
const tableMaster =
|
|
24
|
+
await this.entityTableRepository.findByMappedEntityType(
|
|
25
|
+
mappedEntityType,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (!tableMaster) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Entity with mappedEntityType "${mappedEntityType}" not found.`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return tableMaster;
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error();
|
|
37
|
+
}
|
|
20
38
|
}
|
|
21
39
|
|
|
22
40
|
async findByEntityTypeAndListType(entityType: string, listType: string) {
|
|
@@ -38,15 +56,24 @@ export class EntityTableService {
|
|
|
38
56
|
);
|
|
39
57
|
}
|
|
40
58
|
|
|
41
|
-
async getTableMetaDataForListing(
|
|
42
|
-
|
|
59
|
+
async getTableMetaDataForListing(
|
|
60
|
+
entityType: string,
|
|
61
|
+
listType: string,
|
|
62
|
+
userId?: number,
|
|
63
|
+
) {
|
|
64
|
+
return await this.getTableMetaData(
|
|
65
|
+
entityType,
|
|
66
|
+
listType,
|
|
67
|
+
DISPLAY_LIST,
|
|
68
|
+
userId,
|
|
69
|
+
);
|
|
43
70
|
}
|
|
44
71
|
|
|
45
72
|
async getTableMetaData(
|
|
46
73
|
entityType: string,
|
|
47
74
|
listType: string,
|
|
48
75
|
displayType: string,
|
|
49
|
-
userId?: number
|
|
76
|
+
userId?: number,
|
|
50
77
|
) {
|
|
51
78
|
let entityTable = await this.findByEntityTypeAndListTypeAndDisplayType(
|
|
52
79
|
entityType,
|
|
@@ -61,22 +88,27 @@ export class EntityTableService {
|
|
|
61
88
|
entityTable.id,
|
|
62
89
|
entityTable.entity_type,
|
|
63
90
|
);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
entityTableDto.operation_list = {
|
|
92
|
+
text: await this.listMasterService.getDropdownOptions('OPT', {}),
|
|
93
|
+
number: await this.listMasterService.getDropdownOptions('OPN', {}),
|
|
94
|
+
date: await this.listMasterService.getDropdownOptions('OPD', {}),
|
|
95
|
+
select: await this.listMasterService.getDropdownOptions('OPS', {}),
|
|
96
|
+
multiselect: await this.listMasterService.getDropdownOptions('OPM', {}),
|
|
97
|
+
// Add any other operations you want to include
|
|
98
|
+
};
|
|
99
|
+
entityTableDto.default_filter =
|
|
100
|
+
await this.savedFilterRepoService.getDefaultFilterByEntityType(
|
|
101
|
+
entityTable.list_type,
|
|
102
|
+
);
|
|
103
|
+
if (userId) {
|
|
104
|
+
entityTableDto.saved_filter =
|
|
105
|
+
await this.savedFilterRepoService.getSavedFiltersByUserIdAndEntityType(
|
|
106
|
+
userId,
|
|
107
|
+
entityTable.list_type,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
76
110
|
}
|
|
77
111
|
|
|
78
|
-
|
|
79
|
-
|
|
80
112
|
return entityTableDto;
|
|
81
113
|
}
|
|
82
114
|
}
|