diff --git a/package-lock.json b/package-lock.json index 398411ef5f..290cc9a086 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35132,9 +35132,9 @@ } }, "packages/web-main/node_modules/@tanstack/react-router": { - "version": "1.34.5", - "resolved": "https://registry.npmjs.org/@tanstack/react-router/-/react-router-1.34.5.tgz", - "integrity": "sha512-mOMbNHSJ1cAgRuJj9W35wteQL7zFiCNJYgg3QHkxj+obO9zQWiAwycFs0hQTRxqzGfC+jhVLJe1+cW93BhqKyA==", + "version": "1.36.3", + "resolved": "https://registry.npmjs.org/@tanstack/react-router/-/react-router-1.36.3.tgz", + "integrity": "sha512-587W8jYCUtK9HsPSkmSbxm9VHH+ullmAT/ttOIbMjqhKLg9Sb30Gg6NxzGlzxRSF0t6QSy28wt+4ChPREVizFA==", "dependencies": { "@tanstack/history": "1.31.16", "@tanstack/react-store": "^0.2.1", @@ -35154,9 +35154,9 @@ } }, "packages/web-main/node_modules/@tanstack/router-devtools": { - "version": "1.34.5", - "resolved": "https://registry.npmjs.org/@tanstack/router-devtools/-/router-devtools-1.34.5.tgz", - "integrity": "sha512-ps0SC14ijFkYkmvqRDlIo7M182Kinvs9syNbQJ5NZT3HjC4yNSZpKWIFkEEDL9IhQvIXQbk0FROz/c7Us7VpsA==", + "version": "1.36.3", + "resolved": "https://registry.npmjs.org/@tanstack/router-devtools/-/router-devtools-1.36.3.tgz", + "integrity": "sha512-GfYDsubnyv18R2ni03oojczr1jfwTYo2TXi5yNLAGVRYHaLFPeTplobM8MZbTzTb0E+CKtlrmkoOx8AODmurvQ==", "dependencies": { "clsx": "^2.1.0", "date-fns": "^2.29.1", @@ -35170,7 +35170,7 @@ "url": "https://github.com/sponsors/tannerlinsley" }, "peerDependencies": { - "@tanstack/react-router": "^1.34.5", + "@tanstack/react-router": "^1.36.3", "react": ">=16.8", "react-dom": ">=16.8" } diff --git a/packages/app-api/src/executors/executeFunction.ts b/packages/app-api/src/executors/executeFunction.ts index 1e26eeffcb..8f4d2b20e0 100644 --- a/packages/app-api/src/executors/executeFunction.ts +++ b/packages/app-api/src/executors/executeFunction.ts @@ -16,7 +16,13 @@ import { TakaroEventFunctionLog, TakaroEventFunctionResult, BaseEvent, + TakaroEventHookExecuted, + TakaroEventCronjobExecuted, + TakaroEventHookDetails, + TakaroEventCronjobDetails, } from '@takaro/modules'; +import { HookService } from '../service/HookService.js'; +import { CronJobService } from '../service/CronJobService.js'; let rateLimiter: RateLimiterRedis | null = null; @@ -82,7 +88,7 @@ export async function executeFunction( const dataForEvent = { ...data }; delete dataForEvent.token; delete dataForEvent.url; - const meta: Partial = { + const meta: Partial = { data: dataForEvent, }; @@ -99,7 +105,7 @@ export async function executeFunction( eventData.eventName = EVENT_TYPES.COMMAND_EXECUTED; - meta.command = new TakaroEventCommandDetails({ + (meta as TakaroEventCommandExecuted).command = new TakaroEventCommandDetails({ id: command.id, name: command.name, arguments: data.arguments, @@ -127,10 +133,26 @@ export async function executeFunction( if (isHookData(data)) { eventData.eventName = EVENT_TYPES.HOOK_EXECUTED; + const hookService = new HookService(domainId); + const hook = await hookService.findOne(data.itemId); + if (!hook) throw new errors.InternalServerError(); + + (meta as TakaroEventHookExecuted).hook = new TakaroEventHookDetails({ + id: hook.id, + name: hook.name, + }); } if (isCronData(data)) { eventData.eventName = EVENT_TYPES.CRONJOB_EXECUTED; + const cronService = new CronJobService(domainId); + const cron = await cronService.findOne(data.itemId); + if (!cron) throw new errors.InternalServerError(); + + (meta as TakaroEventCronjobExecuted).cronjob = new TakaroEventCronjobDetails({ + id: cron.id, + name: cron.name, + }); } try { diff --git a/packages/lib-modules/src/dto/takaroEvents.ts b/packages/lib-modules/src/dto/takaroEvents.ts index 4f5c27f2d9..335e1d2e41 100644 --- a/packages/lib-modules/src/dto/takaroEvents.ts +++ b/packages/lib-modules/src/dto/takaroEvents.ts @@ -116,6 +116,20 @@ export class TakaroEventCommandDetails extends TakaroDTO; } +export class TakaroEventHookDetails extends TakaroDTO { + @IsString() + id: string; + @IsString() + name: string; +} + +export class TakaroEventCronjobDetails extends TakaroDTO { + @IsString() + id: string; + @IsString() + name: string; +} + export class TakaroEventCommandExecuted extends BaseEvent { @IsString() type = TakaroEvents.COMMAND_EXECUTED; @@ -143,6 +157,11 @@ export class TakaroEventHookExecuted extends BaseEvent @ValidateNested({ each: true }) @Type(() => TakaroEventFunctionResult) result: TakaroEventFunctionResult; + + @IsOptional() + @ValidateNested() + @Type(() => TakaroEventHookDetails) + hook: TakaroEventHookDetails; } export class TakaroEventCronjobExecuted extends BaseEvent { @@ -155,6 +174,11 @@ export class TakaroEventCronjobExecuted extends BaseEvent TakaroEventFunctionResult) result: TakaroEventFunctionResult; + + @IsOptional() + @ValidateNested() + @Type(() => TakaroEventCronjobDetails) + cronjob: TakaroEventCronjobDetails; } export class TakaroEventRoleMeta extends TakaroDTO { diff --git a/packages/web-main/src/components/events/EventFeed/EventItem.tsx b/packages/web-main/src/components/events/EventFeed/EventItem.tsx index 53fb587721..0c0e1ec64b 100644 --- a/packages/web-main/src/components/events/EventFeed/EventItem.tsx +++ b/packages/web-main/src/components/events/EventFeed/EventItem.tsx @@ -108,11 +108,20 @@ export const EventItem: FC = ({ event }) => { ); break; case EventOutputDTOEventNameEnum.HookExecuted: + properties = ( + <> + + + + + ); + break; case EventOutputDTOEventNameEnum.CronjobExecuted: properties = ( <> + ); break;