6654 serverless functions add a deploy button disable deploy when autosave (#6715)

- improvements on serverless function behavior (autosave performances,
deploy on execution only)
- add versioning to serverless functions
- add a publish endpoint to create a new version of a serverless
function
  - add deploy and reset to lastVersion button in the settings section:
<img width="736" alt="image"
src="https://github.com/user-attachments/assets/2001f8d2-07a4-4f79-84dd-ec74b6f301d3">
This commit is contained in:
martmull
2024-08-23 12:06:03 +02:00
committed by GitHub
parent 7ca091faa5
commit 6f9aa1e870
42 changed files with 850 additions and 269 deletions

View File

@ -1,11 +1,11 @@
import { ArgsType, Field } from '@nestjs/graphql';
import { ArgsType, Field, InputType } from '@nestjs/graphql';
import { IsNotEmpty, IsObject, IsOptional, IsUUID } from 'class-validator';
import graphqlTypeJson from 'graphql-type-json';
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
@ArgsType()
@InputType()
export class ExecuteServerlessFunctionInput {
@Field(() => UUIDScalarType, {
description: 'Id of the serverless function to execute',
@ -21,4 +21,11 @@ export class ExecuteServerlessFunctionInput {
@IsObject()
@IsOptional()
payload?: JSON;
@Field(() => String, {
nullable: false,
description: 'Version of the serverless function to execute',
defaultValue: 'latest',
})
version: string;
}

View File

@ -0,0 +1,16 @@
import { Field, ID, InputType } from '@nestjs/graphql';
import { IDField } from '@ptc-org/nestjs-query-graphql';
@InputType()
export class GetServerlessFunctionSourceCodeInput {
@IDField(() => ID, { description: 'The id of the function.' })
id!: string;
@Field(() => String, {
nullable: false,
description: 'The version of the function',
defaultValue: 'draft',
})
version: string;
}

View File

@ -0,0 +1,9 @@
import { ID, InputType } from '@nestjs/graphql';
import { IDField } from '@ptc-org/nestjs-query-graphql';
@InputType()
export class PublishServerlessFunctionInput {
@IDField(() => ID, { description: 'The id of the function.' })
id!: string;
}

View File

@ -14,6 +14,7 @@ import {
IsDateString,
IsEnum,
IsNotEmpty,
IsNumber,
IsString,
IsUUID,
} from 'class-validator';
@ -59,12 +60,11 @@ export class ServerlessFunctionDTO {
@IsString()
@IsNotEmpty()
@Field()
sourceCodeFullPath: string;
runtime: string;
@IsString()
@IsNotEmpty()
@Field()
runtime: string;
@Field({ nullable: true })
latestVersion: string;
@IsEnum(ServerlessFunctionSyncStatus)
@IsNotEmpty()