Skip to content

Commit

Permalink
Update endpoint + listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
thomtrp committed Aug 1, 2024
1 parent 47db158 commit 8cdc8fe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { Field, InputType } from '@nestjs/graphql';
import graphqlTypeJson from 'graphql-type-json';

@InputType()
export class WorkflowInput {
export class RunWorkflowVersionInput {
@Field(() => String, {
description: 'Workflow version ID',
nullable: false,
})
workflowVersionId: string;

@Field(() => graphqlTypeJson, {
description: 'Execution result in JSON format',
nullable: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UseGuards } from '@nestjs/common';
import { Args, Mutation, Resolver } from '@nestjs/graphql';

import { WorkflowInput } from 'src/engine/core-modules/workflow/dtos/workflow-input.dto';
import { RunWorkflowVersionInput } from 'src/engine/core-modules/workflow/dtos/run-workflow-version-input.dto';
import { WorkflowTriggerResultDTO } from 'src/engine/core-modules/workflow/dtos/workflow-trigger-result.dto';
import { workflowTriggerGraphqlApiExceptionHandler } from 'src/engine/core-modules/workflow/utils/workflow-trigger-graphql-api-exception-handler.util';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
Expand Down Expand Up @@ -32,14 +32,13 @@ export class WorkflowTriggerResolver {
}

@Mutation(() => WorkflowTriggerResultDTO)
async triggerWorkflow(
async runWorkflowVersion(
@AuthWorkspace() { id: workspaceId }: Workspace,
@Args('workflowVersionId') workflowVersionId: string,
@Args('input') { payload }: WorkflowInput,
@Args('input') { workflowVersionId, payload }: RunWorkflowVersionInput,
) {
try {
return {
result: await this.workflowTriggerService.runWorkflow(
result: await this.workflowTriggerService.runWorkflowVersion(
workspaceId,
workflowVersionId,
payload ?? {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { OnEvent } from '@nestjs/event-emitter';
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
import { IsFeatureEnabledService } from 'src/engine/core-modules/feature-flag/services/is-feature-enabled.service';
import { ObjectRecordCreateEvent } from 'src/engine/integrations/event-emitter/types/object-record-create.event';
import { ObjectRecordDeleteEvent } from 'src/engine/integrations/event-emitter/types/object-record-delete.event';
import { ObjectRecordUpdateEvent } from 'src/engine/integrations/event-emitter/types/object-record-update.event';
import { InjectMessageQueue } from 'src/engine/integrations/message-queue/decorators/message-queue.decorator';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
Expand All @@ -25,8 +27,13 @@ export class DatabaseEventTriggerListener {
private readonly isFeatureFlagEnabledService: IsFeatureEnabledService,
) {}

@OnEvent('**')
async handleEvent(payload: ObjectRecordCreateEvent<any>) {
@OnEvent(['*.created', '*.updated', '*.deleted'])
async handleEvent(
payload:
| ObjectRecordCreateEvent<any>
| ObjectRecordUpdateEvent<any>
| ObjectRecordDeleteEvent<any>,
) {
const workspaceId = payload.workspaceId;
const eventName = payload.name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class WorkflowTriggerService {
private readonly workflowRunnerService: WorkflowRunnerService,
) {}

async runWorkflow(
async runWorkflowVersion(
workspaceId: string,
workflowVersionId: string,
payload: object,
Expand Down

0 comments on commit 8cdc8fe

Please sign in to comment.