rez_core 2.2.134 → 2.2.136
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/.vscode/extensions.json +5 -0
- package/dist/module/auth/strategies/google.strategy.d.ts +1 -0
- package/dist/module/auth/strategies/google.strategy.js +20 -15
- package/dist/module/auth/strategies/google.strategy.js.map +1 -1
- package/dist/module/dashboard/controller/dashboard.controller.d.ts +32 -0
- package/dist/module/dashboard/controller/dashboard.controller.js +42 -0
- package/dist/module/dashboard/controller/dashboard.controller.js.map +1 -0
- package/dist/module/dashboard/dashboard.module.js +6 -2
- package/dist/module/dashboard/dashboard.module.js.map +1 -1
- package/dist/module/dashboard/entity/dashboard_page_data.entity.d.ts +3 -0
- package/dist/module/dashboard/entity/dashboard_page_data.entity.js +14 -1
- package/dist/module/dashboard/entity/dashboard_page_data.entity.js.map +1 -1
- package/dist/module/dashboard/entity/widget_master.entity.d.ts +1 -0
- package/dist/module/dashboard/entity/widget_master.entity.js +6 -1
- package/dist/module/dashboard/entity/widget_master.entity.js.map +1 -1
- package/dist/module/dashboard/repository/dashboard.repository.d.ts +9 -0
- package/dist/module/dashboard/repository/dashboard.repository.js +47 -0
- package/dist/module/dashboard/repository/dashboard.repository.js.map +1 -0
- package/dist/module/dashboard/service/dashboard.service.d.ts +32 -0
- package/dist/module/dashboard/service/dashboard.service.js +44 -0
- package/dist/module/dashboard/service/dashboard.service.js.map +1 -0
- package/dist/module/user/controller/login.controller.d.ts +4 -2
- package/dist/module/user/controller/login.controller.js +11 -6
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +2 -1
- package/dist/module/user/service/login.service.js +1 -13
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/workflow/repository/stage.repository.js +2 -2
- package/dist/module/workflow/repository/stage.repository.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/auth/strategies/google.strategy.ts +22 -18
- package/src/module/dashboard/controller/dashboard.controller.ts +25 -0
- package/src/module/dashboard/dashboard.module.ts +6 -2
- package/src/module/dashboard/entity/dashboard_page_data.entity.ts +10 -0
- package/src/module/dashboard/entity/widget_master.entity.ts +4 -0
- package/src/module/dashboard/repository/dashboard.repository.ts +36 -0
- package/src/module/dashboard/service/dashboard.service.ts +42 -0
- package/src/module/user/controller/login.controller.ts +6 -3
- package/src/module/user/service/login.service.ts +16 -15
- package/src/module/workflow/repository/stage.repository.ts +2 -2
package/package.json
CHANGED
|
@@ -5,22 +5,14 @@ import { Strategy, VerifyCallback } from 'passport-google-oauth20';
|
|
|
5
5
|
|
|
6
6
|
@Injectable()
|
|
7
7
|
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
|
8
|
-
constructor(configService: ConfigService) {
|
|
9
|
-
const clientID = configService.get<string>('CLIENT_ID');
|
|
10
|
-
const clientSecret = configService.get<string>('CLIENT_SECRET');
|
|
11
|
-
const callbackURL = configService.get<string>('CALLBACK_URL');
|
|
12
|
-
|
|
13
|
-
console.log('Google OAuth config', {
|
|
14
|
-
clientID,
|
|
15
|
-
clientSecret,
|
|
16
|
-
callbackURL,
|
|
17
|
-
});
|
|
18
|
-
|
|
8
|
+
constructor(private configService: ConfigService) {
|
|
19
9
|
super({
|
|
20
|
-
clientID,
|
|
21
|
-
clientSecret,
|
|
22
|
-
callbackURL,
|
|
23
|
-
scope: ['email', 'profile'],
|
|
10
|
+
clientID: configService.get('CLIENT_ID'),
|
|
11
|
+
clientSecret: configService.get('CLIENT_SECRET'),
|
|
12
|
+
callbackURL: configService.get('CALLBACK_URL'),
|
|
13
|
+
scope: ['openid', 'email', 'profile'],
|
|
14
|
+
accessType: 'offline',
|
|
15
|
+
prompt: 'consent',
|
|
24
16
|
});
|
|
25
17
|
}
|
|
26
18
|
|
|
@@ -30,8 +22,20 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
|
|
30
22
|
profile: any,
|
|
31
23
|
done: VerifyCallback,
|
|
32
24
|
) {
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
25
|
+
const email = profile.emails?.[0]?.value ?? null;
|
|
26
|
+
const name = {
|
|
27
|
+
givenName: profile.name?.givenName ?? '',
|
|
28
|
+
familyName: profile.name?.familyName ?? '',
|
|
29
|
+
displayName: profile.displayName ?? '',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// attach what you need; do not persist here if you follow clean patterns
|
|
33
|
+
return done(null, {
|
|
34
|
+
email,
|
|
35
|
+
name,
|
|
36
|
+
accessToken,
|
|
37
|
+
refreshToken,
|
|
38
|
+
provider: 'google',
|
|
39
|
+
});
|
|
36
40
|
}
|
|
37
41
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Controller,
|
|
3
|
+
Get,
|
|
4
|
+
Param,
|
|
5
|
+
ParseIntPipe,
|
|
6
|
+
Req,
|
|
7
|
+
UseGuards,
|
|
8
|
+
} from '@nestjs/common';
|
|
9
|
+
import { DashboardService } from '../service/dashboard.service';
|
|
10
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
11
|
+
|
|
12
|
+
@Controller('dashboard')
|
|
13
|
+
export class DashboardController {
|
|
14
|
+
constructor(private readonly dashboardService: DashboardService) {}
|
|
15
|
+
|
|
16
|
+
@Get('page-data/:pageId')
|
|
17
|
+
@UseGuards(JwtAuthGuard)
|
|
18
|
+
async getDashboard(
|
|
19
|
+
@Param('pageId', ParseIntPipe) pageId: number,
|
|
20
|
+
@Req() req: any,
|
|
21
|
+
) {
|
|
22
|
+
const loggedInUser = req.user.userData;
|
|
23
|
+
return this.dashboardService.getDashboardPage(pageId, loggedInUser);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -3,13 +3,17 @@ import { EntityModule } from '../meta/entity.module';
|
|
|
3
3
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
4
4
|
import { WidgetMaster } from './entity/widget_master.entity';
|
|
5
5
|
import { DashboardPageData } from './entity/dashboard_page_data.entity';
|
|
6
|
+
import { DashboardController } from './controller/dashboard.controller';
|
|
7
|
+
import { DashboardService } from './service/dashboard.service';
|
|
8
|
+
import { DashboardRepository } from './repository/dashboard.repository';
|
|
6
9
|
|
|
7
10
|
@Module({
|
|
8
11
|
imports: [
|
|
9
12
|
EntityModule,
|
|
10
13
|
TypeOrmModule.forFeature([WidgetMaster, DashboardPageData]),
|
|
11
14
|
],
|
|
12
|
-
controllers: [],
|
|
13
|
-
providers: [],
|
|
15
|
+
controllers: [DashboardController],
|
|
16
|
+
providers: [DashboardService, DashboardRepository],
|
|
17
|
+
exports: [DashboardService],
|
|
14
18
|
})
|
|
15
19
|
export class DashboardModule {}
|
|
@@ -3,15 +3,25 @@ import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
|
3
3
|
|
|
4
4
|
@Entity({ name: 'cr_dashboard_page_data' })
|
|
5
5
|
export class DashboardPageData extends BaseEntity {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.entity_type = 'DASH';
|
|
9
|
+
}
|
|
6
10
|
@Column({ type: 'int', nullable: true })
|
|
7
11
|
page_sequence: number;
|
|
8
12
|
|
|
9
13
|
@Column({ type: 'varchar', nullable: true })
|
|
10
14
|
applicable_type: string;
|
|
11
15
|
|
|
16
|
+
@Column({ type: 'varchar', nullable: true })
|
|
17
|
+
applicable_id: string;
|
|
18
|
+
|
|
12
19
|
@Column({ type: 'boolean', nullable: true })
|
|
13
20
|
is_hidden: boolean;
|
|
14
21
|
|
|
15
22
|
@Column({ type: 'json', nullable: true })
|
|
16
23
|
layout_json: any;
|
|
24
|
+
|
|
25
|
+
@Column({ type: 'varchar', nullable: true })
|
|
26
|
+
mapped_entity_type: string;
|
|
17
27
|
}
|
|
@@ -3,6 +3,10 @@ import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
|
3
3
|
|
|
4
4
|
@Entity({ name: 'cr_widget_master' })
|
|
5
5
|
export class WidgetMaster extends BaseEntity {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.entity_type = 'WIDG';
|
|
9
|
+
}
|
|
6
10
|
@Column({ type: 'varchar', nullable: true })
|
|
7
11
|
api_url: string;
|
|
8
12
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { DataSource } from 'typeorm';
|
|
3
|
+
import { DashboardPageData } from '../entity/dashboard_page_data.entity';
|
|
4
|
+
import { WidgetMaster } from '../entity/widget_master.entity';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class DashboardRepository {
|
|
8
|
+
constructor(private readonly dataSource: DataSource) {}
|
|
9
|
+
|
|
10
|
+
async getDashboardPageData(
|
|
11
|
+
pageId: number,
|
|
12
|
+
organization_id: number,
|
|
13
|
+
): Promise<DashboardPageData | null> {
|
|
14
|
+
return await this.dataSource
|
|
15
|
+
.getRepository(DashboardPageData)
|
|
16
|
+
.createQueryBuilder('page')
|
|
17
|
+
.where('page.id = :pageId', { pageId })
|
|
18
|
+
.andWhere('page.organization_id = :organization_id', { organization_id })
|
|
19
|
+
.getOne();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async getWidgetsByIds(
|
|
23
|
+
widgetIds: number[],
|
|
24
|
+
organization_id: number,
|
|
25
|
+
): Promise<WidgetMaster[]> {
|
|
26
|
+
if (!widgetIds.length) return [];
|
|
27
|
+
return await this.dataSource
|
|
28
|
+
.getRepository(WidgetMaster)
|
|
29
|
+
.createQueryBuilder('widget')
|
|
30
|
+
.where('widget.id IN (:...widgetIds)', { widgetIds })
|
|
31
|
+
.andWhere('widget.organization_id = :organization_id', {
|
|
32
|
+
organization_id,
|
|
33
|
+
})
|
|
34
|
+
.getMany();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
2
|
+
import { DashboardRepository } from '../repository/dashboard.repository';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class DashboardService {
|
|
6
|
+
constructor(private readonly dashboardRepo: DashboardRepository) {}
|
|
7
|
+
|
|
8
|
+
async getDashboardPage(pageId: number, loggedInUser: any) {
|
|
9
|
+
const organizationId = loggedInUser.organization_id;
|
|
10
|
+
// 1. Get page data
|
|
11
|
+
const page = await this.dashboardRepo.getDashboardPageData(
|
|
12
|
+
pageId,
|
|
13
|
+
organizationId,
|
|
14
|
+
);
|
|
15
|
+
if (!page)
|
|
16
|
+
throw new NotFoundException(`Dashboard Page ${pageId} not found`);
|
|
17
|
+
|
|
18
|
+
const layout = page.layout_json || [];
|
|
19
|
+
const widgetIds = layout.map((b: any) => Number(b.w_id));
|
|
20
|
+
|
|
21
|
+
// 2. Fetch widget details
|
|
22
|
+
const widgets = await this.dashboardRepo.getWidgetsByIds(
|
|
23
|
+
widgetIds,
|
|
24
|
+
organizationId,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// Convert to map
|
|
28
|
+
const widgetMap = {};
|
|
29
|
+
widgets.forEach((w) => {
|
|
30
|
+
widgetMap[w.id] = w;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const { layout_json, ...pageData } = page;
|
|
34
|
+
|
|
35
|
+
// 3. Return
|
|
36
|
+
return {
|
|
37
|
+
page_data: pageData,
|
|
38
|
+
layout_json: layout,
|
|
39
|
+
widget_json: widgetMap,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -14,12 +14,14 @@ import { GoogleAuthGuard } from '../../../module/auth/guards/google-auth.guard';
|
|
|
14
14
|
import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
|
|
15
15
|
import { Request, Response } from 'express';
|
|
16
16
|
import { UserSessionService } from '../service/user-session.service';
|
|
17
|
+
import { ConfigService } from '@nestjs/config';
|
|
17
18
|
|
|
18
19
|
@Controller('auth')
|
|
19
20
|
export class LoginController {
|
|
20
21
|
constructor(
|
|
21
22
|
private loginService: LoginService,
|
|
22
23
|
private userSessionService: UserSessionService,
|
|
24
|
+
private configService: ConfigService,
|
|
23
25
|
) {}
|
|
24
26
|
|
|
25
27
|
@Post('login')
|
|
@@ -55,11 +57,12 @@ export class LoginController {
|
|
|
55
57
|
// 2️⃣ Handles Google callback, validates user, creates session, and returns JWT
|
|
56
58
|
@Get('google/callback')
|
|
57
59
|
@UseGuards(GoogleAuthGuard)
|
|
58
|
-
async googleAuthRedirect(@Req() req) {
|
|
59
|
-
let { email, name } = req.user
|
|
60
|
+
async googleAuthRedirect(@Req() req: any, @Res() res: Response) {
|
|
61
|
+
let { email, name } = req.user; // Extracted from Google Strategy
|
|
60
62
|
|
|
61
63
|
// Call LoginService to validate user, create session, and return JWT
|
|
62
|
-
|
|
64
|
+
const token = await this.loginService.loginWithGoogle(email, name);
|
|
65
|
+
return res.redirect(`${this.configService.get('BASE_URL')}?token=${token}`);
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
@UseGuards(JwtAuthGuard)
|
|
@@ -235,22 +235,23 @@ export class LoginService {
|
|
|
235
235
|
let user = await this.userService.findByEmailId(email);
|
|
236
236
|
|
|
237
237
|
if (!user) {
|
|
238
|
+
return new BadRequestException('User not found');
|
|
238
239
|
// If user doesn't exist, create a new user record
|
|
239
|
-
user = new UserData();
|
|
240
|
-
user.email_id = email;
|
|
241
|
-
user.first_name = name.givenName;
|
|
242
|
-
user.last_name = name.familyName;
|
|
243
|
-
|
|
244
|
-
user.name = user.first_name + ' ' + user.last_name;
|
|
245
|
-
let savedUserResponse = await this.userService.createEntity(user, null);
|
|
246
|
-
|
|
247
|
-
if (savedUserResponse.success) {
|
|
248
|
-
|
|
249
|
-
} else {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
240
|
+
// user = new UserData();
|
|
241
|
+
// user.email_id = email;
|
|
242
|
+
// user.first_name = name.givenName;
|
|
243
|
+
// user.last_name = name.familyName;
|
|
244
|
+
|
|
245
|
+
// user.name = user.first_name + ' ' + user.last_name;
|
|
246
|
+
// // let savedUserResponse = await this.userService.createEntity(user, null);
|
|
247
|
+
|
|
248
|
+
// if (savedUserResponse.success) {
|
|
249
|
+
// user = savedUserResponse.data as UserData;
|
|
250
|
+
// } else {
|
|
251
|
+
// throw new BadRequestException(
|
|
252
|
+
// savedUserResponse.error || 'Failed to create user',
|
|
253
|
+
// );
|
|
254
|
+
// }
|
|
254
255
|
}
|
|
255
256
|
|
|
256
257
|
// Create session (Same as JWT login flow)
|
|
@@ -78,7 +78,7 @@ export class StageRepository {
|
|
|
78
78
|
)) as StageGroup;
|
|
79
79
|
|
|
80
80
|
if (!stageGroup) {
|
|
81
|
-
|
|
81
|
+
return [];
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
// 2. Fetch all groups + stages in one query
|
|
@@ -88,7 +88,7 @@ export class StageRepository {
|
|
|
88
88
|
g.id as stage_group_id, g.name as stage_group_name, g.workflow_id,
|
|
89
89
|
s.*
|
|
90
90
|
FROM cr_wf_stage_group g
|
|
91
|
-
|
|
91
|
+
INNER JOIN cr_wf_stage s ON s.stage_group_id = g.id
|
|
92
92
|
WHERE g.workflow_id = ? AND g.organization_id = ?
|
|
93
93
|
ORDER BY g.id, s.id
|
|
94
94
|
`,
|