The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
6654 serverless functions add a deploy button disable deploy when autosave (#6715)
martmull6f9aa1e870b1
diff --git a/packages/twenty-front/src/generated-metadata/gql.ts b/packages/twenty-front/src/generated-metadata/gql.tsindex 1aca61a965d..4c43b04b58b 100644--- a/packages/twenty-front/src/generated-metadata/gql.ts+++ b/packages/twenty-front/src/generated-metadata/gql.ts@@ -33,13 +33,15 @@ const documents = {"\n mutation DeleteOneFieldMetadataItem($idToDelete: UUID!) {\n deleteOneField(input: { id: $idToDelete }) {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n": types.DeleteOneFieldMetadataItemDocument,"\n mutation DeleteOneRelationMetadataItem($idToDelete: UUID!) {\n deleteOneRelation(input: { id: $idToDelete }) {\n id\n }\n }\n": types.DeleteOneRelationMetadataItemDocument,"\n query ObjectMetadataItems(\n $objectFilter: objectFilter\n $fieldFilter: fieldFilter\n ) {\n objects(paging: { first: 1000 }, filter: $objectFilter) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isRemote\n isActive\n isSystem\n createdAt\n updatedAt\n labelIdentifierFieldMetadataId\n imageIdentifierFieldMetadataId\n fields(paging: { first: 1000 }, filter: $fieldFilter) {\n edges {\n node {\n id\n type\n name\n label\n description\n icon\n isCustom\n isActive\n isSystem\n isNullable\n createdAt\n updatedAt\n fromRelationMetadata {\n id\n relationType\n toObjectMetadata {\n id\n dataSourceId\n nameSingular\n namePlural\n isSystem\n isRemote\n }\n toFieldMetadataId\n }\n toRelationMetadata {\n id\n relationType\n fromObjectMetadata {\n id\n dataSourceId\n nameSingular\n namePlural\n isSystem\n isRemote\n }\n fromFieldMetadataId\n }\n defaultValue\n options\n relationDefinition {\n relationId\n direction\n sourceObjectMetadata {\n id\n nameSingular\n namePlural\n }\n sourceFieldMetadata {\n id\n name\n }\n targetObjectMetadata {\n id\n nameSingular\n namePlural\n }\n targetFieldMetadata {\n id\n name\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n }\n }\n": types.ObjectMetadataItemsDocument,- "\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n sourceCodeHash\n sourceCodeFullPath\n runtime\n syncStatus\n createdAt\n updatedAt\n }\n": types.ServerlessFunctionFieldsFragmentDoc,+ "\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n sourceCodeHash\n runtime\n syncStatus\n latestVersion\n createdAt\n updatedAt\n }\n": types.ServerlessFunctionFieldsFragmentDoc,"\n \n mutation CreateOneServerlessFunctionItem(\n $input: CreateServerlessFunctionInput!\n ) {\n createOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.CreateOneServerlessFunctionItemDocument,"\n \n mutation DeleteOneServerlessFunction($input: DeleteServerlessFunctionInput!) {\n deleteOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.DeleteOneServerlessFunctionDocument,- "\n mutation ExecuteOneServerlessFunction($id: UUID!, $payload: JSON!) {\n executeOneServerlessFunction(id: $id, payload: $payload) {\n data\n duration\n status\n error\n }\n }\n": types.ExecuteOneServerlessFunctionDocument,+ "\n mutation ExecuteOneServerlessFunction(\n $input: ExecuteServerlessFunctionInput!\n ) {\n executeOneServerlessFunction(input: $input) {\n data\n duration\n status\n error\n }\n }\n": types.ExecuteOneServerlessFunctionDocument,+ "\n \n mutation PublishOneServerlessFunction(\n $input: PublishServerlessFunctionInput!\n ) {\n publishServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.PublishOneServerlessFunctionDocument,"\n \n mutation UpdateOneServerlessFunction($input: UpdateServerlessFunctionInput!) {\n updateOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n": types.UpdateOneServerlessFunctionDocument,"\n \n query GetManyServerlessFunctions {\n serverlessFunctions(paging: { first: 100 }) {\n edges {\n node {\n ...ServerlessFunctionFields\n }\n }\n }\n }\n": types.GetManyServerlessFunctionsDocument,"\n \n query GetOneServerlessFunction($id: UUID!) {\n serverlessFunction(id: $id) {\n ...ServerlessFunctionFields\n }\n }\n": types.GetOneServerlessFunctionDocument,+ "\n query FindOneServerlessFunctionSourceCode(\n $input: GetServerlessFunctionSourceCodeInput!\n ) {\n getServerlessFunctionSourceCode(input: $input)\n }\n": types.FindOneServerlessFunctionSourceCodeDocument,};/**@@ -139,7 +141,7 @@ export function graphql(source: "\n query ObjectMetadataItems(\n $objectFilt/*** The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.*/-export function graphql(source: "\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n sourceCodeHash\n sourceCodeFullPath\n runtime\n syncStatus\n createdAt\n updatedAt\n }\n"): (typeof documents)["\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n sourceCodeHash\n sourceCodeFullPath\n runtime\n syncStatus\n createdAt\n updatedAt\n }\n"];+export function graphql(source: "\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n sourceCodeHash\n runtime\n syncStatus\n latestVersion\n createdAt\n updatedAt\n }\n"): (typeof documents)["\n fragment ServerlessFunctionFields on ServerlessFunction {\n id\n name\n description\n sourceCodeHash\n runtime\n syncStatus\n latestVersion\n createdAt\n updatedAt\n }\n"];/*** The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.*/@@ -151,7 +153,11 @@ export function graphql(source: "\n \n mutation DeleteOneServerlessFunction($i/*** The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.*/-export function graphql(source: "\n mutation ExecuteOneServerlessFunction($id: UUID!, $payload: JSON!) {\n executeOneServerlessFunction(id: $id, payload: $payload) {\n data\n duration\n status\n error\n }\n }\n"): (typeof documents)["\n mutation ExecuteOneServerlessFunction($id: UUID!, $payload: JSON!) {\n executeOneServerlessFunction(id: $id, payload: $payload) {\n data\n duration\n status\n error\n }\n }\n"];+export function graphql(source: "\n mutation ExecuteOneServerlessFunction(\n $input: ExecuteServerlessFunctionInput!\n ) {\n executeOneServerlessFunction(input: $input) {\n data\n duration\n status\n error\n }\n }\n"): (typeof documents)["\n mutation ExecuteOneServerlessFunction(\n $input: ExecuteServerlessFunctionInput!\n ) {\n executeOneServerlessFunction(input: $input) {\n data\n duration\n status\n error\n }\n }\n"];+/**+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.+ */+export function graphql(source: "\n \n mutation PublishOneServerlessFunction(\n $input: PublishServerlessFunctionInput!\n ) {\n publishServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n mutation PublishOneServerlessFunction(\n $input: PublishServerlessFunctionInput!\n ) {\n publishServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"];/*** The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.*/@@ -164,6 +170,10 @@ export function graphql(source: "\n \n query GetManyServerlessFunctions {\n* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.*/export function graphql(source: "\n \n query GetOneServerlessFunction($id: UUID!) {\n serverlessFunction(id: $id) {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n query GetOneServerlessFunction($id: UUID!) {\n serverlessFunction(id: $id) {\n ...ServerlessFunctionFields\n }\n }\n"];+/**+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.+ */+export function graphql(source: "\n query FindOneServerlessFunctionSourceCode(\n $input: GetServerlessFunctionSourceCodeInput!\n ) {\n getServerlessFunctionSourceCode(input: $input)\n }\n"): (typeof documents)["\n query FindOneServerlessFunctionSourceCode(\n $input: GetServerlessFunctionSourceCodeInput!\n ) {\n getServerlessFunctionSourceCode(input: $input)\n }\n"];export function graphql(source: string) {return (documents as any)[source] ?? {};diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.tsindex ca9941fc60c..7ee649b5c5c 100644--- a/packages/twenty-front/src/generated-metadata/graphql.ts+++ b/packages/twenty-front/src/generated-metadata/graphql.ts@@ -310,6 +310,15 @@ export type ExchangeAuthCode = {refreshToken: AuthToken;};+export type ExecuteServerlessFunctionInput = {+ /** Id of the serverless function to execute */+ id: Scalars['UUID']['input'];+ /** Payload in JSON format */+ payload?: InputMaybe<Scalars['JSON']['input']>;+ /** Version of the serverless function to execute */+ version?: Scalars['String']['input'];+};+export type FeatureFlag = {__typename?: 'FeatureFlag';id: Scalars['UUID']['output'];@@ -389,6 +398,13 @@ export type FullName = {lastName: Scalars['String']['output'];};+export type GetServerlessFunctionSourceCodeInput = {+ /** The id of the function. */+ id: Scalars['ID']['input'];+ /** The version of the function */+ version?: Scalars['String']['input'];+};+export type InvalidatePassword = {__typename?: 'InvalidatePassword';/** Boolean that confirms query was dispatched */@@ -451,8 +467,9 @@ export type Mutation = {generateJWT: AuthTokens;generateTransientToken: TransientToken;impersonate: Verify;+ publishServerlessFunction: ServerlessFunction;renewToken: AuthTokens;- runWorkflowVersion: WorkflowTriggerResult;+ runWorkflowVersion: WorkflowRun;sendInviteLink: SendInviteLink;signUp: LoginToken;skipSyncEmailOnboardingStep: OnboardingStepSuccess;@@ -584,8 +601,7 @@ export type MutationExchangeAuthorizationCodeArgs = {export type MutationExecuteOneServerlessFunctionArgs = {- id: Scalars['UUID']['input'];- payload?: InputMaybe<Scalars['JSON']['input']>;+ input: ExecuteServerlessFunctionInput;};@@ -605,6 +621,11 @@ export type MutationImpersonateArgs = {};+export type MutationPublishServerlessFunctionArgs = {+ input: PublishServerlessFunctionInput;+};++export type MutationRenewTokenArgs = {appToken: Scalars['String']['input'];};@@ -772,6 +793,11 @@ export type ProductPricesEntity = {totalNumberOfPrices: Scalars['Int']['output'];};+export type PublishServerlessFunctionInput = {+ /** The id of the function. */+ id: Scalars['ID']['input'];+};+export type Query = {__typename?: 'Query';billingPortalSession: SessionEntity;@@ -789,6 +815,7 @@ export type Query = {getAISQLQuery: AisqlQueryResult;getPostgresCredentials?: Maybe<PostgresCredentials>;getProductPrices: ProductPricesEntity;+ getServerlessFunctionSourceCode: Scalars['String']['output'];getTimelineCalendarEventsFromCompanyId: TimelineCalendarEventsWithTotal;getTimelineCalendarEventsFromPersonId: TimelineCalendarEventsWithTotal;getTimelineThreadsFromCompanyId: TimelineThreadsWithTotal;@@ -860,6 +887,11 @@ export type QueryGetProductPricesArgs = {};+export type QueryGetServerlessFunctionSourceCodeArgs = {+ input: GetServerlessFunctionSourceCodeInput;+};++export type QueryGetTimelineCalendarEventsFromCompanyIdArgs = {companyId: Scalars['UUID']['input'];page: Scalars['Int']['input'];@@ -1026,9 +1058,9 @@ export type ServerlessFunction = {createdAt: Scalars['DateTime']['output'];description?: Maybe<Scalars['String']['output']>;id: Scalars['UUID']['output'];+ latestVersion?: Maybe<Scalars['String']['output']>;name: Scalars['String']['output'];runtime: Scalars['String']['output'];- sourceCodeFullPath: Scalars['String']['output'];sourceCodeHash: Scalars['String']['output'];syncStatus: ServerlessFunctionSyncStatus;updatedAt: Scalars['DateTime']['output'];@@ -1367,10 +1399,9 @@ export type Verify = {user: User;};-export type WorkflowTriggerResult = {- __typename?: 'WorkflowTriggerResult';- /** Execution result in JSON format */- result?: Maybe<Scalars['JSON']['output']>;+export type WorkflowRun = {+ __typename?: 'WorkflowRun';+ workflowRunId: Scalars['UUID']['output'];};export type Workspace = {@@ -1380,7 +1411,6 @@ export type Workspace = {billingSubscriptions?: Maybe<Array<BillingSubscription>>;createdAt: Scalars['DateTime']['output'];currentBillingSubscription?: Maybe<BillingSubscription>;- currentMetadataVersion: Scalars['Float']['output'];databaseSchema: Scalars['String']['output'];databaseUrl: Scalars['String']['output'];deletedAt?: Maybe<Scalars['DateTime']['output']>;@@ -1693,52 +1723,65 @@ export type ObjectMetadataItemsQueryVariables = Exact<{export type ObjectMetadataItemsQuery = { __typename?: 'Query', objects: { __typename?: 'ObjectConnection', edges: Array<{ __typename?: 'objectEdge', node: { __typename?: 'object', id: any, dataSourceId: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isRemote: boolean, isActive: boolean, isSystem: boolean, createdAt: any, updatedAt: any, labelIdentifierFieldMetadataId?: string | null, imageIdentifierFieldMetadataId?: string | null, fields: { __typename?: 'ObjectFieldsConnection', edges: Array<{ __typename?: 'fieldEdge', node: { __typename?: 'field', id: any, type: FieldMetadataType, name: string, label: string, description?: string | null, icon?: string | null, isCustom?: boolean | null, isActive?: boolean | null, isSystem?: boolean | null, isNullable?: boolean | null, createdAt: any, updatedAt: any, defaultValue?: any | null, options?: any | null, fromRelationMetadata?: { __typename?: 'relation', id: any, relationType: RelationMetadataType, toFieldMetadataId: string, toObjectMetadata: { __typename?: 'object', id: any, dataSourceId: string, nameSingular: string, namePlural: string, isSystem: boolean, isRemote: boolean } } | null, toRelationMetadata?: { __typename?: 'relation', id: any, relationType: RelationMetadataType, fromFieldMetadataId: string, fromObjectMetadata: { __typename?: 'object', id: any, dataSourceId: string, nameSingular: string, namePlural: string, isSystem: boolean, isRemote: boolean } } | null, relationDefinition?: { __typename?: 'RelationDefinition', relationId: any, direction: RelationDefinitionType, sourceObjectMetadata: { __typename?: 'object', id: any, nameSingular: string, namePlural: string }, sourceFieldMetadata: { __typename?: 'field', id: any, name: string }, targetObjectMetadata: { __typename?: 'object', id: any, nameSingular: string, namePlural: string }, targetFieldMetadata: { __typename?: 'field', id: any, name: string } } | null } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } };-export type ServerlessFunctionFieldsFragment = { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, createdAt: any, updatedAt: any };+export type ServerlessFunctionFieldsFragment = { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, latestVersion?: string | null, createdAt: any, updatedAt: any };export type CreateOneServerlessFunctionItemMutationVariables = Exact<{input: CreateServerlessFunctionInput;}>;-export type CreateOneServerlessFunctionItemMutation = { __typename?: 'Mutation', createOneServerlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, createdAt: any, updatedAt: any } };+export type CreateOneServerlessFunctionItemMutation = { __typename?: 'Mutation', createOneServerlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, latestVersion?: string | null, createdAt: any, updatedAt: any } };export type DeleteOneServerlessFunctionMutationVariables = Exact<{input: DeleteServerlessFunctionInput;}>;-export type DeleteOneServerlessFunctionMutation = { __typename?: 'Mutation', deleteOneServerlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, createdAt: any, updatedAt: any } };+export type DeleteOneServerlessFunctionMutation = { __typename?: 'Mutation', deleteOneServerlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, latestVersion?: string | null, createdAt: any, updatedAt: any } };export type ExecuteOneServerlessFunctionMutationVariables = Exact<{- id: Scalars['UUID']['input'];- payload: Scalars['JSON']['input'];+ input: ExecuteServerlessFunctionInput;}>;export type ExecuteOneServerlessFunctionMutation = { __typename?: 'Mutation', executeOneServerlessFunction: { __typename?: 'ServerlessFunctionExecutionResult', data?: any | null, duration: number, status: ServerlessFunctionExecutionStatus, error?: any | null } };+export type PublishOneServerlessFunctionMutationVariables = Exact<{+ input: PublishServerlessFunctionInput;+}>;+++export type PublishOneServerlessFunctionMutation = { __typename?: 'Mutation', publishServerlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, latestVersion?: string | null, createdAt: any, updatedAt: any } };+export type UpdateOneServerlessFunctionMutationVariables = Exact<{input: UpdateServerlessFunctionInput;}>;-export type UpdateOneServerlessFunctionMutation = { __typename?: 'Mutation', updateOneServerlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, createdAt: any, updatedAt: any } };+export type UpdateOneServerlessFunctionMutation = { __typename?: 'Mutation', updateOneServerlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, latestVersion?: string | null, createdAt: any, updatedAt: any } };export type GetManyServerlessFunctionsQueryVariables = Exact<{ [key: string]: never; }>;-export type GetManyServerlessFunctionsQuery = { __typename?: 'Query', serverlessFunctions: { __typename?: 'ServerlessFunctionConnection', edges: Array<{ __typename?: 'ServerlessFunctionEdge', node: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, createdAt: any, updatedAt: any } }> } };+export type GetManyServerlessFunctionsQuery = { __typename?: 'Query', serverlessFunctions: { __typename?: 'ServerlessFunctionConnection', edges: Array<{ __typename?: 'ServerlessFunctionEdge', node: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, latestVersion?: string | null, createdAt: any, updatedAt: any } }> } };export type GetOneServerlessFunctionQueryVariables = Exact<{id: Scalars['UUID']['input'];}>;-export type GetOneServerlessFunctionQuery = { __typename?: 'Query', serverlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, createdAt: any, updatedAt: any } };+export type GetOneServerlessFunctionQuery = { __typename?: 'Query', serverlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description?: string | null, sourceCodeHash: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, latestVersion?: string | null, createdAt: any, updatedAt: any } };++export type FindOneServerlessFunctionSourceCodeQueryVariables = Exact<{+ input: GetServerlessFunctionSourceCodeInput;+}>;+++export type FindOneServerlessFunctionSourceCodeQuery = { __typename?: 'Query', getServerlessFunctionSourceCode: string };export const RemoteServerFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"RemoteServerFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"RemoteServer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"foreignDataWrapperId"}},{"kind":"Field","name":{"kind":"Name","value":"foreignDataWrapperOptions"}},{"kind":"Field","name":{"kind":"Name","value":"foreignDataWrapperType"}},{"kind":"Field","name":{"kind":"Name","value":"userMappingOptions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"}}]}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"schema"}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}}]} as unknown as DocumentNode<RemoteServerFieldsFragment, unknown>;export const RemoteTableFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"RemoteTableFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"RemoteTable"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"schema"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"schemaPendingUpdates"}}]}}]} as unknown as DocumentNode<RemoteTableFieldsFragment, unknown>;-export const ServerlessFunctionFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeFullPath"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<ServerlessFunctionFieldsFragment, unknown>;+export const ServerlessFunctionFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"latestVersion"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<ServerlessFunctionFieldsFragment, unknown>;export const CreateServerDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"createServer"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateRemoteServerInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneRemoteServer"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"RemoteServerFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"RemoteServerFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"RemoteServer"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"foreignDataWrapperId"}},{"kind":"Field","name":{"kind":"Name","value":"foreignDataWrapperOptions"}},{"kind":"Field","name":{"kind":"Name","value":"foreignDataWrapperType"}},{"kind":"Field","name":{"kind":"Name","value":"userMappingOptions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"}}]}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"schema"}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}}]} as unknown as DocumentNode<CreateServerMutation, CreateServerMutationVariables>;export const DeleteServerDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"deleteServer"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"RemoteServerIdInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteOneRemoteServer"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode<DeleteServerMutation, DeleteServerMutationVariables>;export const SyncRemoteTableDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"syncRemoteTable"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"RemoteTableInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"syncRemoteTable"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"RemoteTableFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"RemoteTableFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"RemoteTable"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"schema"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"schemaPendingUpdates"}}]}}]} as unknown as DocumentNode<SyncRemoteTableMutation, SyncRemoteTableMutationVariables>;@@ -1757,9 +1800,11 @@ export const DeleteOneObjectMetadataItemDocument = {"kind":"Document","definitioexport const DeleteOneFieldMetadataItemDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteOneFieldMetadataItem"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"idToDelete"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteOneField"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"idToDelete"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<DeleteOneFieldMetadataItemMutation, DeleteOneFieldMetadataItemMutationVariables>;export const DeleteOneRelationMetadataItemDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteOneRelationMetadataItem"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"idToDelete"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteOneRelation"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"idToDelete"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode<DeleteOneRelationMetadataItemMutation, DeleteOneRelationMetadataItemMutationVariables>;export const ObjectMetadataItemsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ObjectMetadataItems"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"objectFilter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"objectFilter"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fieldFilter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"fieldFilter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"objects"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"1000"}}]}},{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"objectFilter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isRemote"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"labelIdentifierFieldMetadataId"}},{"kind":"Field","name":{"kind":"Name","value":"imageIdentifierFieldMetadataId"}},{"kind":"Field","name":{"kind":"Name","value":"fields"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"1000"}}]}},{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fieldFilter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"fromRelationMetadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"relationType"}},{"kind":"Field","name":{"kind":"Name","value":"toObjectMetadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isRemote"}}]}},{"kind":"Field","name":{"kind":"Name","value":"toFieldMetadataId"}}]}},{"kind":"Field","name":{"kind":"Name","value":"toRelationMetadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"relationType"}},{"kind":"Field","name":{"kind":"Name","value":"fromObjectMetadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isRemote"}}]}},{"kind":"Field","name":{"kind":"Name","value":"fromFieldMetadataId"}}]}},{"kind":"Field","name":{"kind":"Name","value":"defaultValue"}},{"kind":"Field","name":{"kind":"Name","value":"options"}},{"kind":"Field","name":{"kind":"Name","value":"relationDefinition"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"relationId"}},{"kind":"Field","name":{"kind":"Name","value":"direction"}},{"kind":"Field","name":{"kind":"Name","value":"sourceObjectMetadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}}]}},{"kind":"Field","name":{"kind":"Name","value":"sourceFieldMetadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"targetObjectMetadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}}]}},{"kind":"Field","name":{"kind":"Name","value":"targetFieldMetadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}},{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}},{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}}]}}]}}]} as unknown as DocumentNode<ObjectMetadataItemsQuery, ObjectMetadataItemsQueryVariables>;-export const CreateOneServerlessFunctionItemDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOneServerlessFunctionItem"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateServerlessFunctionInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneServerlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeFullPath"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<CreateOneServerlessFunctionItemMutation, CreateOneServerlessFunctionItemMutationVariables>;-export const DeleteOneServerlessFunctionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteOneServerlessFunction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DeleteServerlessFunctionInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteOneServerlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeFullPath"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<DeleteOneServerlessFunctionMutation, DeleteOneServerlessFunctionMutationVariables>;-export const ExecuteOneServerlessFunctionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ExecuteOneServerlessFunction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"payload"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"JSON"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"executeOneServerlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"payload"},"value":{"kind":"Variable","name":{"kind":"Name","value":"payload"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"}},{"kind":"Field","name":{"kind":"Name","value":"duration"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"error"}}]}}]}}]} as unknown as DocumentNode<ExecuteOneServerlessFunctionMutation, ExecuteOneServerlessFunctionMutationVariables>;-export const UpdateOneServerlessFunctionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateOneServerlessFunction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateServerlessFunctionInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateOneServerlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeFullPath"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<UpdateOneServerlessFunctionMutation, UpdateOneServerlessFunctionMutationVariables>;-export const GetManyServerlessFunctionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetManyServerlessFunctions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"serverlessFunctions"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"100"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeFullPath"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<GetManyServerlessFunctionsQuery, GetManyServerlessFunctionsQueryVariables>;-export const GetOneServerlessFunctionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOneServerlessFunction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"serverlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeFullPath"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<GetOneServerlessFunctionQuery, GetOneServerlessFunctionQueryVariables>;\ No newline at end of file+export const CreateOneServerlessFunctionItemDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOneServerlessFunctionItem"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateServerlessFunctionInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneServerlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"latestVersion"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<CreateOneServerlessFunctionItemMutation, CreateOneServerlessFunctionItemMutationVariables>;+export const DeleteOneServerlessFunctionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteOneServerlessFunction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DeleteServerlessFunctionInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteOneServerlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"latestVersion"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<DeleteOneServerlessFunctionMutation, DeleteOneServerlessFunctionMutationVariables>;+export const ExecuteOneServerlessFunctionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ExecuteOneServerlessFunction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ExecuteServerlessFunctionInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"executeOneServerlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"data"}},{"kind":"Field","name":{"kind":"Name","value":"duration"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"error"}}]}}]}}]} as unknown as DocumentNode<ExecuteOneServerlessFunctionMutation, ExecuteOneServerlessFunctionMutationVariables>;+export const PublishOneServerlessFunctionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"PublishOneServerlessFunction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"PublishServerlessFunctionInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"publishServerlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"latestVersion"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<PublishOneServerlessFunctionMutation, PublishOneServerlessFunctionMutationVariables>;+export const UpdateOneServerlessFunctionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateOneServerlessFunction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateServerlessFunctionInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateOneServerlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"latestVersion"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<UpdateOneServerlessFunctionMutation, UpdateOneServerlessFunctionMutationVariables>;+export const GetManyServerlessFunctionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetManyServerlessFunctions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"serverlessFunctions"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"100"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"latestVersion"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<GetManyServerlessFunctionsQuery, GetManyServerlessFunctionsQueryVariables>;+export const GetOneServerlessFunctionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetOneServerlessFunction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"serverlessFunction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ServerlessFunctionFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ServerlessFunctionFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ServerlessFunction"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"sourceCodeHash"}},{"kind":"Field","name":{"kind":"Name","value":"runtime"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"latestVersion"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<GetOneServerlessFunctionQuery, GetOneServerlessFunctionQueryVariables>;+export const FindOneServerlessFunctionSourceCodeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindOneServerlessFunctionSourceCode"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"GetServerlessFunctionSourceCodeInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"getServerlessFunctionSourceCode"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}]}]}}]} as unknown as DocumentNode<FindOneServerlessFunctionSourceCodeQuery, FindOneServerlessFunctionSourceCodeQueryVariables>;\ No newline at end of filediff --git a/packages/twenty-front/src/modules/object-record/hooks/useRestoreManyRecords.ts b/packages/twenty-front/src/modules/object-record/hooks/useRestoreManyRecords.tsindex f1fb1c17c13..55bd5cc5e86 100644--- a/packages/twenty-front/src/modules/object-record/hooks/useRestoreManyRecords.ts+++ b/packages/twenty-front/src/modules/object-record/hooks/useRestoreManyRecords.ts@@ -58,7 +58,9 @@ export const useRestoreManyRecords = ({// TODO: fix optimistic effectconst findOneQueryName = `FindOne${capitalize(objectNameSingular)}`;- const findManyQueryName = `FindMany${capitalize(objectMetadataItem.namePlural)}`;+ const findManyQueryName = `FindMany${capitalize(+ objectMetadataItem.namePlural,+ )}`;const restoredRecordsResponse = await apolloClient.mutate({mutation: restoreManyRecordsMutation,diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionCodeEditorTab.tsx b/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionCodeEditorTab.tsxindex a74a0889dc2..a74892409ad 100644--- a/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionCodeEditorTab.tsx+++ b/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionCodeEditorTab.tsx@@ -1,4 +1,4 @@-import { H2Title, IconPlayerPlay } from 'twenty-ui';+import { H2Title, IconPlayerPlay, IconGitCommit, IconRestore } from 'twenty-ui';import { CodeEditor } from '@/ui/input/code-editor/components/CodeEditor';import { Section } from '@/ui/layout/section/components/Section';import { ServerlessFunctionFormValues } from '@/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState';@@ -14,13 +14,23 @@ const StyledTabList = styled(TabList)`export const SettingsServerlessFunctionCodeEditorTab = ({formValues,handleExecute,+ handlePublish,+ handleReset,+ resetDisabled,+ publishDisabled,onChange,+ setIsCodeValid,}: {formValues: ServerlessFunctionFormValues;handleExecute: () => void;+ handlePublish: () => void;+ handleReset: () => void;+ resetDisabled: boolean;+ publishDisabled: boolean;onChange: (key: string) => (value: string) => void;+ setIsCodeValid: (isCodeValid: boolean) => void;}) => {- const HeaderButton = (+ const TestButton = (<Buttontitle="Test"variant="primary"@@ -30,6 +40,26 @@ export const SettingsServerlessFunctionCodeEditorTab = ({onClick={handleExecute}/>);+ const PublishButton = (+ <Button+ title="Publish"+ variant="secondary"+ size="small"+ Icon={IconGitCommit}+ onClick={handlePublish}+ disabled={publishDisabled}+ />+ );+ const ResetButton = (+ <Button+ title="Reset"+ variant="secondary"+ size="small"+ Icon={IconRestore}+ onClick={handleReset}+ disabled={resetDisabled}+ />+ );const TAB_LIST_COMPONENT_ID = 'serverless-function-editor';@@ -41,7 +71,10 @@ export const SettingsServerlessFunctionCodeEditorTab = ({);const Header = (- <CoreEditorHeader leftNodes={[HeaderTabList]} rightNodes={[HeaderButton]} />+ <CoreEditorHeader+ leftNodes={[HeaderTabList]}+ rightNodes={[ResetButton, PublishButton, TestButton]}+ />);return (@@ -53,6 +86,7 @@ export const SettingsServerlessFunctionCodeEditorTab = ({<CodeEditorvalue={formValues.code}onChange={onChange('code')}+ setIsCodeValid={setIsCodeValid}header={Header}/></Section>diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTabEffect.tsx b/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTabEffect.tsxindex 64cff208b49..0bd86e69207 100644--- a/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTabEffect.tsx+++ b/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTabEffect.tsx@@ -1,4 +1,4 @@-import React from 'react';+import React, { useEffect } from 'react';import { useRecoilValue, useSetRecoilState } from 'recoil';import {DEFAULT_OUTPUT_VALUE,@@ -13,11 +13,16 @@ export const SettingsServerlessFunctionTestTabEffect = () => {const setSettingsServerlessFunctionCodeEditorOutputParams = useSetRecoilState(settingsServerlessFunctionCodeEditorOutputParamsState,);- if (settingsServerlessFunctionOutput.data !== DEFAULT_OUTPUT_VALUE) {- setSettingsServerlessFunctionCodeEditorOutputParams({- language: 'json',- height: 300,- });- }+ useEffect(() => {+ if (settingsServerlessFunctionOutput.data !== DEFAULT_OUTPUT_VALUE) {+ setSettingsServerlessFunctionCodeEditorOutputParams({+ language: 'json',+ height: 300,+ });+ }+ }, [+ settingsServerlessFunctionOutput.data,+ setSettingsServerlessFunctionCodeEditorOutputParams,+ ]);return <></>;};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment.ts b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment.tsindex dc48df97d08..2fd1e250661 100644--- a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment.ts+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment.ts@@ -6,9 +6,9 @@ export const SERVERLESS_FUNCTION_FRAGMENT = gql`namedescriptionsourceCodeHash- sourceCodeFullPathruntimesyncStatus+ latestVersioncreatedAtupdatedAt}diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/executeOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/executeOneServerlessFunction.tsindex 9054e26abcb..09d4518b0cc 100644--- a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/executeOneServerlessFunction.ts+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/executeOneServerlessFunction.ts@@ -1,8 +1,10 @@import { gql } from '@apollo/client';export const EXECUTE_ONE_SERVERLESS_FUNCTION = gql`- mutation ExecuteOneServerlessFunction($id: UUID!, $payload: JSON!) {- executeOneServerlessFunction(id: $id, payload: $payload) {+ mutation ExecuteOneServerlessFunction(+ $input: ExecuteServerlessFunctionInput!+ ) {+ executeOneServerlessFunction(input: $input) {datadurationstatusdiff --git a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/publishOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/publishOneServerlessFunction.tsnew file mode 100644index 00000000000..d8fbcb7915b--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/publishOneServerlessFunction.ts@@ -0,0 +1,13 @@+import { gql } from '@apollo/client';+import { SERVERLESS_FUNCTION_FRAGMENT } from '@/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment';++export const PUBLISH_ONE_SERVERLESS_FUNCTION = gql`+ ${SERVERLESS_FUNCTION_FRAGMENT}+ mutation PublishOneServerlessFunction(+ $input: PublishServerlessFunctionInput!+ ) {+ publishServerlessFunction(input: $input) {+ ...ServerlessFunctionFields+ }+ }+`;diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/queries/findOneServerlessFunctionSourceCode.ts b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/queries/findOneServerlessFunctionSourceCode.tsnew file mode 100644index 00000000000..510eeb33a65--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/queries/findOneServerlessFunctionSourceCode.ts@@ -0,0 +1,9 @@+import { gql } from '@apollo/client';++export const FIND_ONE_SERVERLESS_FUNCTION_SOURCE_CODE = gql`+ query FindOneServerlessFunctionSourceCode(+ $input: GetServerlessFunctionSourceCodeInput!+ ) {+ getServerlessFunctionSourceCode(input: $input)+ }+`;diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/__tests__/useServerlessFunctionUpdateFormState.test.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/__tests__/useServerlessFunctionUpdateFormState.test.tsindex e243fb4d860..1e60fa426a5 100644--- a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/__tests__/useServerlessFunctionUpdateFormState.test.ts+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/__tests__/useServerlessFunctionUpdateFormState.test.ts@@ -9,6 +9,13 @@ jest.mock(}),);+jest.mock(+ '@/settings/serverless-functions/hooks/useGetOneServerlessFunctionSourceCode',+ () => ({+ useGetOneServerlessFunctionSourceCode: jest.fn(),+ }),+);+describe('useServerlessFunctionUpdateFormState', () => {test('should return a form', () => {const serverlessFunctionId = 'serverlessFunctionId';@@ -20,6 +27,14 @@ describe('useServerlessFunctionUpdateFormState', () => {serverlessFunction: { sourceCodeFullPath: undefined },},);+ const useGetOneServerlessFunctionSourceCodeMock = jest.requireMock(+ '@/settings/serverless-functions/hooks/useGetOneServerlessFunctionSourceCode',+ );+ useGetOneServerlessFunctionSourceCodeMock.useGetOneServerlessFunctionSourceCode.mockReturnValue(+ {+ code: 'export const handler = () => {}',+ },+ );const { result } = renderHook(() => useServerlessFunctionUpdateFormState(serverlessFunctionId),{diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useDeleteOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useDeleteOneServerlessFunction.tsindex 1a4d66fdf9c..db1c3f5a68f 100644--- a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useDeleteOneServerlessFunction.ts+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useDeleteOneServerlessFunction.ts@@ -1,13 +1,13 @@import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';import { ApolloClient, useMutation } from '@apollo/client';import { getOperationName } from '@apollo/client/utilities';-import { FIND_MANY_SERVERLESS_FUNCTIONS } from '@/settings/serverless-functions/graphql/queries/findManyServerlessFunctions';import { DELETE_ONE_SERVERLESS_FUNCTION } from '@/settings/serverless-functions/graphql/mutations/deleteOneServerlessFunction';import {DeleteServerlessFunctionInput,DeleteOneServerlessFunctionMutation,DeleteOneServerlessFunctionMutationVariables,} from '~/generated-metadata/graphql';+import { FIND_ONE_SERVERLESS_FUNCTION_SOURCE_CODE } from '@/settings/serverless-functions/graphql/queries/findOneServerlessFunctionSourceCode';export const useDeleteOneServerlessFunction = () => {const apolloMetadataClient = useApolloMetadataClient();@@ -26,7 +26,9 @@ export const useDeleteOneServerlessFunction = () => {input,},awaitRefetchQueries: true,- refetchQueries: [getOperationName(FIND_MANY_SERVERLESS_FUNCTIONS) ?? ''],+ refetchQueries: [+ getOperationName(FIND_ONE_SERVERLESS_FUNCTION_SOURCE_CODE) ?? '',+ ],});};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useExecuteOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useExecuteOneServerlessFunction.tsindex 84394ac20a6..8825a68d925 100644--- a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useExecuteOneServerlessFunction.ts+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useExecuteOneServerlessFunction.ts@@ -2,6 +2,7 @@ import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadaimport { ApolloClient, useMutation } from '@apollo/client';import { EXECUTE_ONE_SERVERLESS_FUNCTION } from '@/settings/serverless-functions/graphql/mutations/executeOneServerlessFunction';import {+ ExecuteServerlessFunctionInput,ExecuteOneServerlessFunctionMutation,ExecuteOneServerlessFunctionMutationVariables,} from '~/generated-metadata/graphql';@@ -16,13 +17,11 @@ export const useExecuteOneServerlessFunction = () => {});const executeOneServerlessFunction = async (- id: string,- payload: object = {},+ input: ExecuteServerlessFunctionInput,) => {return await mutate({variables: {- id,- payload,+ input,},});};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useGetOneServerlessFunctionSourceCode.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useGetOneServerlessFunctionSourceCode.tsnew file mode 100644index 00000000000..b39f919039b--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useGetOneServerlessFunctionSourceCode.ts@@ -0,0 +1,30 @@+import { useQuery } from '@apollo/client';+import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';+import { FIND_ONE_SERVERLESS_FUNCTION_SOURCE_CODE } from '@/settings/serverless-functions/graphql/queries/findOneServerlessFunctionSourceCode';+import {+ FindOneServerlessFunctionSourceCodeQuery,+ FindOneServerlessFunctionSourceCodeQueryVariables,+} from '~/generated-metadata/graphql';++export const useGetOneServerlessFunctionSourceCode = ({+ id,+ version,+ onCompleted,+}: {+ id: string;+ version: string;+ onCompleted?: (data: FindOneServerlessFunctionSourceCodeQuery) => void;+}) => {+ const apolloMetadataClient = useApolloMetadataClient();+ const { data, loading } = useQuery<+ FindOneServerlessFunctionSourceCodeQuery,+ FindOneServerlessFunctionSourceCodeQueryVariables+ >(FIND_ONE_SERVERLESS_FUNCTION_SOURCE_CODE, {+ client: apolloMetadataClient ?? undefined,+ variables: {+ input: { id, version },+ },+ onCompleted,+ });+ return { code: data?.getServerlessFunctionSourceCode, loading };+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/usePublishOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/usePublishOneServerlessFunction.tsnew file mode 100644index 00000000000..02b8a3e1fec--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/usePublishOneServerlessFunction.ts@@ -0,0 +1,36 @@+import { ApolloClient, useMutation } from '@apollo/client';+import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';+import { PUBLISH_ONE_SERVERLESS_FUNCTION } from '@/settings/serverless-functions/graphql/mutations/publishOneServerlessFunction';+import {+ PublishServerlessFunctionInput,+ PublishOneServerlessFunctionMutation,+ PublishOneServerlessFunctionMutationVariables,+} from '~/generated-metadata/graphql';+import { getOperationName } from '@apollo/client/utilities';+import { FIND_ONE_SERVERLESS_FUNCTION_SOURCE_CODE } from '@/settings/serverless-functions/graphql/queries/findOneServerlessFunctionSourceCode';++export const usePublishOneServerlessFunction = () => {+ const apolloMetadataClient = useApolloMetadataClient();+ const [mutate] = useMutation<+ PublishOneServerlessFunctionMutation,+ PublishOneServerlessFunctionMutationVariables+ >(PUBLISH_ONE_SERVERLESS_FUNCTION, {+ client: apolloMetadataClient ?? ({} as ApolloClient<any>),+ });++ const publishOneServerlessFunction = async (+ input: PublishServerlessFunctionInput,+ ) => {+ return await mutate({+ variables: {+ input,+ },+ awaitRefetchQueries: true,+ refetchQueries: [+ getOperationName(FIND_ONE_SERVERLESS_FUNCTION_SOURCE_CODE) ?? '',+ ],+ });+ };++ return { publishOneServerlessFunction };+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState.tsindex f1055751879..aa336b97716 100644--- a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState.ts+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState.ts@@ -1,7 +1,7 @@-import { Dispatch, SetStateAction, useEffect, useState } from 'react';-import { getFileAbsoluteURI } from '~/utils/file/getFileAbsoluteURI';-import { isDefined } from '~/utils/isDefined';+import { Dispatch, SetStateAction, useState } from 'react';import { useGetOneServerlessFunction } from '@/settings/serverless-functions/hooks/useGetOneServerlessFunction';+import { useGetOneServerlessFunctionSourceCode } from '@/settings/serverless-functions/hooks/useGetOneServerlessFunctionSourceCode';+import { FindOneServerlessFunctionSourceCodeQuery } from '~/generated-metadata/graphql';export type ServerlessFunctionNewFormValues = {name: string;@@ -28,30 +28,21 @@ export const useServerlessFunctionUpdateFormState = (const { serverlessFunction } =useGetOneServerlessFunction(serverlessFunctionId);- useEffect(() => {- const getFileContent = async () => {- const resp = await fetch(- getFileAbsoluteURI(serverlessFunction?.sourceCodeFullPath),- );- if (resp.status !== 200) {- throw new Error('Network response was not ok');- } else {- const result = await resp.text();- const newState = {- code: result,- name: serverlessFunction?.name || '',- description: serverlessFunction?.description || '',- };- setFormValues((prevState) => ({- ...prevState,- ...newState,- }));- }- };- if (isDefined(serverlessFunction?.sourceCodeFullPath)) {- getFileContent();- }- }, [serverlessFunction, setFormValues]);+ useGetOneServerlessFunctionSourceCode({+ id: serverlessFunctionId,+ version: 'draft',+ onCompleted: (data: FindOneServerlessFunctionSourceCodeQuery) => {+ const newState = {+ code: data?.getServerlessFunctionSourceCode || '',+ name: serverlessFunction?.name || '',+ description: serverlessFunction?.description || '',+ };+ setFormValues((prevState) => ({+ ...prevState,+ ...newState,+ }));+ },+ });return [formValues, setFormValues];};diff --git a/packages/twenty-front/src/modules/ui/input/code-editor/components/CodeEditor.tsx b/packages/twenty-front/src/modules/ui/input/code-editor/components/CodeEditor.tsxindex ca73f277989..6f99e8310ba 100644--- a/packages/twenty-front/src/modules/ui/input/code-editor/components/CodeEditor.tsx+++ b/packages/twenty-front/src/modules/ui/input/code-editor/components/CodeEditor.tsx@@ -1,5 +1,5 @@import Editor, { Monaco, EditorProps } from '@monaco-editor/react';-import { editor } from 'monaco-editor';+import { editor, MarkerSeverity } from 'monaco-editor';import { codeEditorTheme } from '@/ui/input/code-editor/theme/CodeEditorTheme';import { useTheme } from '@emotion/react';import styled from '@emotion/styled';@@ -24,17 +24,20 @@ const StyledEditor = styled(Editor)`type CodeEditorProps = Omit<EditorProps, 'onChange'> & {header: React.ReactNode;onChange?: (value: string) => void;+ setIsCodeValid?: (isCodeValid: boolean) => void;};export const CodeEditor = ({value = DEFAULT_CODE,onChange,+ setIsCodeValid,language = 'typescript',- height = 500,+ height = 450,options = undefined,header,}: CodeEditorProps) => {const theme = useTheme();+const handleEditorDidMount = (editor: editor.IStandaloneCodeEditor,monaco: Monaco,@@ -42,6 +45,17 @@ export const CodeEditor = ({monaco.editor.defineTheme('codeEditorTheme', codeEditorTheme(theme));monaco.editor.setTheme('codeEditorTheme');};++ const handleEditorValidation = (markers: editor.IMarker[]) => {+ for (const marker of markers) {+ if (marker.severity === MarkerSeverity.Error) {+ setIsCodeValid?.(false);+ return;+ }+ }+ setIsCodeValid?.(true);+ };+useEffect(() => {const style = document.createElement('style');style.innerHTML = `@@ -63,6 +77,7 @@ export const CodeEditor = ({value={value}onMount={handleEditorDidMount}onChange={(value?: string) => value && onChange?.(value)}+ onValidate={handleEditorValidation}options={{...options,overviewRulerLanes: 0,diff --git a/packages/twenty-front/src/pages/settings/serverless-functions/ResetServerlessFunctionStatesEffect.tsx b/packages/twenty-front/src/pages/settings/serverless-functions/ResetServerlessFunctionStatesEffect.tsxindex 595f2b2a1d4..95f243cbe91 100644--- a/packages/twenty-front/src/pages/settings/serverless-functions/ResetServerlessFunctionStatesEffect.tsx+++ b/packages/twenty-front/src/pages/settings/serverless-functions/ResetServerlessFunctionStatesEffect.tsx@@ -2,6 +2,7 @@ import { settingsServerlessFunctionCodeEditorOutputParamsState } from '@/settingimport { settingsServerlessFunctionInputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionInputState';import { settingsServerlessFunctionOutputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionOutputState';import { useResetRecoilState } from 'recoil';+import { useEffect } from 'react';export const ResetServerlessFunctionStatesEffect = () => {const resetSettingsServerlessFunctionInput = useResetRecoilState(@@ -13,8 +14,14 @@ export const ResetServerlessFunctionStatesEffect = () => {const resetSettingsServerlessFunctionCodeEditorOutputParamsState =useResetRecoilState(settingsServerlessFunctionCodeEditorOutputParamsState);- resetSettingsServerlessFunctionInput();- resetSettingsServerlessFunctionOutput();- resetSettingsServerlessFunctionCodeEditorOutputParamsState();+ useEffect(() => {+ resetSettingsServerlessFunctionInput();+ resetSettingsServerlessFunctionOutput();+ resetSettingsServerlessFunctionCodeEditorOutputParamsState();+ }, [+ resetSettingsServerlessFunctionInput,+ resetSettingsServerlessFunctionOutput,+ resetSettingsServerlessFunctionCodeEditorOutputParamsState,+ ]);return <></>;};diff --git a/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionDetail.tsx b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionDetail.tsxindex b67cd465547..057c8f3ceaa 100644--- a/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionDetail.tsx+++ b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionDetail.tsx@@ -6,6 +6,7 @@ import { SettingsServerlessFunctionTestTabEffect } from '@/settings/serverless-fimport { useExecuteOneServerlessFunction } from '@/settings/serverless-functions/hooks/useExecuteOneServerlessFunction';import { useServerlessFunctionUpdateFormState } from '@/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState';import { useUpdateOneServerlessFunction } from '@/settings/serverless-functions/hooks/useUpdateOneServerlessFunction';+import { usePublishOneServerlessFunction } from '@/settings/serverless-functions/hooks/usePublishOneServerlessFunction';import { settingsServerlessFunctionInputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionInputState';import { settingsServerlessFunctionOutputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionOutputState';import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';@@ -18,7 +19,10 @@ import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';import { useParams } from 'react-router-dom';import { useRecoilValue, useSetRecoilState } from 'recoil';import { IconCode, IconFunction, IconSettings, IconTestPipe } from 'twenty-ui';+import { isDefined } from '~/utils/isDefined';import { useDebouncedCallback } from 'use-debounce';+import { useGetOneServerlessFunctionSourceCode } from '@/settings/serverless-functions/hooks/useGetOneServerlessFunctionSourceCode';+import { useState } from 'react';const TAB_LIST_COMPONENT_ID = 'serverless-function-detail';@@ -29,10 +33,16 @@ export const SettingsServerlessFunctionDetail = () => {TAB_LIST_COMPONENT_ID,);const activeTabId = useRecoilValue(activeTabIdState);+ const [isCodeValid, setIsCodeValid] = useState(true);const { executeOneServerlessFunction } = useExecuteOneServerlessFunction();const { updateOneServerlessFunction } = useUpdateOneServerlessFunction();+ const { publishOneServerlessFunction } = usePublishOneServerlessFunction();const [formValues, setFormValues] =useServerlessFunctionUpdateFormState(serverlessFunctionId);+ const { code: latestVersionCode } = useGetOneServerlessFunctionSourceCode({+ id: serverlessFunctionId,+ version: 'latest',+ });const setSettingsServerlessFunctionOutput = useSetRecoilState(settingsServerlessFunctionOutputState,);@@ -70,13 +80,56 @@ export const SettingsServerlessFunctionDetail = () => {};};- const handleExecute = async () => {- await handleSave();+ const resetDisabled =+ !isDefined(latestVersionCode) || latestVersionCode === formValues.code;+ const publishDisabled = !isCodeValid || latestVersionCode === formValues.code;++ const handleReset = async () => {try {- const result = await executeOneServerlessFunction(- serverlessFunctionId,- JSON.parse(settingsServerlessFunctionInput),+ const newState = {+ code: latestVersionCode || '',+ };+ setFormValues((prevState) => ({+ ...prevState,+ ...newState,+ }));+ await handleSave();+ } catch (err) {+ enqueueSnackBar(+ (err as Error)?.message || 'An error occurred while reset function',+ {+ variant: SnackBarVariant.Error,+ },);+ }+ };++ const handlePublish = async () => {+ try {+ await publishOneServerlessFunction({+ id: serverlessFunctionId,+ });+ enqueueSnackBar(`New function version has been published`, {+ variant: SnackBarVariant.Success,+ });+ } catch (err) {+ enqueueSnackBar(+ (err as Error)?.message ||+ 'An error occurred while publishing new version',+ {+ variant: SnackBarVariant.Error,+ },+ );+ }+ };++ const handleExecute = async () => {+ try {+ const result = await executeOneServerlessFunction({+ id: serverlessFunctionId,+ payload: JSON.parse(settingsServerlessFunctionInput),+ version: 'draft',+ });setSettingsServerlessFunctionOutput({data: result?.data?.executeOneServerlessFunction?.data? JSON.stringify(@@ -119,7 +172,12 @@ export const SettingsServerlessFunctionDetail = () => {<SettingsServerlessFunctionCodeEditorTabformValues={formValues}handleExecute={handleExecute}+ handlePublish={handlePublish}+ handleReset={handleReset}+ resetDisabled={resetDisabled}+ publishDisabled={publishDisabled}onChange={onChange}+ setIsCodeValid={setIsCodeValid}/>);case 'test':diff --git a/packages/twenty-server/src/database/typeorm/metadata/migrations/1724171584314-updateServerlessFunction.ts b/packages/twenty-server/src/database/typeorm/metadata/migrations/1724171584314-updateServerlessFunction.tsnew file mode 100644index 00000000000..ee134cb0773--- /dev/null+++ b/packages/twenty-server/src/database/typeorm/metadata/migrations/1724171584314-updateServerlessFunction.ts@@ -0,0 +1,25 @@+import { MigrationInterface, QueryRunner } from 'typeorm';++export class UpdateServerlessFunction1724171584314+ implements MigrationInterface+{+ name = 'UpdateServerlessFunction1724171584314';++ public async up(queryRunner: QueryRunner): Promise<void> {+ await queryRunner.query(+ `ALTER TABLE "metadata"."serverlessFunction" DROP COLUMN "sourceCodeFullPath"`,+ );+ await queryRunner.query(+ `ALTER TABLE "metadata"."serverlessFunction" ADD "latestVersion" character varying`,+ );+ }++ public async down(queryRunner: QueryRunner): Promise<void> {+ await queryRunner.query(+ `ALTER TABLE "metadata"."serverlessFunction" DROP COLUMN "latestVersion"`,+ );+ await queryRunner.query(+ `ALTER TABLE "metadata"."serverlessFunction" ADD "sourceCodeFullPath" character varying NOT NULL`,+ );+ }+}diff --git a/packages/twenty-server/src/engine/integrations/file-storage/drivers/interfaces/storage-driver.interface.ts b/packages/twenty-server/src/engine/integrations/file-storage/drivers/interfaces/storage-driver.interface.tsindex 08c9f070806..84cf20a2189 100644--- a/packages/twenty-server/src/engine/integrations/file-storage/drivers/interfaces/storage-driver.interface.ts+++ b/packages/twenty-server/src/engine/integrations/file-storage/drivers/interfaces/storage-driver.interface.ts@@ -13,4 +13,8 @@ export interface StorageDriver {from: { folderPath: string; filename: string };to: { folderPath: string; filename: string };}): Promise<void>;+ copy(params: {+ from: { folderPath: string; filename?: string };+ to: { folderPath: string; filename?: string };+ }): Promise<void>;}diff --git a/packages/twenty-server/src/engine/integrations/file-storage/drivers/local.driver.ts b/packages/twenty-server/src/engine/integrations/file-storage/drivers/local.driver.tsindex 3a2e46f9396..e7d9f6bf7c3 100644--- a/packages/twenty-server/src/engine/integrations/file-storage/drivers/local.driver.ts+++ b/packages/twenty-server/src/engine/integrations/file-storage/drivers/local.driver.ts@@ -70,6 +70,13 @@ export class LocalDriver implements StorageDriver {params.filename,);+ if (!existsSync(filePath)) {+ throw new FileStorageException(+ 'File not found',+ FileStorageExceptionCode.FILE_NOT_FOUND,+ );+ }+try {return createReadStream(filePath);} catch (error) {@@ -115,4 +122,34 @@ export class LocalDriver implements StorageDriver {throw error;}}++ async copy(params: {+ from: { folderPath: string; filename?: string };+ to: { folderPath: string; filename?: string };+ }): Promise<void> {+ const fromPath = join(+ `${this.options.storagePath}/`,+ params.from.folderPath,+ params.from.filename || '',+ );++ const toPath = join(+ `${this.options.storagePath}/`,+ params.to.folderPath,+ params.to.filename || '',+ );++ try {+ await fs.cp(fromPath, toPath, { recursive: true });+ } catch (error) {+ if (error.code === 'ENOENT') {+ throw new FileStorageException(+ 'File not found',+ FileStorageExceptionCode.FILE_NOT_FOUND,+ );+ }++ throw error;+ }+ }}diff --git a/packages/twenty-server/src/engine/integrations/file-storage/drivers/s3.driver.ts b/packages/twenty-server/src/engine/integrations/file-storage/drivers/s3.driver.tsindex 7ced7608d9a..d882db903b6 100644--- a/packages/twenty-server/src/engine/integrations/file-storage/drivers/s3.driver.ts+++ b/packages/twenty-server/src/engine/integrations/file-storage/drivers/s3.driver.ts@@ -187,6 +187,42 @@ export class S3Driver implements StorageDriver {}}+ async copy(params: {+ from: { folderPath: string; filename?: string };+ to: { folderPath: string; filename?: string };+ }): Promise<void> {+ const fromKey = `${params.from.folderPath}/${params.from.filename || ''}`;+ const toKey = `${params.to.folderPath}/${params.to.filename || ''}`;++ try {+ // Check if the source file exists+ await this.s3Client.send(+ new HeadObjectCommand({+ Bucket: this.bucketName,+ Key: fromKey,+ }),+ );++ // Copy the object to the new location+ await this.s3Client.send(+ new CopyObjectCommand({+ CopySource: `${this.bucketName}/${fromKey}`,+ Bucket: this.bucketName,+ Key: toKey,+ }),+ );+ } catch (error) {+ if (error.name === 'NotFound') {+ throw new FileStorageException(+ 'File not found',+ FileStorageExceptionCode.FILE_NOT_FOUND,+ );+ }+ // For other errors, throw the original error+ throw error;+ }+ }+async checkBucketExists(args: HeadBucketCommandInput) {try {await this.s3Client.headBucket(args);diff --git a/packages/twenty-server/src/engine/integrations/file-storage/file-storage.service.ts b/packages/twenty-server/src/engine/integrations/file-storage/file-storage.service.tsindex 65133f991f3..a6eeb6c2041 100644--- a/packages/twenty-server/src/engine/integrations/file-storage/file-storage.service.ts+++ b/packages/twenty-server/src/engine/integrations/file-storage/file-storage.service.ts@@ -33,4 +33,11 @@ export class FileStorageService implements StorageDriver {}): Promise<void> {return this.driver.move(params);}++ copy(params: {+ from: { folderPath: string; filename?: string };+ to: { folderPath: string; filename?: string };+ }): Promise<void> {+ return this.driver.copy(params);+ }}diff --git a/packages/twenty-server/src/engine/integrations/serverless/drivers/base-serverless.driver.ts b/packages/twenty-server/src/engine/integrations/serverless/drivers/base-serverless.driver.tsindex e26666dc531..bce3c8e42d1 100644--- a/packages/twenty-server/src/engine/integrations/serverless/drivers/base-serverless.driver.ts+++ b/packages/twenty-server/src/engine/integrations/serverless/drivers/base-serverless.driver.ts@@ -1,27 +1,19 @@-import { join } from 'path';--import { FileFolder } from 'src/engine/core-modules/file/interfaces/file-folder.interface';-import { FileStorageService } from 'src/engine/integrations/file-storage/file-storage.service';import { readFileContent } from 'src/engine/integrations/file-storage/utils/read-file-content';import { SOURCE_FILE_NAME } from 'src/engine/integrations/serverless/drivers/constants/source-file-name';import { compileTypescript } from 'src/engine/integrations/serverless/drivers/utils/compile-typescript';import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';+import { getServerlessFolder } from 'src/engine/integrations/serverless/utils/serverless-get-folder.utils';export class BaseServerlessDriver {- getFolderPath(serverlessFunction: ServerlessFunctionEntity) {- return join(- 'workspace-' + serverlessFunction.workspaceId,- FileFolder.ServerlessFunction,- serverlessFunction.id,- );- }-async getCompiledCode(serverlessFunction: ServerlessFunctionEntity,fileStorageService: FileStorageService,) {- const folderPath = this.getFolderPath(serverlessFunction);+ const folderPath = getServerlessFolder({+ serverlessFunction,+ version: 'draft',+ });const fileStream = await fileStorageService.read({folderPath,filename: SOURCE_FILE_NAME,diff --git a/packages/twenty-server/src/engine/integrations/serverless/drivers/interfaces/serverless-driver.interface.ts b/packages/twenty-server/src/engine/integrations/serverless/drivers/interfaces/serverless-driver.interface.tsindex 21f87ef926d..549289707fb 100644--- a/packages/twenty-server/src/engine/integrations/serverless/drivers/interfaces/serverless-driver.interface.ts+++ b/packages/twenty-server/src/engine/integrations/serverless/drivers/interfaces/serverless-driver.interface.ts@@ -16,9 +16,14 @@ export type ServerlessExecuteResult = {export interface ServerlessDriver {delete(serverlessFunction: ServerlessFunctionEntity): Promise<void>;- build(serverlessFunction: ServerlessFunctionEntity): Promise<void>;+ build(+ serverlessFunction: ServerlessFunctionEntity,+ version: string,+ ): Promise<void>;+ publish(serverlessFunction: ServerlessFunctionEntity): Promise<string>;execute(serverlessFunction: ServerlessFunctionEntity,payload: object | undefined,+ version: string,): Promise<ServerlessExecuteResult>;}diff --git a/packages/twenty-server/src/engine/integrations/serverless/drivers/lambda.driver.ts b/packages/twenty-server/src/engine/integrations/serverless/drivers/lambda.driver.tsindex 4889ff0fcb1..719b4934b15 100644--- a/packages/twenty-server/src/engine/integrations/serverless/drivers/lambda.driver.ts+++ b/packages/twenty-server/src/engine/integrations/serverless/drivers/lambda.driver.ts@@ -9,6 +9,9 @@ import {UpdateFunctionCodeCommand,DeleteFunctionCommand,ResourceNotFoundException,+ waitUntilFunctionUpdatedV2,+ PublishVersionCommandInput,+ PublishVersionCommand,} from '@aws-sdk/client-lambda';import { CreateFunctionCommandInput } from '@aws-sdk/client-lambda/dist-types/commands/CreateFunctionCommand';import { UpdateFunctionCodeCommandInput } from '@aws-sdk/client-lambda/dist-types/commands/UpdateFunctionCodeCommand';@@ -24,6 +27,10 @@ import { FileStorageService } from 'src/engine/integrations/file-storage/file-stimport { BaseServerlessDriver } from 'src/engine/integrations/serverless/drivers/base-serverless.driver';import { BuildDirectoryManagerService } from 'src/engine/integrations/serverless/drivers/services/build-directory-manager.service';import { ServerlessFunctionExecutionStatus } from 'src/engine/metadata-modules/serverless-function/dtos/serverless-function-execution-result.dto';+import {+ ServerlessFunctionException,+ ServerlessFunctionExceptionCode,+} from 'src/engine/metadata-modules/serverless-function/serverless-function.exception';export interface LambdaDriverOptions extends LambdaClientConfig {fileStorageService: FileStorageService;@@ -51,12 +58,10 @@ export class LambdaDriverthis.buildDirectoryManagerService = options.buildDirectoryManagerService;}- private async checkFunctionExists(- serverlessFunctionId: string,- ): Promise<boolean> {+ private async checkFunctionExists(functionName: string): Promise<boolean> {try {const getFunctionCommand = new GetFunctionCommand({- FunctionName: serverlessFunctionId,+ FunctionName: functionName,});await this.lambdaClient.send(getFunctionCommand);@@ -132,42 +137,85 @@ export class LambdaDriverawait this.lambdaClient.send(command);}+ const waitParams = { FunctionName: serverlessFunction.id };++ await waitUntilFunctionUpdatedV2(+ { client: this.lambdaClient, maxWaitTime: 5 },+ waitParams,+ );+await this.buildDirectoryManagerService.clean();}+ async publish(serverlessFunction: ServerlessFunctionEntity) {+ await this.build(serverlessFunction);+ const params: PublishVersionCommandInput = {+ FunctionName: serverlessFunction.id,+ };++ const command = new PublishVersionCommand(params);++ const result = await this.lambdaClient.send(command);+ const newVersion = result.Version;++ if (!newVersion) {+ throw new Error('New published version is undefined');+ }++ return newVersion;+ }+async execute(functionToExecute: ServerlessFunctionEntity,payload: object | undefined = undefined,+ version: string,): Promise<ServerlessExecuteResult> {+ const computedVersion =+ version === 'latest' ? functionToExecute.latestVersion : version;++ const functionName =+ computedVersion === 'draft'+ ? functionToExecute.id+ : `${functionToExecute.id}:${computedVersion}`;const startTime = Date.now();const params = {- FunctionName: functionToExecute.id,+ FunctionName: functionName,Payload: JSON.stringify(payload),};const command = new InvokeCommand(params);- const result = await this.lambdaClient.send(command);+ try {+ const result = await this.lambdaClient.send(command);++ const parsedResult = result.Payload+ ? JSON.parse(result.Payload.transformToString())+ : {};- const parsedResult = result.Payload- ? JSON.parse(result.Payload.transformToString())- : {};+ const duration = Date.now() - startTime;- const duration = Date.now() - startTime;+ if (result.FunctionError) {+ return {+ data: null,+ duration,+ status: ServerlessFunctionExecutionStatus.ERROR,+ error: parsedResult,+ };+ }- if (result.FunctionError) {return {- data: null,+ data: parsedResult,duration,- status: ServerlessFunctionExecutionStatus.ERROR,- error: parsedResult,+ status: ServerlessFunctionExecutionStatus.SUCCESS,};+ } catch (error) {+ if (error instanceof ResourceNotFoundException) {+ throw new ServerlessFunctionException(+ `Function Version '${version}' does not exist`,+ ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,+ );+ }+ throw error;}-- return {- data: parsedResult,- duration,- status: ServerlessFunctionExecutionStatus.SUCCESS,- };}}diff --git a/packages/twenty-server/src/engine/integrations/serverless/drivers/local.driver.ts b/packages/twenty-server/src/engine/integrations/serverless/drivers/local.driver.tsindex c811426b3cd..60933461b10 100644--- a/packages/twenty-server/src/engine/integrations/serverless/drivers/local.driver.ts+++ b/packages/twenty-server/src/engine/integrations/serverless/drivers/local.driver.ts@@ -10,6 +10,7 @@ import {ServerlessExecuteError,ServerlessExecuteResult,} from 'src/engine/integrations/serverless/drivers/interfaces/serverless-driver.interface';+import { FileStorageExceptionCode } from 'src/engine/integrations/file-storage/interfaces/file-storage-exception';import { FileStorageService } from 'src/engine/integrations/file-storage/file-storage.service';import { readFileContent } from 'src/engine/integrations/file-storage/utils/read-file-content';@@ -17,6 +18,11 @@ import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverlessimport { BUILD_FILE_NAME } from 'src/engine/integrations/serverless/drivers/constants/build-file-name';import { BaseServerlessDriver } from 'src/engine/integrations/serverless/drivers/base-serverless.driver';import { ServerlessFunctionExecutionStatus } from 'src/engine/metadata-modules/serverless-function/dtos/serverless-function-execution-result.dto';+import {+ ServerlessFunctionException,+ ServerlessFunctionExceptionCode,+} from 'src/engine/metadata-modules/serverless-function/serverless-function.exception';+import { getServerlessFolder } from 'src/engine/integrations/serverless/utils/serverless-get-folder.utils';export interface LocalDriverOptions {fileStorageService: FileStorageService;@@ -33,11 +39,7 @@ export class LocalDriverthis.fileStorageService = options.fileStorageService;}- async delete(serverlessFunction: ServerlessFunctionEntity) {- await this.fileStorageService.delete({- folderPath: this.getFolderPath(serverlessFunction),- });- }+ async delete() {}async build(serverlessFunction: ServerlessFunctionEntity) {const javascriptCode = await this.getCompiledCode(@@ -49,20 +51,48 @@ export class LocalDriverfile: javascriptCode,name: BUILD_FILE_NAME,mimeType: undefined,- folder: this.getFolderPath(serverlessFunction),+ folder: getServerlessFolder({+ serverlessFunction,+ version: 'draft',+ }),});}+ async publish(serverlessFunction: ServerlessFunctionEntity) {+ await this.build(serverlessFunction);++ return serverlessFunction.latestVersion+ ? `${parseInt(serverlessFunction.latestVersion, 10) + 1}`+ : '1';+ }+async execute(serverlessFunction: ServerlessFunctionEntity,payload: object | undefined = undefined,+ version: string,): Promise<ServerlessExecuteResult> {const startTime = Date.now();- const fileStream = await this.fileStorageService.read({- folderPath: this.getFolderPath(serverlessFunction),- filename: BUILD_FILE_NAME,- });- const fileContent = await readFileContent(fileStream);+ let fileContent = '';++ try {+ const fileStream = await this.fileStorageService.read({+ folderPath: getServerlessFolder({+ serverlessFunction,+ version,+ }),+ filename: BUILD_FILE_NAME,+ });++ fileContent = await readFileContent(fileStream);+ } catch (error) {+ if (error.code === FileStorageExceptionCode.FILE_NOT_FOUND) {+ throw new ServerlessFunctionException(+ `Function Version '${version}' does not exist`,+ ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,+ );+ }+ throw error;+ }const tmpFilePath = join(tmpdir(), `${v4()}.js`);diff --git a/packages/twenty-server/src/engine/integrations/serverless/serverless.service.ts b/packages/twenty-server/src/engine/integrations/serverless/serverless.service.tsindex 4ca59624575..747feae9a1c 100644--- a/packages/twenty-server/src/engine/integrations/serverless/serverless.service.ts+++ b/packages/twenty-server/src/engine/integrations/serverless/serverless.service.ts@@ -16,14 +16,22 @@ export class ServerlessService implements ServerlessDriver {return this.driver.delete(serverlessFunction);}- async build(serverlessFunction: ServerlessFunctionEntity): Promise<void> {- return this.driver.build(serverlessFunction);+ async build(+ serverlessFunction: ServerlessFunctionEntity,+ version: string,+ ): Promise<void> {+ return this.driver.build(serverlessFunction, version);+ }++ async publish(serverlessFunction: ServerlessFunctionEntity): Promise<string> {+ return this.driver.publish(serverlessFunction);}async execute(serverlessFunction: ServerlessFunctionEntity,payload: object | undefined = undefined,+ version: string,): Promise<ServerlessExecuteResult> {- return this.driver.execute(serverlessFunction, payload);+ return this.driver.execute(serverlessFunction, payload, version);}}diff --git a/packages/twenty-server/src/engine/integrations/serverless/utils/serverless-get-folder.utils.ts b/packages/twenty-server/src/engine/integrations/serverless/utils/serverless-get-folder.utils.tsnew file mode 100644index 00000000000..8dc4a97bf70--- /dev/null+++ b/packages/twenty-server/src/engine/integrations/serverless/utils/serverless-get-folder.utils.ts@@ -0,0 +1,23 @@+import { join } from 'path';++import { FileFolder } from 'src/engine/core-modules/file/interfaces/file-folder.interface';++import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';++export const getServerlessFolder = ({+ serverlessFunction,+ version,+}: {+ serverlessFunction: ServerlessFunctionEntity;+ version?: string;+}) => {+ const computedVersion =+ version === 'latest' ? serverlessFunction.latestVersion : version;++ return join(+ 'workspace-' + serverlessFunction.workspaceId,+ FileFolder.ServerlessFunction,+ serverlessFunction.id,+ computedVersion || '',+ );+};diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/execute-serverless-function.input.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/execute-serverless-function.input.tsindex 08071b04f5e..85fff20ccbc 100644--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/execute-serverless-function.input.ts+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/execute-serverless-function.input.ts@@ -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;}diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/get-serverless-function-source-code.input.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/get-serverless-function-source-code.input.tsnew file mode 100644index 00000000000..47b552fd1fd--- /dev/null+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/get-serverless-function-source-code.input.ts@@ -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;+}diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/publish-serverless-function.input.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/publish-serverless-function.input.tsnew file mode 100644index 00000000000..ca40bd384be--- /dev/null+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/publish-serverless-function.input.ts@@ -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;+}diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/serverless-function.dto.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/serverless-function.dto.tsindex 3d348fdb336..ff5a4c7d57a 100644--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/serverless-function.dto.ts+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/serverless-function.dto.ts@@ -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()diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.entity.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.entity.tsindex a5893abe2ae..3e985e5bd95 100644--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.entity.ts+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.entity.ts@@ -28,11 +28,11 @@ export class ServerlessFunctionEntity {@Column({ nullable: true })description: string;- @Column({ nullable: false })- sourceCodeHash: string;+ @Column({ nullable: true })+ latestVersion: string;@Column({ nullable: false })- sourceCodeFullPath: string;+ sourceCodeHash: string;@Column({ nullable: false, default: ServerlessFunctionRuntime.NODE18 })runtime: ServerlessFunctionRuntime;diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.exception.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.exception.tsindex 6f0430431a3..e76f76cc7dd 100644--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.exception.ts+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.exception.ts@@ -9,6 +9,7 @@ export class ServerlessFunctionException extends CustomException {export enum ServerlessFunctionExceptionCode {SERVERLESS_FUNCTION_NOT_FOUND = 'SERVERLESS_FUNCTION_NOT_FOUND',+ SERVERLESS_FUNCTION_VERSION_NOT_FOUND = 'SERVERLESS_FUNCTION_VERSION_NOT_FOUND',FEATURE_FLAG_INVALID = 'FEATURE_FLAG_INVALID',SERVERLESS_FUNCTION_ALREADY_EXIST = 'SERVERLESS_FUNCTION_ALREADY_EXIST',SERVERLESS_FUNCTION_NOT_READY = 'SERVERLESS_FUNCTION_NOT_READY',diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.interceptor.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.interceptor.tsdeleted file mode 100644index 7120a5c5f37..00000000000--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.interceptor.ts+++ /dev/null@@ -1,57 +0,0 @@-import {- CallHandler,- ExecutionContext,- Injectable,- NestInterceptor,-} from '@nestjs/common';--import { Observable, map } from 'rxjs';--import { FileService } from 'src/engine/core-modules/file/services/file.service';--@Injectable()-export class ServerlessFunctionInterceptor implements NestInterceptor {- constructor(private readonly fileService: FileService) {}-- intercept(context: ExecutionContext, next: CallHandler): Observable<any> {- return next.handle().pipe(- map(async (data) => {- if (data.edges && Array.isArray(data.edges)) {- return {- ...data,- edges: Promise.all(- data.edges.map((item) => ({- ...item,- node: this.processItem(item.node),- })),- ),- };- } else {- return this.processItem(data);- }- }),- );- }-- private async processItem(item: any): Promise<any> {- if (item && item.sourceCodeFullPath) {- const workspaceId = item.workspace?.id || item.workspaceId;-- if (!workspaceId) {- return item;- }-- const signedPayload = await this.fileService.encodeFileToken({- serverlessFunctionId: item.id,- workspace_id: workspaceId,- });-- return {- ...item,- sourceCodeFullPath: `${item.sourceCodeFullPath}?token=${signedPayload}`,- };- }-- return item;- }-}diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.module.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.module.tsindex 1fdbdfe5a5a..bbea9dac81f 100644--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.module.ts+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.module.ts@@ -15,7 +15,6 @@ import { JwtAuthGuard } from 'src/engine/guards/jwt.auth.guard';import { ServerlessModule } from 'src/engine/integrations/serverless/serverless.module';import { ServerlessFunctionDTO } from 'src/engine/metadata-modules/serverless-function/dtos/serverless-function.dto';import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';-import { ServerlessFunctionInterceptor } from 'src/engine/metadata-modules/serverless-function/serverless-function.interceptor';import { ServerlessFunctionResolver } from 'src/engine/metadata-modules/serverless-function/serverless-function.resolver';import { ServerlessFunctionService } from 'src/engine/metadata-modules/serverless-function/serverless-function.service';@@ -45,7 +44,6 @@ import { ServerlessFunctionService } from 'src/engine/metadata-modules/serverlesupdate: { disabled: true },delete: { disabled: true },guards: [JwtAuthGuard],- interceptors: [ServerlessFunctionInterceptor],},],}),diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.resolver.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.resolver.tsindex b4995634421..cd1a232c24b 100644--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.resolver.ts+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.resolver.ts@@ -1,5 +1,5 @@-import { UseGuards, UseInterceptors } from '@nestjs/common';-import { Args, Mutation, Resolver } from '@nestjs/graphql';+import { UseGuards } from '@nestjs/common';+import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';import { InjectRepository } from '@nestjs/typeorm';import { FileUpload, GraphQLUpload } from 'graphql-upload';@@ -21,9 +21,10 @@ import {ServerlessFunctionException,ServerlessFunctionExceptionCode,} from 'src/engine/metadata-modules/serverless-function/serverless-function.exception';-import { ServerlessFunctionInterceptor } from 'src/engine/metadata-modules/serverless-function/serverless-function.interceptor';import { ServerlessFunctionService } from 'src/engine/metadata-modules/serverless-function/serverless-function.service';import { serverlessFunctionGraphQLApiExceptionHandler } from 'src/engine/metadata-modules/serverless-function/utils/serverless-function-graphql-api-exception-handler.utils';+import { GetServerlessFunctionSourceCodeInput } from 'src/engine/metadata-modules/serverless-function/dtos/get-serverless-function-source-code.input';+import { PublishServerlessFunctionInput } from 'src/engine/metadata-modules/serverless-function/dtos/publish-serverless-function.input';@UseGuards(JwtAuthGuard)@Resolver()@@ -50,6 +51,24 @@ export class ServerlessFunctionResolver {}}+ @Query(() => String)+ async getServerlessFunctionSourceCode(+ @Args('input') input: GetServerlessFunctionSourceCodeInput,+ @AuthWorkspace() { id: workspaceId }: Workspace,+ ) {+ try {+ await this.checkFeatureFlag(workspaceId);++ return await this.serverlessFunctionService.getServerlessFunctionSourceCode(+ workspaceId,+ input.id,+ input.version,+ );+ } catch (error) {+ serverlessFunctionGraphQLApiExceptionHandler(error);+ }+ }+@Mutation(() => ServerlessFunctionDTO)async deleteOneServerlessFunction(@Args('input') input: DeleteServerlessFunctionInput,@@ -67,7 +86,6 @@ export class ServerlessFunctionResolver {}}- @UseInterceptors(ServerlessFunctionInterceptor)@Mutation(() => ServerlessFunctionDTO)async updateOneServerlessFunction(@Args('input')@@ -86,7 +104,6 @@ export class ServerlessFunctionResolver {}}- @UseInterceptors(ServerlessFunctionInterceptor)@Mutation(() => ServerlessFunctionDTO)async createOneServerlessFunction(@Args('input')@@ -109,7 +126,6 @@ export class ServerlessFunctionResolver {}}- @UseInterceptors(ServerlessFunctionInterceptor)@Mutation(() => ServerlessFunctionDTO)async createOneServerlessFunctionFromFile(@Args({ name: 'file', type: () => GraphQLUpload })@@ -133,17 +149,36 @@ export class ServerlessFunctionResolver {@Mutation(() => ServerlessFunctionExecutionResultDTO)async executeOneServerlessFunction(- @Args() executeServerlessFunctionInput: ExecuteServerlessFunctionInput,+ @Args('input') input: ExecuteServerlessFunctionInput,@AuthWorkspace() { id: workspaceId }: Workspace,) {try {await this.checkFeatureFlag(workspaceId);- const { id, payload } = executeServerlessFunctionInput;+ const { id, payload, version } = input;- return await this.serverlessFunctionService.executeOne(+ return await this.serverlessFunctionService.executeOneServerlessFunction(id,workspaceId,payload,+ version,+ );+ } catch (error) {+ serverlessFunctionGraphQLApiExceptionHandler(error);+ }+ }++ @Mutation(() => ServerlessFunctionDTO)+ async publishServerlessFunction(+ @Args('input') input: PublishServerlessFunctionInput,+ @AuthWorkspace() { id: workspaceId }: Workspace,+ ) {+ try {+ await this.checkFeatureFlag(workspaceId);+ const { id } = input;++ return await this.serverlessFunctionService.publishOneServerlessFunction(+ id,+ workspaceId,);} catch (error) {serverlessFunctionGraphQLApiExceptionHandler(error);diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.service.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.service.tsindex 38768d44a71..5b6cf876563 100644--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.service.ts+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.service.ts@@ -1,15 +1,12 @@import { Injectable } from '@nestjs/common';import { InjectRepository } from '@nestjs/typeorm';-import { join } from 'path';-import { TypeOrmQueryService } from '@ptc-org/nestjs-query-typeorm';import { FileUpload } from 'graphql-upload';import { Repository } from 'typeorm';-import { v4 } from 'uuid';-import { FileFolder } from 'src/engine/core-modules/file/interfaces/file-folder.interface';import { ServerlessExecuteResult } from 'src/engine/integrations/serverless/drivers/interfaces/serverless-driver.interface';+import { FileStorageExceptionCode } from 'src/engine/integrations/file-storage/interfaces/file-storage-exception';import { FileStorageService } from 'src/engine/integrations/file-storage/file-storage.service';import { readFileContent } from 'src/engine/integrations/file-storage/utils/read-file-content';@@ -26,6 +23,8 @@ import {ServerlessFunctionExceptionCode,} from 'src/engine/metadata-modules/serverless-function/serverless-function.exception';import { serverlessFunctionCreateHash } from 'src/engine/metadata-modules/serverless-function/utils/serverless-function-create-hash.utils';+import { isDefined } from 'src/utils/is-defined';+import { getServerlessFolder } from 'src/engine/integrations/serverless/utils/serverless-get-folder.utils';@Injectable()export class ServerlessFunctionService extends TypeOrmQueryService<ServerlessFunctionEntity> {@@ -38,10 +37,54 @@ export class ServerlessFunctionService extends TypeOrmQueryService<ServerlessFunsuper(serverlessFunctionRepository);}- async executeOne(+ async getServerlessFunctionSourceCode(+ workspaceId: string,+ id: string,+ version: string,+ ) {+ try {+ const serverlessFunction =+ await this.serverlessFunctionRepository.findOne({+ where: {+ id,+ workspaceId,+ },+ });++ if (!serverlessFunction) {+ throw new ServerlessFunctionException(+ `Function does not exist`,+ ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,+ );+ }++ const folderPath = getServerlessFolder({+ serverlessFunction,+ version,+ });++ const fileStream = await this.fileStorageService.read({+ folderPath,+ filename: SOURCE_FILE_NAME,+ });++ return await readFileContent(fileStream);+ } catch (error) {+ if (error.code === FileStorageExceptionCode.FILE_NOT_FOUND) {+ throw new ServerlessFunctionException(+ `Function Version '${version}' does not exist`,+ ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,+ );+ }+ throw error;+ }+ }++ async executeOneServerlessFunction(id: string,workspaceId: string,payload: object | undefined = undefined,+ version = 'latest',): Promise<ServerlessExecuteResult> {const functionToExecute = await this.serverlessFunctionRepository.findOne({where: {@@ -60,13 +103,73 @@ export class ServerlessFunctionService extends TypeOrmQueryService<ServerlessFunif (functionToExecute.syncStatus === ServerlessFunctionSyncStatus.NOT_READY) {+ await this.serverlessService.build(functionToExecute, version);+ await super.updateOne(functionToExecute.id, {+ syncStatus: ServerlessFunctionSyncStatus.READY,+ });+ }++ return this.serverlessService.execute(functionToExecute, payload, version);+ }++ async publishOneServerlessFunction(id: string, workspaceId: string) {+ const existingServerlessFunction =+ await this.serverlessFunctionRepository.findOne({+ where: { id, workspaceId },+ });++ if (!existingServerlessFunction) {throw new ServerlessFunctionException(- `Function is not ready to be executed`,+ `Function does not exist`,ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,);}- return this.serverlessService.execute(functionToExecute, payload);+ if (isDefined(existingServerlessFunction.latestVersion)) {+ const latestCode = await this.getServerlessFunctionSourceCode(+ workspaceId,+ id,+ 'latest',+ );+ const draftCode = await this.getServerlessFunctionSourceCode(+ workspaceId,+ id,+ 'draft',+ );++ if (+ serverlessFunctionCreateHash(latestCode) ===+ serverlessFunctionCreateHash(draftCode)+ ) {+ throw new Error(+ 'Cannot publish a new version when code has not changed',+ );+ }+ }++ const newVersion = await this.serverlessService.publish(+ existingServerlessFunction,+ );++ const draftFolderPath = getServerlessFolder({+ serverlessFunction: existingServerlessFunction,+ version: 'draft',+ });+ const newFolderPath = getServerlessFolder({+ serverlessFunction: existingServerlessFunction,+ version: newVersion,+ });++ await this.fileStorageService.copy({+ from: { folderPath: draftFolderPath },+ to: { folderPath: newFolderPath },+ });++ await super.updateOne(existingServerlessFunction.id, {+ latestVersion: newVersion,+ });++ return await this.findById(existingServerlessFunction.id);}async deleteOneServerlessFunction(id: string, workspaceId: string) {@@ -86,6 +189,12 @@ export class ServerlessFunctionService extends TypeOrmQueryService<ServerlessFunawait this.serverlessService.delete(existingServerlessFunction);+ await this.fileStorageService.delete({+ folderPath: getServerlessFolder({+ serverlessFunction: existingServerlessFunction,+ }),+ });+return existingServerlessFunction;}@@ -105,34 +214,23 @@ export class ServerlessFunctionService extends TypeOrmQueryService<ServerlessFun);}- const codeHasChanged =- serverlessFunctionCreateHash(serverlessFunctionInput.code) !==- existingServerlessFunction.sourceCodeHash;-await super.updateOne(existingServerlessFunction.id, {name: serverlessFunctionInput.name,description: serverlessFunctionInput.description,- sourceCodeHash: serverlessFunctionCreateHash(- serverlessFunctionInput.code,- ),+ syncStatus: ServerlessFunctionSyncStatus.NOT_READY,});- if (codeHasChanged) {- const fileFolder = join(- 'workspace-' + workspaceId,- FileFolder.ServerlessFunction,- existingServerlessFunction.id,- );-- await this.fileStorageService.write({- file: serverlessFunctionInput.code,- name: SOURCE_FILE_NAME,- mimeType: undefined,- folder: fileFolder,- });+ const fileFolder = getServerlessFolder({+ serverlessFunction: existingServerlessFunction,+ version: 'draft',+ });- await this.serverlessService.build(existingServerlessFunction);- }+ await this.fileStorageService.write({+ file: serverlessFunctionInput.code,+ name: SOURCE_FILE_NAME,+ mimeType: undefined,+ folder: fileFolder,+ });return await this.findById(existingServerlessFunction.id);}@@ -162,41 +260,24 @@ export class ServerlessFunctionService extends TypeOrmQueryService<ServerlessFuntypescriptCode = await readFileContent(code.createReadStream());}- const serverlessFunctionId = v4();-- const fileFolderWithoutWorkspace = join(- FileFolder.ServerlessFunction,- serverlessFunctionId,- );-- const fileFolder = join(- 'workspace-' + workspaceId,- fileFolderWithoutWorkspace,- );-- const sourceCodeFullPath =- fileFolderWithoutWorkspace + '/' + SOURCE_FILE_NAME;-- const serverlessFunction = await super.createOne({+ const createdServerlessFunction = await super.createOne({...serverlessFunctionInput,- id: serverlessFunctionId,workspaceId,sourceCodeHash: serverlessFunctionCreateHash(typescriptCode),- sourceCodeFullPath,+ });++ const draftFileFolder = getServerlessFolder({+ serverlessFunction: createdServerlessFunction,+ version: 'draft',});await this.fileStorageService.write({file: typescriptCode,name: SOURCE_FILE_NAME,mimeType: undefined,- folder: fileFolder,- });-- await this.serverlessService.build(serverlessFunction);- await super.updateOne(serverlessFunctionId, {- syncStatus: ServerlessFunctionSyncStatus.READY,+ folder: draftFileFolder,});- return await this.findById(serverlessFunctionId);+ return await this.findById(createdServerlessFunction.id);}}diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/utils/serverless-function-graphql-api-exception-handler.utils.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/utils/serverless-function-graphql-api-exception-handler.utils.tsindex 8f4bc41c941..c8c20ea6c7f 100644--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/utils/serverless-function-graphql-api-exception-handler.utils.ts+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/utils/serverless-function-graphql-api-exception-handler.utils.ts@@ -13,6 +13,7 @@ export const serverlessFunctionGraphQLApiExceptionHandler = (error: any) => {if (error instanceof ServerlessFunctionException) {switch (error.code) {case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND:+ case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_VERSION_NOT_FOUND:throw new NotFoundError(error.message);case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_ALREADY_EXIST:throw new ConflictError(error.message);diff --git a/packages/twenty-server/src/modules/workflow/workflow-step-executor/workflow-step-executors/code-action-executor.ts b/packages/twenty-server/src/modules/workflow/workflow-step-executor/workflow-step-executors/code-action-executor.tsindex ae8b857540f..fb9dbf5cb66 100644--- a/packages/twenty-server/src/modules/workflow/workflow-step-executor/workflow-step-executors/code-action-executor.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-step-executor/workflow-step-executors/code-action-executor.ts@@ -33,11 +33,12 @@ export class CodeActionExecutor implements WorkflowStepExecutor {);}- const result = await this.serverlessFunctionService.executeOne(- step.settings.serverlessFunctionId,- workspaceId,- payload,- );+ const result =+ await this.serverlessFunctionService.executeOneServerlessFunction(+ step.settings.serverlessFunctionId,+ workspaceId,+ payload,+ );return { data: result.data, ...(result.error && { error: result.error }) };}diff --git a/packages/twenty-ui/src/display/icon/components/TablerIcons.ts b/packages/twenty-ui/src/display/icon/components/TablerIcons.tsindex 722507d11c9..9e05f1390ff 100644--- a/packages/twenty-ui/src/display/icon/components/TablerIcons.ts+++ b/packages/twenty-ui/src/display/icon/components/TablerIcons.ts@@ -90,6 +90,7 @@ export {IconFocusCentered,IconForbid,IconFunction,+ IconGitCommit,IconGripVertical,IconH1,IconH2,