import { Field, InputType } from '@nestjs/graphql'; import { Type } from 'class-transformer'; import { IsNotEmpty, IsNumber, IsObject, IsOptional, IsString, IsUUID, Matches, Max, Min, ValidateNested, } from 'class-validator'; import graphqlTypeJson from 'graphql-type-json'; import { CronTriggerSettings, DatabaseEventTriggerSettings, HttpRouteTriggerSettings, ToolTriggerSettings, WorkflowActionTriggerSettings, } from 'twenty-shared/application'; import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars'; import { HANDLER_NAME_REGEX } from 'src/engine/metadata-modules/logic-function/constants/handler.contant'; import type { JsonbProperty } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/types/jsonb-property.type'; @InputType() class UpdateLogicFunctionFromSourceInputUpdates { @IsString() @Field({ nullable: true }) @IsOptional() name?: string; @IsString() @Field({ nullable: true }) @IsOptional() description?: string; @IsNumber() @Field({ nullable: true }) @Min(1) @Max(900) @IsOptional() timeoutSeconds?: number; @IsString() @Field({ nullable: true }) @IsOptional() sourceHandlerCode?: string; @IsString() @Matches(HANDLER_NAME_REGEX, { message: 'handlerName must be a valid JavaScript identifier or dotted path', }) @Field({ nullable: true }) @IsOptional() handlerName?: string; @IsString() @Field({ nullable: true }) @IsOptional() sourceHandlerPath?: string; @IsObject() @Field(() => graphqlTypeJson, { nullable: true }) @IsOptional() cronTriggerSettings?: JsonbProperty; @IsObject() @Field(() => graphqlTypeJson, { nullable: true }) @IsOptional() databaseEventTriggerSettings?: JsonbProperty; @IsObject() @Field(() => graphqlTypeJson, { nullable: true }) @IsOptional() httpRouteTriggerSettings?: JsonbProperty; @IsObject() @Field(() => graphqlTypeJson, { nullable: true }) @IsOptional() toolTriggerSettings?: JsonbProperty; @IsObject() @Field(() => graphqlTypeJson, { nullable: true }) @IsOptional() workflowActionTriggerSettings?: JsonbProperty; } @InputType() export class UpdateLogicFunctionFromSourceInput { @Field(() => UUIDScalarType, { description: 'Id of the logic function to update', }) @IsNotEmpty() @IsUUID() id: string; @Type(() => UpdateLogicFunctionFromSourceInputUpdates) @ValidateNested() @Field(() => UpdateLogicFunctionFromSourceInputUpdates, { description: 'The logic function updates', }) update: UpdateLogicFunctionFromSourceInputUpdates; }