rez_core 5.0.155 → 5.0.157
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/config/bull.config.js +4 -4
- package/dist/config/bull.config.js.map +1 -1
- package/dist/config/database.config.js +1 -1
- package/dist/config/database.config.js.map +1 -1
- package/dist/core.module.js +5 -2
- package/dist/core.module.js.map +1 -1
- package/dist/migrations/1732612800000-AddEntityJsonGinIndex.d.ts +6 -0
- package/dist/migrations/1732612800000-AddEntityJsonGinIndex.js +32 -0
- package/dist/migrations/1732612800000-AddEntityJsonGinIndex.js.map +1 -0
- package/dist/module/entity_json/controller/entity_json.controller.d.ts +2 -9
- package/dist/module/entity_json/entity/entityJson.entity.d.ts +2 -1
- package/dist/module/entity_json/entity/entityJson.entity.js +5 -1
- package/dist/module/entity_json/entity/entityJson.entity.js.map +1 -1
- package/dist/module/entity_json/entity_json.module.js +7 -2
- package/dist/module/entity_json/entity_json.module.js.map +1 -1
- package/dist/module/entity_json/service/entity_json.service.d.ts +2 -10
- package/dist/module/entity_json/service/entity_json.service.js +54 -4
- package/dist/module/entity_json/service/entity_json.service.js.map +1 -1
- package/dist/module/filter/controller/filter.controller.d.ts +12 -0
- package/dist/module/filter/controller/filter.controller.js +1 -1
- package/dist/module/filter/controller/filter.controller.js.map +1 -1
- package/dist/module/filter/entity/saved-filter-master.entity.d.ts +1 -2
- package/dist/module/filter/entity/saved-filter-master.entity.js +2 -6
- package/dist/module/filter/entity/saved-filter-master.entity.js.map +1 -1
- package/dist/module/filter/filter.module.js +11 -2
- package/dist/module/filter/filter.module.js.map +1 -1
- package/dist/module/filter/repository/saved-filter.repository.d.ts +5 -1
- package/dist/module/filter/repository/saved-filter.repository.js +5 -1
- package/dist/module/filter/repository/saved-filter.repository.js.map +1 -1
- package/dist/module/filter/service/filter.service.d.ts +37 -1
- package/dist/module/filter/service/filter.service.js +31 -43
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/filter/service/flatjson-filter.service.d.ts +32 -0
- package/dist/module/filter/service/flatjson-filter.service.js +626 -0
- package/dist/module/filter/service/flatjson-filter.service.js.map +1 -0
- package/dist/module/integration/service/wrapper.service.d.ts +1 -3
- package/dist/module/integration/service/wrapper.service.js +2 -24
- package/dist/module/integration/service/wrapper.service.js.map +1 -1
- package/dist/module/linked_attributes/controller/linked_attributes.controller.d.ts +19 -0
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js +77 -0
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js.map +1 -1
- package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.d.ts +13 -0
- package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.js +64 -0
- package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.js.map +1 -0
- package/dist/module/linked_attributes/linked_attributes.module.js +8 -1
- package/dist/module/linked_attributes/linked_attributes.module.js.map +1 -1
- package/dist/module/linked_attributes/service/linked_attributes.service.d.ts +41 -1
- package/dist/module/linked_attributes/service/linked_attributes.service.js +266 -2
- package/dist/module/linked_attributes/service/linked_attributes.service.js.map +1 -1
- package/dist/module/meta/dto/entity-table.dto.d.ts +4 -1
- package/dist/module/meta/dto/entity-table.dto.js.map +1 -1
- package/dist/module/meta/service/media-data.service.js +5 -18
- package/dist/module/meta/service/media-data.service.js.map +1 -1
- package/dist/module/workflow/service/action.service.js +10 -2
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.js +5 -4
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/table.config.d.ts +3 -1
- package/dist/table.config.js +2 -0
- package/dist/table.config.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/config/bull.config.ts +4 -4
- package/src/config/database.config.ts +1 -1
- package/src/core.module.ts +5 -2
- package/src/migrations/1732612800000-AddEntityJsonGinIndex.ts +41 -0
- package/src/module/entity_json/docs/FlatJson_Filterin_System.md +2804 -0
- package/src/module/entity_json/entity/entityJson.entity.ts +4 -1
- package/src/module/entity_json/entity_json.module.ts +8 -3
- package/src/module/entity_json/service/entity_json.service.ts +139 -32
- package/src/module/filter/controller/filter.controller.ts +1 -3
- package/src/module/filter/entity/saved-filter-master.entity.ts +2 -5
- package/src/module/filter/filter.module.ts +11 -2
- package/src/module/filter/repository/saved-filter.repository.ts +5 -9
- package/src/module/filter/service/filter.service.ts +115 -67
- package/src/module/filter/service/flatjson-filter.service.ts +902 -0
- package/src/module/filter/test/flatjson-filter.service.spec.ts +415 -0
- package/src/module/integration/service/wrapper.service.ts +0 -37
- package/src/module/linked_attributes/controller/linked_attributes.controller.ts +86 -0
- package/src/module/linked_attributes/dto/create-linked-attribute-smart.dto.ts +54 -0
- package/src/module/linked_attributes/linked_attributes.module.ts +9 -2
- package/src/module/linked_attributes/service/linked_attributes.service.ts +548 -3
- package/src/module/linked_attributes/test/linked-attributes.service.spec.ts +244 -0
- package/src/module/meta/dto/entity-table.dto.ts +1 -3
- package/src/module/meta/service/media-data.service.ts +9 -27
- package/src/module/workflow/service/action.service.ts +10 -6
- package/src/module/workflow/service/task.service.ts +13 -14
- package/src/table.config.ts +2 -0
|
@@ -29,11 +29,14 @@ export class EntityJson {
|
|
|
29
29
|
created_by: number;
|
|
30
30
|
|
|
31
31
|
@Column({ type: 'int', nullable: true })
|
|
32
|
-
|
|
32
|
+
organization_id: number;
|
|
33
33
|
|
|
34
34
|
@CreateDateColumn({ type: 'timestamp', nullable: true })
|
|
35
35
|
created_at: Date;
|
|
36
36
|
|
|
37
37
|
@UpdateDateColumn({ type: 'timestamp', nullable: true })
|
|
38
38
|
updated_at: Date;
|
|
39
|
+
|
|
40
|
+
@UpdateDateColumn({ type: 'varchar', nullable: true })
|
|
41
|
+
updated_by: string;
|
|
39
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Module } from '@nestjs/common';
|
|
1
|
+
import { Module, forwardRef } from '@nestjs/common';
|
|
2
2
|
import { EntityModule } from '../meta/entity.module';
|
|
3
3
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
4
4
|
import { EntityJSONService } from './service/entity_json.service';
|
|
@@ -10,9 +10,14 @@ import { EntityJSONRepository } from './service/entityJson.repository';
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@Module({
|
|
13
|
-
imports: [
|
|
13
|
+
imports: [
|
|
14
|
+
forwardRef(() => EntityModule),
|
|
15
|
+
TypeOrmModule.forFeature([EntityJson]),
|
|
16
|
+
forwardRef(() => FilterModule),
|
|
17
|
+
UtilsModule,
|
|
18
|
+
],
|
|
14
19
|
controllers: [EntityJSONController],
|
|
15
20
|
providers: [EntityJSONService,EntityJSONRepository],
|
|
16
|
-
exports: [],
|
|
21
|
+
exports: [EntityJSONService],
|
|
17
22
|
})
|
|
18
23
|
export class EntityJSONModule {}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable, forwardRef } from '@nestjs/common';
|
|
2
2
|
import { LinkedAttributes } from 'src/module/linked_attributes/entity/linked_attribute.entity';
|
|
3
3
|
import { AttributeMaster } from 'src/module/meta/entity/attribute-master.entity';
|
|
4
4
|
import { EntityRelation } from 'src/module/meta/entity/entity-relation.entity';
|
|
@@ -14,6 +14,7 @@ export class EntityJSONService extends EntityServiceImpl {
|
|
|
14
14
|
private readonly dataSource: DataSource,
|
|
15
15
|
private readonly loggerService: LoggingService,
|
|
16
16
|
private readonly EntityJSONRepository: EntityJSONRepository,
|
|
17
|
+
@Inject(forwardRef(() => FilterService))
|
|
17
18
|
private readonly filterService: FilterService,
|
|
18
19
|
) {
|
|
19
20
|
super();
|
|
@@ -22,22 +23,40 @@ export class EntityJSONService extends EntityServiceImpl {
|
|
|
22
23
|
async getAttributeForFlatJSON(
|
|
23
24
|
entityType: string,
|
|
24
25
|
loggedInUser: any,
|
|
25
|
-
flag?: 'flat_json' | 'dropdown' | 'all',
|
|
26
|
-
) {
|
|
26
|
+
flag?: 'flat_json' | 'dropdown' | 'all' | 'filter_attribute',
|
|
27
|
+
) : Promise<any> {
|
|
27
28
|
const orgId = loggedInUser.organization_id;
|
|
28
|
-
|
|
29
|
-
await this.loggerService.log(
|
|
30
|
-
|
|
29
|
+
|
|
30
|
+
await this.loggerService.log(
|
|
31
|
+
'info',
|
|
32
|
+
'EntityJSONService',
|
|
33
|
+
'getAttributeForFlatJSON',
|
|
34
|
+
`Loading attributes for entity: ${entityType}, org: ${orgId}`,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// MAIN ATTRIBUTES
|
|
31
38
|
const mainAttributes = await this.dataSource
|
|
32
39
|
.getRepository(AttributeMaster)
|
|
33
40
|
.createQueryBuilder('attr')
|
|
34
|
-
.select([
|
|
41
|
+
.select([
|
|
42
|
+
'attr.id',
|
|
43
|
+
'attr.name',
|
|
44
|
+
'attr.flat_json_key',
|
|
45
|
+
'attr.attribute_key',
|
|
46
|
+
'attr.data_type',
|
|
47
|
+
])
|
|
35
48
|
.where('attr.mapped_entity_type = :entityType', { entityType })
|
|
36
49
|
.andWhere('attr.organization_id = :orgId', { orgId })
|
|
37
50
|
.getMany();
|
|
38
|
-
|
|
39
|
-
await this.loggerService.log(
|
|
40
|
-
|
|
51
|
+
|
|
52
|
+
await this.loggerService.log(
|
|
53
|
+
'debug',
|
|
54
|
+
'EntityJSONService',
|
|
55
|
+
'getAttributeForFlatJSON',
|
|
56
|
+
`Loaded ${mainAttributes.length} main attributes`,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// RELATED ENTITY TYPES
|
|
41
60
|
const relatedEntityTypes = await this.dataSource
|
|
42
61
|
.getRepository(EntityRelation)
|
|
43
62
|
.createQueryBuilder('rel')
|
|
@@ -46,23 +65,42 @@ export class EntityJSONService extends EntityServiceImpl {
|
|
|
46
65
|
.andWhere('rel.organization_id = :orgId', { orgId })
|
|
47
66
|
.andWhere('rel.relation_type = :relationType', { relationType: 'ONE_TO_ONE' })
|
|
48
67
|
.getRawMany();
|
|
49
|
-
|
|
68
|
+
|
|
50
69
|
const relatedTypesList = relatedEntityTypes.map(x => x.rel_target_entity_type);
|
|
51
|
-
|
|
52
|
-
await this.loggerService.log(
|
|
53
|
-
|
|
70
|
+
|
|
71
|
+
await this.loggerService.log(
|
|
72
|
+
'debug',
|
|
73
|
+
'EntityJSONService',
|
|
74
|
+
'getAttributeForFlatJSON',
|
|
75
|
+
`Found ${relatedTypesList.length} ONE-TO-ONE related entity types`,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// RELATED ATTRIBUTES
|
|
54
79
|
const relatedAttributes = relatedTypesList.length
|
|
55
80
|
? await this.dataSource
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
81
|
+
.getRepository(AttributeMaster)
|
|
82
|
+
.createQueryBuilder('attr')
|
|
83
|
+
.select([
|
|
84
|
+
'attr.id',
|
|
85
|
+
'attr.name',
|
|
86
|
+
'attr.flat_json_key',
|
|
87
|
+
'attr.mapped_entity_type',
|
|
88
|
+
'attr.attribute_key',
|
|
89
|
+
'attr.data_type',
|
|
90
|
+
])
|
|
91
|
+
.where('attr.mapped_entity_type IN (:...types)', { types: relatedTypesList })
|
|
92
|
+
.andWhere('attr.organization_id = :orgId', { orgId })
|
|
93
|
+
.getMany()
|
|
62
94
|
: [];
|
|
63
|
-
|
|
64
|
-
await this.loggerService.log(
|
|
65
|
-
|
|
95
|
+
|
|
96
|
+
await this.loggerService.log(
|
|
97
|
+
'debug',
|
|
98
|
+
'EntityJSONService',
|
|
99
|
+
'getAttributeForFlatJSON',
|
|
100
|
+
`Loaded ${relatedAttributes.length} related attributes`,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// LINKED ATTRIBUTES
|
|
66
104
|
const linkedAttributes = await this.dataSource
|
|
67
105
|
.getRepository(LinkedAttributes)
|
|
68
106
|
.createQueryBuilder('fla')
|
|
@@ -78,40 +116,109 @@ export class EntityJSONService extends EntityServiceImpl {
|
|
|
78
116
|
'fla.saved_filter_code AS saved_filter_code',
|
|
79
117
|
'attr.name AS name',
|
|
80
118
|
'attr.id AS id',
|
|
119
|
+
'attr.data_type AS data_type',
|
|
81
120
|
])
|
|
82
121
|
.where('attr.organization_id = :orgId', { orgId })
|
|
83
122
|
.getRawMany();
|
|
84
|
-
|
|
85
|
-
await this.loggerService.log(
|
|
86
|
-
|
|
123
|
+
|
|
124
|
+
await this.loggerService.log(
|
|
125
|
+
'debug',
|
|
126
|
+
'EntityJSONService',
|
|
127
|
+
'getAttributeForFlatJSON',
|
|
128
|
+
`Loaded ${linkedAttributes.length} linked attributes`,
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
// -------------------------------------------------------------------------
|
|
132
|
+
// ✅ FLAG: filter_attribute (NEW)
|
|
133
|
+
// -------------------------------------------------------------------------
|
|
134
|
+
if (flag === 'filter_attribute') {
|
|
135
|
+
const filterAttributes: any[] = [];
|
|
136
|
+
|
|
137
|
+
// MAIN
|
|
138
|
+
filterAttributes.push(
|
|
139
|
+
...mainAttributes.map(a => ({
|
|
140
|
+
id: a.id,
|
|
141
|
+
name: a.name,
|
|
142
|
+
data_type: a.data_type,
|
|
143
|
+
flat_json_key: a.flat_json_key,
|
|
144
|
+
source: 'main',
|
|
145
|
+
})),
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// RELATED
|
|
149
|
+
filterAttributes.push(
|
|
150
|
+
...relatedAttributes.map(a => ({
|
|
151
|
+
id: a.id,
|
|
152
|
+
name: a.name,
|
|
153
|
+
data_type: a.data_type,
|
|
154
|
+
flat_json_key: a.flat_json_key,
|
|
155
|
+
source: 'related',
|
|
156
|
+
})),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// LINKED
|
|
160
|
+
filterAttributes.push(
|
|
161
|
+
...linkedAttributes.map(l => ({
|
|
162
|
+
id: l.id,
|
|
163
|
+
name: l.name,
|
|
164
|
+
data_type: l.data_type,
|
|
165
|
+
flat_json_key: l.target_attribute_key, // attribute_key
|
|
166
|
+
source: 'linked',
|
|
167
|
+
})),
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
return filterAttributes;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// -------------------------------------------------------------------------
|
|
174
|
+
// ORIGINAL flat_json FLAG (unchanged)
|
|
175
|
+
// -------------------------------------------------------------------------
|
|
87
176
|
if (flag === 'flat_json' || flag === 'all') {
|
|
88
177
|
const result: Record<string, null> = {};
|
|
178
|
+
|
|
89
179
|
mainAttributes.forEach(attr => {
|
|
90
180
|
if (attr.flat_json_key) result[attr.flat_json_key] = null;
|
|
91
181
|
});
|
|
182
|
+
|
|
92
183
|
relatedAttributes.forEach(attr => {
|
|
93
184
|
if (attr.flat_json_key) result[attr.flat_json_key] = null;
|
|
94
185
|
});
|
|
186
|
+
|
|
95
187
|
linkedAttributes.forEach(link => {
|
|
96
188
|
if (link.target_attribute_key) result[link.target_attribute_key] = null;
|
|
97
189
|
});
|
|
98
|
-
|
|
190
|
+
|
|
99
191
|
if (flag === 'all') {
|
|
100
|
-
return {
|
|
192
|
+
return {
|
|
193
|
+
flat_json: result,
|
|
194
|
+
attributes: {
|
|
195
|
+
mainAttributes,
|
|
196
|
+
relatedAttributes,
|
|
197
|
+
linkedAttributes,
|
|
198
|
+
},
|
|
199
|
+
};
|
|
101
200
|
}
|
|
102
|
-
|
|
201
|
+
|
|
103
202
|
return result;
|
|
104
203
|
}
|
|
105
|
-
|
|
204
|
+
|
|
205
|
+
// -------------------------------------------------------------------------
|
|
206
|
+
// ORIGINAL dropdown FLAG (unchanged)
|
|
207
|
+
// -------------------------------------------------------------------------
|
|
106
208
|
const dropdown: any[] = [];
|
|
209
|
+
|
|
107
210
|
dropdown.push(...mainAttributes.map(a => ({ label: a.name, value: a.flat_json_key })));
|
|
108
211
|
dropdown.push(...relatedAttributes.map(a => ({ label: a.name, value: a.flat_json_key })));
|
|
212
|
+
|
|
109
213
|
if (linkedAttributes.length > 0) {
|
|
110
|
-
dropdown.push(
|
|
214
|
+
dropdown.push(
|
|
215
|
+
...linkedAttributes.map(a => ({ label: a.name, value: a.target_attribute_key })),
|
|
216
|
+
);
|
|
111
217
|
}
|
|
112
|
-
|
|
218
|
+
|
|
113
219
|
return dropdown;
|
|
114
220
|
}
|
|
221
|
+
|
|
115
222
|
|
|
116
223
|
async updateEntityJSON(entityType: string, entityId: number, loggedInUser) {
|
|
117
224
|
await this.loggerService.log('info', 'EntityJSONService', 'updateEntityJSON', `Building flat JSON for entity: ${entityType}#${entityId}`);
|
|
@@ -24,9 +24,6 @@ export class SavedFilterMaster extends BaseEntity {
|
|
|
24
24
|
@Column({ type: 'boolean', default: false, nullable: true })
|
|
25
25
|
is_shared: boolean;
|
|
26
26
|
|
|
27
|
-
@Column({ type: '
|
|
28
|
-
is_editable:
|
|
29
|
-
|
|
30
|
-
@Column({ type: 'varchar', length: 200, nullable: true })
|
|
31
|
-
description: string;
|
|
27
|
+
@Column({ type: 'varchar', length: 100, nullable: true })
|
|
28
|
+
is_editable: string;
|
|
32
29
|
}
|
|
@@ -5,15 +5,22 @@ import { SavedFilterDetail } from './entity/saved-filter-detail.entity';
|
|
|
5
5
|
import { SavedFilterMaster } from './entity/saved-filter-master.entity';
|
|
6
6
|
import { SavedFilterRepositoryService } from './repository/saved-filter.repository';
|
|
7
7
|
import { EntityModule } from '../meta/entity.module';
|
|
8
|
+
import { EntityJSONModule } from '../entity_json/entity_json.module';
|
|
8
9
|
import { FilterService } from './service/filter.service';
|
|
9
10
|
import { FilterController } from './controller/filter.controller';
|
|
10
11
|
import { FilterEvaluatorService } from './service/filter-evaluator.service';
|
|
11
12
|
import { SavedFilterDetailRepository } from './repository/saved.filter-detail.repository';
|
|
13
|
+
import { FlatjsonFilterService } from './service/flatjson-filter.service';
|
|
14
|
+
import { ConfigModule } from '@nestjs/config';
|
|
15
|
+
import { UtilsModule } from 'src/utils/utils.module';
|
|
12
16
|
|
|
13
17
|
@Module({
|
|
14
18
|
imports: [
|
|
15
19
|
TypeOrmModule.forFeature([SavedFilterDetail, SavedFilterMaster]),
|
|
16
|
-
forwardRef(() => EntityModule)
|
|
20
|
+
forwardRef(() => EntityModule),
|
|
21
|
+
forwardRef(() => EntityJSONModule),
|
|
22
|
+
ConfigModule,
|
|
23
|
+
UtilsModule,
|
|
17
24
|
],
|
|
18
25
|
controllers: [FilterController],
|
|
19
26
|
providers: [
|
|
@@ -21,13 +28,15 @@ import { SavedFilterDetailRepository } from './repository/saved.filter-detail.re
|
|
|
21
28
|
SavedFilterRepositoryService,
|
|
22
29
|
FilterService,
|
|
23
30
|
FilterEvaluatorService,
|
|
24
|
-
SavedFilterDetailRepository
|
|
31
|
+
SavedFilterDetailRepository,
|
|
32
|
+
FlatjsonFilterService,
|
|
25
33
|
],
|
|
26
34
|
exports: [
|
|
27
35
|
'SavedFilterService',
|
|
28
36
|
SavedFilterRepositoryService,
|
|
29
37
|
FilterService,
|
|
30
38
|
FilterEvaluatorService,
|
|
39
|
+
FlatjsonFilterService,
|
|
31
40
|
],
|
|
32
41
|
})
|
|
33
42
|
export class FilterModule {}
|
|
@@ -107,7 +107,6 @@ export class SavedFilterRepositoryService {
|
|
|
107
107
|
value: filter.id,
|
|
108
108
|
code: filter.code,
|
|
109
109
|
}));
|
|
110
|
-
// return filters;
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
async getSharedFiltersByLevelTypeAndLevelId(
|
|
@@ -128,14 +127,11 @@ export class SavedFilterRepositoryService {
|
|
|
128
127
|
},
|
|
129
128
|
});
|
|
130
129
|
|
|
131
|
-
return filters
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// code: filter.code,
|
|
137
|
-
|
|
138
|
-
// }));
|
|
130
|
+
return filters.map((filter) => ({
|
|
131
|
+
label: filter.name,
|
|
132
|
+
value: filter.id,
|
|
133
|
+
code: filter.code,
|
|
134
|
+
}));
|
|
139
135
|
}
|
|
140
136
|
|
|
141
137
|
async getFilterById(id: number): Promise<
|
|
@@ -11,6 +11,7 @@ import { LoggingService } from 'src/utils/service/loggingUtil.service';
|
|
|
11
11
|
import { ConfigService } from '@nestjs/config';
|
|
12
12
|
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
13
13
|
import { EntityManager } from 'typeorm';
|
|
14
|
+
import { FlatjsonFilterService } from './flatjson-filter.service';
|
|
14
15
|
|
|
15
16
|
@Injectable()
|
|
16
17
|
export class FilterService {
|
|
@@ -26,6 +27,7 @@ export class FilterService {
|
|
|
26
27
|
@Inject() protected readonly loggingService: LoggingService,
|
|
27
28
|
private readonly configService: ConfigService,
|
|
28
29
|
private readonly reflectionHelper: ReflectionHelper,
|
|
30
|
+
private readonly flatjsonFilterService: FlatjsonFilterService,
|
|
29
31
|
) {}
|
|
30
32
|
|
|
31
33
|
private async gettab_value_counts(
|
|
@@ -96,6 +98,51 @@ export class FilterService {
|
|
|
96
98
|
];
|
|
97
99
|
}
|
|
98
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Route to flatjson or traditional filtering based on configuration
|
|
103
|
+
*/
|
|
104
|
+
async applyFilterWithRouting(dto: FilterRequestDto) {
|
|
105
|
+
// Check if flatjson filtering is enabled via config or query param
|
|
106
|
+
const useFlatjson = dto.queryParams?.use_flatjson === 'true';
|
|
107
|
+
|
|
108
|
+
if (useFlatjson) {
|
|
109
|
+
await this.loggingService.log(
|
|
110
|
+
'info',
|
|
111
|
+
'FilterService',
|
|
112
|
+
'applyFilterWithRouting',
|
|
113
|
+
`Using FLATJSON filtering for ${dto.entity_type}`,
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// Use new flatjson filtering service
|
|
117
|
+
const result = await this.flatjsonFilterService.applyFlatjsonFilter(dto);
|
|
118
|
+
|
|
119
|
+
// Transform to match existing response format
|
|
120
|
+
return {
|
|
121
|
+
success: true,
|
|
122
|
+
data: {
|
|
123
|
+
entity_tabs: result.tabCounts || [],
|
|
124
|
+
entity_list: result.data,
|
|
125
|
+
pagination: {
|
|
126
|
+
total: result.total,
|
|
127
|
+
page: result.page,
|
|
128
|
+
size: result.size,
|
|
129
|
+
totalPages: result.totalPages,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
} else {
|
|
134
|
+
await this.loggingService.log(
|
|
135
|
+
'info',
|
|
136
|
+
'FilterService',
|
|
137
|
+
'applyFilterWithRouting',
|
|
138
|
+
`Using TRADITIONAL filtering for ${dto.entity_type}`,
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// Use traditional filtering
|
|
142
|
+
return this.applyFilterWrapper(dto);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
99
146
|
async applyFilterWrapper(dto: FilterRequestDto) {
|
|
100
147
|
const {
|
|
101
148
|
entity_type,
|
|
@@ -421,60 +468,60 @@ export class FilterService {
|
|
|
421
468
|
|
|
422
469
|
const dataWhere = [...baseWhere];
|
|
423
470
|
|
|
424
|
-
if (tabs?.columnName && tabs?.value) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
471
|
+
// if (tabs?.columnName && tabs?.value) {
|
|
472
|
+
// const tabAttrMeta = attributeMetaMap[tabs.columnName];
|
|
473
|
+
// const tabValue = tabs.value.toLowerCase();
|
|
474
|
+
|
|
475
|
+
// if (tabValue === 'others') {
|
|
476
|
+
// // Extract 'value' (IDs) from showList, ignore 'all'
|
|
477
|
+
// const valuesToExclude = showList
|
|
478
|
+
// .filter((v) => v.label.toLowerCase() !== 'all')
|
|
479
|
+
// .map((v) => v.value);
|
|
480
|
+
|
|
481
|
+
// if (valuesToExclude.length > 0) {
|
|
482
|
+
// for (const value of valuesToExclude) {
|
|
483
|
+
// const resolvedId = await this.resolverService.getResolvedId(
|
|
484
|
+
// loggedInUser,
|
|
485
|
+
// tabs.columnName,
|
|
486
|
+
// value,
|
|
487
|
+
// entity_type,
|
|
488
|
+
// );
|
|
489
|
+
// if (resolvedId) {
|
|
490
|
+
// const tabCondition = this.buildCondition(
|
|
491
|
+
// {
|
|
492
|
+
// filter_attribute: tabs.columnName,
|
|
493
|
+
// filter_operator: 'not_equal',
|
|
494
|
+
// filter_value: [resolvedId],
|
|
495
|
+
// skip_id: true,
|
|
496
|
+
// },
|
|
497
|
+
// tabAttrMeta,
|
|
498
|
+
// );
|
|
499
|
+
// if (tabCondition) dataWhere.push(tabCondition);
|
|
500
|
+
// }
|
|
501
|
+
// }
|
|
502
|
+
// }
|
|
503
|
+
// } else if (tabValue !== 'all') {
|
|
504
|
+
// const resolvedId = await this.resolverService.getResolvedId(
|
|
505
|
+
// loggedInUser,
|
|
506
|
+
// tabs.columnName,
|
|
507
|
+
// tabs.value,
|
|
508
|
+
// entity_type,
|
|
509
|
+
// );
|
|
510
|
+
|
|
511
|
+
// if (resolvedId) {
|
|
512
|
+
// const tabCondition = this.buildCondition(
|
|
513
|
+
// {
|
|
514
|
+
// filter_attribute: tabs.columnName,
|
|
515
|
+
// filter_operator: 'equal',
|
|
516
|
+
// filter_value: [resolvedId],
|
|
517
|
+
// skip_id: true,
|
|
518
|
+
// },
|
|
519
|
+
// tabAttrMeta,
|
|
520
|
+
// );
|
|
521
|
+
// if (tabCondition) dataWhere.push(tabCondition);
|
|
522
|
+
// }
|
|
523
|
+
// }
|
|
524
|
+
// }
|
|
478
525
|
|
|
479
526
|
let qb = this.entityManager
|
|
480
527
|
.createQueryBuilder()
|
|
@@ -517,11 +564,11 @@ export class FilterService {
|
|
|
517
564
|
|
|
518
565
|
const formattedEntityList = entity_list.map(formatDatesInRow);
|
|
519
566
|
|
|
520
|
-
const resolvedEntityList = await Promise.all(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
);
|
|
567
|
+
// const resolvedEntityList = await Promise.all(
|
|
568
|
+
// formattedEntityList.map((row) =>
|
|
569
|
+
// this.resolverService.getResolvedData(loggedInUser, row, entity_type),
|
|
570
|
+
// ),
|
|
571
|
+
// );
|
|
525
572
|
|
|
526
573
|
const resolvedTabs = await Promise.all(
|
|
527
574
|
filteredTabs.map(async (tab) => {
|
|
@@ -535,14 +582,15 @@ export class FilterService {
|
|
|
535
582
|
return tab;
|
|
536
583
|
}
|
|
537
584
|
|
|
538
|
-
const resolvedVal = await this.resolverService.getResolvedValue(
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
);
|
|
585
|
+
// const resolvedVal = await this.resolverService.getResolvedValue(
|
|
586
|
+
// loggedInUser,
|
|
587
|
+
// tabAttrKey,
|
|
588
|
+
// tab.tab_value,
|
|
589
|
+
// entity_type,
|
|
590
|
+
// );
|
|
591
|
+
|
|
544
592
|
|
|
545
|
-
return { ...tab, tab_value:
|
|
593
|
+
return { ...tab, tab_value: tab.tab_value ?? tab.tab_value };
|
|
546
594
|
}),
|
|
547
595
|
);
|
|
548
596
|
|
|
@@ -562,7 +610,7 @@ export class FilterService {
|
|
|
562
610
|
success: true,
|
|
563
611
|
data: {
|
|
564
612
|
entity_tabs: resolvedTabs,
|
|
565
|
-
entity_list:
|
|
613
|
+
entity_list: formattedEntityList,
|
|
566
614
|
pagination: {
|
|
567
615
|
total,
|
|
568
616
|
page,
|