Add custom routes to migration v2 (#14846)

## Context
Add routes to migration V2
- Resolvers
- Service v2
- Builder
- Validator
- Action runner

Next PR: Add to twenty-cli to sync routes with serverless
This commit is contained in:
Weiko
2025-10-03 00:20:21 +02:00
committed by GitHub
parent dcfae3821c
commit 0b60aa4249
80 changed files with 2242 additions and 151 deletions
@@ -1,19 +1,32 @@
import { Field, InputType } from '@nestjs/graphql';
import { IsNotEmpty, IsObject, IsUUID } from 'class-validator';
import { Type } from 'class-transformer';
import { IsNotEmpty, IsObject, IsUUID, ValidateNested } from 'class-validator';
import GraphQLJSON from 'graphql-type-json';
import { CronTriggerSettings } from 'src/engine/metadata-modules/cron-trigger/entities/cron-trigger.entity';
@InputType()
export class UpdateCronTriggerInput {
@IsUUID()
@IsNotEmpty()
@Field(() => String)
id: string;
class UpdateCronTriggerInputUpdates {
@IsObject()
@IsNotEmpty()
@Field(() => GraphQLJSON)
settings: CronTriggerSettings;
}
@InputType()
export class UpdateCronTriggerInput {
@IsUUID()
@IsNotEmpty()
@Field(() => String, {
description: 'The id of the cron trigger to update',
})
id: string;
@Type(() => UpdateCronTriggerInputUpdates)
@ValidateNested()
@Field(() => UpdateCronTriggerInputUpdates, {
description: 'The cron trigger updates',
})
update: UpdateCronTriggerInputUpdates;
}
@@ -40,8 +40,8 @@ export class CronTrigger extends SyncableEntity {
@JoinColumn({ name: 'serverlessFunctionId' })
serverlessFunction: Relation<ServerlessFunctionEntity>;
@Column({ nullable: true, type: 'uuid' })
serverlessFunctionId: string | null;
@Column({ nullable: false, type: 'uuid' })
serverlessFunctionId: string;
@Column({ nullable: false, type: 'uuid' })
workspaceId: string;
@@ -9,4 +9,5 @@ export class CronTriggerException extends CustomException {
export enum CronTriggerExceptionCode {
CRON_TRIGGER_NOT_FOUND = 'CRON_TRIGGER_NOT_FOUND',
CRON_TRIGGER_ALREADY_EXIST = 'CRON_TRIGGER_ALREADY_EXIST',
SERVERLESS_FUNCTION_NOT_FOUND = 'SERVERLESS_FUNCTION_NOT_FOUND',
}
@@ -36,7 +36,7 @@ export class CronTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatCronTriggerMaps'],
flatEntities: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -64,6 +64,10 @@ export class CronTriggerV2Service {
to: toFlatCronTriggerMaps,
},
},
dependencyAllFlatEntityMaps: {
flatServerlessFunctionMaps:
flatEntityMaps.flatServerlessFunctionMaps,
},
buildOptions: {
isSystemBuild: false,
inferDeletionFromMissingEntities: false,
@@ -82,7 +86,7 @@ export class CronTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatCronTriggerMaps'],
flatEntities: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -100,7 +104,7 @@ export class CronTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatCronTriggerMaps'],
flatEntities: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -131,6 +135,10 @@ export class CronTriggerV2Service {
to: toFlatCronTriggerMaps,
},
},
dependencyAllFlatEntityMaps: {
flatServerlessFunctionMaps:
flatEntityMaps.flatServerlessFunctionMaps,
},
buildOptions: {
isSystemBuild: false,
inferDeletionFromMissingEntities: false,
@@ -166,11 +174,14 @@ export class CronTriggerV2Service {
destroyCronTriggerInput: CronTriggerIdInput;
workspaceId: string;
}): Promise<FlatCronTrigger> {
const { flatCronTriggerMaps: existingFlatCronTriggerMaps } =
const {
flatCronTriggerMaps: existingFlatCronTriggerMaps,
flatServerlessFunctionMaps: existingFlatServerlessFunctionMaps,
} =
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatCronTriggerMaps'],
flatEntities: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -202,6 +213,9 @@ export class CronTriggerV2Service {
to: toFlatCronTriggerMaps,
},
},
dependencyAllFlatEntityMaps: {
flatServerlessFunctionMaps: existingFlatServerlessFunctionMaps,
},
buildOptions: {
isSystemBuild: false,
inferDeletionFromMissingEntities: true,
@@ -25,7 +25,7 @@ export const fromUpdateCronTriggerInputToFlatCronTriggerToUpdateOrThrow = ({
return {
...existingFlatCronTrigger,
settings: updateCronTriggerInput.settings,
settings: updateCronTriggerInput.update.settings,
updatedAt: new Date(),
};
};