rez_core 1.0.61 → 1.0.62

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 (43) hide show
  1. package/dist/module/enterprise/entity/enterprise.entity.d.ts +7 -7
  2. package/dist/module/enterprise/entity/enterprise.entity.js +7 -7
  3. package/dist/module/enterprise/entity/enterprise.entity.js.map +1 -1
  4. package/dist/module/enterprise/repository/enterprise.repository.d.ts +8 -0
  5. package/dist/module/enterprise/repository/enterprise.repository.js +48 -0
  6. package/dist/module/enterprise/repository/enterprise.repository.js.map +1 -0
  7. package/dist/module/enterprise/service/enterprise.service.d.ts +8 -0
  8. package/dist/module/enterprise/service/enterprise.service.js +31 -0
  9. package/dist/module/enterprise/service/enterprise.service.js.map +1 -0
  10. package/dist/module/meta/controller/view-master.controller.d.ts +7 -0
  11. package/dist/module/meta/controller/view-master.controller.js +62 -0
  12. package/dist/module/meta/controller/view-master.controller.js.map +1 -0
  13. package/dist/module/meta/entity/view-master.entity.d.ts +2 -0
  14. package/dist/module/meta/entity/view-master.entity.js +8 -0
  15. package/dist/module/meta/entity/view-master.entity.js.map +1 -1
  16. package/dist/module/meta/entity.module.js +4 -1
  17. package/dist/module/meta/entity.module.js.map +1 -1
  18. package/dist/module/meta/repository/view-master.repository.d.ts +7 -0
  19. package/dist/module/meta/repository/view-master.repository.js +38 -0
  20. package/dist/module/meta/repository/view-master.repository.js.map +1 -0
  21. package/dist/module/meta/service/entity-list.service.d.ts +1 -1
  22. package/dist/module/meta/service/entity-list.service.js.map +1 -1
  23. package/dist/module/meta/service/entity-master.service.d.ts +1 -1
  24. package/dist/module/meta/service/entity-master.service.js +11 -6
  25. package/dist/module/meta/service/entity-master.service.js.map +1 -1
  26. package/dist/module/meta/service/view-master.service.d.ts +13 -2
  27. package/dist/module/meta/service/view-master.service.js +41 -22
  28. package/dist/module/meta/service/view-master.service.js.map +1 -1
  29. package/dist/module/user/service/user.service.js +2 -1
  30. package/dist/module/user/service/user.service.js.map +1 -1
  31. package/dist/tsconfig.build.tsbuildinfo +1 -1
  32. package/package.json +1 -1
  33. package/src/module/enterprise/entity/enterprise.entity.ts +7 -7
  34. package/src/module/enterprise/repository/enterprise.repository.ts +31 -0
  35. package/src/module/enterprise/service/enterprise.service.ts +16 -0
  36. package/src/module/meta/controller/view-master.controller.ts +48 -0
  37. package/src/module/meta/entity/view-master.entity.ts +6 -0
  38. package/src/module/meta/entity.module.ts +4 -1
  39. package/src/module/meta/repository/view-master.repository.ts +24 -0
  40. package/src/module/meta/service/entity-list.service.ts +2 -2
  41. package/src/module/meta/service/entity-master.service.ts +15 -11
  42. package/src/module/meta/service/view-master.service.ts +51 -28
  43. package/src/module/user/service/user.service.ts +6 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "1.0.61",
3
+ "version": "1.0.62",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -6,7 +6,7 @@ export class EnterpriseData {
6
6
  id: number;
7
7
 
8
8
  @Column({ name: 'entity_type', type: 'varchar', nullable: true, length: 50 })
9
- entityType: string;
9
+ entity_type: string;
10
10
 
11
11
  @Column({ name: 'code', type: 'varchar', nullable: true, length: 50 })
12
12
  code: string;
@@ -18,20 +18,20 @@ export class EnterpriseData {
18
18
  status: string;
19
19
 
20
20
  @Column({ name: 'created_by', type: 'int', nullable: true })
21
- createdBy: number;
21
+ created_by: number;
22
22
 
23
23
  @Column({ name: 'modified_by', type: 'int', nullable: true })
24
- modifiedBy: number;
24
+ modified_by: number;
25
25
 
26
26
  @Column({ name: 'created_date', type: 'datetime', nullable: true })
27
- createdDate: Date;
27
+ created_date: Date;
28
28
 
29
29
  @Column({ name: 'modified_date', type: 'datetime', nullable: true })
30
- modifiedDate: Date;
30
+ modified_date: Date;
31
31
 
32
32
  @Column({ name: 'app_code', type: 'varchar', nullable: true, length: 50 })
33
- appCode: string;
33
+ app_code: string;
34
34
 
35
35
  @Column({ name: 'app_url_name', type: 'varchar', nullable: true, length: 50 })
36
- appUrlName: string;
36
+ app_url_name: string;
37
37
  }
@@ -0,0 +1,31 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { EnterpriseData } from '../entity/enterprise.entity';
4
+ import { Repository } from 'typeorm';
5
+
6
+ @Injectable()
7
+ export class EnterpriseRepository {
8
+ constructor(
9
+ @InjectRepository(EnterpriseData)
10
+ private readonly enterpriseRepository: Repository<EnterpriseData>,
11
+ ) {}
12
+
13
+ async save(enterpriseData: EnterpriseData) {
14
+ enterpriseData.created_date = new Date();
15
+ return await this.enterpriseRepository.save(enterpriseData);
16
+ }
17
+
18
+ async update(enterpriseData: EnterpriseData): Promise<EnterpriseData | null> {
19
+ const existingEnterprise = await this.enterpriseRepository.findOne({
20
+ where: { id: enterpriseData.id },
21
+ });
22
+ if (!existingEnterprise) {
23
+ throw new Error(`Enterprise with id ${enterpriseData.id} not found`);
24
+ }
25
+ enterpriseData.modified_date = new Date();
26
+ await this.enterpriseRepository.update(enterpriseData.id, enterpriseData);
27
+ return await this.enterpriseRepository.findOne({
28
+ where: { id: enterpriseData.id },
29
+ });
30
+ }
31
+ }
@@ -0,0 +1,16 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { EnterpriseRepository } from '../repository/enterprise.repository';
3
+ import { EnterpriseData } from '../entity/enterprise.entity';
4
+
5
+ @Injectable()
6
+ export class EnterpriseService {
7
+ constructor(private readonly enterpriseRepository: EnterpriseRepository) {}
8
+
9
+ async create(enterpriseData: EnterpriseData): Promise<EnterpriseData> {
10
+ return await this.enterpriseRepository.save(enterpriseData);
11
+ }
12
+
13
+ async update(enterpriseData: EnterpriseData): Promise<EnterpriseData|null> {
14
+ return await this.enterpriseRepository.update(enterpriseData);
15
+ }
16
+ }
@@ -0,0 +1,48 @@
1
+ import {
2
+ Controller,
3
+ Get,
4
+ Query,
5
+ Res,
6
+ HttpStatus,
7
+ UseGuards,
8
+ Inject,
9
+ } from '@nestjs/common';
10
+ import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
11
+ import { Response } from 'express';
12
+ import { ViewMasterService } from '../service/view-master.service';
13
+
14
+ @Controller('entity')
15
+ @UseGuards(JwtAuthGuard)
16
+ export class ViewMasterController {
17
+ constructor(@Inject("ViewMasterService") private readonly viewMaster: ViewMasterService) {}
18
+
19
+ @Get('viewMaster')
20
+ async getEntityJsonByType(
21
+ @Query('entity_type') entityType: string,
22
+ @Query('type') type:string,
23
+ @Res() res: Response,
24
+ ) {
25
+ try {
26
+ if (!entityType || !type) {
27
+ return res.status(HttpStatus.BAD_REQUEST).json({
28
+ success: false,
29
+ message: 'Missing entity_type or type query parameter',
30
+ });
31
+ }
32
+
33
+ const result = await this.viewMaster.getEntityJson(entityType, type);
34
+
35
+ return res.status(HttpStatus.OK).json({
36
+ success: true,
37
+ message: 'Entity data fetched successfully',
38
+ data: result,
39
+ });
40
+ } catch (error) {
41
+ return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
42
+ success: false,
43
+ message: error.message || 'Error fetching entity data',
44
+ });
45
+ }
46
+ }
47
+ }
48
+
@@ -24,6 +24,12 @@ export class ViewMaster extends BaseEntity {
24
24
  @Column({type: 'json', nullable: true})
25
25
  published_form_fields: string;
26
26
 
27
+ @Column({type: 'json',nullable:true})
28
+ meta_json:string;
29
+
30
+ @Column({ nullable:true})
31
+ type: string;
32
+
27
33
  @Column({type: 'int'})
28
34
  is_default: number;
29
35
  }
@@ -32,6 +32,8 @@ import { SectionMaster } from './entity/section-master.entity';
32
32
  import { FieldGroup } from './entity/field-group.entity';
33
33
  import { FieldGroupService } from './service/field-group.service';
34
34
  import { ViewMasterService } from './service/view-master.service';
35
+ import { ViewMasterController } from './controller/view-master.controller';
36
+ import { ViewMaterRespository } from './repository/view-master.repository';
35
37
 
36
38
  @Module({
37
39
  imports: [
@@ -67,6 +69,7 @@ import { ViewMasterService } from './service/view-master.service';
67
69
  AttributeMasterService,
68
70
  SectionMasterService,
69
71
  FieldGroupService,
72
+ ViewMaterRespository,
70
73
  { provide: 'ViewMasterService', useClass: ViewMasterService },
71
74
  ],
72
75
  exports: [
@@ -81,6 +84,6 @@ import { ViewMasterService } from './service/view-master.service';
81
84
  FieldGroupService,
82
85
  'ViewMasterService',
83
86
  ],
84
- controllers: [EntityController, MasterController, MediaController],
87
+ controllers: [EntityController, MasterController, MediaController, ViewMasterController],
85
88
  })
86
89
  export class EntityModule {}
@@ -0,0 +1,24 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { BaseEntity, Repository } from 'typeorm';
4
+ import { ViewMaster } from '../entity/view-master.entity';
5
+
6
+ @Injectable()
7
+ export class ViewMaterRespository {
8
+ constructor(
9
+ @InjectRepository(ViewMaster)
10
+ private readonly viewMasterRepository: Repository<ViewMaster>,
11
+ ) {}
12
+
13
+ async getEntityJson(
14
+ entityType: string,
15
+ type: string,
16
+ ): Promise<ViewMaster | null> {
17
+ const viewMaster = await this.viewMasterRepository.findOneBy({
18
+ mapped_entity_type: entityType,
19
+ type: type,
20
+ });
21
+
22
+ return viewMaster;
23
+ }
24
+ }
@@ -148,8 +148,8 @@ export class EntityListService {
148
148
 
149
149
  public async getMaxSequenceNumber(
150
150
  tableName: string,
151
- parentType: string,
152
- parentId: number,
151
+ parentType: string | null,
152
+ parentId: number | null,
153
153
  ) {
154
154
  let query = `SELECT COUNT(1) seq_no
155
155
  FROM ${tableName} WHERE 1=1 `;
@@ -10,18 +10,22 @@ export class EntityMasterService {
10
10
  private entityMasterRepository: Repository<EntityMaster>,
11
11
  ) {}
12
12
 
13
- async getEntityData(mappedEntityType: string): Promise<EntityMaster> {
14
- const entityMaster = await this.entityMasterRepository.findOne({
15
- where: { mapped_entity_type: mappedEntityType },
16
- });
17
-
18
- if (!entityMaster) {
19
- throw new Error(
20
- `Entity with mappedEntityType "${mappedEntityType}" not found.`,
21
- );
13
+ async getEntityData(mappedEntityType: string|null): Promise<EntityMaster> {
14
+ if (mappedEntityType) {
15
+ const entityMaster = await this.entityMasterRepository.findOne({
16
+ where: { mapped_entity_type: mappedEntityType },
17
+ });
18
+
19
+ if (!entityMaster) {
20
+ throw new Error(
21
+ `Entity with mappedEntityType "${mappedEntityType}" not found.`,
22
+ );
23
+ }
24
+
25
+ return entityMaster;
26
+ } else {
27
+ throw new Error();
22
28
  }
23
-
24
- return entityMaster;
25
29
  }
26
30
 
27
31
  async getEntityByTableName(tableName: string) {
@@ -8,17 +8,19 @@ import { SectionMasterService } from './section-master.service';
8
8
  import { SectionMaster } from '../entity/section-master.entity';
9
9
  import { FieldGroup } from '../entity/field-group.entity';
10
10
  import { FieldGroupService } from './field-group.service';
11
+ import { ViewMaterRespository } from '../repository/view-master.repository';
11
12
  @Injectable()
12
13
  export class ViewMasterService extends EntityServiceImpl {
13
14
  constructor(
14
15
  private readonly sectionMasterService: SectionMasterService,
15
16
  private readonly fieldGroupService: FieldGroupService,
17
+ private readonly viewMasterRepoService: ViewMaterRespository
16
18
  ) {
17
19
  super();
18
20
  }
19
21
 
20
22
  async createEntity(
21
- entityData: BaseEntity,
23
+ entityData: ViewMaster,
22
24
  loggedInUser: UserData | null,
23
25
  manager?: EntityManager,
24
26
  ): Promise<BaseEntity> {
@@ -33,40 +35,45 @@ export class ViewMasterService extends EntityServiceImpl {
33
35
  loggedInUser,
34
36
  manager,
35
37
  );
36
- let viewMaster = savedEntity as ViewMaster;
37
38
 
38
- let layout = viewMaster.published_form_layout;
39
+ let viewMaster = savedEntity as ViewMaster;
40
+ if (entityData.type === 'form') {
41
+ let layout = viewMaster.published_form_layout;
39
42
 
40
- const stepsData = this.sectionMasterService.parseLayout(layout);
41
- for (var step of stepsData) {
42
- let sectionMaster = new SectionMaster();
43
- sectionMaster.name = step.stepLabel;
44
- sectionMaster.position = step.stepPosition;
45
- sectionMaster.description = step.stepLabel;
46
- sectionMaster.parent_id = viewMaster.id;
47
- sectionMaster.parent_type = viewMaster.entity_type;
43
+ const stepsData = this.sectionMasterService.parseLayout(layout);
44
+ for (var step of stepsData) {
45
+ let sectionMaster = new SectionMaster();
46
+ sectionMaster.name = step.stepLabel;
47
+ sectionMaster.position = step.stepPosition;
48
+ sectionMaster.description = step.stepLabel;
49
+ sectionMaster.parent_id = viewMaster.id;
50
+ sectionMaster.parent_type = viewMaster.entity_type;
48
51
 
49
- const savedSectionMaster = await this.sectionMasterService.createEntity(
50
- sectionMaster,
51
- loggedInUser,
52
- manager,
53
- );
52
+ const savedSectionMaster = await this.sectionMasterService.createEntity(
53
+ sectionMaster,
54
+ loggedInUser,
55
+ manager,
56
+ );
54
57
 
55
- const fieldGroups = step.fieldsGroup;
56
- console.log('fieldGroups', fieldGroups);
58
+ const fieldGroups = step.fieldsGroup;
59
+ console.log('fieldGroups', fieldGroups);
57
60
 
58
- for (var fieldGroup of fieldGroups) {
59
- let fieldsGroup = new FieldGroup();
60
- fieldsGroup.view_id = viewMaster.id;
61
- fieldsGroup.parent_id = savedSectionMaster.id;
62
- fieldsGroup.field_type = fieldGroup.type;
63
- fieldsGroup.label = fieldGroup.label;
64
- fieldsGroup.description = fieldGroup.label;
61
+ for (var fieldGroup of fieldGroups) {
62
+ let fieldsGroup = new FieldGroup();
63
+ fieldsGroup.view_id = viewMaster.id;
64
+ fieldsGroup.parent_id = savedSectionMaster.id;
65
+ fieldsGroup.field_type = fieldGroup.type;
66
+ fieldsGroup.label = fieldGroup.label;
67
+ fieldsGroup.description = fieldGroup.label;
65
68
 
66
- this.fieldGroupService.createEntity(fieldsGroup, loggedInUser, manager);
69
+ this.fieldGroupService.createEntity(
70
+ fieldsGroup,
71
+ loggedInUser,
72
+ manager,
73
+ );
74
+ }
67
75
  }
68
- }
69
-
76
+ }
70
77
  return savedEntity;
71
78
  }
72
79
 
@@ -76,4 +83,20 @@ export class ViewMasterService extends EntityServiceImpl {
76
83
  ): Promise<BaseEntity> {
77
84
  return entityData;
78
85
  }
86
+
87
+ async getEntityJson(entityType: string, type: string) {
88
+
89
+ const res= await this.viewMasterRepoService.getEntityJson(entityType,type)
90
+
91
+ if(type=="form"){
92
+ return {
93
+ formLayoutJson:res?.published_form_layout,
94
+ formFieldJson:res?.published_form_fields
95
+ }
96
+ }else{
97
+ return {
98
+ metaJson:res?.meta_json
99
+ }
100
+ }
101
+ }
79
102
  }
@@ -5,7 +5,10 @@ import { BaseEntity } from '../../meta/entity/base-entity.entity';
5
5
  import { UserRepository } from '../repository/user.repository';
6
6
  import { EncryptUtilService } from '../../../utils/service/encryptUtil.service';
7
7
  import { ClockIDGenService } from '../../../utils/service/clockIDGenUtil.service';
8
- import { ENTITYTYPE_ROLE, STATUS_ACTIVE } from '../../../constant/global.constant';
8
+ import {
9
+ ENTITYTYPE_ROLE,
10
+ STATUS_ACTIVE,
11
+ } from '../../../constant/global.constant';
9
12
  import { CreateUserDto } from '../dto/create-user.dto';
10
13
  import { UserRoleMappingService } from './user-role-mapping.service';
11
14
  import { UserRoleMapping } from '../entity/user-role-mapping.entity';
@@ -28,7 +31,6 @@ export class UserService extends EntityServiceImpl {
28
31
  masterKey = this.configService.get('MASTER_KEY') || '';
29
32
  masterIv = this.configService.get('MASTER_IV') || '';
30
33
 
31
-
32
34
  async createEntity(
33
35
  entityData: BaseEntity,
34
36
  loggedInUser: UserData | null,
@@ -47,7 +49,8 @@ export class UserService extends EntityServiceImpl {
47
49
  throw new BadRequestException('User already exists');
48
50
  }
49
51
  userData.name =
50
- (userData.first_name ? userData.first_name : '') + (userData.last_name ? userData.last_name : '');
52
+ (userData.first_name ? userData.first_name : '') +
53
+ (userData.last_name ? userData.last_name : '');
51
54
  let password;
52
55
  if (userData.password) {
53
56
  password = EncryptUtilService.encryptGCM(