rez_core 1.1.6 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -79,9 +79,8 @@ export class FilterService {
79
79
  } = dto;
80
80
 
81
81
  // Fetch meta
82
- const entityMeta =
83
- await this.entityMasterService.getEntityData(entity_type);
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
- tableName,
130
+ getTableMeta.data_source,
132
131
  tabs?.columnName,
133
132
  baseWhere,
134
133
  );
@@ -368,6 +367,10 @@ export class FilterService {
368
367
  val: any,
369
368
  key: string,
370
369
  ) {
370
+ if (Array.isArray(val) && val.length === 0) {
371
+ return { query: `e.${attr}`, params: {} };
372
+ }
373
+
371
374
  if ((op === 'equal' || op === 'not_equal') && !Array.isArray(val)) {
372
375
  throw new BadRequestException(
373
376
  `Value for multi-select must be an array for operator: ${op}`,
@@ -11,12 +11,18 @@ export class EntityTableRepository {
11
11
  ) {}
12
12
 
13
13
  async findByEntityTypeAndListType(entityType: string, listType: string) {
14
- const temp = await this.entityTableRepository.findOne({
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
- private readonly listMasterService: ListMasterService,
17
-
18
- private readonly savedFilterRepoService: SavedFilterRepositoryService,
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(entityType: string, listType: string,userId?: number) {
42
- return await this.getTableMetaData(entityType, listType, DISPLAY_LIST,userId);
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
- entityTableDto.operation_list = {
65
- "text": await this.listMasterService.getDropdownOptions("OPT",{}),
66
- "number": await this.listMasterService.getDropdownOptions("OPN",{}),
67
- "date": await this.listMasterService.getDropdownOptions("OPD",{}),
68
- "select": await this.listMasterService.getDropdownOptions("OPS",{}),
69
- "multiselect": await this.listMasterService.getDropdownOptions("OPM",{})
70
- // Add any other operations you want to include
71
- };
72
- entityTableDto.default_filter= await this.savedFilterRepoService.getDefaultFilterByEntityType(entityTable.list_type);
73
- if(userId){
74
- entityTableDto.saved_filter = await this.savedFilterRepoService.getSavedFiltersByUserIdAndEntityType(userId, entityTable.list_type);
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
  }