rez_core 5.0.99 → 5.0.101

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 (28) hide show
  1. package/dist/module/entity_json/service/entity_json.service.d.ts +1 -3
  2. package/dist/module/entity_json/service/entity_json.service.js +17 -12
  3. package/dist/module/entity_json/service/entity_json.service.js.map +1 -1
  4. package/dist/module/filter/dto/filter-request.dto.d.ts +2 -2
  5. package/dist/module/filter/service/filter.service.js +3 -1
  6. package/dist/module/filter/service/filter.service.js.map +1 -1
  7. package/dist/module/mapper/service/field-mapper.service.d.ts +1 -3
  8. package/dist/module/mapper/service/field-mapper.service.js +2 -5
  9. package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
  10. package/dist/module/meta/controller/entity.controller.d.ts +3 -3
  11. package/dist/module/meta/controller/entity.controller.js +27 -12
  12. package/dist/module/meta/controller/entity.controller.js.map +1 -1
  13. package/dist/module/meta/service/entity-service-impl.service.d.ts +4 -1
  14. package/dist/module/meta/service/entity-service-impl.service.js +12 -14
  15. package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
  16. package/dist/module/meta/service/entity.service.d.ts +2 -1
  17. package/dist/module/workflow/repository/action.repository.js +2 -2
  18. package/dist/module/workflow/repository/action.repository.js.map +1 -1
  19. package/dist/tsconfig.build.tsbuildinfo +1 -1
  20. package/package.json +1 -1
  21. package/src/module/entity_json/service/entity_json.service.ts +22 -16
  22. package/src/module/filter/dto/filter-request.dto.ts +2 -2
  23. package/src/module/filter/service/filter.service.ts +4 -3
  24. package/src/module/mapper/service/field-mapper.service.ts +0 -2
  25. package/src/module/meta/controller/entity.controller.ts +45 -27
  26. package/src/module/meta/service/entity-service-impl.service.ts +25 -48
  27. package/src/module/meta/service/entity.service.ts +2 -5
  28. package/src/module/workflow/repository/action.repository.ts +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "5.0.99",
3
+ "version": "5.0.101",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,5 +1,4 @@
1
1
  import { Injectable } from '@nestjs/common';
2
- import { FilterService } from 'src/module/filter/service/filter.service';
3
2
  import { LinkedAttributes } from 'src/module/linked_attributes/entity/linked_attribute.entity';
4
3
  import { AttributeMaster } from 'src/module/meta/entity/attribute-master.entity';
5
4
  import { EntityRelation } from 'src/module/meta/entity/entity-relation.entity';
@@ -12,9 +11,8 @@ import { EntityJSONRepository } from './entityJson.repository';
12
11
  export class EntityJSONService extends EntityServiceImpl {
13
12
  constructor(
14
13
  private readonly dataSource: DataSource,
15
- private readonly filterService: FilterService,
16
14
  private readonly loggerService: LoggingService,
17
- private readonly EntityJSONRepository:EntityJSONRepository
15
+ private readonly EntityJSONRepository: EntityJSONRepository,
18
16
  ) {
19
17
  super();
20
18
  }
@@ -53,12 +51,12 @@ export class EntityJSONService extends EntityServiceImpl {
53
51
 
54
52
  const relatedAttributes = relatedTypesList.length
55
53
  ? 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.organization_id = :orgId', { orgId })
61
- .getMany()
54
+ .getRepository(AttributeMaster)
55
+ .createQueryBuilder('attr')
56
+ .select(['attr.id', 'attr.name', 'attr.flat_json_key', 'attr.mapped_entity_type', 'attr.attribute_key'])
57
+ .where('attr.mapped_entity_type IN (:...types)', { types: relatedTypesList })
58
+ .andWhere('attr.organization_id = :orgId', { orgId })
59
+ .getMany()
62
60
  : [];
63
61
 
64
62
  await this.loggerService.log('debug', 'EntityJSONService', 'getAttributeForFlatJSON', `Loaded ${relatedAttributes.length} related attributes`);
@@ -86,9 +84,15 @@ export class EntityJSONService extends EntityServiceImpl {
86
84
 
87
85
  if (flag === 'flat_json' || flag === 'all') {
88
86
  const result: Record<string, null> = {};
89
- mainAttributes.forEach(attr => { if (attr.flat_json_key) result[attr.flat_json_key] = null; });
90
- relatedAttributes.forEach(attr => { if (attr.flat_json_key) result[attr.flat_json_key] = null; });
91
- linkedAttributes.forEach(link => { if (link.target_attribute_key) result[link.target_attribute_key] = null; });
87
+ mainAttributes.forEach(attr => {
88
+ if (attr.flat_json_key) result[attr.flat_json_key] = null;
89
+ });
90
+ relatedAttributes.forEach(attr => {
91
+ if (attr.flat_json_key) result[attr.flat_json_key] = null;
92
+ });
93
+ linkedAttributes.forEach(link => {
94
+ if (link.target_attribute_key) result[link.target_attribute_key] = null;
95
+ });
92
96
 
93
97
  if (flag === 'all') {
94
98
  return { flat_json: result, attributes: { mainAttributes, relatedAttributes, linkedAttributes } };
@@ -128,7 +132,9 @@ export class EntityJSONService extends EntityServiceImpl {
128
132
 
129
133
  const attrMap: Record<string, string> = {};
130
134
  const allAttrs = [...safeAttributes.mainAttributes, ...safeAttributes.relatedAttributes];
131
- allAttrs.forEach(attr => { if (attr.attribute_key) attrMap[attr.attribute_key] = attr.flat_json_key || attr.attribute_key; });
135
+ allAttrs.forEach(attr => {
136
+ if (attr.attribute_key) attrMap[attr.attribute_key] = attr.flat_json_key || attr.attribute_key;
137
+ });
132
138
 
133
139
  const mainData = await this.getResolvedEntityData(entityType, entityId, loggedInUser);
134
140
  this.mergeEntityDataIntoFlatJson(flatJson, mainData, attrMap);
@@ -177,8 +183,8 @@ export class EntityJSONService extends EntityServiceImpl {
177
183
  entity_id: entityId,
178
184
  json_data: flatJson,
179
185
  created_by: loggedInUser.id,
180
- }
181
-
186
+ };
187
+
182
188
  await this.EntityJSONRepository.create(JsonData);
183
189
 
184
190
  return flatJson;
@@ -205,7 +211,7 @@ export class EntityJSONService extends EntityServiceImpl {
205
211
  mappingValue: any,
206
212
  targetAttribute: string,
207
213
  loggedInUser,
208
- entity_id
214
+ entity_id,
209
215
  ) {
210
216
  if (!savedFilterCode && (mappingValue === null || mappingValue === undefined)) return null;
211
217
 
@@ -28,8 +28,8 @@ export interface FilterRequestDto {
28
28
  attributeFilter?: FilterCondition[];
29
29
  sortby?: SortConfig[];
30
30
  tabs?: TabsConfig;
31
- page?: number;
32
- size?: number;
31
+ page?: number|null;
32
+ size?: number|null;
33
33
  loggedInUser: UserData;
34
34
  queryParams?: Record<string, string>;
35
35
  customLevelType?: string;
@@ -278,7 +278,7 @@ export class FilterService {
278
278
  ),
279
279
  ];
280
280
 
281
- // 🧱 Build where clauses
281
+ // 🧱 Build where clausesx
282
282
  const baseWhere = this.buildWhereClauses(baseFilters, attributeMetaMap);
283
283
 
284
284
  // Handle TEMPLATE entity special condition
@@ -485,10 +485,11 @@ export class FilterService {
485
485
 
486
486
  // Apply sorting
487
487
  qb = await this.sortTabsByShowList(qb, sortby, layoutPreference, tabs);
488
-
489
488
  const page = dto.page && dto.page > 0 ? dto.page : 1;
490
489
  const size = dto.size && dto.size > 0 ? dto.size : 10;
491
- qb.skip((page - 1) * size).take(size);
490
+ if (dto.page && dto.size) {
491
+ qb.skip((page - 1) * size).take(size);
492
+ }
492
493
 
493
494
  let query = await qb.getQuery();
494
495
 
@@ -4,7 +4,6 @@ import { FieldMapperDto } from '../dto/field-mapper.dto';
4
4
  import { EntityServiceImpl } from '../../meta/service/entity-service-impl.service';
5
5
  import { UserData } from '../../user/entity/user.entity';
6
6
  import { FieldLovsRepository } from '../repository/field-lovs.repository';
7
- import { FilterService } from 'src/module/filter/service/filter.service';
8
7
  import { BaseEntity } from '../../meta/entity/base-entity.entity';
9
8
  import { LoggingService } from 'src/utils/service/loggingUtil.service';
10
9
 
@@ -13,7 +12,6 @@ export class FieldMapperService extends EntityServiceImpl {
13
12
  constructor(
14
13
  private readonly fieldMapperRepository: FieldMapperRepository,
15
14
  private readonly fieldLovsRepository: FieldLovsRepository,
16
- private readonly filterService: FilterService,
17
15
  @Inject() protected readonly loggingService: LoggingService,
18
16
  ) {
19
17
  super();
@@ -5,29 +5,28 @@ import {
5
5
  Get,
6
6
  HttpCode,
7
7
  HttpStatus,
8
+ InternalServerErrorException,
9
+ NotFoundException,
8
10
  Param,
9
11
  Post,
10
12
  Query,
11
- Res,
12
13
  Req,
13
- UseGuards,
14
- Inject,
15
14
  Request,
16
- InternalServerErrorException,
17
- NotFoundException,
15
+ Res,
16
+ UseGuards,
18
17
  } from '@nestjs/common';
19
18
  import { EntityServiceImpl } from '../service/entity-service-impl.service';
20
- import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
21
19
  import { Response } from 'express';
20
+ import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
22
21
  import { EntityMasterService } from '../service/entity-master.service';
23
22
  import { BaseEntity } from '../entity/base-entity.entity';
24
23
  import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
25
24
  import * as fs from 'fs';
26
25
  import * as path from 'path';
27
- import { UserService } from '../../user/service/user.service';
28
- import { ENTITYTYPE_USER } from '../../../constant/global.constant';
29
26
  import { UserData } from '../../user/entity/user.entity';
30
- import { WorkflowAutomationEngineService } from 'src/module/workflow-automation/service/workflow-automation-engine.service';
27
+ import {
28
+ WorkflowAutomationEngineService,
29
+ } from 'src/module/workflow-automation/service/workflow-automation-engine.service';
31
30
 
32
31
  @UseGuards(JwtAuthGuard)
33
32
  @Controller('entity')
@@ -37,7 +36,8 @@ export class EntityController {
37
36
  private reflectionHelper: ReflectionHelper,
38
37
  private entityMasterService: EntityMasterService,
39
38
  private readonly workflowAutomationEngineService: WorkflowAutomationEngineService,
40
- ) {}
39
+ ) {
40
+ }
41
41
 
42
42
  @Get('getById/:id')
43
43
  // @Roles('USR', 'VIEW')
@@ -231,12 +231,12 @@ export class EntityController {
231
231
  // 2️⃣ Pre-evaluate criteria
232
232
  const workflows = await this.workflowAutomationEngineService[
233
233
  'wfService'
234
- ].getActiveRules(entityType, 'UPDATE', loggedInUser);
234
+ ].getActiveRules(entityType, 'UPDATE', loggedInUser);
235
235
  const preUpdateStates: Record<number, boolean> = {};
236
236
  for (const wf of workflows) {
237
237
  preUpdateStates[wf.id] = await this.workflowAutomationEngineService[
238
238
  'filterEvaluator'
239
- ].evaluateCriteria(
239
+ ].evaluateCriteria(
240
240
  entityType,
241
241
  wf.condition_filter_code,
242
242
  existingEntity.id,
@@ -341,27 +341,45 @@ export class EntityController {
341
341
  }
342
342
 
343
343
  @HttpCode(HttpStatus.OK)
344
- @Post('download-excel/:entity_type')
345
- @HttpCode(HttpStatus.OK)
344
+ @Post('download-report')
346
345
  async downloadExcel(
347
- @Param('entity_type') entityType: string,
348
- @Query('list_entity_type') listEntityType: string,
349
- @Query('display_type') displayType: string,
350
- @Query('sample_export') sampleExport: boolean,
351
- @Query() filterCriteria: Record<string, any>,
352
- @Res() res: Response, // Express Response for file handling
346
+ @Body() body: any,
353
347
  @Req() req: Request & { user: any },
348
+ @Query() queryParams: Record<string, string>,
349
+ @Res() res: Response,
350
+ @Query('level_type') levelType?: string,
351
+ @Query('level_id') levelId?: number,
352
+ @Query('appcode') appCode?: string,
354
353
  ) {
355
354
  try {
356
355
  const loggedInUser = req.user.userData;
357
356
 
358
- const filePath = await this.entityService.generateExcelReport(
359
- entityType,
360
- filterCriteria,
361
- listEntityType,
362
- displayType,
363
- sampleExport,
364
- loggedInUser,
357
+ const {
358
+ entity_type,
359
+ quickFilter,
360
+ savedFilterCode,
361
+ attributeFilter,
362
+ tabs,
363
+ sortby,
364
+ } = body;
365
+
366
+ const { ...otherQueryParams } = queryParams;
367
+
368
+ const filePath = await this.entityService.generateExcelReport({
369
+ entity_type,
370
+ quickFilter,
371
+ savedFilterCode,
372
+ attributeFilter,
373
+ tabs,
374
+ sortby,
375
+ page: null,
376
+ size: null,
377
+ loggedInUser,
378
+ queryParams: otherQueryParams, // only remaining query params
379
+ customLevelType: levelType,
380
+ customLevelId: levelId,
381
+ customAppCode: appCode,
382
+ }
365
383
  );
366
384
 
367
385
  if (!filePath || !fs.existsSync(filePath)) {
@@ -28,6 +28,8 @@ import {
28
28
  import { EntityValidationService } from './entity-validation.service';
29
29
  import { AttributeMasterService } from './attribute-master.service';
30
30
  import { ResolverService } from './resolver.service';
31
+ import { FilterRequestDto } from '../../filter/dto/filter-request.dto';
32
+ import { FilterService } from '../../filter/service/filter.service';
31
33
 
32
34
  @Injectable()
33
35
  export class EntityServiceImpl implements EntityService<BaseEntity> {
@@ -43,6 +45,7 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
43
45
  protected readonly attributeMasterService: AttributeMasterService;
44
46
  @Inject(forwardRef(() => ResolverService))
45
47
  protected readonly resolverService: ResolverService;
48
+ protected readonly filterService: FilterService;
46
49
 
47
50
  async createEntity(
48
51
  entityData: BaseEntity,
@@ -352,24 +355,14 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
352
355
  }
353
356
 
354
357
  async generateExcelReport(
355
- entityType: string,
356
- filterCriteria: Record<string, any>,
357
- listEntityType: string,
358
- displayType: string,
359
- sampleExport: boolean,
360
- loggedInUser: UserData,
358
+ dto: FilterRequestDto
361
359
  ): Promise<string | null> {
362
360
  let fileName: string;
363
361
  try {
364
362
  const excelData = new ExcelData();
365
363
  await this.populateExcelData(
366
364
  excelData,
367
- entityType,
368
- filterCriteria,
369
- listEntityType,
370
- displayType,
371
- sampleExport,
372
- loggedInUser,
365
+ dto
373
366
  );
374
367
 
375
368
  const modifiedDate = new Date().toISOString().replace(/[-T:.Z]/g, '');
@@ -388,52 +381,36 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
388
381
 
389
382
  private async populateExcelData(
390
383
  excelData: ExcelData,
391
- entityType: string,
392
- filterCriteria: Record<string, any>,
393
- listEntityType: string,
394
- displayType: string,
395
- sampleExport: boolean,
396
- loggedInUser: UserData,
384
+ dto: FilterRequestDto
397
385
  ) {
398
- const entityTable =
399
- await this.entityTableService.findByEntityTypeAndListTypeAndDisplayType(
400
- entityType,
401
- listEntityType,
402
- displayType,
403
- loggedInUser.organization_id,
386
+
387
+ const entityMeta = await this.entityMasterService.getEntityData(
388
+ dto.entity_type,
389
+ dto.loggedInUser,
390
+ );
391
+
392
+ const attributes =
393
+ await this.attributeMasterService.findAttributesByMappedEntityType(
394
+ dto.entity_type,
395
+ dto.loggedInUser,
404
396
  );
397
+
398
+ let filterData = await this.filterService.applyFilterWrapper(dto);
399
+ let entityList = filterData.data.entity_list;
400
+
405
401
  const sheet: ExcelsheetData = {
406
- sheetName: entityTable?.data_source || 'sheet',
402
+ sheetName: entityMeta?.name || 'sheet',
407
403
  headers: [],
408
404
  rowList: [],
409
405
  };
410
406
 
411
- if (entityTable) {
412
- const entityTableColumnList =
413
- await this.entityTableColumnService.findByParentIdAndParentType(
414
- entityTable.id,
415
- entityTable.entity_type,
416
- loggedInUser.organization_id,
417
- );
418
-
419
- sheet.headers = entityTableColumnList.map((col) => col.name);
420
- const attributeList = entityTableColumnList.map(
407
+ if (attributes) {
408
+ sheet.headers = attributes.map((col) => col.name);
409
+ const attributeList = attributes.map(
421
410
  (col) => col.attribute_key,
422
411
  );
423
412
 
424
- let filteredList: any[] = [];
425
- if (!sampleExport) {
426
- filteredList = await this.entityListService.getFilteredList(
427
- entityTable,
428
- filterCriteria,
429
- undefined,
430
- undefined,
431
- undefined,
432
- undefined,
433
- );
434
- }
435
-
436
- sheet.rowList = filteredList.map((item) =>
413
+ sheet.rowList = entityList.map((item) =>
437
414
  attributeList.map((attr) =>
438
415
  item[attr] !== undefined ? item[attr] : null,
439
416
  ),
@@ -2,6 +2,7 @@ import { UserData } from '../../user/entity/user.entity';
2
2
  import { BaseEntity } from '../entity/base-entity.entity';
3
3
  import { EntityListData } from '../dto/entity-list-data.dto';
4
4
  import { EntityManager } from 'typeorm';
5
+ import { FilterRequestDto } from '../../filter/dto/filter-request.dto';
5
6
 
6
7
  export interface EntityService<T extends BaseEntity> {
7
8
  createEntity(
@@ -57,11 +58,7 @@ export interface EntityService<T extends BaseEntity> {
57
58
  ): Promise<EntityListData>;
58
59
 
59
60
  generateExcelReport(
60
- entityType: string,
61
- filterCriteria: Record<string, any>,
62
- listEntityType: string,
63
- displayType: string,
64
- sampleExport: boolean,
61
+ dto: FilterRequestDto,
65
62
  loggedInUser: UserData,
66
63
  ): Promise<string | null>;
67
64
  }
@@ -9,9 +9,9 @@ export class ActionRepository {
9
9
 
10
10
  async getReasonCode(loggedInUser: UserData): Promise<any> {
11
11
  const { organization_id } = loggedInUser;
12
- const listMasterItemsRepo =
13
- this.reflectionHelper.getRepoService('ListMasterItems');
14
- const result = await listMasterItemsRepo.find({
12
+ const listMasterRepo =
13
+ this.reflectionHelper.getRepoService('ListMasterData');
14
+ const result = await listMasterRepo.find({
15
15
  where: {
16
16
  organization_id,
17
17
  source: 'master',