rez_core 2.0.96 → 2.0.97

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": "2.0.96",
3
+ "version": "2.0.97",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,12 +1,11 @@
1
- import { Injectable, BadRequestException, Inject } from '@nestjs/common';
1
+ import { BadRequestException, Inject, Injectable } from '@nestjs/common';
2
2
  import { AttributeMasterService } from 'src/module/meta/service/attribute-master.service';
3
3
  import { EntityMasterService } from 'src/module/meta/service/entity-master.service';
4
+ import { EntityTableColumnService } from 'src/module/meta/service/entity-table-column.service';
5
+ import { EntityTableService } from 'src/module/meta/service/entity-table.service';
4
6
  import { DataSource } from 'typeorm';
5
- import { SavedFilterService } from './saved-filter.service';
6
7
  import { FilterRequestDto } from '../dto/filter-request.dto';
7
- import { EntityTableService } from 'src/module/meta/service/entity-table.service';
8
- import { EntityTableColumnService } from 'src/module/meta/service/entity-table-column.service';
9
- import { get } from 'http';
8
+ import { SavedFilterService } from './saved-filter.service';
10
9
 
11
10
  @Injectable()
12
11
  export class FilterService {
@@ -19,7 +18,7 @@ export class FilterService {
19
18
  @Inject('SavedFilterService')
20
19
  private readonly savedFilterService: SavedFilterService,
21
20
  ) {}
22
- private readonly skipLevelFilterEntities = ['USR', 'UPR'];
21
+ private readonly skipLevelFilterEntities = [];
23
22
 
24
23
  private async gettab_value_counts(
25
24
  tableName: string,
@@ -129,11 +128,7 @@ export class FilterService {
129
128
 
130
129
  const baseWhere = this.buildWhereClauses(baseFilters, attributeMetaMap);
131
130
 
132
- if (
133
- level_type &&
134
- level_id &&
135
- !this.skipLevelFilterEntities.includes(entity_type)
136
- ) {
131
+ if (level_type && level_id) {
137
132
  baseWhere.push({
138
133
  query: 'e.level_type = :level_type AND e.level_id = :level_id',
139
134
  params: {
@@ -411,11 +411,11 @@ export class MasterService {
411
411
  row.entity_type = entityType;
412
412
  row.organization_id = loggedInUser.organization_id;
413
413
 
414
- const rowErrors =
415
- await this.entityValidationService.validateExcelEntityData(
416
- row,
417
- entityMaster,
418
- );
414
+ const rowErrors = await this.entityValidationService.validateEntityData(
415
+ row,
416
+ entityMaster,
417
+ loggedInUser,
418
+ );
419
419
 
420
420
  const existingError = errors.find((e) => e.row === i + 1);
421
421
 
@@ -466,13 +466,13 @@ export class MasterService {
466
466
  .andWhere(`${entityMaster.db_table_name}.level_id = :levelId`, {
467
467
  levelId: loggedInUser.level_id,
468
468
  });
469
-
469
+
470
470
  const existing = await qb.limit(1).getRawOne();
471
471
 
472
472
  row.entity_type = entityType;
473
473
  row.organization_id = loggedInUser.organization_id;
474
- row.status="ACTIVE"
475
-
474
+ row.status = 'ACTIVE';
475
+
476
476
  let errors = [];
477
477
  if (existing) {
478
478
  if (duplicateHandling === 'skip_duplicates') continue;
@@ -47,6 +47,7 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
47
47
  await this.entityValidationService.validateEntityData(
48
48
  entityData,
49
49
  entityMaster,
50
+ loggedInUser,
50
51
  );
51
52
  if (validationErrors.length > 0) {
52
53
  throw new BadRequestException({
@@ -49,6 +49,7 @@ export class EntityValidationService {
49
49
  attributeData: AttributeMaster[],
50
50
  entityType: string,
51
51
  db_table_name: string,
52
+ loggedInUser: any,
52
53
  ): Promise<ValidationError[]> {
53
54
  const errors: ValidationError[] = [];
54
55
 
@@ -64,12 +65,16 @@ export class EntityValidationService {
64
65
 
65
66
  // Add AND condition for organization_id if present
66
67
  const orgId = entityData.organization_id;
68
+ const level_type = loggedInUser.level_type;
69
+ const level_id = loggedInUser.level_id;
67
70
 
68
71
  if (orgId !== undefined && orgId !== null) {
69
72
  qb = qb.andWhere(
70
- `${db_table_name}.organization_id = :organization_id`,
73
+ `${db_table_name}.organization_id = :organization_id AND ${db_table_name}.level_type = :level_type AND ${db_table_name}.level_id = :level_id`,
71
74
  {
72
75
  organization_id: orgId,
76
+ level_type: level_type,
77
+ level_id: level_id,
73
78
  },
74
79
  );
75
80
  }
@@ -119,6 +124,7 @@ export class EntityValidationService {
119
124
  async validateEntityData(
120
125
  entityData: Record<string, any>,
121
126
  entityMaster,
127
+ loggedInUser: any,
122
128
  ): Promise<ValidationError[]> {
123
129
  const attributes =
124
130
  await this.attributeMasterService.findAttributesByMappedEntityType(
@@ -131,6 +137,7 @@ export class EntityValidationService {
131
137
  attributes,
132
138
  entityData.entity_type,
133
139
  entityMaster.db_table_name,
140
+ loggedInUser,
134
141
  );
135
142
  const regexErros = await this.validateRegexFields(entityData, attributes);
136
143
  return [...requiredErrors, ...uniqueErrors, ...regexErros];