@hed-hog/core 0.0.356 → 0.0.359
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/auth/guards/auth.guard.d.ts +6 -1
- package/dist/auth/guards/auth.guard.d.ts.map +1 -1
- package/dist/auth/guards/auth.guard.js +33 -2
- package/dist/auth/guards/auth.guard.js.map +1 -1
- package/dist/file/file.controller.d.ts +4 -2
- package/dist/file/file.controller.d.ts.map +1 -1
- package/dist/file/file.controller.js +44 -38
- package/dist/file/file.controller.js.map +1 -1
- package/dist/file/file.service.d.ts +2 -2
- package/dist/file/file.service.d.ts.map +1 -1
- package/dist/file/file.service.js +25 -42
- package/dist/file/file.service.js.map +1 -1
- package/dist/file/provider/azure.provider.d.ts.map +1 -1
- package/dist/file/provider/azure.provider.js +10 -15
- package/dist/file/provider/azure.provider.js.map +1 -1
- package/dist/file/provider/gcs.provider.d.ts.map +1 -1
- package/dist/file/provider/gcs.provider.js +8 -9
- package/dist/file/provider/gcs.provider.js.map +1 -1
- package/dist/file/provider/local.provider.d.ts.map +1 -1
- package/dist/file/provider/local.provider.js +11 -10
- package/dist/file/provider/local.provider.js.map +1 -1
- package/dist/file/provider/provider.factory.d.ts +1 -1
- package/dist/file/provider/provider.factory.d.ts.map +1 -1
- package/dist/file/provider/provider.factory.js +16 -6
- package/dist/file/provider/provider.factory.js.map +1 -1
- package/dist/file/provider/s3.provider.d.ts.map +1 -1
- package/dist/file/provider/s3.provider.js +4 -20
- package/dist/file/provider/s3.provider.js.map +1 -1
- package/dist/file/provider/spaces.provider.d.ts.map +1 -1
- package/dist/file/provider/spaces.provider.js +4 -19
- package/dist/file/provider/spaces.provider.js.map +1 -1
- package/dist/integration-profile/integration-profile.controller.d.ts +1 -1
- package/dist/integration-profile/integration-profile.controller.d.ts.map +1 -1
- package/dist/integration-profile/integration-profile.controller.js +4 -3
- package/dist/integration-profile/integration-profile.controller.js.map +1 -1
- package/dist/integration-profile/integration-profile.service.d.ts +1 -1
- package/dist/integration-profile/integration-profile.service.d.ts.map +1 -1
- package/dist/integration-profile/integration-profile.service.js +7 -4
- package/dist/integration-profile/integration-profile.service.js.map +1 -1
- package/dist/integration-profile/integration-profile.utils.d.ts +6 -0
- package/dist/integration-profile/integration-profile.utils.d.ts.map +1 -1
- package/dist/integration-profile/integration-profile.utils.js +9 -0
- package/dist/integration-profile/integration-profile.utils.js.map +1 -1
- package/dist/mail/mail.module.d.ts.map +1 -1
- package/dist/mail/mail.module.js +9 -4
- package/dist/mail/mail.module.js.map +1 -1
- package/dist/mail/mail.service.d.ts +2 -1
- package/dist/mail/mail.service.d.ts.map +1 -1
- package/dist/mail/mail.service.js +11 -7
- package/dist/mail/mail.service.js.map +1 -1
- package/dist/mcp/guards/mcp-auth.guard.js +1 -1
- package/dist/mcp/guards/mcp-auth.guard.js.map +1 -1
- package/dist/mcp/mcp-api-key.controller.d.ts +2 -0
- package/dist/mcp/mcp-api-key.controller.d.ts.map +1 -1
- package/dist/mcp/mcp-api-key.controller.js +1 -1
- package/dist/mcp/mcp-api-key.controller.js.map +1 -1
- package/dist/mcp/mcp-api-key.service.d.ts +2 -1
- package/dist/mcp/mcp-api-key.service.d.ts.map +1 -1
- package/dist/mcp/mcp-api-key.service.js +6 -2
- package/dist/mcp/mcp-api-key.service.js.map +1 -1
- package/dist/mcp/mcp.module.d.ts.map +1 -1
- package/dist/mcp/mcp.module.js +1 -3
- package/dist/mcp/mcp.module.js.map +1 -1
- package/dist/oauth/interfaces/OAuthProvider.d.ts +1 -1
- package/dist/oauth/interfaces/OAuthProvider.d.ts.map +1 -1
- package/dist/oauth/oauth.controller.d.ts +4 -1
- package/dist/oauth/oauth.controller.d.ts.map +1 -1
- package/dist/oauth/oauth.controller.js +31 -5
- package/dist/oauth/oauth.controller.js.map +1 -1
- package/dist/oauth/oauth.service.d.ts +12 -1
- package/dist/oauth/oauth.service.d.ts.map +1 -1
- package/dist/oauth/oauth.service.js +125 -23
- package/dist/oauth/oauth.service.js.map +1 -1
- package/dist/oauth/providers/abstract.provider.d.ts +1 -1
- package/dist/oauth/providers/abstract.provider.d.ts.map +1 -1
- package/dist/oauth/providers/facebook.provider.d.ts +5 -2
- package/dist/oauth/providers/facebook.provider.d.ts.map +1 -1
- package/dist/oauth/providers/facebook.provider.js +34 -19
- package/dist/oauth/providers/facebook.provider.js.map +1 -1
- package/dist/oauth/providers/github.provider.d.ts +6 -2
- package/dist/oauth/providers/github.provider.d.ts.map +1 -1
- package/dist/oauth/providers/github.provider.js +43 -20
- package/dist/oauth/providers/github.provider.js.map +1 -1
- package/dist/oauth/providers/google.provider.d.ts +5 -2
- package/dist/oauth/providers/google.provider.d.ts.map +1 -1
- package/dist/oauth/providers/google.provider.js +34 -19
- package/dist/oauth/providers/google.provider.js.map +1 -1
- package/dist/oauth/providers/microsoft-entra-id.provider.d.ts +5 -2
- package/dist/oauth/providers/microsoft-entra-id.provider.d.ts.map +1 -1
- package/dist/oauth/providers/microsoft-entra-id.provider.js +43 -40
- package/dist/oauth/providers/microsoft-entra-id.provider.js.map +1 -1
- package/dist/oauth/providers/microsoft.provider.d.ts +5 -2
- package/dist/oauth/providers/microsoft.provider.d.ts.map +1 -1
- package/dist/oauth/providers/microsoft.provider.js +34 -19
- package/dist/oauth/providers/microsoft.provider.js.map +1 -1
- package/dist/profile/profile.controller.js +1 -1
- package/dist/profile/profile.controller.js.map +1 -1
- package/dist/security/security.service.d.ts +2 -0
- package/dist/security/security.service.d.ts.map +1 -1
- package/dist/security/security.service.js +21 -0
- package/dist/security/security.service.js.map +1 -1
- package/dist/setting/setting.service.d.ts +26 -1
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +240 -5
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/user/user.controller.d.ts +2 -1
- package/dist/user/user.controller.d.ts.map +1 -1
- package/dist/user/user.controller.js +5 -4
- package/dist/user/user.controller.js.map +1 -1
- package/dist/user/user.service.d.ts +4 -2
- package/dist/user/user.service.d.ts.map +1 -1
- package/dist/user/user.service.js +19 -4
- package/dist/user/user.service.js.map +1 -1
- package/dist/webhook-integration/dto/webhook-action.dto.d.ts +17 -2
- package/dist/webhook-integration/dto/webhook-action.dto.d.ts.map +1 -1
- package/dist/webhook-integration/dto/webhook-action.dto.js +93 -2
- package/dist/webhook-integration/dto/webhook-action.dto.js.map +1 -1
- package/dist/webhook-integration/webhook-command.registry.d.ts +15 -0
- package/dist/webhook-integration/webhook-command.registry.d.ts.map +1 -0
- package/dist/webhook-integration/webhook-command.registry.js +36 -0
- package/dist/webhook-integration/webhook-command.registry.js.map +1 -0
- package/dist/webhook-integration/webhook-integration.controller.d.ts +19 -0
- package/dist/webhook-integration/webhook-integration.controller.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.controller.js +38 -0
- package/dist/webhook-integration/webhook-integration.controller.js.map +1 -1
- package/dist/webhook-integration/webhook-integration.module.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.module.js +5 -0
- package/dist/webhook-integration/webhook-integration.module.js.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.d.ts +25 -1
- package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.js +332 -23
- package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
- package/hedhog/data/integration_provider.yaml +16 -0
- package/hedhog/data/menu.yaml +0 -16
- package/hedhog/data/route.yaml +32 -383
- package/hedhog/data/setting_group.yaml +179 -174
- package/hedhog/data/setting_subgroup.yaml +16 -0
- package/hedhog/frontend/app/account/components/tokens.tsx.ejs +421 -0
- package/hedhog/frontend/app/account/layout.tsx.ejs +6 -3
- package/hedhog/frontend/app/account/mcp-tokens/page.tsx.ejs +2 -2
- package/hedhog/frontend/app/account/tokens/page.tsx.ejs +5 -0
- package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +414 -76
- package/hedhog/frontend/app/configurations/layout.tsx.ejs +1 -1
- package/hedhog/frontend/app/dashboard/dashboard-home-tabs.tsx.ejs +3 -1
- package/hedhog/frontend/app/integration/profiles/page.tsx.ejs +186 -18
- package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +597 -21
- package/hedhog/frontend/app/mail/profiles/page.tsx.ejs +2 -2
- package/hedhog/frontend/app/setting-list/page.tsx.ejs +229 -395
- package/hedhog/frontend/messages/en.json +67 -3
- package/hedhog/frontend/messages/pt.json +67 -3
- package/hedhog/table/file.yaml +1 -1
- package/hedhog/table/mcp_api_key.yaml +4 -0
- package/hedhog/table/webhook_action.yaml +57 -1
- package/package.json +5 -4
- package/src/auth/guards/auth.guard.ts +32 -0
- package/src/file/file.controller.ts +51 -42
- package/src/file/file.service.ts +31 -52
- package/src/file/provider/azure.provider.ts +14 -28
- package/src/file/provider/gcs.provider.ts +9 -9
- package/src/file/provider/local.provider.ts +10 -13
- package/src/file/provider/provider.factory.ts +19 -7
- package/src/file/provider/s3.provider.ts +4 -20
- package/src/file/provider/spaces.provider.ts +4 -19
- package/src/integration-profile/integration-profile.controller.ts +2 -0
- package/src/integration-profile/integration-profile.service.ts +7 -2
- package/src/integration-profile/integration-profile.utils.ts +17 -0
- package/src/mail/mail.module.ts +14 -4
- package/src/mail/mail.service.ts +12 -7
- package/src/mcp/guards/mcp-auth.guard.ts +1 -1
- package/src/mcp/mcp-api-key.controller.ts +2 -2
- package/src/mcp/mcp-api-key.service.ts +6 -2
- package/src/mcp/mcp.module.ts +1 -3
- package/src/oauth/interfaces/OAuthProvider.ts +1 -1
- package/src/oauth/oauth.controller.ts +30 -2
- package/src/oauth/oauth.service.ts +194 -35
- package/src/oauth/providers/abstract.provider.ts +1 -1
- package/src/oauth/providers/facebook.provider.ts +36 -20
- package/src/oauth/providers/github.provider.ts +46 -23
- package/src/oauth/providers/google.provider.ts +36 -20
- package/src/oauth/providers/microsoft-entra-id.provider.ts +42 -46
- package/src/oauth/providers/microsoft.provider.ts +36 -21
- package/src/profile/profile.controller.ts +2 -2
- package/src/security/security.service.ts +34 -1
- package/src/setting/setting.service.ts +307 -7
- package/src/user/user.controller.ts +4 -1
- package/src/user/user.service.ts +20 -2
- package/src/webhook-integration/dto/webhook-action.dto.ts +85 -4
- package/src/webhook-integration/webhook-command.registry.ts +42 -0
- package/src/webhook-integration/webhook-integration.controller.ts +20 -0
- package/src/webhook-integration/webhook-integration.module.ts +50 -45
- package/src/webhook-integration/webhook-integration.service.ts +374 -11
- package/dist/mail-profile/dto/create.dto.d.ts +0 -23
- package/dist/mail-profile/dto/create.dto.d.ts.map +0 -1
- package/dist/mail-profile/dto/create.dto.js +0 -139
- package/dist/mail-profile/dto/create.dto.js.map +0 -1
- package/dist/mail-profile/dto/update.dto.d.ts +0 -6
- package/dist/mail-profile/dto/update.dto.d.ts.map +0 -1
- package/dist/mail-profile/dto/update.dto.js +0 -9
- package/dist/mail-profile/dto/update.dto.js.map +0 -1
- package/dist/mail-profile/mail-profile.controller.d.ts +0 -94
- package/dist/mail-profile/mail-profile.controller.d.ts.map +0 -1
- package/dist/mail-profile/mail-profile.controller.js +0 -95
- package/dist/mail-profile/mail-profile.controller.js.map +0 -1
- package/dist/mail-profile/mail-profile.module.d.ts +0 -3
- package/dist/mail-profile/mail-profile.module.d.ts.map +0 -1
- package/dist/mail-profile/mail-profile.module.js +0 -31
- package/dist/mail-profile/mail-profile.module.js.map +0 -1
- package/dist/mail-profile/mail-profile.service.d.ts +0 -109
- package/dist/mail-profile/mail-profile.service.d.ts.map +0 -1
- package/dist/mail-profile/mail-profile.service.js +0 -278
- package/dist/mail-profile/mail-profile.service.js.map +0 -1
- package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts +0 -20
- package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts.map +0 -1
- package/dist/mcp/tools/core-mail-profile.mcp-tools.js +0 -96
- package/dist/mcp/tools/core-mail-profile.mcp-tools.js.map +0 -1
- package/dist/whatsapp-profile/dto/create.dto.d.ts +0 -11
- package/dist/whatsapp-profile/dto/create.dto.d.ts.map +0 -1
- package/dist/whatsapp-profile/dto/create.dto.js +0 -55
- package/dist/whatsapp-profile/dto/create.dto.js.map +0 -1
- package/dist/whatsapp-profile/dto/update.dto.d.ts +0 -6
- package/dist/whatsapp-profile/dto/update.dto.d.ts.map +0 -1
- package/dist/whatsapp-profile/dto/update.dto.js +0 -9
- package/dist/whatsapp-profile/dto/update.dto.js.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts +0 -54
- package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.controller.js +0 -85
- package/dist/whatsapp-profile/whatsapp-profile.controller.js.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.module.d.ts +0 -3
- package/dist/whatsapp-profile/whatsapp-profile.module.d.ts.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.module.js +0 -26
- package/dist/whatsapp-profile/whatsapp-profile.module.js.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.service.d.ts +0 -63
- package/dist/whatsapp-profile/whatsapp-profile.service.d.ts.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.service.js +0 -138
- package/dist/whatsapp-profile/whatsapp-profile.service.js.map +0 -1
- package/hedhog/data/mail_profile.yaml +0 -18
- package/hedhog/data/whatsapp_profile.yaml +0 -6
- package/hedhog/table/mail_profile.yaml +0 -75
- package/hedhog/table/whatsapp_profile.yaml +0 -26
- package/src/mail-profile/dto/create.dto.ts +0 -145
- package/src/mail-profile/dto/update.dto.ts +0 -4
- package/src/mail-profile/mail-profile.controller.ts +0 -56
- package/src/mail-profile/mail-profile.module.ts +0 -18
- package/src/mail-profile/mail-profile.service.ts +0 -308
- package/src/mcp/tools/core-mail-profile.mcp-tools.ts +0 -69
- package/src/whatsapp-profile/dto/create.dto.ts +0 -36
- package/src/whatsapp-profile/dto/update.dto.ts +0 -4
- package/src/whatsapp-profile/whatsapp-profile.controller.ts +0 -51
- package/src/whatsapp-profile/whatsapp-profile.module.ts +0 -13
- package/src/whatsapp-profile/whatsapp-profile.service.ts +0 -160
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { DeleteDTO, Role } from '@hed-hog/api';
|
|
2
|
-
import { Pagination } from '@hed-hog/api-pagination';
|
|
3
|
-
import {
|
|
4
|
-
Body,
|
|
5
|
-
Controller,
|
|
6
|
-
Delete,
|
|
7
|
-
Get,
|
|
8
|
-
Inject,
|
|
9
|
-
Param,
|
|
10
|
-
ParseIntPipe,
|
|
11
|
-
Patch,
|
|
12
|
-
Post,
|
|
13
|
-
forwardRef,
|
|
14
|
-
} from '@nestjs/common';
|
|
15
|
-
import { CreateDTO } from './dto/create.dto';
|
|
16
|
-
import { UpdateDTO } from './dto/update.dto';
|
|
17
|
-
import { MailProfileService } from './mail-profile.service';
|
|
18
|
-
|
|
19
|
-
@Role()
|
|
20
|
-
@Controller('mail-profile')
|
|
21
|
-
export class MailProfileController {
|
|
22
|
-
constructor(
|
|
23
|
-
@Inject(forwardRef(() => MailProfileService))
|
|
24
|
-
private readonly mailProfileService: MailProfileService,
|
|
25
|
-
) {}
|
|
26
|
-
|
|
27
|
-
@Get()
|
|
28
|
-
async list(@Pagination() paginationParams) {
|
|
29
|
-
return this.mailProfileService.list(paginationParams);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@Get(':id')
|
|
33
|
-
async get(@Param('id', ParseIntPipe) id: number) {
|
|
34
|
-
return this.mailProfileService.get(id);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@Post()
|
|
38
|
-
async create(@Body() data: CreateDTO) {
|
|
39
|
-
return this.mailProfileService.create(data);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@Post('test')
|
|
43
|
-
async test(@Body() data: CreateDTO) {
|
|
44
|
-
return this.mailProfileService.test(data);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@Patch(':id')
|
|
48
|
-
async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
|
|
49
|
-
return this.mailProfileService.update({ id, data });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@Delete()
|
|
53
|
-
async delete(@Body() data: DeleteDTO) {
|
|
54
|
-
return this.mailProfileService.delete(data);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PaginationModule } from '@hed-hog/api-pagination';
|
|
2
|
-
import { PrismaModule } from '@hed-hog/api-prisma';
|
|
3
|
-
import { forwardRef, Module } from '@nestjs/common';
|
|
4
|
-
import { MailModule } from '../mail/mail.module';
|
|
5
|
-
import { MailProfileController } from './mail-profile.controller';
|
|
6
|
-
import { MailProfileService } from './mail-profile.service';
|
|
7
|
-
|
|
8
|
-
@Module({
|
|
9
|
-
imports: [
|
|
10
|
-
forwardRef(() => PrismaModule),
|
|
11
|
-
forwardRef(() => PaginationModule),
|
|
12
|
-
forwardRef(() => MailModule),
|
|
13
|
-
],
|
|
14
|
-
controllers: [MailProfileController],
|
|
15
|
-
providers: [MailProfileService],
|
|
16
|
-
exports: [MailProfileService],
|
|
17
|
-
})
|
|
18
|
-
export class MailProfileModule {}
|
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
import { DeleteDTO } from '@hed-hog/api';
|
|
2
|
-
import { MailService as MailMainService } from '@hed-hog/api-mail';
|
|
3
|
-
import { PaginationDTO, PaginationService } from '@hed-hog/api-pagination';
|
|
4
|
-
import { PrismaService } from '@hed-hog/api-prisma';
|
|
5
|
-
import {
|
|
6
|
-
BadRequestException,
|
|
7
|
-
Inject,
|
|
8
|
-
Injectable,
|
|
9
|
-
NotFoundException,
|
|
10
|
-
forwardRef,
|
|
11
|
-
} from '@nestjs/common';
|
|
12
|
-
import { MailService } from '../mail/mail.service';
|
|
13
|
-
import { CreateDTO } from './dto/create.dto';
|
|
14
|
-
import { UpdateDTO } from './dto/update.dto';
|
|
15
|
-
|
|
16
|
-
@Injectable()
|
|
17
|
-
export class MailProfileService {
|
|
18
|
-
constructor(
|
|
19
|
-
@Inject(forwardRef(() => PrismaService))
|
|
20
|
-
private readonly prismaService: PrismaService,
|
|
21
|
-
@Inject(forwardRef(() => PaginationService))
|
|
22
|
-
private readonly paginationService: PaginationService,
|
|
23
|
-
@Inject(forwardRef(() => MailMainService))
|
|
24
|
-
private readonly mailMainService: MailMainService,
|
|
25
|
-
@Inject(forwardRef(() => MailService))
|
|
26
|
-
private readonly mailService: MailService,
|
|
27
|
-
) {}
|
|
28
|
-
|
|
29
|
-
async list(paginationParams: PaginationDTO) {
|
|
30
|
-
const fields = ['slug', 'name', 'from_email', 'reply_to_email'];
|
|
31
|
-
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
|
32
|
-
|
|
33
|
-
return this.paginationService.paginate(
|
|
34
|
-
this.prismaService.mail_profile,
|
|
35
|
-
paginationParams,
|
|
36
|
-
{
|
|
37
|
-
where: OR.length > 0 ? { OR } : {},
|
|
38
|
-
select: {
|
|
39
|
-
id: true,
|
|
40
|
-
slug: true,
|
|
41
|
-
name: true,
|
|
42
|
-
provider: true,
|
|
43
|
-
from_name: true,
|
|
44
|
-
from_email: true,
|
|
45
|
-
reply_to_name: true,
|
|
46
|
-
reply_to_email: true,
|
|
47
|
-
created_at: true,
|
|
48
|
-
updated_at: true,
|
|
49
|
-
},
|
|
50
|
-
orderBy: [{ updated_at: 'desc' }, { id: 'desc' }],
|
|
51
|
-
},
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async get(id: number) {
|
|
56
|
-
const profile = await this.prismaService.mail_profile.findUnique({
|
|
57
|
-
where: { id },
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
if (!profile) {
|
|
61
|
-
throw new NotFoundException(`Mail profile with id ${id} not found.`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return profile;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async create(data: CreateDTO) {
|
|
68
|
-
await this.ensureSlugIsAvailable(data.slug);
|
|
69
|
-
this.validateProviderFields(data as unknown as Record<string, unknown>);
|
|
70
|
-
|
|
71
|
-
return this.prismaService.mail_profile.create({
|
|
72
|
-
data: this.normalizeData(data as unknown as Record<string, unknown>) as any,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async update({ id, data }: { id: number; data: UpdateDTO }) {
|
|
77
|
-
const existing = await this.prismaService.mail_profile.findUnique({
|
|
78
|
-
where: { id },
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
if (!existing) {
|
|
82
|
-
throw new NotFoundException(`Mail profile with id ${id} not found.`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (data.slug && data.slug !== existing.slug) {
|
|
86
|
-
await this.ensureSlugIsAvailable(data.slug);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const merged = {
|
|
90
|
-
...existing,
|
|
91
|
-
...data,
|
|
92
|
-
} satisfies Record<string, unknown>;
|
|
93
|
-
|
|
94
|
-
this.validateProviderFields(merged);
|
|
95
|
-
|
|
96
|
-
return this.prismaService.mail_profile.update({
|
|
97
|
-
where: { id },
|
|
98
|
-
data: this.normalizeData(merged) as any,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async delete({ ids }: DeleteDTO): Promise<{ count: number }> {
|
|
103
|
-
if (!ids?.length) {
|
|
104
|
-
throw new BadRequestException('You must select at least one item to delete.');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return this.prismaService.mail_profile.deleteMany({
|
|
108
|
-
where: {
|
|
109
|
-
id: {
|
|
110
|
-
in: ids,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async test(data: CreateDTO) {
|
|
117
|
-
this.validateProviderFields(data as unknown as Record<string, unknown>);
|
|
118
|
-
|
|
119
|
-
const normalized = this.normalizeData(data as unknown as Record<string, unknown>);
|
|
120
|
-
const config = this.buildMailConfig(normalized);
|
|
121
|
-
const destinationEmail = normalized.from_email;
|
|
122
|
-
const sender = normalized.from_name
|
|
123
|
-
? `${normalized.from_name} <${normalized.from_email}>`
|
|
124
|
-
: normalized.from_email;
|
|
125
|
-
const replyTo = normalized.reply_to_email
|
|
126
|
-
? normalized.reply_to_name
|
|
127
|
-
? `${normalized.reply_to_name} <${normalized.reply_to_email}>`
|
|
128
|
-
: normalized.reply_to_email
|
|
129
|
-
: undefined;
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
this.mailMainService.setConfig(config);
|
|
133
|
-
|
|
134
|
-
await this.mailMainService.send({
|
|
135
|
-
to: destinationEmail,
|
|
136
|
-
from: sender,
|
|
137
|
-
replyTo,
|
|
138
|
-
subject: `[HedHog] Teste do perfil ${normalized.name}`,
|
|
139
|
-
body: `
|
|
140
|
-
<p>Este e-mail confirma que o perfil <strong>${normalized.name}</strong> foi validado com sucesso.</p>
|
|
141
|
-
<p><strong>Slug:</strong> ${normalized.slug}</p>
|
|
142
|
-
<p><strong>Provedor:</strong> ${normalized.provider}</p>
|
|
143
|
-
<p><strong>Remetente:</strong> ${sender}</p>
|
|
144
|
-
`,
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
success: true,
|
|
149
|
-
destination: destinationEmail,
|
|
150
|
-
};
|
|
151
|
-
} finally {
|
|
152
|
-
await this.mailService.reloadConfig().catch(() => undefined);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private async ensureSlugIsAvailable(slug: string) {
|
|
157
|
-
const existing = await this.prismaService.mail_profile.findUnique({
|
|
158
|
-
where: { slug },
|
|
159
|
-
select: { id: true },
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
if (existing) {
|
|
163
|
-
throw new BadRequestException(`Mail profile with slug "${slug}" already exists.`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
private validateProviderFields(input: Record<string, unknown>) {
|
|
168
|
-
const provider = String(input.provider ?? '').toUpperCase();
|
|
169
|
-
|
|
170
|
-
if (!provider) {
|
|
171
|
-
throw new BadRequestException('Provider is required.');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (!String(input.from_email ?? '').trim()) {
|
|
175
|
-
throw new BadRequestException('Sender email is required.');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
switch (provider) {
|
|
179
|
-
case 'SMTP':
|
|
180
|
-
if (!String(input.smtp_host ?? '').trim()) {
|
|
181
|
-
throw new BadRequestException('SMTP host is required.');
|
|
182
|
-
}
|
|
183
|
-
if (!input.smtp_port) {
|
|
184
|
-
throw new BadRequestException('SMTP port is required.');
|
|
185
|
-
}
|
|
186
|
-
if (!String(input.smtp_username ?? '').trim()) {
|
|
187
|
-
throw new BadRequestException('SMTP username is required.');
|
|
188
|
-
}
|
|
189
|
-
if (!String(input.smtp_password ?? '').trim()) {
|
|
190
|
-
throw new BadRequestException('SMTP password is required.');
|
|
191
|
-
}
|
|
192
|
-
break;
|
|
193
|
-
case 'GMAIL':
|
|
194
|
-
if (!String(input.gmail_client_id ?? '').trim()) {
|
|
195
|
-
throw new BadRequestException('Gmail client ID is required.');
|
|
196
|
-
}
|
|
197
|
-
if (!String(input.gmail_client_secret ?? '').trim()) {
|
|
198
|
-
throw new BadRequestException('Gmail client secret is required.');
|
|
199
|
-
}
|
|
200
|
-
if (!String(input.gmail_refresh_token ?? '').trim()) {
|
|
201
|
-
throw new BadRequestException('Gmail refresh token is required.');
|
|
202
|
-
}
|
|
203
|
-
break;
|
|
204
|
-
case 'SES':
|
|
205
|
-
if (!String(input.ses_access_key_id ?? '').trim()) {
|
|
206
|
-
throw new BadRequestException('SES access key ID is required.');
|
|
207
|
-
}
|
|
208
|
-
if (!String(input.ses_secret_access_key ?? '').trim()) {
|
|
209
|
-
throw new BadRequestException('SES secret access key is required.');
|
|
210
|
-
}
|
|
211
|
-
if (!String(input.ses_region ?? '').trim()) {
|
|
212
|
-
throw new BadRequestException('SES region is required.');
|
|
213
|
-
}
|
|
214
|
-
break;
|
|
215
|
-
default:
|
|
216
|
-
throw new BadRequestException(`Invalid provider: ${provider}`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
private normalizeData(input: Record<string, unknown>) {
|
|
221
|
-
const provider = String(input.provider ?? '').toUpperCase();
|
|
222
|
-
|
|
223
|
-
return {
|
|
224
|
-
slug: this.normalizeString(input.slug),
|
|
225
|
-
name: this.normalizeString(input.name),
|
|
226
|
-
provider,
|
|
227
|
-
from_name: this.normalizeNullableString(input.from_name),
|
|
228
|
-
from_email: this.normalizeString(input.from_email),
|
|
229
|
-
reply_to_name: this.normalizeNullableString(input.reply_to_name),
|
|
230
|
-
reply_to_email: this.normalizeNullableString(input.reply_to_email),
|
|
231
|
-
smtp_host: provider === 'SMTP' ? this.normalizeNullableString(input.smtp_host) : null,
|
|
232
|
-
smtp_port:
|
|
233
|
-
provider === 'SMTP' && input.smtp_port !== undefined && input.smtp_port !== null
|
|
234
|
-
? Number(input.smtp_port)
|
|
235
|
-
: null,
|
|
236
|
-
smtp_secure: provider === 'SMTP' ? Boolean(input.smtp_secure) : false,
|
|
237
|
-
smtp_username:
|
|
238
|
-
provider === 'SMTP' ? this.normalizeNullableString(input.smtp_username) : null,
|
|
239
|
-
smtp_password:
|
|
240
|
-
provider === 'SMTP' ? this.normalizeNullableString(input.smtp_password) : null,
|
|
241
|
-
gmail_client_id:
|
|
242
|
-
provider === 'GMAIL' ? this.normalizeNullableString(input.gmail_client_id) : null,
|
|
243
|
-
gmail_client_secret:
|
|
244
|
-
provider === 'GMAIL'
|
|
245
|
-
? this.normalizeNullableString(input.gmail_client_secret)
|
|
246
|
-
: null,
|
|
247
|
-
gmail_refresh_token:
|
|
248
|
-
provider === 'GMAIL'
|
|
249
|
-
? this.normalizeNullableString(input.gmail_refresh_token)
|
|
250
|
-
: null,
|
|
251
|
-
ses_access_key_id:
|
|
252
|
-
provider === 'SES' ? this.normalizeNullableString(input.ses_access_key_id) : null,
|
|
253
|
-
ses_secret_access_key:
|
|
254
|
-
provider === 'SES'
|
|
255
|
-
? this.normalizeNullableString(input.ses_secret_access_key)
|
|
256
|
-
: null,
|
|
257
|
-
ses_region: provider === 'SES' ? this.normalizeNullableString(input.ses_region) : null,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
private buildMailConfig(input: ReturnType<MailProfileService['normalizeData']>) {
|
|
262
|
-
switch (input.provider) {
|
|
263
|
-
case 'SMTP':
|
|
264
|
-
return {
|
|
265
|
-
global: true,
|
|
266
|
-
type: 'SMTP' as const,
|
|
267
|
-
host: input.smtp_host ?? '',
|
|
268
|
-
port: input.smtp_port ?? 587,
|
|
269
|
-
secure: input.smtp_secure,
|
|
270
|
-
username: input.smtp_username ?? '',
|
|
271
|
-
password: input.smtp_password ?? '',
|
|
272
|
-
};
|
|
273
|
-
case 'GMAIL':
|
|
274
|
-
return {
|
|
275
|
-
global: true,
|
|
276
|
-
type: 'GMAIL' as const,
|
|
277
|
-
clientId: input.gmail_client_id ?? '',
|
|
278
|
-
clientSecret: input.gmail_client_secret ?? '',
|
|
279
|
-
refreshToken: input.gmail_refresh_token ?? '',
|
|
280
|
-
from: input.from_email,
|
|
281
|
-
};
|
|
282
|
-
case 'SES':
|
|
283
|
-
return {
|
|
284
|
-
global: true,
|
|
285
|
-
type: 'SES' as const,
|
|
286
|
-
region: input.ses_region ?? '',
|
|
287
|
-
accessKeyId: input.ses_access_key_id ?? '',
|
|
288
|
-
secretAccessKey: input.ses_secret_access_key ?? '',
|
|
289
|
-
from: input.from_email,
|
|
290
|
-
};
|
|
291
|
-
default:
|
|
292
|
-
throw new BadRequestException(`Invalid provider: ${input.provider}`);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
private normalizeString(value: unknown) {
|
|
297
|
-
return String(value ?? '').trim();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
private normalizeNullableString(value: unknown) {
|
|
301
|
-
if (value === undefined || value === null) {
|
|
302
|
-
return null;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const normalized = String(value).trim();
|
|
306
|
-
return normalized.length > 0 ? normalized : null;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { IntegrationProfileService } from '../../integration-profile/integration-profile.service';
|
|
3
|
-
import { McpTool } from '../decorators/mcp-tool.decorator';
|
|
4
|
-
import { McpContext } from '../types/mcp-context.type';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class CoreMailProfileMcpTools {
|
|
8
|
-
constructor(private readonly integrationProfileService: IntegrationProfileService) {}
|
|
9
|
-
|
|
10
|
-
@McpTool({
|
|
11
|
-
name: 'core.mail-profile.list',
|
|
12
|
-
description: 'Lists integration profiles with optional pagination. Admin only.',
|
|
13
|
-
inputSchema: {
|
|
14
|
-
type: 'object',
|
|
15
|
-
properties: {
|
|
16
|
-
page: { type: 'number', description: 'Page number (default: 1)' },
|
|
17
|
-
pageSize: { type: 'number', description: 'Items per page (default: 20)' },
|
|
18
|
-
search: { type: 'string', description: 'Search term' },
|
|
19
|
-
sortField: { type: 'string', description: 'Field to sort by' },
|
|
20
|
-
sortOrder: { type: 'string', enum: ['asc', 'desc'], description: 'Sort direction' },
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
readOnly: true,
|
|
24
|
-
})
|
|
25
|
-
async listMailProfiles(
|
|
26
|
-
args: { page?: number; pageSize?: number; search?: string; sortField?: string; sortOrder?: string },
|
|
27
|
-
_context: McpContext,
|
|
28
|
-
): Promise<any> {
|
|
29
|
-
return this.integrationProfileService.list({
|
|
30
|
-
page: args.page ?? 1,
|
|
31
|
-
pageSize: args.pageSize ?? 20,
|
|
32
|
-
search: args.search ?? '',
|
|
33
|
-
sortField: args.sortField ?? 'id',
|
|
34
|
-
sortOrder: (args.sortOrder as any) ?? 'asc',
|
|
35
|
-
fields: '',
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@McpTool({
|
|
40
|
-
name: 'core.mail-profile.get',
|
|
41
|
-
description: 'Returns a single integration profile by ID. Admin only.',
|
|
42
|
-
inputSchema: {
|
|
43
|
-
type: 'object',
|
|
44
|
-
properties: {
|
|
45
|
-
id: { type: 'number', description: 'Profile ID' },
|
|
46
|
-
},
|
|
47
|
-
required: ['id'],
|
|
48
|
-
},
|
|
49
|
-
readOnly: true,
|
|
50
|
-
})
|
|
51
|
-
async getMailProfile(args: { id: number }, _context: McpContext): Promise<any> {
|
|
52
|
-
return this.integrationProfileService.get(args.id);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@McpTool({
|
|
56
|
-
name: 'core.mail-profile.delete',
|
|
57
|
-
description: 'Deletes one or more integration profiles by their IDs. Admin only.',
|
|
58
|
-
inputSchema: {
|
|
59
|
-
type: 'object',
|
|
60
|
-
properties: {
|
|
61
|
-
ids: { type: 'array', items: { type: 'number' }, description: 'Profile IDs to delete' },
|
|
62
|
-
},
|
|
63
|
-
required: ['ids'],
|
|
64
|
-
},
|
|
65
|
-
})
|
|
66
|
-
async deleteMailProfiles(args: { ids: number[] }, _context: McpContext): Promise<any> {
|
|
67
|
-
return this.integrationProfileService.delete({ ids: args.ids });
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
-
import { Transform } from 'class-transformer';
|
|
3
|
-
import { IsIn, IsString, MaxLength } from 'class-validator';
|
|
4
|
-
|
|
5
|
-
const providerOptions = ['WHATSAPP_API'] as const;
|
|
6
|
-
|
|
7
|
-
export class CreateDTO {
|
|
8
|
-
@IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
|
|
9
|
-
@MaxLength(127)
|
|
10
|
-
@Transform(({ value }) => String(value ?? '').trim())
|
|
11
|
-
slug: string;
|
|
12
|
-
|
|
13
|
-
@IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
|
|
14
|
-
@MaxLength(127)
|
|
15
|
-
@Transform(({ value }) => String(value ?? '').trim())
|
|
16
|
-
name: string;
|
|
17
|
-
|
|
18
|
-
@IsIn(providerOptions)
|
|
19
|
-
@Transform(({ value }) => String(value ?? '').trim().toUpperCase())
|
|
20
|
-
provider: (typeof providerOptions)[number];
|
|
21
|
-
|
|
22
|
-
@IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
|
|
23
|
-
@MaxLength(255)
|
|
24
|
-
@Transform(({ value }) => String(value ?? '').trim())
|
|
25
|
-
host: string;
|
|
26
|
-
|
|
27
|
-
@IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
|
|
28
|
-
@MaxLength(255)
|
|
29
|
-
@Transform(({ value }) => String(value ?? '').trim())
|
|
30
|
-
token: string;
|
|
31
|
-
|
|
32
|
-
@IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
|
|
33
|
-
@MaxLength(127)
|
|
34
|
-
@Transform(({ value }) => String(value ?? '').trim())
|
|
35
|
-
instance_name: string;
|
|
36
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { DeleteDTO, Role } from '@hed-hog/api';
|
|
2
|
-
import { Pagination } from '@hed-hog/api-pagination';
|
|
3
|
-
import {
|
|
4
|
-
Body,
|
|
5
|
-
Controller,
|
|
6
|
-
Delete,
|
|
7
|
-
Get,
|
|
8
|
-
Inject,
|
|
9
|
-
Param,
|
|
10
|
-
ParseIntPipe,
|
|
11
|
-
Patch,
|
|
12
|
-
Post,
|
|
13
|
-
forwardRef,
|
|
14
|
-
} from '@nestjs/common';
|
|
15
|
-
import { CreateDTO } from './dto/create.dto';
|
|
16
|
-
import { UpdateDTO } from './dto/update.dto';
|
|
17
|
-
import { WhatsAppProfileService } from './whatsapp-profile.service';
|
|
18
|
-
|
|
19
|
-
@Role()
|
|
20
|
-
@Controller('whatsapp-profile')
|
|
21
|
-
export class WhatsAppProfileController {
|
|
22
|
-
constructor(
|
|
23
|
-
@Inject(forwardRef(() => WhatsAppProfileService))
|
|
24
|
-
private readonly whatsappProfileService: WhatsAppProfileService,
|
|
25
|
-
) {}
|
|
26
|
-
|
|
27
|
-
@Get()
|
|
28
|
-
async list(@Pagination() paginationParams) {
|
|
29
|
-
return this.whatsappProfileService.list(paginationParams);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@Get(':id')
|
|
33
|
-
async get(@Param('id', ParseIntPipe) id: number) {
|
|
34
|
-
return this.whatsappProfileService.get(id);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@Post()
|
|
38
|
-
async create(@Body() data: CreateDTO) {
|
|
39
|
-
return this.whatsappProfileService.create(data);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@Patch(':id')
|
|
43
|
-
async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
|
|
44
|
-
return this.whatsappProfileService.update({ id, data });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@Delete()
|
|
48
|
-
async delete(@Body() data: DeleteDTO) {
|
|
49
|
-
return this.whatsappProfileService.delete(data);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { PaginationModule } from '@hed-hog/api-pagination';
|
|
2
|
-
import { PrismaModule } from '@hed-hog/api-prisma';
|
|
3
|
-
import { forwardRef, Module } from '@nestjs/common';
|
|
4
|
-
import { WhatsAppProfileController } from './whatsapp-profile.controller';
|
|
5
|
-
import { WhatsAppProfileService } from './whatsapp-profile.service';
|
|
6
|
-
|
|
7
|
-
@Module({
|
|
8
|
-
imports: [forwardRef(() => PrismaModule), forwardRef(() => PaginationModule)],
|
|
9
|
-
controllers: [WhatsAppProfileController],
|
|
10
|
-
providers: [WhatsAppProfileService],
|
|
11
|
-
exports: [WhatsAppProfileService],
|
|
12
|
-
})
|
|
13
|
-
export class WhatsAppProfileModule {}
|