rez_core 5.0.210 → 6.1.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.
- package/dist/config/database.config.js +1 -1
- package/dist/config/database.config.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/controller/entity_json.controller.js.map +1 -1
- 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 +5 -12
- package/dist/module/entity_json/service/entity_json.service.js +111 -29
- 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/filter.module.js +11 -2
- package/dist/module/filter/filter.module.js.map +1 -1
- package/dist/module/filter/service/filter.service.d.ts +38 -2
- package/dist/module/filter/service/filter.service.js +50 -56
- 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 +632 -0
- package/dist/module/filter/service/flatjson-filter.service.js.map +1 -0
- package/dist/module/filter/service/saved-filter.service.d.ts +3 -2
- package/dist/module/filter/service/saved-filter.service.js +14 -18
- package/dist/module/filter/service/saved-filter.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 +4 -2
- 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 +265 -1
- package/dist/module/linked_attributes/service/linked_attributes.service.js.map +1 -1
- package/dist/module/meta/controller/attribute-master.controller.d.ts +3 -0
- package/dist/module/meta/controller/attribute-master.controller.js +12 -0
- package/dist/module/meta/controller/attribute-master.controller.js.map +1 -1
- package/dist/module/meta/entity.module.js +2 -2
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/service/attribute-master.service.d.ts +6 -1
- package/dist/module/meta/service/attribute-master.service.js +20 -2
- package/dist/module/meta/service/attribute-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-master.service.js +1 -0
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-relation.service.d.ts +4 -3
- package/dist/module/meta/service/entity-relation.service.js +10 -4
- package/dist/module/meta/service/entity-relation.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +2 -2
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.d.ts +5 -4
- package/dist/module/meta/service/entity-table.service.js +45 -24
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/module/meta/service/resolver.service.d.ts +1 -1
- package/dist/module/meta/service/resolver.service.js +6 -3
- package/dist/module/meta/service/resolver.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +2 -3
- package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
- package/dist/table.config.d.ts +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/config/database.config.ts +1 -1
- package/src/migrations/1732612800000-AddEntityJsonGinIndex.ts +41 -0
- package/src/module/entity_json/controller/entity_json.controller.ts +13 -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 +9 -5
- package/src/module/entity_json/service/entity_json.service.ts +236 -49
- package/src/module/filter/controller/filter.controller.ts +4 -4
- package/src/module/filter/filter.module.ts +12 -3
- package/src/module/filter/service/filter.service.ts +147 -94
- package/src/module/filter/service/flatjson-filter.service.ts +903 -0
- package/src/module/filter/service/saved-filter.service.ts +16 -26
- package/src/module/filter/test/flatjson-filter.service.spec.ts +415 -0
- package/src/module/linked_attributes/controller/linked_attributes.controller.ts +85 -0
- package/src/module/linked_attributes/dto/create-linked-attribute-smart.dto.ts +54 -0
- package/src/module/linked_attributes/linked_attributes.module.ts +5 -3
- package/src/module/linked_attributes/service/linked_attributes.service.ts +545 -2
- package/src/module/linked_attributes/test/linked-attributes.service.spec.ts +244 -0
- package/src/module/meta/controller/attribute-master.controller.ts +12 -0
- package/src/module/meta/entity.module.ts +3 -3
- package/src/module/meta/service/attribute-master.service.ts +29 -1
- package/src/module/meta/service/entity-master.service.ts +1 -0
- package/src/module/meta/service/entity-relation.service.ts +10 -6
- package/src/module/meta/service/entity-service-impl.service.ts +2 -1
- package/src/module/meta/service/entity-table.service.ts +82 -68
- package/src/module/meta/service/entity.service.ts +0 -1
- package/src/module/meta/service/resolver.service.ts +7 -3
- package/src/module/workflow-automation/service/workflow-automation.service.ts +2 -4
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
forwardRef,
|
|
4
|
+
Inject,
|
|
5
|
+
Injectable,
|
|
6
|
+
} from '@nestjs/common';
|
|
2
7
|
import { AttributeMasterService } from 'src/module/meta/service/attribute-master.service';
|
|
3
8
|
import { EntityMasterService } from 'src/module/meta/service/entity-master.service';
|
|
4
9
|
import { FilterCondition, FilterRequestDto } from '../dto/filter-request.dto';
|
|
@@ -11,23 +16,30 @@ import { LoggingService } from 'src/utils/service/loggingUtil.service';
|
|
|
11
16
|
import { ConfigService } from '@nestjs/config';
|
|
12
17
|
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
13
18
|
import { EntityManager } from 'typeorm';
|
|
19
|
+
import { FlatjsonFilterService } from './flatjson-filter.service';
|
|
14
20
|
|
|
15
21
|
@Injectable()
|
|
16
22
|
export class FilterService {
|
|
17
23
|
constructor(
|
|
18
24
|
private entityManager: EntityManager,
|
|
25
|
+
@Inject(forwardRef(() => AttributeMasterService))
|
|
19
26
|
private readonly attributeMasterService: AttributeMasterService,
|
|
27
|
+
@Inject(forwardRef(() => EntityMasterService))
|
|
20
28
|
private readonly entityMasterService: EntityMasterService,
|
|
21
|
-
@Inject('SavedFilterService')
|
|
22
|
-
private readonly savedFilterService: SavedFilterService,
|
|
23
29
|
@Inject('EntityRelationService')
|
|
24
30
|
private readonly entityRelationService: EntityRelationService,
|
|
31
|
+
@Inject('SavedFilterService')
|
|
32
|
+
private readonly savedFilterService: SavedFilterService,
|
|
33
|
+
@Inject(forwardRef(() => ResolverService))
|
|
25
34
|
private readonly resolverService: ResolverService,
|
|
26
|
-
@Inject()
|
|
35
|
+
@Inject(forwardRef(() => LoggingService))
|
|
36
|
+
protected readonly loggingService: LoggingService,
|
|
27
37
|
private readonly configService: ConfigService,
|
|
38
|
+
@Inject(forwardRef(() => ReflectionHelper))
|
|
28
39
|
private readonly reflectionHelper: ReflectionHelper,
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
@Inject(forwardRef(() => FlatjsonFilterService))
|
|
41
|
+
private readonly flatjsonFilterService: FlatjsonFilterService,
|
|
42
|
+
) {}
|
|
31
43
|
|
|
32
44
|
schema = this.configService.get('DB_SCHEMA');
|
|
33
45
|
|
|
@@ -82,7 +94,6 @@ export class FilterService {
|
|
|
82
94
|
GROUP BY ${column}
|
|
83
95
|
`;
|
|
84
96
|
|
|
85
|
-
|
|
86
97
|
const rows = await this.entityManager.query(rawSQL, values);
|
|
87
98
|
|
|
88
99
|
const total = rows.reduce(
|
|
@@ -99,6 +110,51 @@ export class FilterService {
|
|
|
99
110
|
];
|
|
100
111
|
}
|
|
101
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Route to flatjson or traditional filtering based on configuration
|
|
115
|
+
*/
|
|
116
|
+
async applyFilterWithRouting(dto: FilterRequestDto) {
|
|
117
|
+
// Check if flatjson filtering is enabled via config or query param
|
|
118
|
+
const useFlatjson = dto.queryParams?.use_flatjson === 'true';
|
|
119
|
+
|
|
120
|
+
if (useFlatjson) {
|
|
121
|
+
await this.loggingService.log(
|
|
122
|
+
'info',
|
|
123
|
+
'FilterService',
|
|
124
|
+
'applyFilterWithRouting',
|
|
125
|
+
`Using FLATJSON filtering for ${dto.entity_type}`,
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
// Use new flatjson filtering service
|
|
129
|
+
const result = await this.flatjsonFilterService.applyFlatjsonFilter(dto);
|
|
130
|
+
|
|
131
|
+
// Transform to match existing response format
|
|
132
|
+
return {
|
|
133
|
+
success: true,
|
|
134
|
+
data: {
|
|
135
|
+
entity_tabs: result.tabCounts || [],
|
|
136
|
+
entity_list: result.data,
|
|
137
|
+
pagination: {
|
|
138
|
+
total: result.total,
|
|
139
|
+
page: result.page,
|
|
140
|
+
size: result.size,
|
|
141
|
+
totalPages: result.totalPages,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
} else {
|
|
146
|
+
await this.loggingService.log(
|
|
147
|
+
'info',
|
|
148
|
+
'FilterService',
|
|
149
|
+
'applyFilterWithRouting',
|
|
150
|
+
`Using TRADITIONAL filtering for ${dto.entity_type}`,
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
// Use traditional filtering
|
|
154
|
+
return this.applyFilterWrapper(dto);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
102
158
|
async applyFilterWrapper(dto: FilterRequestDto) {
|
|
103
159
|
const {
|
|
104
160
|
entity_type,
|
|
@@ -229,6 +285,7 @@ export class FilterService {
|
|
|
229
285
|
id: user_id,
|
|
230
286
|
appcode,
|
|
231
287
|
organization_id,
|
|
288
|
+
enterprise_id,
|
|
232
289
|
} = loggedInUser || {};
|
|
233
290
|
|
|
234
291
|
// Fetch meta from entity table service
|
|
@@ -284,7 +341,6 @@ export class FilterService {
|
|
|
284
341
|
|
|
285
342
|
// Handle TEMPLATE entity special condition
|
|
286
343
|
if (entity_type === 'TEMP' || entity_type === 'TEM') {
|
|
287
|
-
|
|
288
344
|
if (level_type === 'ORG') {
|
|
289
345
|
baseWhere.push({
|
|
290
346
|
query: ` ((e.level_type = 'ORG' AND e.level_id = '${loggedInUser.enterprise_id}'))`,
|
|
@@ -325,8 +381,7 @@ export class FilterService {
|
|
|
325
381
|
!customLevelId
|
|
326
382
|
) {
|
|
327
383
|
baseWhere.push({
|
|
328
|
-
query:
|
|
329
|
-
'e.level_type = :level_type AND e.level_id = :level_id',
|
|
384
|
+
query: 'e.level_type = :level_type AND e.level_id = :level_id',
|
|
330
385
|
params: {
|
|
331
386
|
level_type,
|
|
332
387
|
level_id,
|
|
@@ -421,60 +476,60 @@ export class FilterService {
|
|
|
421
476
|
|
|
422
477
|
const dataWhere = [...baseWhere];
|
|
423
478
|
|
|
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
|
-
}
|
|
479
|
+
// if (tabs?.columnName && tabs?.value) {
|
|
480
|
+
// const tabAttrMeta = attributeMetaMap[tabs.columnName];
|
|
481
|
+
// const tabValue = tabs.value.toLowerCase();
|
|
482
|
+
|
|
483
|
+
// if (tabValue === 'others') {
|
|
484
|
+
// // Extract 'value' (IDs) from showList, ignore 'all'
|
|
485
|
+
// const valuesToExclude = showList
|
|
486
|
+
// .filter((v) => v.label.toLowerCase() !== 'all')
|
|
487
|
+
// .map((v) => v.value);
|
|
488
|
+
|
|
489
|
+
// if (valuesToExclude.length > 0) {
|
|
490
|
+
// for (const value of valuesToExclude) {
|
|
491
|
+
// const resolvedId = await this.resolverService.getResolvedId(
|
|
492
|
+
// loggedInUser,
|
|
493
|
+
// tabs.columnName,
|
|
494
|
+
// value,
|
|
495
|
+
// entity_type,
|
|
496
|
+
// );
|
|
497
|
+
// if (resolvedId) {
|
|
498
|
+
// const tabCondition = this.buildCondition(
|
|
499
|
+
// {
|
|
500
|
+
// filter_attribute: tabs.columnName,
|
|
501
|
+
// filter_operator: 'not_equal',
|
|
502
|
+
// filter_value: [resolvedId],
|
|
503
|
+
// skip_id: true,
|
|
504
|
+
// },
|
|
505
|
+
// tabAttrMeta,
|
|
506
|
+
// );
|
|
507
|
+
// if (tabCondition) dataWhere.push(tabCondition);
|
|
508
|
+
// }
|
|
509
|
+
// }
|
|
510
|
+
// }
|
|
511
|
+
// } else if (tabValue !== 'all') {
|
|
512
|
+
// const resolvedId = await this.resolverService.getResolvedId(
|
|
513
|
+
// loggedInUser,
|
|
514
|
+
// tabs.columnName,
|
|
515
|
+
// tabs.value,
|
|
516
|
+
// entity_type,
|
|
517
|
+
// );
|
|
518
|
+
|
|
519
|
+
// if (resolvedId) {
|
|
520
|
+
// const tabCondition = this.buildCondition(
|
|
521
|
+
// {
|
|
522
|
+
// filter_attribute: tabs.columnName,
|
|
523
|
+
// filter_operator: 'equal',
|
|
524
|
+
// filter_value: [resolvedId],
|
|
525
|
+
// skip_id: true,
|
|
526
|
+
// },
|
|
527
|
+
// tabAttrMeta,
|
|
528
|
+
// );
|
|
529
|
+
// if (tabCondition) dataWhere.push(tabCondition);
|
|
530
|
+
// }
|
|
531
|
+
// }
|
|
532
|
+
// }
|
|
478
533
|
|
|
479
534
|
let qb = this.entityManager
|
|
480
535
|
.createQueryBuilder()
|
|
@@ -517,11 +572,11 @@ export class FilterService {
|
|
|
517
572
|
|
|
518
573
|
const formattedEntityList = entity_list.map(formatDatesInRow);
|
|
519
574
|
|
|
520
|
-
const resolvedEntityList = await Promise.all(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
);
|
|
575
|
+
// const resolvedEntityList = await Promise.all(
|
|
576
|
+
// formattedEntityList.map((row) =>
|
|
577
|
+
// this.resolverService.getResolvedData(loggedInUser, row, entity_type),
|
|
578
|
+
// ),
|
|
579
|
+
// );
|
|
525
580
|
|
|
526
581
|
const resolvedTabs = await Promise.all(
|
|
527
582
|
filteredTabs.map(async (tab) => {
|
|
@@ -535,14 +590,14 @@ export class FilterService {
|
|
|
535
590
|
return tab;
|
|
536
591
|
}
|
|
537
592
|
|
|
538
|
-
const resolvedVal = await this.resolverService.getResolvedValue(
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
);
|
|
593
|
+
// const resolvedVal = await this.resolverService.getResolvedValue(
|
|
594
|
+
// loggedInUser,
|
|
595
|
+
// tabAttrKey,
|
|
596
|
+
// tab.tab_value,
|
|
597
|
+
// entity_type,
|
|
598
|
+
// );
|
|
544
599
|
|
|
545
|
-
return { ...tab, tab_value:
|
|
600
|
+
return { ...tab, tab_value: tab.tab_value ?? tab.tab_value };
|
|
546
601
|
}),
|
|
547
602
|
);
|
|
548
603
|
|
|
@@ -562,7 +617,7 @@ export class FilterService {
|
|
|
562
617
|
success: true,
|
|
563
618
|
data: {
|
|
564
619
|
entity_tabs: resolvedTabs,
|
|
565
|
-
entity_list:
|
|
620
|
+
entity_list: formattedEntityList,
|
|
566
621
|
pagination: {
|
|
567
622
|
total,
|
|
568
623
|
page,
|
|
@@ -694,30 +749,28 @@ export class FilterService {
|
|
|
694
749
|
layoutPreference: any,
|
|
695
750
|
tabs: any,
|
|
696
751
|
) {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
752
|
+
const sorting = layoutPreference?.mapped_json?.sorting;
|
|
753
|
+
|
|
754
|
+
if (sorting) {
|
|
755
|
+
if (Array.isArray(sorting?.tabs)) {
|
|
756
|
+
const preferenceTabArray = sorting?.tabs;
|
|
701
757
|
const tabFilter = preferenceTabArray.find(
|
|
702
|
-
(tabData) => tabData.tab_name === tabs?.value,
|
|
758
|
+
(tabData) => tabData.tab_name?.value === tabs?.value,
|
|
703
759
|
);
|
|
704
|
-
|
|
760
|
+
|
|
761
|
+
tabFilter?.sortby?.forEach(({ column, order }) => {
|
|
762
|
+
qb.addOrderBy(
|
|
763
|
+
`e.${column}`,
|
|
764
|
+
order?.toUpperCase() === 'DSC' ? 'DESC' : 'ASC',
|
|
765
|
+
);
|
|
766
|
+
});
|
|
767
|
+
} else if (Array.isArray(sorting.sortby)) {
|
|
768
|
+
sorting?.sortby?.forEach(({ column, order }) => {
|
|
705
769
|
qb.addOrderBy(
|
|
706
770
|
`e.${column}`,
|
|
707
771
|
order?.toUpperCase() === 'DSC' ? 'DESC' : 'ASC',
|
|
708
772
|
);
|
|
709
773
|
});
|
|
710
|
-
} else if (
|
|
711
|
-
Array.isArray(layoutPreference[0]?.mapped_json?.sorting?.sortby)
|
|
712
|
-
) {
|
|
713
|
-
layoutPreference[0]?.mapped_json?.sorting?.sortby?.forEach(
|
|
714
|
-
({ column, order }) => {
|
|
715
|
-
qb.addOrderBy(
|
|
716
|
-
`e.${column}`,
|
|
717
|
-
order?.toUpperCase() === 'DSC' ? 'DESC' : 'ASC',
|
|
718
|
-
);
|
|
719
|
-
},
|
|
720
|
-
);
|
|
721
774
|
}
|
|
722
775
|
}
|
|
723
776
|
|