@hed-hog/core 0.0.151 → 0.0.153

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 (108) hide show
  1. package/dist/dashboard/dashboard/dashboard.controller.d.ts +214 -9
  2. package/dist/dashboard/dashboard/dashboard.controller.d.ts.map +1 -1
  3. package/dist/dashboard/dashboard/dashboard.controller.js +35 -35
  4. package/dist/dashboard/dashboard/dashboard.controller.js.map +1 -1
  5. package/dist/dashboard/dashboard/dashboard.module.d.ts +1 -1
  6. package/dist/dashboard/dashboard/dashboard.module.d.ts.map +1 -1
  7. package/dist/dashboard/dashboard/dashboard.module.js +11 -6
  8. package/dist/dashboard/dashboard/dashboard.module.js.map +1 -1
  9. package/dist/dashboard/dashboard/dashboard.service.d.ts +217 -16
  10. package/dist/dashboard/dashboard/dashboard.service.d.ts.map +1 -1
  11. package/dist/dashboard/dashboard/dashboard.service.js +115 -28
  12. package/dist/dashboard/dashboard/dashboard.service.js.map +1 -1
  13. package/dist/dashboard/dashboard/dto/create.dto.d.ts +4 -2
  14. package/dist/dashboard/dashboard/dto/create.dto.d.ts.map +1 -1
  15. package/dist/dashboard/dashboard/dto/create.dto.js +10 -1
  16. package/dist/dashboard/dashboard/dto/create.dto.js.map +1 -1
  17. package/dist/dashboard/dashboard/dto/index.d.ts +5 -0
  18. package/dist/dashboard/dashboard/dto/index.d.ts.map +1 -0
  19. package/dist/dashboard/dashboard/dto/index.js +25 -0
  20. package/dist/dashboard/dashboard/dto/index.js.map +1 -0
  21. package/dist/dashboard/dashboard/dto/update.dto.d.ts +5 -4
  22. package/dist/dashboard/dashboard/dto/update.dto.d.ts.map +1 -1
  23. package/dist/dashboard/dashboard/dto/update.dto.js +27 -3
  24. package/dist/dashboard/dashboard/dto/update.dto.js.map +1 -1
  25. package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts +114 -9
  26. package/dist/dashboard/dashboard-component/dashboard-component.controller.d.ts.map +1 -1
  27. package/dist/dashboard/dashboard-component/dashboard-component.controller.js +35 -36
  28. package/dist/dashboard/dashboard-component/dashboard-component.controller.js.map +1 -1
  29. package/dist/dashboard/dashboard-component/dashboard-component.module.js +4 -3
  30. package/dist/dashboard/dashboard-component/dashboard-component.module.js.map +1 -1
  31. package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts +116 -15
  32. package/dist/dashboard/dashboard-component/dashboard-component.service.d.ts.map +1 -1
  33. package/dist/dashboard/dashboard-component/dashboard-component.service.js +109 -22
  34. package/dist/dashboard/dashboard-component/dashboard-component.service.js.map +1 -1
  35. package/dist/dashboard/dashboard-component/dto/create.dto.d.ts +4 -2
  36. package/dist/dashboard/dashboard-component/dto/create.dto.d.ts.map +1 -1
  37. package/dist/dashboard/dashboard-component/dto/create.dto.js +10 -1
  38. package/dist/dashboard/dashboard-component/dto/create.dto.js.map +1 -1
  39. package/dist/dashboard/dashboard-component/dto/index.d.ts +5 -0
  40. package/dist/dashboard/dashboard-component/dto/index.d.ts.map +1 -0
  41. package/dist/dashboard/dashboard-component/dto/index.js +25 -0
  42. package/dist/dashboard/dashboard-component/dto/index.js.map +1 -0
  43. package/dist/dashboard/dashboard-component/dto/update.dto.d.ts +13 -4
  44. package/dist/dashboard/dashboard-component/dto/update.dto.d.ts.map +1 -1
  45. package/dist/dashboard/dashboard-component/dto/update.dto.js +67 -3
  46. package/dist/dashboard/dashboard-component/dto/update.dto.js.map +1 -1
  47. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +56 -0
  48. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts.map +1 -1
  49. package/dist/dashboard/dashboard-core/dashboard-core.controller.js +65 -0
  50. package/dist/dashboard/dashboard-core/dashboard-core.controller.js.map +1 -1
  51. package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +52 -0
  52. package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts.map +1 -1
  53. package/dist/dashboard/dashboard-core/dashboard-core.service.js +221 -0
  54. package/dist/dashboard/dashboard-core/dashboard-core.service.js.map +1 -1
  55. package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts +26 -29
  56. package/dist/dashboard/dashboard-item/dashboard-item.controller.d.ts.map +1 -1
  57. package/dist/dashboard/dashboard-item/dashboard-item.controller.js +24 -43
  58. package/dist/dashboard/dashboard-item/dashboard-item.controller.js.map +1 -1
  59. package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts +30 -34
  60. package/dist/dashboard/dashboard-item/dashboard-item.service.d.ts.map +1 -1
  61. package/dist/dashboard/dashboard-item/dashboard-item.service.js +51 -35
  62. package/dist/dashboard/dashboard-item/dashboard-item.service.js.map +1 -1
  63. package/dist/dashboard/dashboard-item/dto/index.d.ts +5 -0
  64. package/dist/dashboard/dashboard-item/dto/index.d.ts.map +1 -0
  65. package/dist/dashboard/dashboard-item/dto/index.js +25 -0
  66. package/dist/dashboard/dashboard-item/dto/index.js.map +1 -0
  67. package/dist/dashboard/dashboard-item/dto/update.dto.d.ts +7 -4
  68. package/dist/dashboard/dashboard-item/dto/update.dto.d.ts.map +1 -1
  69. package/dist/dashboard/dashboard-item/dto/update.dto.js +42 -3
  70. package/dist/dashboard/dashboard-item/dto/update.dto.js.map +1 -1
  71. package/dist/dashboard/dashboard.module.js +1 -1
  72. package/dist/dashboard/dashboard.module.js.map +1 -1
  73. package/dist/oauth/oauth.controller.d.ts.map +1 -1
  74. package/dist/oauth/oauth.controller.js.map +1 -1
  75. package/dist/oauth/providers/microsoft-entra-id.provider.d.ts.map +1 -1
  76. package/dist/oauth/providers/microsoft-entra-id.provider.js +7 -4
  77. package/dist/oauth/providers/microsoft-entra-id.provider.js.map +1 -1
  78. package/dist/setting/setting.service.d.ts.map +1 -1
  79. package/dist/setting/setting.service.js +1 -0
  80. package/dist/setting/setting.service.js.map +1 -1
  81. package/hedhog/data/route.yaml +44 -14
  82. package/hedhog/data/setting_group.yaml +10 -0
  83. package/hedhog/query/dashboard-seed.sql +131 -0
  84. package/package.json +1 -1
  85. package/src/dashboard/dashboard/dashboard.controller.ts +26 -23
  86. package/src/dashboard/dashboard/dashboard.module.ts +7 -2
  87. package/src/dashboard/dashboard/dashboard.service.ts +125 -44
  88. package/src/dashboard/dashboard/dto/create.dto.ts +12 -3
  89. package/src/dashboard/dashboard/dto/index.ts +7 -0
  90. package/src/dashboard/dashboard/dto/update.dto.ts +17 -3
  91. package/src/dashboard/dashboard-component/dashboard-component.controller.ts +22 -19
  92. package/src/dashboard/dashboard-component/dashboard-component.module.ts +3 -3
  93. package/src/dashboard/dashboard-component/dashboard-component.service.ts +128 -39
  94. package/src/dashboard/dashboard-component/dto/create.dto.ts +12 -3
  95. package/src/dashboard/dashboard-component/dto/index.ts +7 -0
  96. package/src/dashboard/dashboard-component/dto/update.dto.ts +49 -3
  97. package/src/dashboard/dashboard-core/dashboard-core.controller.ts +53 -2
  98. package/src/dashboard/dashboard-core/dashboard-core.service.ts +271 -0
  99. package/src/dashboard/dashboard-item/dashboard-item.controller.ts +17 -26
  100. package/src/dashboard/dashboard-item/dashboard-item.service.ts +55 -47
  101. package/src/dashboard/dashboard-item/dto/index.ts +7 -0
  102. package/src/dashboard/dashboard-item/dto/update.dto.ts +27 -3
  103. package/src/dashboard/dashboard.module.ts +2 -2
  104. package/src/language/en.json +4 -1
  105. package/src/language/pt.json +4 -1
  106. package/src/oauth/oauth.controller.ts +1 -2
  107. package/src/oauth/providers/microsoft-entra-id.provider.ts +9 -4
  108. package/src/setting/setting.service.ts +1 -0
@@ -1,5 +1,6 @@
1
- import { Pagination } from '@hed-hog/api-pagination';
1
+ import { Role } from '@hed-hog/api';
2
2
  import { Locale } from '@hed-hog/api-locale';
3
+ import { Pagination } from '@hed-hog/api-pagination';
3
4
  import {
4
5
  Body,
5
6
  Controller,
@@ -8,14 +9,12 @@ import {
8
9
  Inject,
9
10
  Param,
10
11
  ParseIntPipe,
11
- Patch,
12
12
  Post,
13
- forwardRef,
13
+ Query,
14
+ forwardRef
14
15
  } from '@nestjs/common';
15
- import { CreateDTO } from './dto/create.dto';
16
- import { UpdateDTO } from './dto/update.dto';
17
16
  import { DashboardItemService } from './dashboard-item.service';
18
- import { Role, DeleteDTO } from '@hed-hog/api';
17
+ import { CreateDashboardItemDTO } from './dto';
19
18
 
20
19
  @Role()
21
20
  @Controller('dashboard-item')
@@ -26,30 +25,22 @@ export class DashboardItemController {
26
25
  ) {}
27
26
 
28
27
  @Get()
29
- async list(@Pagination() paginationParams) {
30
- return this.dashboardItemService.list(paginationParams);
31
- }
32
-
33
- @Get(':id')
34
- async get(@Param('id', ParseIntPipe) id: number) {
35
- return this.dashboardItemService.get(id);
28
+ getAllDashboardItems(
29
+ @Pagination() paginationParams,
30
+ @Locale() locale: string,
31
+ @Query('dashboardId') dashboardId?: string,
32
+ ) {
33
+ const id = dashboardId ? parseInt(dashboardId) : undefined;
34
+ return this.dashboardItemService.getAllDashboardItems(paginationParams, locale, id);
36
35
  }
37
36
 
38
37
  @Post()
39
- async create(@Body() data: CreateDTO) {
40
- return this.dashboardItemService.create(data);
41
- }
42
-
43
- @Patch(':id')
44
- async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
45
- return this.dashboardItemService.update({
46
- id,
47
- data,
48
- });
38
+ createDashboardItem(@Body() data: CreateDashboardItemDTO, @Locale() locale: string) {
39
+ return this.dashboardItemService.createDashboardItem(data, locale);
49
40
  }
50
41
 
51
- @Delete()
52
- async delete(@Body() data: DeleteDTO) {
53
- return this.dashboardItemService.delete(data);
42
+ @Delete(':id')
43
+ deleteDashboardItem(@Param('id', ParseIntPipe) id: number, @Locale() locale: string) {
44
+ return this.dashboardItemService.deleteDashboardItem(id, locale);
54
45
  }
55
46
  }
@@ -1,14 +1,13 @@
1
- import { DeleteDTO } from '@hed-hog/api';
2
- import { PaginationDTO, PaginationService } from '@hed-hog/api-pagination';
1
+ import { getLocaleText, LocaleService } from '@hed-hog/api-locale';
2
+ import { PaginationService } from '@hed-hog/api-pagination';
3
3
  import { PrismaService } from '@hed-hog/api-prisma';
4
4
  import {
5
- BadRequestException,
6
- Inject,
7
- Injectable,
8
- forwardRef,
5
+ forwardRef,
6
+ Inject,
7
+ Injectable,
8
+ NotFoundException
9
9
  } from '@nestjs/common';
10
- import { CreateDTO } from './dto/create.dto';
11
- import { UpdateDTO } from './dto/update.dto';
10
+ import { CreateDashboardItemDTO } from './dto';
12
11
 
13
12
  @Injectable()
14
13
  export class DashboardItemService {
@@ -17,66 +16,75 @@ export class DashboardItemService {
17
16
  private readonly prismaService: PrismaService,
18
17
  @Inject(forwardRef(() => PaginationService))
19
18
  private readonly paginationService: PaginationService,
19
+ @Inject(forwardRef(() => LocaleService))
20
+ private readonly localeService: LocaleService,
20
21
  ) {}
21
22
 
22
- async list(paginationParams: PaginationDTO) {
23
- const fields = [];
24
- const OR: any[] = this.prismaService.createInsensitiveSearch(
25
- fields,
26
- paginationParams,
27
- );
28
-
29
- if (paginationParams.search && !isNaN(+paginationParams.search)) {
30
- OR.push({ id: { equals: +paginationParams.search } });
31
- }
32
-
23
+ async getAllDashboardItems(paginationParams, locale: string, dashboardId?: number) {
33
24
  return this.paginationService.paginate(
34
25
  this.prismaService.dashboard_item,
35
26
  paginationParams,
36
27
  {
37
- where: {
38
- OR,
39
- },
28
+ where: dashboardId ? { dashboard_id: dashboardId } : undefined,
40
29
  include: {
41
- dashboard_component: true,
42
- dashboard: true,
30
+ dashboard: {
31
+ include: {
32
+ dashboard_locale: {
33
+ include: {
34
+ locale: true,
35
+ },
36
+ },
37
+ },
38
+ },
39
+ dashboard_component: {
40
+ include: {
41
+ dashboard_component_locale: {
42
+ include: {
43
+ locale: true,
44
+ },
45
+ },
46
+ },
47
+ },
48
+ },
49
+ orderBy: {
50
+ id: 'desc',
43
51
  },
44
52
  },
53
+ 'dashboardItem',
45
54
  );
46
55
  }
47
56
 
48
- async get(id: number) {
49
- return this.prismaService.dashboard_item.findUnique({
50
- where: { id: id },
51
- });
52
- }
53
-
54
- async create(data: CreateDTO) {
57
+ async createDashboardItem(data: CreateDashboardItemDTO, locale: string) {
55
58
  return this.prismaService.dashboard_item.create({
56
- data,
59
+ data: {
60
+ dashboard_id: data.dashboard_id,
61
+ component_id: data.component_id,
62
+ width: data.width,
63
+ height: data.height,
64
+ x_axis: data.x_axis,
65
+ y_axis: data.y_axis,
66
+ },
67
+ include: {
68
+ dashboard: true,
69
+ dashboard_component: true,
70
+ },
57
71
  });
58
72
  }
59
73
 
60
- async update({ id, data }: { id: number; data: UpdateDTO }) {
61
- return this.prismaService.dashboard_item.update({
62
- where: { id: id },
63
- data,
74
+ async deleteDashboardItem(id: number, locale: string) {
75
+ const item = await this.prismaService.dashboard_item.findUnique({
76
+ where: { id },
64
77
  });
65
- }
66
78
 
67
- async delete({ ids }: DeleteDTO): Promise<{count:number}> {
68
- if (ids == undefined || ids == null) {
69
- throw new BadRequestException(
70
- 'You must select at least one item to delete.',
79
+ if (!item) {
80
+ throw new NotFoundException(
81
+ getLocaleText('dashboardItemNotFound', locale, 'Dashboard item not found'),
71
82
  );
72
83
  }
73
84
 
74
- return this.prismaService.dashboard_item.deleteMany({
75
- where: {
76
- id: {
77
- in: ids,
78
- },
79
- },
85
+ await this.prismaService.dashboard_item.delete({
86
+ where: { id },
80
87
  });
88
+ return { success: true };
81
89
  }
82
90
  }
@@ -0,0 +1,7 @@
1
+ export * from './create.dto';
2
+ export * from './update.dto';
3
+
4
+ // Aliases para compatibilidade
5
+ export { CreateDTO as CreateDashboardItemDTO } from './create.dto';
6
+ export { UpdateDTO as UpdateDashboardItemDTO } from './update.dto';
7
+
@@ -1,4 +1,28 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateDTO } from './create.dto';
1
+ import { getLocaleText } from '@hed-hog/api-locale';
2
+ import { IsNumber, IsOptional } from 'class-validator';
3
3
 
4
- export class UpdateDTO extends PartialType(CreateDTO) {}
4
+ export class UpdateDTO {
5
+ @IsOptional()
6
+ @IsNumber({}, { message: (args) => getLocaleText('validation.numberRequired', args.value) })
7
+ component_id?: number;
8
+
9
+ @IsOptional()
10
+ @IsNumber({}, { message: (args) => getLocaleText('validation.numberRequired', args.value) })
11
+ dashboard_id?: number;
12
+
13
+ @IsOptional()
14
+ @IsNumber({}, { message: (args) => getLocaleText('validation.numberRequired', args.value) })
15
+ width?: number;
16
+
17
+ @IsOptional()
18
+ @IsNumber({}, { message: (args) => getLocaleText('validation.numberRequired', args.value) })
19
+ height?: number;
20
+
21
+ @IsOptional()
22
+ @IsNumber({}, { message: (args) => getLocaleText('validation.numberRequired', args.value) })
23
+ x_axis?: number;
24
+
25
+ @IsOptional()
26
+ @IsNumber({}, { message: (args) => getLocaleText('validation.numberRequired', args.value) })
27
+ y_axis?: number;
28
+ }
@@ -5,13 +5,13 @@ import { DashboardComponentModule } from './dashboard-component/dashboard-compon
5
5
  import { DashboardCoreModule } from './dashboard-core/dashboard-core.module';
6
6
  import { DashboardItemModule } from './dashboard-item/dashboard-item.module';
7
7
  import { DashboardUserModule } from './dashboard-user/dashboard-user.module';
8
- import { DashboardModule2 } from './dashboard/dashboard.module';
8
+ import { DashboardCrudModule } from './dashboard/dashboard.module';
9
9
 
10
10
  @Module({
11
11
  imports: [
12
12
  forwardRef(() => LocaleModule),
13
13
  forwardRef(() => PrismaModule),
14
- forwardRef(() => DashboardModule2),
14
+ forwardRef(() => DashboardCrudModule),
15
15
  forwardRef(() => DashboardComponentModule),
16
16
  forwardRef(() => DashboardItemModule),
17
17
  forwardRef(() => DashboardUserModule),
@@ -167,5 +167,8 @@
167
167
  },
168
168
  "mail_sent_not_found": "Mail sent record not found.",
169
169
  "validationSslugMustBeString": "Slug must be a string.",
170
- "sessionRevoked": "Session has been revoked or expired."
170
+ "sessionRevoked": "Session has been revoked or expired.",
171
+ "dashboardNotFound": "Dashboard not found.",
172
+ "dashboardComponentNotFound": "Dashboard component not found.",
173
+ "dashboardItemNotFound": "Dashboard item not found."
171
174
  }
@@ -167,5 +167,8 @@
167
167
  },
168
168
  "mail_sent_not_found": "Registro de e-mail enviado não encontrado.",
169
169
  "validationSslugMustBeString": "O slug deve ser uma string.",
170
- "sessionRevoked": "Sessão foi revogada ou expirada."
170
+ "sessionRevoked": "Sessão foi revogada ou expirou.",
171
+ "dashboardNotFound": "Dashboard não encontrado.",
172
+ "dashboardComponentNotFound": "Componente de dashboard não encontrado.",
173
+ "dashboardItemNotFound": "Item de dashboard não encontrado."
171
174
  }
@@ -20,7 +20,7 @@ import { OAuthService } from './oauth.service';
20
20
  export class OAuthController {
21
21
  constructor(private readonly service: OAuthService, private readonly settingService: SettingService) {}
22
22
 
23
- @Public()
23
+ @Public()
24
24
  @Get('github/callback')
25
25
  async githubCallback(
26
26
  @Query('code') code: string,
@@ -33,7 +33,6 @@ export class OAuthController {
33
33
  return res.redirect(redirectURL);
34
34
  }
35
35
 
36
-
37
36
  @Public()
38
37
  @Get(':provider/login')
39
38
  async login(@Param('provider') provider: string, @Res() res) {
@@ -19,12 +19,17 @@ export class MicrosoftEntraIdProvider extends BaseOAuthProvider {
19
19
 
20
20
  async getAuthUrl(callbackPath: string) {
21
21
  const settings = await this.setting.getSettingValues([
22
- 'microsoft_client_id',
23
- 'microsoft_client_secret',
24
- 'microsoft_scopes',
25
- 'microsoft_tenant_id',
22
+ 'microsoft_entra_id_client_id',
23
+ 'microsoft_entra_id_client_secret',
24
+ 'microsoft_entra_id_scopes',
25
+ 'microsoft_entra_id_tenant_id',
26
26
  'url',
27
27
  ]);
28
+
29
+ console.log({
30
+ settings
31
+ })
32
+
28
33
  const tenantId = settings['microsoft_tenant_id'];
29
34
  const redirectURI = new URL(callbackPath, settings['url']).toString();
30
35
  const scopes = settings['microsoft_scopes'];
@@ -182,6 +182,7 @@ export class SettingService {
182
182
  'time-format',
183
183
  'timezone',
184
184
  'menu-width',
185
+ 'providers'
185
186
  ];
186
187
  const setting = await this.getSettingValues(slugs);
187
188
  return { locales, setting };