rez_core 5.0.170 → 5.0.173

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": "5.0.170",
3
+ "version": "5.0.173",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -10,6 +10,9 @@ import { UtilsModule } from 'src/utils/utils.module';
10
10
  import { EntityModule } from '../meta/entity.module';
11
11
  import { OrganizationRepository } from './repository/organization.repository';
12
12
  import { SchoolRepository } from './repository/school.repository';
13
+ import { WorkflowAutomationModule } from '../workflow-automation/workflow-automation.module';
14
+ import { EnterpriseService } from './service/enterprise.service';
15
+ import { BrandService } from './service/brand.service';
13
16
 
14
17
  @Module({
15
18
  imports: [
@@ -24,7 +27,12 @@ import { SchoolRepository } from './repository/school.repository';
24
27
  OrganizationAppMappingService,
25
28
  SchoolRepository,
26
29
  OrganizationRepository,
30
+ EnterpriseService,
31
+ {
32
+ provide: 'BrandService',
33
+ useClass: BrandService,
34
+ },
27
35
  ],
28
- exports: [OrganizationService, OrganizationRepository],
36
+ exports: [OrganizationService, OrganizationRepository,EnterpriseService],
29
37
  })
30
38
  export class EnterpriseModule {}
@@ -98,14 +98,17 @@ export class SavedFilterRepositoryService {
98
98
  where: {
99
99
  user_id: loggedInUser.id,
100
100
  mapped_entity_type: entityType,
101
+ level_type: loggedInUser.level_type,
102
+ level_id: loggedInUser.level_id,
101
103
  status: 'ACTIVE',
104
+ is_shared: false,
102
105
  },
103
106
  order: {
104
107
  created_date: 'DESC',
105
108
  },
106
109
  });
107
110
 
108
- if (!filters?.length) {
111
+ if (filters?.length) {
109
112
  for (const filter of filters) {
110
113
  try {
111
114
  const baseUrl = this.configService.get<string>('REDIRECT_BE_URL');
@@ -151,14 +154,13 @@ export class SavedFilterRepositoryService {
151
154
  mapped_entity_type: entityType,
152
155
  is_shared: true,
153
156
  status: 'ACTIVE',
154
- user_id: Not(loggedInUser.id),
155
157
  },
156
158
  order: {
157
159
  created_date: 'DESC',
158
160
  },
159
161
  });
160
162
 
161
- if (!filters?.length) {
163
+ if (filters?.length) {
162
164
  for (const filter of filters) {
163
165
  try {
164
166
  const baseUrl = this.configService.get<string>('REDIRECT_BE_URL');
@@ -27,8 +27,8 @@ export class EntityMasterRepository {
27
27
  if (data) {
28
28
  const listMasterItemsRepo = this.reflectionHelper.getRepoService('ListMasterItems');
29
29
  let listMasterItemsata = await listMasterItemsRepo.findOne({
30
- where: { id: data.status }
31
- })
30
+ where: { id: data.status },
31
+ });
32
32
 
33
33
  data.status = listMasterItemsata?.name;
34
34
  }
@@ -94,13 +94,27 @@ export class EntityMasterRepository {
94
94
  where: {
95
95
  mapped_entity_type: entity_type,
96
96
  data_type: 'DATE',
97
- enterprise_id
98
- }
99
- })
97
+ enterprise_id,
98
+ },
99
+ });
100
100
 
101
101
  return attributes.map((attr) => ({
102
102
  label: attr.name,
103
103
  value: attr.attribute_key,
104
104
  }));
105
105
  }
106
+
107
+ async findByEnterpriseIdAndAppCode(enterprise_id, appcode?) {
108
+ let where = {
109
+ enterprise_id,
110
+ };
111
+
112
+ if (appcode) {
113
+ where['appcode'] = appcode;
114
+ }
115
+ return await this.entityMasterRepository.find({
116
+ where,
117
+ select: ['name', 'mapped_entity_type']
118
+ });
119
+ }
106
120
  }
@@ -19,6 +19,7 @@ export class EntityDynamicService {
19
19
  private readonly configService: ConfigService,
20
20
  ) {
21
21
  }
22
+
22
23
  schema = this.configService.get('DB_SCHEMA');
23
24
 
24
25
  // -----------------------------
@@ -76,15 +77,16 @@ export class EntityDynamicService {
76
77
  // -------------------------------------------------------
77
78
  // AUTO-CODE GENERATION (POSTGRES SAFE)
78
79
  // -------------------------------------------------------
79
- const entityMaster = await this.entityMasterRepo.getEntityByMappedEntityType(entityType, loggedInUser.enterprise_id)
80
+ const entityMaster = await this.entityMasterRepo.getEntityByMappedEntityType(entityType, loggedInUser.enterprise_id);
80
81
 
81
82
  if (!entityData.code && entityData.entity_type && entityMaster) {
82
83
  // Extract integer suffix
83
84
  // const repo = this.reflectionHelper.getRepoService(entityMaster.entity_data_class);
84
85
 
85
86
  const result = this.entityManager.query(
86
- `SELECT MAX(id) as seq_no FROM ${this.schema}.${entityMaster.db_table_name}`
87
- )
87
+ `SELECT MAX(id) as seq_no
88
+ FROM ${this.schema}.${entityMaster.db_table_name}`,
89
+ );
88
90
 
89
91
  let maxSeq = Number(result[0]?.max_seq_no) || 0;
90
92
  maxSeq++;
@@ -251,7 +253,7 @@ export class EntityDynamicService {
251
253
  const relations = await relationRepo.find({
252
254
  where: {
253
255
  source_entity_type: entityType,
254
- organization_id: loggedInUser.organization_id,
256
+ enterprise_id: loggedInUser.enterprise_id,
255
257
  },
256
258
  });
257
259
 
@@ -569,9 +571,9 @@ export class EntityDynamicService {
569
571
  row[attr.attribute_key] =
570
572
  row[attr.attribute_key] != null
571
573
  ? await this.mediaDataService.getMediaDownloadUrl(
572
- Number(row[attr.attribute_key]),
573
- loggedInUser,
574
- )
574
+ Number(row[attr.attribute_key]),
575
+ loggedInUser,
576
+ )
575
577
  : null;
576
578
  }
577
579
  }
@@ -590,7 +592,7 @@ export class EntityDynamicService {
590
592
  const organizationId = loggedInUser.organization_id;
591
593
 
592
594
  const entityMaster = await this.entityMasterRepo.getEntityByMappedEntityType(entityType, enterprise_id);
593
- if(!entityMaster) return null;
595
+ if (!entityMaster) return null;
594
596
 
595
597
  const validAttributes = await this.getAttributeCodes(
596
598
  entityType,
@@ -630,9 +632,9 @@ export class EntityDynamicService {
630
632
  row[attr.attribute_key] =
631
633
  row[attr.attribute_key] != null
632
634
  ? await this.mediaDataService.getMediaDownloadUrl(
633
- Number(row[attr.attribute_key]),
634
- loggedInUser,
635
- )
635
+ Number(row[attr.attribute_key]),
636
+ loggedInUser,
637
+ )
636
638
  : null;
637
639
  }
638
640
  }
@@ -730,19 +732,15 @@ export class EntityDynamicService {
730
732
  loggedInUser: any,
731
733
  appcode?: string,
732
734
  ): Promise<any> {
733
- const organizationId = loggedInUser.organization_id;
734
735
 
735
- let query = `SELECT name as label, mapped_entity_type as value
736
- FROM frm_entity_master
737
- WHERE organization_id = $1`;
738
- const params = [organizationId];
736
+ const entityMasters = await this.entityMasterRepo.findByEnterpriseIdAndAppCode(loggedInUser.enterprise_id, appcode);
739
737
 
740
- if (appcode) {
741
- query += ` AND appcode = $2`;
742
- params.push(appcode);
743
- }
738
+ let dropdown = [] as any;
739
+ entityMasters.map(entityMaster => dropdown.push({
740
+ label: entityMaster.name,
741
+ value: entityMaster.mapped_entity_type,
742
+ }));
744
743
 
745
- const dropdown = await this.entityManager.query(query, params);
746
744
  return dropdown;
747
745
  }
748
746
 
@@ -1,8 +1,8 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { AttributeMasterService } from 'src/module/meta/service/attribute-master.service';
3
3
  import { AttributeMaster } from '../entity/attribute-master.entity';
4
- import { ReflectionHelper } from 'src/utils/service/reflection-helper.service';
5
- import { DataSource } from 'typeorm';
4
+ import { EntityManager } from 'typeorm';
5
+ import { ConfigService } from '@nestjs/config';
6
6
 
7
7
  interface ValidationError {
8
8
  field: string;
@@ -13,9 +13,12 @@ interface ValidationError {
13
13
  export class EntityValidationService {
14
14
  constructor(
15
15
  private readonly attributeMasterService: AttributeMasterService,
16
- private readonly reflectionHelper: ReflectionHelper,
17
- private dataSource: DataSource,
18
- ) {}
16
+ private entityManager: EntityManager,
17
+ private configService: ConfigService,
18
+ ) {
19
+ }
20
+
21
+ schema = this.configService.get('DB_SCHEMA');
19
22
 
20
23
  /**
21
24
  * Validates required fields based on attribute metadata.
@@ -58,23 +61,21 @@ export class EntityValidationService {
58
61
  const value = entityData[attr.attribute_key];
59
62
 
60
63
  if (this.hasValidValue(value)) {
61
- let qb = this.dataSource
64
+ let qb = this.entityManager
62
65
  .createQueryBuilder()
63
66
  .select('*')
64
- .from(db_table_name, db_table_name)
67
+ .from(`${this.schema}.${db_table_name}`, db_table_name)
65
68
  .where(`${db_table_name}.${attr.attribute_key} = :value`, { value });
66
69
 
67
70
  // Add AND condition for organization_id/level_type/level_id if present
68
71
  if (entityType !== 'ORG' && entityType !== 'ORGP') {
69
- const orgId = loggedInUser.organization_id;
70
72
  const level_type = loggedInUser.level_type;
71
73
  const level_id = loggedInUser.level_id;
72
74
 
73
- if (orgId !== undefined && orgId !== null) {
75
+ if (level_type !== undefined && level_type !== null) {
74
76
  qb = qb.andWhere(
75
- `${db_table_name}.organization_id = :organization_id AND ${db_table_name}.level_type = :level_type AND ${db_table_name}.level_id = :level_id`,
77
+ `${db_table_name}.level_type = :level_type AND ${db_table_name}.level_id = :level_id`,
76
78
  {
77
- organization_id: orgId,
78
79
  level_type,
79
80
  level_id,
80
81
  },
@@ -196,27 +196,25 @@ export class ResolverService {
196
196
 
197
197
  // -------- MASTER data_source_type --------
198
198
  else if (attr.data_source_type === 'master') {
199
+ const repo = this.reflectionHelper.getRepoService('ListMasterItems');
199
200
  if (Array.isArray(rawValue)) {
200
201
  const resolvedValues: string[] = [];
201
202
  for (const code of rawValue) {
202
- const repo = this.reflectionHelper.getRepoService('ListMasterItems');
203
-
204
203
  let item = repo.findOne({
205
204
  where: {
206
205
  id: code,
207
- organization_id: loggedInUser.organization_id,
206
+ enterprise_id: loggedInUser.enterprise_id,
208
207
  },
209
208
  });
210
209
  resolvedValues.push(item?.[attr.data_source_attribute] ?? code);
211
210
  }
212
211
  return resolvedValues;
213
212
  } else {
214
- const repo = this.reflectionHelper.getRepoService('ListMasterItems');
215
213
  if (typeof rawValue !== 'number') return rawValue;
216
214
  let item = await repo.findOne({
217
215
  where: {
218
216
  id: Number(rawValue),
219
- organization_id: loggedInUser.organization_id,
217
+ enterprise_id: loggedInUser.enterprise_id,
220
218
  },
221
219
  });
222
220
  return item?.[attr.data_source_attribute] ?? rawValue;