@hed-hog/core 0.0.367 → 0.0.370

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 (62) hide show
  1. package/dist/file/file.service.d.ts +1 -0
  2. package/dist/file/file.service.d.ts.map +1 -1
  3. package/dist/file/file.service.js +1 -1
  4. package/dist/file/file.service.js.map +1 -1
  5. package/dist/notification/events/notification-stale-progress-check.event.d.ts +6 -0
  6. package/dist/notification/events/notification-stale-progress-check.event.d.ts.map +1 -0
  7. package/dist/notification/events/notification-stale-progress-check.event.js +11 -0
  8. package/dist/notification/events/notification-stale-progress-check.event.js.map +1 -0
  9. package/dist/notification/notification.service.d.ts +4 -1
  10. package/dist/notification/notification.service.d.ts.map +1 -1
  11. package/dist/notification/notification.service.js +9 -26
  12. package/dist/notification/notification.service.js.map +1 -1
  13. package/dist/task/task.service.d.ts +19 -0
  14. package/dist/task/task.service.d.ts.map +1 -1
  15. package/dist/task/task.service.js +46 -0
  16. package/dist/task/task.service.js.map +1 -1
  17. package/dist/user/user.controller.d.ts +23 -5
  18. package/dist/user/user.controller.d.ts.map +1 -1
  19. package/dist/user/user.controller.js +32 -15
  20. package/dist/user/user.controller.js.map +1 -1
  21. package/dist/user/user.service.d.ts +28 -8
  22. package/dist/user/user.service.d.ts.map +1 -1
  23. package/dist/user/user.service.js +120 -8
  24. package/dist/user/user.service.js.map +1 -1
  25. package/hedhog/data/integration_event_catalog.yaml +118 -118
  26. package/hedhog/data/route.yaml +162 -204
  27. package/hedhog/data/setting_group.yaml +14 -0
  28. package/hedhog/frontend/app/roles/page.tsx.ejs +4 -1
  29. package/hedhog/frontend/app/users/user-logs.tsx.ejs +190 -0
  30. package/hedhog/frontend/app/users/user-sheet.tsx.ejs +15 -1
  31. package/hedhog/frontend/messages/en.json +13 -0
  32. package/hedhog/frontend/messages/pt.json +13 -0
  33. package/hedhog/table/event_webhook.yaml +55 -55
  34. package/hedhog/table/event_webhook_delivery_log.yaml +66 -66
  35. package/hedhog/table/event_webhook_event.yaml +26 -26
  36. package/hedhog/table/integration_event_catalog.yaml +41 -41
  37. package/hedhog/table/mcp_conversation.yaml +12 -12
  38. package/hedhog/table/mcp_conversation_message.yaml +23 -23
  39. package/hedhog/table/mcp_tool_call_log.yaml +22 -22
  40. package/hedhog/table/route.yaml +33 -33
  41. package/hedhog/table/user_change_log.yaml +40 -0
  42. package/hedhog/table/webhook_call_log.yaml +46 -46
  43. package/hedhog/table/webhook_integration.yaml +43 -43
  44. package/package.json +5 -5
  45. package/src/file/file.service.ts +2 -1
  46. package/src/integration/types/event.types.ts +4 -4
  47. package/src/mcp/decorators/mcp-tool.decorator.ts +7 -7
  48. package/src/mcp/guards/mcp-permission.guard.ts +51 -51
  49. package/src/mcp/interfaces/mcp-tool-definition.interface.ts +6 -6
  50. package/src/mcp/mcp-server.service.ts +87 -87
  51. package/src/mcp/types/mcp-context.type.ts +6 -6
  52. package/src/mcp-chat/dto/create-conversation.dto.ts +7 -7
  53. package/src/mcp-chat/dto/send-message.dto.ts +7 -7
  54. package/src/notification/events/notification-stale-progress-check.event.ts +5 -0
  55. package/src/notification/notification.service.ts +12 -25
  56. package/src/route/dto/create.dto.ts +32 -32
  57. package/src/route/dto/update.dto.ts +31 -31
  58. package/src/task/task.service.ts +52 -0
  59. package/src/user/user.controller.ts +23 -9
  60. package/src/user/user.service.ts +183 -8
  61. package/src/webhook-integration/integration-event-catalog.controller.ts +50 -50
  62. package/src/webhook-integration/integration-event-catalog.service.ts +117 -117
@@ -1,12 +1,12 @@
1
- columns:
2
- - type: pk
3
- - name: user_id
4
- type: fk
5
- references:
6
- table: user
7
- column: id
8
- onDelete: CASCADE
9
- - name: title
10
- isNullable: true
11
- - type: created_at
12
- - type: updated_at
1
+ columns:
2
+ - type: pk
3
+ - name: user_id
4
+ type: fk
5
+ references:
6
+ table: user
7
+ column: id
8
+ onDelete: CASCADE
9
+ - name: title
10
+ isNullable: true
11
+ - type: created_at
12
+ - type: updated_at
@@ -1,23 +1,23 @@
1
- columns:
2
- - type: pk
3
- - name: conversation_id
4
- type: fk
5
- references:
6
- table: mcp_conversation
7
- column: id
8
- onDelete: CASCADE
9
- - name: role
10
- type: enum
11
- enum:
12
- - user
13
- - assistant
14
- - tool_call
15
- - tool_result
16
- - name: content
17
- type: text
18
- - name: tool_name
19
- isNullable: true
20
- - name: tool_call_id
21
- isNullable: true
22
- - type: created_at
23
- - type: updated_at
1
+ columns:
2
+ - type: pk
3
+ - name: conversation_id
4
+ type: fk
5
+ references:
6
+ table: mcp_conversation
7
+ column: id
8
+ onDelete: CASCADE
9
+ - name: role
10
+ type: enum
11
+ enum:
12
+ - user
13
+ - assistant
14
+ - tool_call
15
+ - tool_result
16
+ - name: content
17
+ type: text
18
+ - name: tool_name
19
+ isNullable: true
20
+ - name: tool_call_id
21
+ isNullable: true
22
+ - type: created_at
23
+ - type: updated_at
@@ -1,22 +1,22 @@
1
- columns:
2
- - type: pk
3
- - name: user_id
4
- type: fk
5
- references:
6
- table: user
7
- column: id
8
- onDelete: SET NULL
9
- isNullable: true
10
- - name: tool_name
11
- - name: input
12
- type: text
13
- isNullable: true
14
- - name: success
15
- type: boolean
16
- default: false
17
- - name: error
18
- isNullable: true
19
- - name: duration_ms
20
- type: int
21
- - type: created_at
22
- - type: updated_at
1
+ columns:
2
+ - type: pk
3
+ - name: user_id
4
+ type: fk
5
+ references:
6
+ table: user
7
+ column: id
8
+ onDelete: SET NULL
9
+ isNullable: true
10
+ - name: tool_name
11
+ - name: input
12
+ type: text
13
+ isNullable: true
14
+ - name: success
15
+ type: boolean
16
+ default: false
17
+ - name: error
18
+ isNullable: true
19
+ - name: duration_ms
20
+ type: int
21
+ - type: created_at
22
+ - type: updated_at
@@ -1,33 +1,33 @@
1
- columns:
2
- - type: pk
3
- - name: type
4
- type: enum
5
- enum:
6
- - HTTP
7
- - MCP
8
- default: HTTP
9
- - name: name
10
- isNullable: true
11
- - name: url
12
- isNullable: true
13
- - name: method
14
- type: enum
15
- enum:
16
- - GET
17
- - POST
18
- - PATCH
19
- - DELETE
20
- - PUT
21
- - OPTIONS
22
- - HEAD
23
- isNullable: true
24
- - name: tool_name
25
- isNullable: true
26
- - name: description
27
- isNullable: true
28
- - type: created_at
29
- - type: updated_at
30
- indices:
31
- - columns:
32
- - tool_name
33
- isUnique: true
1
+ columns:
2
+ - type: pk
3
+ - name: type
4
+ type: enum
5
+ enum:
6
+ - HTTP
7
+ - MCP
8
+ default: HTTP
9
+ - name: name
10
+ isNullable: true
11
+ - name: url
12
+ isNullable: true
13
+ - name: method
14
+ type: enum
15
+ enum:
16
+ - GET
17
+ - POST
18
+ - PATCH
19
+ - DELETE
20
+ - PUT
21
+ - OPTIONS
22
+ - HEAD
23
+ isNullable: true
24
+ - name: tool_name
25
+ isNullable: true
26
+ - name: description
27
+ isNullable: true
28
+ - type: created_at
29
+ - type: updated_at
30
+ indices:
31
+ - columns:
32
+ - tool_name
33
+ isUnique: true
@@ -0,0 +1,40 @@
1
+ columns:
2
+ - type: pk
3
+ - name: target_user_id
4
+ type: fk
5
+ references:
6
+ table: user
7
+ column: id
8
+ onDelete: CASCADE
9
+ onUpdate: CASCADE
10
+ - name: actor_user_id
11
+ type: fk
12
+ isNullable: true
13
+ references:
14
+ table: user
15
+ column: id
16
+ onDelete: SET NULL
17
+ onUpdate: CASCADE
18
+ - name: action
19
+ type: varchar
20
+ length: 80
21
+ - name: summary
22
+ type: text
23
+ isNullable: true
24
+ - name: before_data
25
+ type: text
26
+ isNullable: true
27
+ - name: after_data
28
+ type: text
29
+ isNullable: true
30
+ - name: ip_address
31
+ type: varchar
32
+ length: 64
33
+ isNullable: true
34
+ - type: created_at
35
+ - type: updated_at
36
+
37
+ indices:
38
+ - columns: [target_user_id]
39
+ - columns: [actor_user_id]
40
+ - columns: [action]
@@ -1,46 +1,46 @@
1
- columns:
2
- - type: pk
3
- - type: fk
4
- name: webhook_integration_id
5
- isNullable: true
6
- references:
7
- table: webhook_integration
8
- column: id
9
- onDelete: set null
10
- onUpdate: cascade
11
- - name: public_uuid
12
- type: varchar
13
- length: 36
14
- - name: status
15
- type: enum
16
- enum:
17
- - success
18
- - failed
19
- - name: remote_ip
20
- type: varchar
21
- length: 127
22
- isNullable: true
23
- - name: duration_ms
24
- type: int
25
- default: 0
26
- - name: error_message
27
- type: text
28
- isNullable: true
29
- - name: payload_summary
30
- type: json
31
- isNullable: true
32
- - name: response_summary
33
- type: json
34
- isNullable: true
35
- - type: created_at
36
- - type: updated_at
37
- indices:
38
- - columns:
39
- - webhook_integration_id
40
- - columns:
41
- - public_uuid
42
- - columns:
43
- - status
44
- - columns:
45
- - created_at
46
-
1
+ columns:
2
+ - type: pk
3
+ - type: fk
4
+ name: webhook_integration_id
5
+ isNullable: true
6
+ references:
7
+ table: webhook_integration
8
+ column: id
9
+ onDelete: set null
10
+ onUpdate: cascade
11
+ - name: public_uuid
12
+ type: varchar
13
+ length: 36
14
+ - name: status
15
+ type: enum
16
+ enum:
17
+ - success
18
+ - failed
19
+ - name: remote_ip
20
+ type: varchar
21
+ length: 127
22
+ isNullable: true
23
+ - name: duration_ms
24
+ type: int
25
+ default: 0
26
+ - name: error_message
27
+ type: text
28
+ isNullable: true
29
+ - name: payload_summary
30
+ type: json
31
+ isNullable: true
32
+ - name: response_summary
33
+ type: json
34
+ isNullable: true
35
+ - type: created_at
36
+ - type: updated_at
37
+ indices:
38
+ - columns:
39
+ - webhook_integration_id
40
+ - columns:
41
+ - public_uuid
42
+ - columns:
43
+ - status
44
+ - columns:
45
+ - created_at
46
+
@@ -1,43 +1,43 @@
1
- columns:
2
- - type: pk
3
- - type: slug
4
- - name: name
5
- type: varchar
6
- length: 127
7
- - name: description
8
- type: text
9
- isNullable: true
10
- - name: public_uuid
11
- type: varchar
12
- length: 36
13
- - name: status
14
- type: enum
15
- enum:
16
- - active
17
- - inactive
18
- default: active
19
- - name: require_token
20
- type: boolean
21
- default: false
22
- - name: token_hash
23
- type: varchar
24
- length: 128
25
- isNullable: true
26
- - name: allowed_ips
27
- type: json
28
- isNullable: true
29
- - name: body_schema
30
- type: json
31
- isNullable: true
32
- - type: created_at
33
- - type: updated_at
34
- indices:
35
- - columns:
36
- - slug
37
- isUnique: true
38
- - columns:
39
- - public_uuid
40
- isUnique: true
41
- - columns:
42
- - status
43
-
1
+ columns:
2
+ - type: pk
3
+ - type: slug
4
+ - name: name
5
+ type: varchar
6
+ length: 127
7
+ - name: description
8
+ type: text
9
+ isNullable: true
10
+ - name: public_uuid
11
+ type: varchar
12
+ length: 36
13
+ - name: status
14
+ type: enum
15
+ enum:
16
+ - active
17
+ - inactive
18
+ default: active
19
+ - name: require_token
20
+ type: boolean
21
+ default: false
22
+ - name: token_hash
23
+ type: varchar
24
+ length: 128
25
+ isNullable: true
26
+ - name: allowed_ips
27
+ type: json
28
+ isNullable: true
29
+ - name: body_schema
30
+ type: json
31
+ isNullable: true
32
+ - type: created_at
33
+ - type: updated_at
34
+ indices:
35
+ - columns:
36
+ - slug
37
+ isUnique: true
38
+ - columns:
39
+ - public_uuid
40
+ isUnique: true
41
+ - columns:
42
+ - status
43
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hed-hog/core",
3
- "version": "0.0.367",
3
+ "version": "0.0.370",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -38,12 +38,12 @@
38
38
  "speakeasy": "^2.0.0",
39
39
  "ua-parser-js": "^2.0.10",
40
40
  "uuid": "^11.1.0",
41
- "@hed-hog/api-locale": "0.0.14",
42
41
  "@hed-hog/api": "0.0.8",
43
- "@hed-hog/api-prisma": "0.0.6",
44
- "@hed-hog/api-mail": "0.0.9",
42
+ "@hed-hog/api-locale": "0.0.14",
45
43
  "@hed-hog/api-pagination": "0.0.7",
46
- "@hed-hog/api-types": "0.0.1"
44
+ "@hed-hog/api-prisma": "0.0.6",
45
+ "@hed-hog/api-types": "0.0.1",
46
+ "@hed-hog/api-mail": "0.0.9"
47
47
  },
48
48
  "exports": {
49
49
  ".": {
@@ -490,6 +490,7 @@ export class FileService implements OnModuleInit {
490
490
  mimetype?: string;
491
491
  size?: number;
492
492
  encoding?: string;
493
+ skipMimeValidation?: boolean;
493
494
  },
494
495
  ) {
495
496
  if (!filePath) {
@@ -511,7 +512,7 @@ export class FileService implements OnModuleInit {
511
512
  metadata?.originalname ?? metadata?.filename ?? basename(filePath),
512
513
  );
513
514
 
514
- if (!(await this.acceptMimetypes(mimetype))) {
515
+ if (!metadata?.skipMimeValidation && !(await this.acceptMimetypes(mimetype))) {
515
516
  throw new BadRequestException(`Invalid file type: ${mimetype}`);
516
517
  }
517
518
 
@@ -32,10 +32,10 @@ export enum LinkType {
32
32
  /**
33
33
  * Domain event interface that is published and processed
34
34
  */
35
- export interface DomainEvent {
36
- outboxEventId?: string;
37
- eventName: string;
38
- sourceModule: string;
35
+ export interface DomainEvent {
36
+ outboxEventId?: string;
37
+ eventName: string;
38
+ sourceModule: string;
39
39
  aggregateType: string;
40
40
  aggregateId: string;
41
41
  payload: Record<string, any>;
@@ -1,7 +1,7 @@
1
- import { SetMetadata } from '@nestjs/common';
2
- import { McpToolDefinition } from '../interfaces/mcp-tool-definition.interface';
3
-
4
- export const MCP_TOOL_METADATA = 'mcp:tool';
5
-
6
- export const McpTool = (definition: McpToolDefinition): MethodDecorator =>
7
- SetMetadata(MCP_TOOL_METADATA, definition);
1
+ import { SetMetadata } from '@nestjs/common';
2
+ import { McpToolDefinition } from '../interfaces/mcp-tool-definition.interface';
3
+
4
+ export const MCP_TOOL_METADATA = 'mcp:tool';
5
+
6
+ export const McpTool = (definition: McpToolDefinition): MethodDecorator =>
7
+ SetMetadata(MCP_TOOL_METADATA, definition);
@@ -1,51 +1,51 @@
1
- import { PrismaService } from '@hed-hog/api-prisma';
2
- import {
3
- CanActivate,
4
- ExecutionContext,
5
- ForbiddenException,
6
- Injectable,
7
- } from '@nestjs/common';
8
- import { Request } from 'express';
9
-
10
- @Injectable()
11
- export class McpPermissionGuard implements CanActivate {
12
- constructor(private readonly prisma: PrismaService) {}
13
-
14
- async canActivate(context: ExecutionContext): Promise<boolean> {
15
- const request = context.switchToHttp().getRequest<Request>();
16
-
17
- // Only POST requests carry tool invocations
18
- if (request.method !== 'POST') return true;
19
-
20
- const body = request.body as any;
21
- const toolName: string | undefined =
22
- body?.method === 'tools/call' ? body?.params?.name : undefined;
23
-
24
- // tools/list, initialize, ping, etc. — no per-tool permission check needed
25
- if (!toolName) return true;
26
-
27
- const userId = (request as any)?.auth?.sub;
28
-
29
- const count = await this.prisma.route.count({
30
- where: {
31
- type: 'MCP' as any,
32
- tool_name: toolName,
33
- role_route: {
34
- some: {
35
- role: {
36
- role_user: {
37
- some: { user_id: userId },
38
- },
39
- },
40
- },
41
- },
42
- },
43
- });
44
-
45
- if (count === 0) {
46
- throw new ForbiddenException(`Access denied to MCP tool '${toolName}'`);
47
- }
48
-
49
- return true;
50
- }
51
- }
1
+ import { PrismaService } from '@hed-hog/api-prisma';
2
+ import {
3
+ CanActivate,
4
+ ExecutionContext,
5
+ ForbiddenException,
6
+ Injectable,
7
+ } from '@nestjs/common';
8
+ import { Request } from 'express';
9
+
10
+ @Injectable()
11
+ export class McpPermissionGuard implements CanActivate {
12
+ constructor(private readonly prisma: PrismaService) {}
13
+
14
+ async canActivate(context: ExecutionContext): Promise<boolean> {
15
+ const request = context.switchToHttp().getRequest<Request>();
16
+
17
+ // Only POST requests carry tool invocations
18
+ if (request.method !== 'POST') return true;
19
+
20
+ const body = request.body as any;
21
+ const toolName: string | undefined =
22
+ body?.method === 'tools/call' ? body?.params?.name : undefined;
23
+
24
+ // tools/list, initialize, ping, etc. — no per-tool permission check needed
25
+ if (!toolName) return true;
26
+
27
+ const userId = (request as any)?.auth?.sub;
28
+
29
+ const count = await this.prisma.route.count({
30
+ where: {
31
+ type: 'MCP' as any,
32
+ tool_name: toolName,
33
+ role_route: {
34
+ some: {
35
+ role: {
36
+ role_user: {
37
+ some: { user_id: userId },
38
+ },
39
+ },
40
+ },
41
+ },
42
+ },
43
+ });
44
+
45
+ if (count === 0) {
46
+ throw new ForbiddenException(`Access denied to MCP tool '${toolName}'`);
47
+ }
48
+
49
+ return true;
50
+ }
51
+ }
@@ -1,6 +1,6 @@
1
- export interface McpToolDefinition {
2
- name: string;
3
- description: string;
4
- inputSchema?: Record<string, any>;
5
- readOnly?: boolean;
6
- }
1
+ export interface McpToolDefinition {
2
+ name: string;
3
+ description: string;
4
+ inputSchema?: Record<string, any>;
5
+ readOnly?: boolean;
6
+ }