Skip to content

The open alternative to Salesforce, designed for AI.

2.5 KB
Raw Blame
import { Field, Float, InputType } from '@nestjs/graphql';

import {
  IsBoolean,
  IsEnum,
  IsNotEmpty,
  IsNumber,
  IsObject,
  IsOptional,
  IsString,
  IsUUID,
} from 'class-validator';
import GraphQLJSON from 'graphql-type-json';

import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
import { type PathCommandMenuItemPayload } from 'src/engine/metadata-modules/command-menu-item/dtos/types/path-command-menu-item-payload.type';
import { CommandMenuItemAvailabilityType } from 'twenty-shared/types';
import { EngineComponentKey } from 'src/engine/metadata-modules/command-menu-item/enums/engine-component-key.enum';

@InputType()
export class CreateCommandMenuItemInput {
  @IsUUID()
  @IsOptional()
  @Field(() => UUIDScalarType, { nullable: true })
  workflowVersionId?: string;

  @IsUUID()
  @IsOptional()
  @Field(() => UUIDScalarType, { nullable: true })
  coreWorkflowVersionId?: string;

  @IsUUID()
  @IsOptional()
  @Field(() => UUIDScalarType, { nullable: true })
  frontComponentId?: string;

  @IsEnum(EngineComponentKey)
  @IsNotEmpty()
  @Field(() => EngineComponentKey)
  engineComponentKey: EngineComponentKey;

  @IsString()
  @IsNotEmpty()
  @Field()
  label: string;

  @IsString()
  @IsOptional()
  @Field({ nullable: true })
  icon?: string;

  @IsString()
  @IsOptional()
  @Field({ nullable: true })
  shortLabel?: string;

  @IsNumber()
  @IsOptional()
  @Field(() => Float, { nullable: true })
  position?: number;

  @IsBoolean()
  @IsOptional()
  @Field({ nullable: true })
  isPinned?: boolean;

  @IsEnum(CommandMenuItemAvailabilityType)
  @IsOptional()
  @Field(() => CommandMenuItemAvailabilityType, { nullable: true })
  availabilityType?: CommandMenuItemAvailabilityType;

  @IsString({ each: true })
  @IsOptional()
  @Field(() => [String], { nullable: true })
  hotKeys?: string[];

  @IsString()
  @IsOptional()
  @Field({ nullable: true })
  conditionalAvailabilityExpression?: string;

  @IsString()
  @IsOptional()
  @Field({ nullable: true })
  conditionalPinnedExpression?: string;

  @IsUUID()
  @IsOptional()
  @Field(() => UUIDScalarType, { nullable: true })
  availabilityObjectMetadataId?: string;

  @IsObject()
  @IsOptional()
  @Field(() => GraphQLJSON, { nullable: true })
  payload?: PathCommandMenuItemPayload;

  @IsUUID()
  @IsOptional()
  @Field(() => UUIDScalarType, { nullable: true })
  navigationTargetObjectMetadataId?: string;

  @IsUUID()
  @IsOptional()
  @Field(() => UUIDScalarType, { nullable: true })
  pageLayoutId?: string;
}