rez_core 6.5.52 → 6.5.53
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/dist/module/enterprise/service/enterprise.service.js +2 -0
- package/dist/module/enterprise/service/enterprise.service.js.map +1 -1
- package/dist/module/enterprise/service/organization.service.d.ts +2 -2
- package/dist/module/enterprise/service/organization.service.js +8 -3
- package/dist/module/enterprise/service/organization.service.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.js +9 -7
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/notification/notification.module.js +3 -2
- package/dist/module/notification/notification.module.js.map +1 -1
- package/dist/module/notification/service/email.service.d.ts +1 -0
- package/dist/module/notification/service/email.service.js +14 -0
- package/dist/module/notification/service/email.service.js.map +1 -1
- package/dist/module/notification/service/otp.service.d.ts +2 -2
- package/dist/module/notification/service/otp.service.js +4 -4
- package/dist/module/notification/service/otp.service.js.map +1 -1
- package/dist/module/preference_master/entity/preference.entity.d.ts +9 -0
- package/dist/module/preference_master/entity/preference.entity.js +48 -0
- package/dist/module/preference_master/entity/preference.entity.js.map +1 -0
- package/dist/module/preference_master/preference.service.d.ts +8 -0
- package/dist/module/preference_master/preference.service.js +31 -0
- package/dist/module/preference_master/preference.service.js.map +1 -0
- package/dist/module/preference_master/repo/preference.repository.d.ts +8 -0
- package/dist/module/preference_master/repo/preference.repository.js +48 -0
- package/dist/module/preference_master/repo/preference.repository.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/enterprise/service/enterprise.service.ts +2 -0
- package/src/module/enterprise/service/organization.service.ts +11 -5
- package/src/module/module/repository/module-access.repository.ts +9 -7
- package/src/module/notification/notification.module.ts +6 -3
- package/src/module/notification/service/email.service.ts +16 -1
- package/src/module/notification/service/otp.service.ts +13 -3
- package/src/module/preference_master/entity/preference.entity.ts +25 -0
- package/src/module/preference_master/preference.service.ts +27 -0
- package/src/module/preference_master/repo/preference.repository.ts +36 -0
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { EnterpriseRepository } from '../repository/enterprise.repository';
|
|
3
3
|
import { EnterpriseData } from '../entity/enterprise.entity';
|
|
4
|
+
import { StatusConstant } from '../../../constant/status.constant';
|
|
4
5
|
|
|
5
6
|
@Injectable()
|
|
6
7
|
export class EnterpriseService {
|
|
@@ -10,6 +11,7 @@ export class EnterpriseService {
|
|
|
10
11
|
enterpriseData: EnterpriseData,
|
|
11
12
|
loggedInUser: any,
|
|
12
13
|
): Promise<EnterpriseData> {
|
|
14
|
+
enterpriseData.status = StatusConstant.ACTIVE;
|
|
13
15
|
return await this.enterpriseRepository.save(enterpriseData, loggedInUser);
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
-
import { ClockIDGenService } from 'src/utils/service/clockIDGenUtil.service';
|
|
4
3
|
import { EntityManager, IsNull, Repository } from 'typeorm';
|
|
5
4
|
import { OrganizationData } from '../entity/organization.entity';
|
|
5
|
+
import { ClockIDGenService } from 'src/utils/service/clockIDGenUtil.service';
|
|
6
|
+
import { UserService } from 'src/module/user/service/user.service';
|
|
7
|
+
import { ENTITYTYPE_USER } from 'src/constant/global.constant';
|
|
6
8
|
// import { BrandRepository } from '../repository/brand.repository';
|
|
7
|
-
import { WBSCodeGenService } from 'src/utils/service/wbsCodeGen.service';
|
|
8
9
|
import { SchoolRepository } from '../repository/school.repository';
|
|
10
|
+
import { WBSCodeGenService } from 'src/utils/service/wbsCodeGen.service';
|
|
11
|
+
import { StatusConstant } from '../../../constant/status.constant';
|
|
9
12
|
|
|
10
13
|
@Injectable()
|
|
11
14
|
export class OrganizationService {
|
|
@@ -66,6 +69,7 @@ export class OrganizationService {
|
|
|
66
69
|
|
|
67
70
|
const subOrgWbsCode = this.wbcCodeGenService.padCode(nextSubOrgCode);
|
|
68
71
|
organizationDto.wbs_code = `${parentOrg.wbs_code}.${subOrgWbsCode}`;
|
|
72
|
+
organizationDto.parent_id = parentOrgId;
|
|
69
73
|
} else {
|
|
70
74
|
// Main org case: no parent_id
|
|
71
75
|
const existingOrgs = await repo.find({
|
|
@@ -92,8 +96,10 @@ export class OrganizationService {
|
|
|
92
96
|
organizationDto.wbs_code = this.wbcCodeGenService.padCode(nextOrgCode);
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
organizationDto.code
|
|
96
|
-
|
|
99
|
+
if (!organizationDto.code) {
|
|
100
|
+
organizationDto.code = this.idGen.idGenerator('ORG');
|
|
101
|
+
}
|
|
102
|
+
organizationDto.status = StatusConstant.ACTIVE;
|
|
97
103
|
|
|
98
104
|
if (loggedInUser) {
|
|
99
105
|
organizationDto.modified_by = loggedInUser.id;
|
|
@@ -165,7 +165,7 @@ export class ModuleAccessRepository {
|
|
|
165
165
|
|
|
166
166
|
async getAllModulesByLevel(mainModIds: string[], appcode: string, levelType) {
|
|
167
167
|
const appMasterRepo = this.reflectionHelper.getRepoService('AppMaster');
|
|
168
|
-
|
|
168
|
+
// TODO Permissions not getting populated
|
|
169
169
|
const appMaster = await appMasterRepo.find({
|
|
170
170
|
where: {
|
|
171
171
|
code: appcode,
|
|
@@ -209,14 +209,16 @@ export class ModuleAccessRepository {
|
|
|
209
209
|
|
|
210
210
|
const modules = allModules.map((m) => m.id);
|
|
211
211
|
|
|
212
|
-
const allActions = await this.moduleActionRepo.
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
const allActions: any = await this.moduleActionRepo.createQueryBuilder('action')
|
|
213
|
+
.select(['action.id', 'action.action_name', 'module.module_code'])
|
|
214
|
+
.leftJoin('action.module', 'module')
|
|
215
|
+
.where('module.module_id IN (:...moduleIds)', { modules })
|
|
216
|
+
.getMany();
|
|
215
217
|
|
|
216
218
|
// Map actions by module_code with VIEW action first
|
|
217
219
|
const actionMap = allActions.reduce(
|
|
218
220
|
(acc, action) => {
|
|
219
|
-
if (!acc[action.
|
|
221
|
+
if (!acc[action.module_code]) acc[action.module_code] = [];
|
|
220
222
|
|
|
221
223
|
const actionItem = {
|
|
222
224
|
action: action.action_code,
|
|
@@ -224,9 +226,9 @@ export class ModuleAccessRepository {
|
|
|
224
226
|
};
|
|
225
227
|
|
|
226
228
|
if (action.action_code === 'VIEW') {
|
|
227
|
-
acc[action.
|
|
229
|
+
acc[action.module_code].unshift(actionItem); // ➕ Add VIEW at start
|
|
228
230
|
} else {
|
|
229
|
-
acc[action.
|
|
231
|
+
acc[action.module_code].push(actionItem); // ➕ Add others at end
|
|
230
232
|
}
|
|
231
233
|
|
|
232
234
|
return acc;
|
|
@@ -16,10 +16,13 @@ import { NotificationData } from './entity/notification.entity';
|
|
|
16
16
|
import { NotificationsController } from './controller/notification.controller';
|
|
17
17
|
import { NotificationsService } from './service/notification.service';
|
|
18
18
|
import { FirebaseAdminProvider } from './firebase-admin.config';
|
|
19
|
+
import { PreferenceService } from '../preference_master/preference.service';
|
|
20
|
+
import { PreferenceRepository } from '../meta/repository/preference.repository';
|
|
21
|
+
import { PreferenceData } from '../preference_master/entity/preference.entity';
|
|
19
22
|
|
|
20
23
|
@Module({
|
|
21
24
|
imports: [
|
|
22
|
-
TypeOrmModule.forFeature([Otp, NotificationData]),
|
|
25
|
+
TypeOrmModule.forFeature([Otp, NotificationData, PreferenceData]),
|
|
23
26
|
MailerModule.forRootAsync({
|
|
24
27
|
imports: [ConfigModule],
|
|
25
28
|
inject: [ConfigService],
|
|
@@ -54,7 +57,7 @@ import { FirebaseAdminProvider } from './firebase-admin.config';
|
|
|
54
57
|
OtpRepository,
|
|
55
58
|
EmailService,
|
|
56
59
|
NotificationsService,
|
|
57
|
-
FirebaseAdminProvider
|
|
60
|
+
FirebaseAdminProvider
|
|
58
61
|
],
|
|
59
62
|
exports: [
|
|
60
63
|
OtpService,
|
|
@@ -64,4 +67,4 @@ import { FirebaseAdminProvider } from './firebase-admin.config';
|
|
|
64
67
|
],
|
|
65
68
|
controllers: [OtpController, NotificationsController],
|
|
66
69
|
})
|
|
67
|
-
export class NotificationModule {}
|
|
70
|
+
export class NotificationModule { }
|
|
@@ -10,7 +10,7 @@ export class EmailService {
|
|
|
10
10
|
private readonly mailerService: MailerService,
|
|
11
11
|
private readonly datasource: DataSource,
|
|
12
12
|
private readonly icsService: IcsMeetingService,
|
|
13
|
-
) {}
|
|
13
|
+
) { }
|
|
14
14
|
|
|
15
15
|
async sendEmail(
|
|
16
16
|
email: string,
|
|
@@ -124,4 +124,19 @@ export class EmailService {
|
|
|
124
124
|
|
|
125
125
|
return { success: true, message: 'Email sent successfully' };
|
|
126
126
|
}
|
|
127
|
+
|
|
128
|
+
async sendEmailWithoutTemplate(to: string, subject: string, body: string) {
|
|
129
|
+
try {
|
|
130
|
+
await this.mailerService.sendMail({
|
|
131
|
+
to,
|
|
132
|
+
subject,
|
|
133
|
+
html: body,
|
|
134
|
+
});
|
|
135
|
+
console.log(`Email sent successfully to ${to} via NodeMailer.`);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error(`Failed to send email to ${to} via NodeMailer:`, error);
|
|
138
|
+
throw error; // Re-throw to allow calling context to handle
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
127
142
|
}
|
|
@@ -6,6 +6,7 @@ import { Otp } from '../entity/otp.entity';
|
|
|
6
6
|
import { OtpRepository } from '../repository/otp.repository';
|
|
7
7
|
import { LoginService } from './../../user/service/login.service';
|
|
8
8
|
import { EmailService } from './email.service';
|
|
9
|
+
import { PreferenceService } from 'src/module/preference_master/preference.service';
|
|
9
10
|
|
|
10
11
|
@Injectable()
|
|
11
12
|
export class OtpService {
|
|
@@ -14,8 +15,9 @@ export class OtpService {
|
|
|
14
15
|
private readonly idGen: ClockIDGenService,
|
|
15
16
|
private configService: ConfigService,
|
|
16
17
|
private readonly loginService: LoginService,
|
|
17
|
-
private readonly emailService: EmailService,
|
|
18
18
|
private readonly dataSource: DataSource,
|
|
19
|
+
// private readonly preferenceService: PreferenceService,
|
|
20
|
+
private readonly emailService: EmailService,
|
|
19
21
|
) {
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -40,7 +42,7 @@ export class OtpService {
|
|
|
40
42
|
otp.verified = 0;
|
|
41
43
|
otp.expiration_date = new Date(Date.now() + expiresIn * 60 * 1000);
|
|
42
44
|
|
|
43
|
-
const userData = await this.dataSource
|
|
45
|
+
const userData: any = await this.dataSource
|
|
44
46
|
.getRepository('sso_user')
|
|
45
47
|
.findOne({ where: { email_id: identifier } });
|
|
46
48
|
|
|
@@ -49,7 +51,15 @@ export class OtpService {
|
|
|
49
51
|
otp: otp.otp,
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
//
|
|
54
|
+
// TODO: Inject and use PreferenceService here
|
|
55
|
+
// const preference = await this.preferenceService.fetchPreferenceByType('OTP', true);
|
|
56
|
+
|
|
57
|
+
// if (preference) {
|
|
58
|
+
// let otpBody = preference.filter((item) => item.key === 'OTP_BODY')[0].value;
|
|
59
|
+
// otpBody = otpBody.replace('${otp}', otp.otp);
|
|
60
|
+
// const otpSubject = preference.filter((item) => item.key === 'OTP_SUBJECT')[0].value;
|
|
61
|
+
// this.emailService.sendEmailWithoutTemplate(userData.email_id, otpSubject, otpBody);
|
|
62
|
+
// }
|
|
53
63
|
|
|
54
64
|
return await this.otpRepository.save(otp);
|
|
55
65
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity('sso_preference_master')
|
|
4
|
+
export class PreferenceData {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id: number;
|
|
7
|
+
|
|
8
|
+
@Column({ name: 'enterprise_id', type: 'int' })
|
|
9
|
+
enterpriseId: number;
|
|
10
|
+
|
|
11
|
+
@Column({ name: 'preference_type', type: 'varchar', length: 15 })
|
|
12
|
+
preferenceType: string;
|
|
13
|
+
|
|
14
|
+
@Column({ type: 'varchar', length: 255 })
|
|
15
|
+
key: string;
|
|
16
|
+
|
|
17
|
+
@Column({ type: 'text' })
|
|
18
|
+
value: string;
|
|
19
|
+
|
|
20
|
+
@CreateDateColumn({ name: 'created_date', type: 'timestamp' })
|
|
21
|
+
createdDate: Date;
|
|
22
|
+
|
|
23
|
+
@Column({ type: 'boolean', default: true })
|
|
24
|
+
status: boolean;
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/module/preference_master/preference.service.ts
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { PreferenceData } from './entity/preference.entity';
|
|
4
|
+
import { PreferenceRepository } from './repo/preference.repository';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class PreferenceService {
|
|
8
|
+
constructor(
|
|
9
|
+
private readonly preferenceRepository: PreferenceRepository
|
|
10
|
+
) { }
|
|
11
|
+
|
|
12
|
+
async fetchPreference(
|
|
13
|
+
entID: number,
|
|
14
|
+
key: string,
|
|
15
|
+
status: boolean,
|
|
16
|
+
): Promise<PreferenceData | null> {
|
|
17
|
+
return await this.preferenceRepository.findByEntIdAndKeyAndStatus(
|
|
18
|
+
entID,
|
|
19
|
+
key,
|
|
20
|
+
status,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async fetchPreferenceByType(preferenceType: string, status: boolean) {
|
|
25
|
+
return await this.preferenceRepository.findByPreferenceType(preferenceType, status);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/module/preference_master/preference.repository.ts
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { Repository } from 'typeorm';
|
|
4
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
5
|
+
import { PreferenceData } from '../entity/preference.entity';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class PreferenceRepository {
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectRepository(PreferenceData)
|
|
11
|
+
private preferenceRepository: Repository<PreferenceData>,
|
|
12
|
+
) { }
|
|
13
|
+
|
|
14
|
+
async findByEntIdAndKeyAndStatus(
|
|
15
|
+
entID: number,
|
|
16
|
+
key: string,
|
|
17
|
+
status: boolean,
|
|
18
|
+
): Promise<PreferenceData | null> {
|
|
19
|
+
return this.preferenceRepository.findOne({
|
|
20
|
+
where: {
|
|
21
|
+
enterpriseId: entID,
|
|
22
|
+
key,
|
|
23
|
+
status,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async findByPreferenceType(preferenceType: string, status: boolean) {
|
|
29
|
+
return this.preferenceRepository.find({
|
|
30
|
+
where: {
|
|
31
|
+
preferenceType,
|
|
32
|
+
status,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|