Merge branch 'release/workflows-fixes' of github.com:ToolJet/ToolJet into release/workflows-fixes

This commit is contained in:
Akshay Sasidharan 2025-07-10 12:48:40 +05:30
commit ea8f020fa1
3 changed files with 28 additions and 3 deletions

View file

@ -52,6 +52,11 @@ export class AppsModule extends SubModule {
'services/page.util.service',
]);
const { AppsActionsListener, TemporalService } = await this.getProviders(configs, 'workflows', [
'listeners/app-actions.listener',
'services/temporal.service',
]);
return {
module: AppsModule,
imports: [
@ -74,6 +79,8 @@ export class AppsModule extends SubModule {
VersionRepository,
AppsRepository,
AppGitRepository,
AppsActionsListener,
TemporalService,
PageService,
EventsService,
AppsUtilService,

View file

@ -42,6 +42,7 @@ import { AUDIT_LOGS_REQUEST_CONTEXT_KEY } from '@modules/app/constants';
import { MODULES } from '@modules/app/constants/modules';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { AppGitRepository } from '@modules/app-git/repository';
import { WorkflowSchedule } from '@entities/workflow_schedule.entity';
@Injectable()
export class AppsService implements IAppsService {
@ -181,7 +182,24 @@ export class AppsService implements IAppsService {
const { organizationId } = user;
const { id } = app;
await this.appRepository.delete({ id, organizationId });
await dbTransactionWrap(async (manager: EntityManager) => {
const schedules = await manager
.createQueryBuilder(WorkflowSchedule, 'workflowSchedule')
.innerJoinAndSelect('workflowSchedule.workflow', 'appVersion')
.where('appVersion.appId = :appId', { appId: id })
.getMany();
// Emit event with schedule IDs for temporal schedule cleanup
if (schedules.length > 0) {
const scheduleIds = schedules.map((schedule) => schedule.id);
this.eventEmitter.emit('app.deleted', {
appId: id,
scheduleIds: scheduleIds,
});
}
await manager.delete(App, { id, organizationId });
});
//APP_DELETE audit
RequestContext.setLocals(AUDIT_LOGS_REQUEST_CONTEXT_KEY, {

View file

@ -4,8 +4,8 @@ import { OnEvent } from '@nestjs/event-emitter';
@Injectable()
export class AppsActionsListener {
constructor() {}
@OnEvent('beforeAppDelete')
@OnEvent('app.deleted')
async handleAppDeletion(args: { appId: string }) {
throw new Error('Method not implemented');
console.log(`App with ID ${args.appId} has been deleted.`);
}
}