rez_core 5.0.211 → 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.
Files changed (95) hide show
  1. package/dist/config/database.config.js +1 -1
  2. package/dist/config/database.config.js.map +1 -1
  3. package/dist/migrations/1732612800000-AddEntityJsonGinIndex.d.ts +6 -0
  4. package/dist/migrations/1732612800000-AddEntityJsonGinIndex.js +32 -0
  5. package/dist/migrations/1732612800000-AddEntityJsonGinIndex.js.map +1 -0
  6. package/dist/module/entity_json/controller/entity_json.controller.d.ts +2 -9
  7. package/dist/module/entity_json/controller/entity_json.controller.js.map +1 -1
  8. package/dist/module/entity_json/entity/entityJson.entity.d.ts +2 -1
  9. package/dist/module/entity_json/entity/entityJson.entity.js +5 -1
  10. package/dist/module/entity_json/entity/entityJson.entity.js.map +1 -1
  11. package/dist/module/entity_json/entity_json.module.js +7 -2
  12. package/dist/module/entity_json/entity_json.module.js.map +1 -1
  13. package/dist/module/entity_json/service/entity_json.service.d.ts +5 -12
  14. package/dist/module/entity_json/service/entity_json.service.js +111 -29
  15. package/dist/module/entity_json/service/entity_json.service.js.map +1 -1
  16. package/dist/module/filter/controller/filter.controller.d.ts +12 -0
  17. package/dist/module/filter/controller/filter.controller.js +1 -1
  18. package/dist/module/filter/controller/filter.controller.js.map +1 -1
  19. package/dist/module/filter/filter.module.js +11 -2
  20. package/dist/module/filter/filter.module.js.map +1 -1
  21. package/dist/module/filter/service/filter.service.d.ts +38 -2
  22. package/dist/module/filter/service/filter.service.js +42 -49
  23. package/dist/module/filter/service/filter.service.js.map +1 -1
  24. package/dist/module/filter/service/flatjson-filter.service.d.ts +32 -0
  25. package/dist/module/filter/service/flatjson-filter.service.js +632 -0
  26. package/dist/module/filter/service/flatjson-filter.service.js.map +1 -0
  27. package/dist/module/filter/service/saved-filter.service.d.ts +3 -2
  28. package/dist/module/filter/service/saved-filter.service.js +14 -18
  29. package/dist/module/filter/service/saved-filter.service.js.map +1 -1
  30. package/dist/module/linked_attributes/controller/linked_attributes.controller.d.ts +19 -0
  31. package/dist/module/linked_attributes/controller/linked_attributes.controller.js +77 -0
  32. package/dist/module/linked_attributes/controller/linked_attributes.controller.js.map +1 -1
  33. package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.d.ts +13 -0
  34. package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.js +64 -0
  35. package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.js.map +1 -0
  36. package/dist/module/linked_attributes/linked_attributes.module.js +4 -2
  37. package/dist/module/linked_attributes/linked_attributes.module.js.map +1 -1
  38. package/dist/module/linked_attributes/service/linked_attributes.service.d.ts +41 -1
  39. package/dist/module/linked_attributes/service/linked_attributes.service.js +265 -1
  40. package/dist/module/linked_attributes/service/linked_attributes.service.js.map +1 -1
  41. package/dist/module/meta/controller/attribute-master.controller.d.ts +3 -0
  42. package/dist/module/meta/controller/attribute-master.controller.js +12 -0
  43. package/dist/module/meta/controller/attribute-master.controller.js.map +1 -1
  44. package/dist/module/meta/entity.module.js +2 -2
  45. package/dist/module/meta/entity.module.js.map +1 -1
  46. package/dist/module/meta/service/attribute-master.service.d.ts +6 -1
  47. package/dist/module/meta/service/attribute-master.service.js +20 -2
  48. package/dist/module/meta/service/attribute-master.service.js.map +1 -1
  49. package/dist/module/meta/service/entity-master.service.js +1 -0
  50. package/dist/module/meta/service/entity-master.service.js.map +1 -1
  51. package/dist/module/meta/service/entity-relation.service.d.ts +4 -3
  52. package/dist/module/meta/service/entity-relation.service.js +10 -4
  53. package/dist/module/meta/service/entity-relation.service.js.map +1 -1
  54. package/dist/module/meta/service/entity-service-impl.service.d.ts +1 -1
  55. package/dist/module/meta/service/entity-service-impl.service.js +2 -2
  56. package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
  57. package/dist/module/meta/service/entity-table.service.d.ts +5 -4
  58. package/dist/module/meta/service/entity-table.service.js +45 -24
  59. package/dist/module/meta/service/entity-table.service.js.map +1 -1
  60. package/dist/module/meta/service/resolver.service.d.ts +1 -1
  61. package/dist/module/meta/service/resolver.service.js +6 -3
  62. package/dist/module/meta/service/resolver.service.js.map +1 -1
  63. package/dist/module/workflow-automation/service/workflow-automation.service.js +2 -3
  64. package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
  65. package/dist/table.config.d.ts +1 -1
  66. package/dist/tsconfig.build.tsbuildinfo +1 -1
  67. package/package.json +1 -1
  68. package/src/config/database.config.ts +1 -1
  69. package/src/migrations/1732612800000-AddEntityJsonGinIndex.ts +41 -0
  70. package/src/module/entity_json/controller/entity_json.controller.ts +13 -0
  71. package/src/module/entity_json/docs/FlatJson_Filterin_System.md +2804 -0
  72. package/src/module/entity_json/entity/entityJson.entity.ts +4 -1
  73. package/src/module/entity_json/entity_json.module.ts +9 -5
  74. package/src/module/entity_json/service/entity_json.service.ts +236 -49
  75. package/src/module/filter/controller/filter.controller.ts +4 -4
  76. package/src/module/filter/filter.module.ts +12 -3
  77. package/src/module/filter/service/filter.service.ts +130 -71
  78. package/src/module/filter/service/flatjson-filter.service.ts +903 -0
  79. package/src/module/filter/service/saved-filter.service.ts +16 -26
  80. package/src/module/filter/test/flatjson-filter.service.spec.ts +415 -0
  81. package/src/module/linked_attributes/controller/linked_attributes.controller.ts +85 -0
  82. package/src/module/linked_attributes/dto/create-linked-attribute-smart.dto.ts +54 -0
  83. package/src/module/linked_attributes/linked_attributes.module.ts +5 -3
  84. package/src/module/linked_attributes/service/linked_attributes.service.ts +545 -2
  85. package/src/module/linked_attributes/test/linked-attributes.service.spec.ts +244 -0
  86. package/src/module/meta/controller/attribute-master.controller.ts +12 -0
  87. package/src/module/meta/entity.module.ts +3 -3
  88. package/src/module/meta/service/attribute-master.service.ts +29 -1
  89. package/src/module/meta/service/entity-master.service.ts +1 -0
  90. package/src/module/meta/service/entity-relation.service.ts +10 -6
  91. package/src/module/meta/service/entity-service-impl.service.ts +2 -1
  92. package/src/module/meta/service/entity-table.service.ts +82 -68
  93. package/src/module/meta/service/entity.service.ts +0 -1
  94. package/src/module/meta/service/resolver.service.ts +7 -3
  95. package/src/module/workflow-automation/service/workflow-automation.service.ts +2 -4
@@ -29,11 +29,14 @@ export class EntityJson {
29
29
  created_by: number;
30
30
 
31
31
  @Column({ type: 'int', nullable: true })
32
- updated_by: number;
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';
@@ -8,11 +8,15 @@ import { UtilsModule } from 'src/utils/utils.module';
8
8
  import { EntityJson } from './entity/entityJson.entity';
9
9
  import { EntityJSONRepository } from './service/entityJson.repository';
10
10
 
11
-
12
11
  @Module({
13
- imports: [EntityModule, TypeOrmModule.forFeature([EntityJson]),FilterModule,UtilsModule],
12
+ imports: [
13
+ forwardRef(() => EntityModule),
14
+ TypeOrmModule.forFeature([EntityJson]),
15
+ forwardRef(() => FilterModule),
16
+ UtilsModule,
17
+ ],
14
18
  controllers: [EntityJSONController],
15
- providers: [EntityJSONService,EntityJSONRepository],
16
- exports: [],
19
+ providers: [EntityJSONService, EntityJSONRepository],
20
+ exports: [EntityJSONService],
17
21
  })
18
22
  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';
@@ -7,37 +7,57 @@ import { LoggingService } from 'src/utils/service/loggingUtil.service';
7
7
  import { DataSource } from 'typeorm';
8
8
  import { EntityJSONRepository } from './entityJson.repository';
9
9
  import { FilterService } from '../../filter/service/filter.service';
10
+ import { AttributeMasterService } from 'src/module/meta/service/attribute-master.service';
11
+ import { ResolverService } from 'src/module/meta/service/resolver.service';
10
12
 
11
13
  @Injectable()
12
- export class EntityJSONService extends EntityServiceImpl {
14
+ export class EntityJSONService {
13
15
  constructor(
14
16
  private readonly dataSource: DataSource,
15
17
  private readonly loggerService: LoggingService,
16
18
  private readonly EntityJSONRepository: EntityJSONRepository,
17
- private readonly filterService: FilterService,
19
+ @Inject(forwardRef(() => FilterService)) private readonly filterService: FilterService,
20
+ @Inject(forwardRef(() => EntityServiceImpl)) private readonly entityServiceImpl: EntityServiceImpl
18
21
  ) {
19
- super();
20
22
  }
21
23
 
22
24
  async getAttributeForFlatJSON(
23
25
  entityType: string,
24
26
  loggedInUser: any,
25
- flag?: 'flat_json' | 'dropdown' | 'all',
26
- ) {
27
- const entId = loggedInUser.entId;
28
-
29
- await this.loggerService.log('info', 'EntityJSONService', 'getAttributeForFlatJSON', `Loading attributes for entity: ${entityType}, ent: ${entId}`);
30
-
27
+ flag?: 'flat_json' | 'dropdown' | 'all' | 'filter_attribute',
28
+ ): Promise<any> {
29
+ const entId = loggedInUser.enterprise_id;
30
+
31
+ await this.loggerService.log(
32
+ 'info',
33
+ 'EntityJSONService',
34
+ 'getAttributeForFlatJSON',
35
+ `Loading attributes for entity: ${entityType}, org: ${entId}`,
36
+ );
37
+
38
+ // MAIN ATTRIBUTES
31
39
  const mainAttributes = await this.dataSource
32
40
  .getRepository(AttributeMaster)
33
41
  .createQueryBuilder('attr')
34
- .select(['attr.id', 'attr.name', 'attr.flat_json_key', 'attr.attribute_key'])
42
+ .select([
43
+ 'attr.id',
44
+ 'attr.name',
45
+ 'attr.flat_json_key',
46
+ 'attr.attribute_key',
47
+ 'attr.data_type',
48
+ ])
35
49
  .where('attr.mapped_entity_type = :entityType', { entityType })
36
50
  .andWhere('attr.enterprise_id = :entId', { entId })
37
51
  .getMany();
38
52
 
39
- await this.loggerService.log('debug', 'EntityJSONService', 'getAttributeForFlatJSON', `Loaded ${mainAttributes.length} main attributes`);
53
+ await this.loggerService.log(
54
+ 'debug',
55
+ 'EntityJSONService',
56
+ 'getAttributeForFlatJSON',
57
+ `Loaded ${mainAttributes.length} main attributes`,
58
+ );
40
59
 
60
+ // RELATED ENTITY TYPES
41
61
  const relatedEntityTypes = await this.dataSource
42
62
  .getRepository(EntityRelation)
43
63
  .createQueryBuilder('rel')
@@ -47,22 +67,45 @@ export class EntityJSONService extends EntityServiceImpl {
47
67
  .andWhere('rel.relation_type = :relationType', { relationType: 'ONE_TO_ONE' })
48
68
  .getRawMany();
49
69
 
50
- const relatedTypesList = relatedEntityTypes.map(x => x.rel_target_entity_type);
70
+ const relatedTypesList = relatedEntityTypes.map(
71
+ (x) => x.rel_target_entity_type,
72
+ );
51
73
 
52
- await this.loggerService.log('debug', 'EntityJSONService', 'getAttributeForFlatJSON', `Found ${relatedTypesList.length} ONE-TO-ONE related entity types`);
74
+ await this.loggerService.log(
75
+ 'debug',
76
+ 'EntityJSONService',
77
+ 'getAttributeForFlatJSON',
78
+ `Found ${relatedTypesList.length} ONE-TO-ONE related entity types`,
79
+ );
53
80
 
81
+ // RELATED ATTRIBUTES
54
82
  const relatedAttributes = relatedTypesList.length
55
83
  ? await this.dataSource
56
- .getRepository(AttributeMaster)
57
- .createQueryBuilder('attr')
58
- .select(['attr.id', 'attr.name', 'attr.flat_json_key', 'attr.mapped_entity_type', 'attr.attribute_key'])
59
- .where('attr.mapped_entity_type IN (:...types)', { types: relatedTypesList })
60
- .andWhere('attr.enterprise_id = :entId', { entId })
61
- .getMany()
84
+ .getRepository(AttributeMaster)
85
+ .createQueryBuilder('attr')
86
+ .select([
87
+ 'attr.id',
88
+ 'attr.name',
89
+ 'attr.flat_json_key',
90
+ 'attr.mapped_entity_type',
91
+ 'attr.attribute_key',
92
+ 'attr.data_type',
93
+ ])
94
+ .where('attr.mapped_entity_type IN (:...types)', {
95
+ types: relatedTypesList,
96
+ })
97
+ .andWhere('attr.enterprise_id = :entId', { entId })
98
+ .getMany()
62
99
  : [];
63
100
 
64
- await this.loggerService.log('debug', 'EntityJSONService', 'getAttributeForFlatJSON', `Loaded ${relatedAttributes.length} related attributes`);
101
+ await this.loggerService.log(
102
+ 'debug',
103
+ 'EntityJSONService',
104
+ 'getAttributeForFlatJSON',
105
+ `Loaded ${relatedAttributes.length} related attributes`,
106
+ );
65
107
 
108
+ // LINKED ATTRIBUTES
66
109
  const linkedAttributes = await this.dataSource
67
110
  .getRepository(LinkedAttributes)
68
111
  .createQueryBuilder('fla')
@@ -78,48 +121,145 @@ export class EntityJSONService extends EntityServiceImpl {
78
121
  'fla.saved_filter_code AS saved_filter_code',
79
122
  'attr.name AS name',
80
123
  'attr.id AS id',
124
+ 'attr.data_type AS data_type',
81
125
  ])
82
126
  .where('attr.enterprise_id = :entId', { entId })
83
127
  .getRawMany();
84
128
 
85
- await this.loggerService.log('debug', 'EntityJSONService', 'getAttributeForFlatJSON', `Loaded ${linkedAttributes.length} linked attributes`);
129
+ await this.loggerService.log(
130
+ 'debug',
131
+ 'EntityJSONService',
132
+ 'getAttributeForFlatJSON',
133
+ `Loaded ${linkedAttributes.length} linked attributes`,
134
+ );
135
+
136
+ // -------------------------------------------------------------------------
137
+ // ✅ FLAG: filter_attribute (NEW)
138
+ // -------------------------------------------------------------------------
139
+ if (flag === 'filter_attribute') {
140
+ const filterAttributes: any[] = [];
141
+
142
+ // MAIN
143
+ filterAttributes.push(
144
+ ...mainAttributes.map((a) => ({
145
+ id: a.id,
146
+ name: a.name,
147
+ data_type: a.data_type,
148
+ attribute_key: a.flat_json_key,
149
+ source: 'main',
150
+ })),
151
+ );
152
+
153
+ // RELATED
154
+ filterAttributes.push(
155
+ ...relatedAttributes.map((a) => ({
156
+ id: a.id,
157
+ name: a.name,
158
+ data_type: a.data_type,
159
+ attribute_key: a.flat_json_key,
160
+ source: 'related',
161
+ })),
162
+ );
86
163
 
164
+ // LINKED
165
+ filterAttributes.push(
166
+ ...linkedAttributes.map((l) => ({
167
+ id: l.id,
168
+ name: l.name,
169
+ data_type: l.data_type,
170
+ attribute_key: l.target_attribute_key, // attribute_key
171
+ source: 'linked',
172
+ })),
173
+ );
174
+
175
+ return filterAttributes;
176
+ }
177
+
178
+ // -------------------------------------------------------------------------
179
+ // ORIGINAL flat_json FLAG (unchanged)
180
+ // -------------------------------------------------------------------------
87
181
  if (flag === 'flat_json' || flag === 'all') {
88
182
  const result: Record<string, null> = {};
89
- mainAttributes.forEach(attr => {
183
+
184
+ mainAttributes.forEach((attr) => {
90
185
  if (attr.flat_json_key) result[attr.flat_json_key] = null;
91
186
  });
92
- relatedAttributes.forEach(attr => {
187
+
188
+ relatedAttributes.forEach((attr) => {
93
189
  if (attr.flat_json_key) result[attr.flat_json_key] = null;
94
190
  });
95
- linkedAttributes.forEach(link => {
191
+
192
+ linkedAttributes.forEach((link) => {
96
193
  if (link.target_attribute_key) result[link.target_attribute_key] = null;
97
194
  });
98
195
 
99
196
  if (flag === 'all') {
100
- return { flat_json: result, attributes: { mainAttributes, relatedAttributes, linkedAttributes } };
197
+ return {
198
+ flat_json: result,
199
+ attributes: {
200
+ mainAttributes,
201
+ relatedAttributes,
202
+ linkedAttributes,
203
+ },
204
+ };
101
205
  }
102
206
 
103
207
  return result;
104
208
  }
105
209
 
210
+ // -------------------------------------------------------------------------
211
+ // ORIGINAL dropdown FLAG (unchanged)
212
+ // -------------------------------------------------------------------------
106
213
  const dropdown: any[] = [];
107
- dropdown.push(...mainAttributes.map(a => ({ label: a.name, value: a.flat_json_key })));
108
- dropdown.push(...relatedAttributes.map(a => ({ label: a.name, value: a.flat_json_key })));
214
+
215
+ dropdown.push(
216
+ ...mainAttributes.map((a) => ({ label: a.name, value: a.flat_json_key })),
217
+ );
218
+ dropdown.push(
219
+ ...relatedAttributes.map((a) => ({
220
+ label: a.name,
221
+ value: a.flat_json_key,
222
+ })),
223
+ );
224
+
109
225
  if (linkedAttributes.length > 0) {
110
- dropdown.push(...linkedAttributes.map(a => ({ label: a.name, value: a.attribute_key })));
226
+ dropdown.push(
227
+ ...linkedAttributes.map((a) => ({
228
+ label: a.name,
229
+ value: a.target_attribute_key,
230
+ })),
231
+ );
111
232
  }
112
233
 
113
234
  return dropdown;
114
235
  }
115
236
 
116
237
  async updateEntityJSON(entityType: string, entityId: number, loggedInUser) {
117
- await this.loggerService.log('info', 'EntityJSONService', 'updateEntityJSON', `Building flat JSON for entity: ${entityType}#${entityId}`);
118
-
119
- const response = await this.getAttributeForFlatJSON(entityType, loggedInUser, 'all');
120
-
121
- if (!response || !('flat_json' in response) || !('attributes' in response) || !response.attributes) {
122
- await this.loggerService.log('error', 'EntityJSONService', 'updateEntityJSON', `getAttributeForFlatJSON() did not return expected structure`);
238
+ await this.loggerService.log(
239
+ 'info',
240
+ 'EntityJSONService',
241
+ 'updateEntityJSON',
242
+ `Building flat JSON for entity: ${entityType}#${entityId}`,
243
+ );
244
+
245
+ const response = await this.getAttributeForFlatJSON(
246
+ entityType,
247
+ loggedInUser,
248
+ 'all',
249
+ );
250
+
251
+ if (
252
+ !response ||
253
+ !('flat_json' in response) ||
254
+ !('attributes' in response) ||
255
+ !response.attributes
256
+ ) {
257
+ await this.loggerService.log(
258
+ 'error',
259
+ 'EntityJSONService',
260
+ 'updateEntityJSON',
261
+ `getAttributeForFlatJSON() did not return expected structure`,
262
+ );
123
263
  return null;
124
264
  }
125
265
 
@@ -133,25 +273,42 @@ export class EntityJSONService extends EntityServiceImpl {
133
273
  };
134
274
 
135
275
  const attrMap: Record<string, string> = {};
136
- const allAttrs = [...safeAttributes.mainAttributes, ...safeAttributes.relatedAttributes];
137
- allAttrs.forEach(attr => {
138
- if (attr.attribute_key) attrMap[attr.attribute_key] = attr.flat_json_key || attr.attribute_key;
276
+ const allAttrs = [
277
+ ...safeAttributes.mainAttributes,
278
+ ...safeAttributes.relatedAttributes,
279
+ ];
280
+ allAttrs.forEach((attr) => {
281
+ if (attr.attribute_key)
282
+ attrMap[attr.attribute_key] = attr.flat_json_key || attr.attribute_key;
139
283
  });
140
284
 
141
- const mainData = await this.getResolvedEntityData(entityType, entityId, loggedInUser);
285
+ const mainData = await this.entityServiceImpl.getResolvedEntityData(
286
+ entityType,
287
+ entityId,
288
+ loggedInUser,
289
+ true
290
+ );
142
291
  this.mergeEntityDataIntoFlatJson(flatJson, mainData, attrMap);
143
292
 
144
293
  const relations = await this.dataSource
145
294
  .getRepository('frm_entity_relation_data')
146
295
  .createQueryBuilder('erd')
147
- .select(['erd.target_entity_id AS target_entity_id', 'erd.target_entity_type AS target_entity_type'])
296
+ .select([
297
+ 'erd.target_entity_id AS target_entity_id',
298
+ 'erd.target_entity_type AS target_entity_type',
299
+ ])
148
300
  .where('erd.source_entity_type = :entityType', { entityType })
149
301
  .andWhere('erd.source_entity_id = :entityId', { entityId })
150
302
  .andWhere('erd.relation_type = :rt', { rt: 'ONE_TO_ONE' })
151
303
  .getRawMany();
152
304
 
153
305
  for (const rel of relations) {
154
- const relatedData = await this.getResolvedEntityData(rel.target_entity_type, rel.target_entity_id, loggedInUser);
306
+ const relatedData = await this.entityServiceImpl.getResolvedEntityData(
307
+ rel.target_entity_type,
308
+ rel.target_entity_id,
309
+ loggedInUser,
310
+ true
311
+ );
155
312
  this.mergeEntityDataIntoFlatJson(flatJson, relatedData, attrMap);
156
313
  }
157
314
 
@@ -175,11 +332,16 @@ export class EntityJSONService extends EntityServiceImpl {
175
332
  );
176
333
 
177
334
  if (value !== null && value !== undefined) {
178
- flatJson[targetKey] = value;
335
+ flatJson[targetKey] = typeof value === 'string' ? value.toLowerCase() : value;
179
336
  }
180
337
  }
181
338
 
182
- await this.loggerService.log('info', 'EntityJSONService', 'updateEntityJSON', `Saving flat JSON for entity: ${entityType}#${entityId}`);
339
+ await this.loggerService.log(
340
+ 'info',
341
+ 'EntityJSONService',
342
+ 'updateEntityJSON',
343
+ `Saving flat JSON for entity: ${entityType}#${entityId}`,
344
+ );
183
345
  let JsonData = {
184
346
  entity_type: entityType,
185
347
  entity_id: entityId,
@@ -192,7 +354,11 @@ export class EntityJSONService extends EntityServiceImpl {
192
354
  return flatJson;
193
355
  }
194
356
 
195
- private mergeEntityDataIntoFlatJson(flatJson: Record<string, any>, entityData: any | any[], attrMap: Record<string, string>) {
357
+ private mergeEntityDataIntoFlatJson(
358
+ flatJson: Record<string, any>,
359
+ entityData: any | any[],
360
+ attrMap: Record<string, string>,
361
+ ) {
196
362
  const records = Array.isArray(entityData) ? entityData : [entityData];
197
363
 
198
364
  for (const record of records) {
@@ -200,7 +366,9 @@ export class EntityJSONService extends EntityServiceImpl {
200
366
  for (const key of Object.keys(record)) {
201
367
  const flatKey = attrMap[key] || key;
202
368
  if (flatJson.hasOwnProperty(flatKey)) {
203
- flatJson[flatKey] = record[key];
369
+ const value = record[key];
370
+ // Convert string values to lowercase
371
+ flatJson[flatKey] = typeof value === 'string' ? value.toLowerCase() : value;
204
372
  }
205
373
  }
206
374
  }
@@ -215,27 +383,46 @@ export class EntityJSONService extends EntityServiceImpl {
215
383
  loggedInUser,
216
384
  entity_id,
217
385
  ) {
218
- if (!savedFilterCode && (mappingValue === null || mappingValue === undefined)) return null;
386
+ if (
387
+ !savedFilterCode &&
388
+ (mappingValue === null || mappingValue === undefined)
389
+ )
390
+ return null;
219
391
 
220
392
  const dto: any = {
221
393
  entity_type: childEntityType,
222
394
  savedFilterCode,
223
395
  page: 1,
224
396
  size: 1,
397
+ loggedInUser
225
398
  };
226
399
 
227
- if (mappingValue !== null && mappingValue !== undefined && mappingValue !== '') {
400
+ if (
401
+ mappingValue !== null &&
402
+ mappingValue !== undefined &&
403
+ mappingValue !== ''
404
+ ) {
228
405
  dto.quickFilter = [
229
- { filter_attribute: childFilterAttribute, filter_operator: 'equal', filter_value: mappingValue },
406
+ {
407
+ filter_attribute: childFilterAttribute,
408
+ filter_operator: 'equal',
409
+ filter_value: mappingValue,
410
+ },
230
411
  ];
231
412
  }
232
413
 
233
414
  dto.quickFilter = [
234
- { filter_attribute: 'parent_id', filter_operator: 'equal', filter_value: [entity_id] },
415
+ {
416
+ filter_attribute: 'parent_id',
417
+ filter_operator: 'equal',
418
+ filter_value: [entity_id],
419
+ },
235
420
  ];
236
421
 
237
422
  const result = await this.filterService.applyFilter(dto);
238
423
  const rows = result?.data?.entity_list || [];
239
424
  return rows.length ? (rows[0][childFilterAttribute] ?? null) : null;
240
425
  }
426
+
427
+
241
428
  }
@@ -8,7 +8,9 @@ import {
8
8
  Param,
9
9
  Inject,
10
10
  UseGuards,
11
- Req, HttpCode, HttpStatus,
11
+ Req,
12
+ HttpCode,
13
+ HttpStatus,
12
14
  } from '@nestjs/common';
13
15
  import { FilterService } from '../service/filter.service';
14
16
  import { SavedFilterService } from '../service/saved-filter.service';
@@ -49,9 +51,7 @@ export class FilterController {
49
51
  sortby,
50
52
  } = body;
51
53
 
52
-
53
-
54
- return this.filterService.applyFilterWrapper({
54
+ return this.filterService.applyFilterWithRouting({
55
55
  entity_type,
56
56
  quickFilter,
57
57
  savedFilterCode,
@@ -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
- export class FilterModule {}
42
+ export class FilterModule {}