The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Serverless function UI (#6388)
martmull00fea179204b
diff --git a/packages/twenty-front/codegen-metadata.cjs b/packages/twenty-front/codegen-metadata.cjsindex d7ee2eb00c0..e0ed6e079cb 100644--- a/packages/twenty-front/codegen-metadata.cjs+++ b/packages/twenty-front/codegen-metadata.cjs@@ -3,6 +3,7 @@ module.exports = {documents: ['./src/modules/databases/graphql/**/*.ts','./src/modules/object-metadata/graphql/*.ts',+ './src/modules/settings/serverless-functions/graphql/**/*.ts','./src/modules/object-record/graphql/*.tsx','./src/modules/metadata/graphql/*.ts',],diff --git a/packages/twenty-front/codegen.cjs b/packages/twenty-front/codegen.cjsindex fcc0ef27a5c..ceb453fb982 100644--- a/packages/twenty-front/codegen.cjs+++ b/packages/twenty-front/codegen.cjs@@ -4,6 +4,7 @@ module.exports = {'!./src/modules/databases/**','!./src/modules/object-metadata/**','!./src/modules/object-record/**',+ '!./src/modules/settings/serverless-functions/**','./src/modules/**/*.tsx','./src/modules/**/*.ts','!./src/**/*.test.tsx',diff --git a/packages/twenty-front/public/images/placeholders/background/empty_functions_bg.png b/packages/twenty-front/public/images/placeholders/background/empty_functions_bg.pngnew file mode 100644index 00000000000..c65890384cbBinary files /dev/null and b/packages/twenty-front/public/images/placeholders/background/empty_functions_bg.png differdiff --git a/packages/twenty-front/public/images/placeholders/dark-background/empty_functions_bg.png b/packages/twenty-front/public/images/placeholders/dark-background/empty_functions_bg.pngnew file mode 100644index 00000000000..dd7ad6995a9Binary files /dev/null and b/packages/twenty-front/public/images/placeholders/dark-background/empty_functions_bg.png differdiff --git a/packages/twenty-front/public/images/placeholders/dark-moving-image/empty_functions.png b/packages/twenty-front/public/images/placeholders/dark-moving-image/empty_functions.pngnew file mode 100644index 00000000000..079fb7f2e3bBinary files /dev/null and b/packages/twenty-front/public/images/placeholders/dark-moving-image/empty_functions.png differdiff --git a/packages/twenty-front/public/images/placeholders/moving-image/empty_functions.png b/packages/twenty-front/public/images/placeholders/moving-image/empty_functions.pngnew file mode 100644index 00000000000..f9f914e9189Binary files /dev/null and b/packages/twenty-front/public/images/placeholders/moving-image/empty_functions.png differdiff --git a/packages/twenty-front/src/App.tsx b/packages/twenty-front/src/App.tsxindex c9740c087ae..a6bf9f2183d 100644--- a/packages/twenty-front/src/App.tsx+++ b/packages/twenty-front/src/App.tsx@@ -82,7 +82,10 @@ import { SettingsWorkspace } from '~/pages/settings/SettingsWorkspace';import { SettingsWorkspaceMembers } from '~/pages/settings/SettingsWorkspaceMembers';import { Tasks } from '~/pages/tasks/Tasks';import { getPageTitleFromPath } from '~/utils/title-utils';+import { SettingsServerlessFunctions } from '~/pages/settings/serverless-functions/SettingsServerlessFunctions';+import { SettingsServerlessFunctionsNew } from '~/pages/settings/serverless-functions/SettingsServerlessFunctionsNew';import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';+import { SettingsServerlessFunctionDetailWrapper } from '~/pages/settings/serverless-functions/SettingsServerlessFunctionDetailWrapper';const ProvidersThatNeedRouterContext = () => {const { pathname } = useLocation();@@ -130,6 +133,7 @@ const ProvidersThatNeedRouterContext = () => {const createRouter = (isBillingEnabled?: boolean,isCRMMigrationEnabled?: boolean,+ isServerlessFunctionSettingsEnabled?: boolean,) =>createBrowserRouter(createRoutesFromElements(@@ -256,6 +260,22 @@ const createRouter = (</Routes>}/>+ {isServerlessFunctionSettingsEnabled && (+ <>+ <Route+ path={SettingsPath.ServerlessFunctions}+ element={<SettingsServerlessFunctions />}+ />+ <Route+ path={SettingsPath.NewServerlessFunction}+ element={<SettingsServerlessFunctionsNew />}+ />+ <Route+ path={SettingsPath.ServerlessFunctionDetail}+ element={<SettingsServerlessFunctionDetailWrapper />}+ />+ </>+ )}<Routepath={SettingsPath.Integrations}element={<SettingsIntegrations />}@@ -304,10 +324,17 @@ const createRouter = (export const App = () => {const billing = useRecoilValue(billingState);const isCRMMigrationEnabled = useIsFeatureEnabled('IS_CRM_MIGRATION_ENABLED');+ const isServerlessFunctionSettingsEnabled = useIsFeatureEnabled(+ 'IS_FUNCTION_SETTINGS_ENABLED',+ );return (<RouterProvider- router={createRouter(billing?.isBillingEnabled, isCRMMigrationEnabled)}+ router={createRouter(+ billing?.isBillingEnabled,+ isCRMMigrationEnabled,+ isServerlessFunctionSettingsEnabled,+ )}/>);};diff --git a/packages/twenty-front/src/generated-metadata/gql.ts b/packages/twenty-front/src/generated-metadata/gql.tsindex ef3aa96421f..d0d3459d93a 100644--- a/packages/twenty-front/src/generated-metadata/gql.ts+++ b/packages/twenty-front/src/generated-metadata/gql.ts@@ -33,6 +33,13 @@ 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 \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 result\n }\n }\n": types.ExecuteOneServerlessFunctionDocument,+ "\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,};/**@@ -129,6 +136,34 @@ export function graphql(source: "\n mutation DeleteOneRelationMetadataItem($idT* 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 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"): (typeof documents)["\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"];+/**+ * 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"];+/**+ * 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 CreateOneServerlessFunctionItem(\n $input: CreateServerlessFunctionInput!\n ) {\n createOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n mutation CreateOneServerlessFunctionItem(\n $input: CreateServerlessFunctionInput!\n ) {\n createOneServerlessFunction(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.+ */+export function graphql(source: "\n \n mutation DeleteOneServerlessFunction($input: DeleteServerlessFunctionInput!) {\n deleteOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n mutation DeleteOneServerlessFunction($input: DeleteServerlessFunctionInput!) {\n deleteOneServerlessFunction(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.+ */+export function graphql(source: "\n mutation ExecuteOneServerlessFunction($id: UUID!, $payload: JSON!) {\n executeOneServerlessFunction(id: $id, payload: $payload) {\n result\n }\n }\n"): (typeof documents)["\n mutation ExecuteOneServerlessFunction($id: UUID!, $payload: JSON!) {\n executeOneServerlessFunction(id: $id, payload: $payload) {\n result\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 UpdateOneServerlessFunction($input: UpdateServerlessFunctionInput!) {\n updateOneServerlessFunction(input: $input) {\n ...ServerlessFunctionFields\n }\n }\n"): (typeof documents)["\n \n mutation UpdateOneServerlessFunction($input: UpdateServerlessFunctionInput!) {\n updateOneServerlessFunction(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.+ */+export function graphql(source: "\n \n query GetManyServerlessFunctions {\n serverlessFunctions(paging: { first: 100 }) {\n edges {\n node {\n ...ServerlessFunctionFields\n }\n }\n }\n }\n"): (typeof documents)["\n \n query GetManyServerlessFunctions {\n serverlessFunctions(paging: { first: 100 }) {\n edges {\n node {\n ...ServerlessFunctionFields\n }\n }\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 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"];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 c330062595c..0acd5cac71b 100644--- a/packages/twenty-front/src/generated-metadata/graphql.ts+++ b/packages/twenty-front/src/generated-metadata/graphql.ts@@ -247,6 +247,17 @@ export type CreateRemoteServerInput = {userMappingOptions?: InputMaybe<UserMappingOptions>;};+export type CreateServerlessFunctionFromFileInput = {+ description?: InputMaybe<Scalars['String']['input']>;+ name: Scalars['String']['input'];+};++export type CreateServerlessFunctionInput = {+ code: Scalars['String']['input'];+ description?: InputMaybe<Scalars['String']['input']>;+ name: Scalars['String']['input'];+};+export type CursorPaging = {/** Paginate after opaque cursor */after?: InputMaybe<Scalars['ConnectionCursor']['input']>;@@ -273,6 +284,11 @@ export type DeleteOneRelationInput = {id: Scalars['UUID']['input'];};+export type DeleteServerlessFunctionInput = {+ /** The id of the function. */+ id: Scalars['ID']['input'];+};+/** Schema update on a table */export enum DistantTableUpdate {ColumnsAdded = 'COLUMNS_ADDED',@@ -415,11 +431,13 @@ export type Mutation = {createOneRelation: Relation;createOneRemoteServer: RemoteServer;createOneServerlessFunction: ServerlessFunction;+ createOneServerlessFunctionFromFile: ServerlessFunction;deleteCurrentWorkspace: Workspace;deleteOneField: Field;deleteOneObject: Object;deleteOneRelation: Relation;deleteOneRemoteServer: RemoteServer;+ deleteOneServerlessFunction: ServerlessFunction;deleteUser: User;disablePostgresProxy: PostgresCredentials;emailPasswordResetLink: EmailPasswordResetLink;@@ -442,6 +460,7 @@ export type Mutation = {updateOneField: Field;updateOneObject: Object;updateOneRemoteServer: RemoteServer;+ updateOneServerlessFunction: ServerlessFunction;updatePasswordViaResetToken: InvalidatePassword;updateWorkspace: Workspace;uploadFile: Scalars['String']['output'];@@ -508,8 +527,13 @@ export type MutationCreateOneRemoteServerArgs = {export type MutationCreateOneServerlessFunctionArgs = {+ input: CreateServerlessFunctionInput;+};+++export type MutationCreateOneServerlessFunctionFromFileArgs = {file: Scalars['Upload']['input'];- name: Scalars['String']['input'];+ input: CreateServerlessFunctionFromFileInput;};@@ -533,6 +557,11 @@ export type MutationDeleteOneRemoteServerArgs = {};+export type MutationDeleteOneServerlessFunctionArgs = {+ input: DeleteServerlessFunctionInput;+};++export type MutationEmailPasswordResetLinkArgs = {email: Scalars['String']['input'];};@@ -546,7 +575,7 @@ export type MutationExchangeAuthorizationCodeArgs = {export type MutationExecuteOneServerlessFunctionArgs = {- name: Scalars['String']['input'];+ id: Scalars['UUID']['input'];payload?: InputMaybe<Scalars['JSON']['input']>;};@@ -621,6 +650,11 @@ export type MutationUpdateOneRemoteServerArgs = {};+export type MutationUpdateOneServerlessFunctionArgs = {+ input: UpdateServerlessFunctionInput;+};++export type MutationUpdatePasswordViaResetTokenArgs = {newPassword: Scalars['String']['input'];passwordResetToken: Scalars['String']['input'];@@ -966,6 +1000,19 @@ export type Sentry = {release?: Maybe<Scalars['String']['output']>;};+export type ServerlessFunction = {+ __typename?: 'ServerlessFunction';+ createdAt: Scalars['DateTime']['output'];+ description: Scalars['String']['output'];+ id: Scalars['UUID']['output'];+ name: Scalars['String']['output'];+ runtime: Scalars['String']['output'];+ sourceCodeFullPath: Scalars['String']['output'];+ sourceCodeHash: Scalars['String']['output'];+ syncStatus: ServerlessFunctionSyncStatus;+ updatedAt: Scalars['DateTime']['output'];+};+export type ServerlessFunctionConnection = {__typename?: 'ServerlessFunctionConnection';/** Array of edges. */@@ -974,12 +1021,36 @@ export type ServerlessFunctionConnection = {pageInfo: PageInfo;};+export type ServerlessFunctionEdge = {+ __typename?: 'ServerlessFunctionEdge';+ /** Cursor for this node. */+ cursor: Scalars['ConnectionCursor']['output'];+ /** The node containing the ServerlessFunction */+ node: ServerlessFunction;+};+export type ServerlessFunctionExecutionResult = {__typename?: 'ServerlessFunctionExecutionResult';/** Execution result in JSON format */result: Scalars['JSON']['output'];};+export type ServerlessFunctionFilter = {+ and?: InputMaybe<Array<ServerlessFunctionFilter>>;+ id?: InputMaybe<UuidFilterComparison>;+ or?: InputMaybe<Array<ServerlessFunctionFilter>>;+};++export type ServerlessFunctionSort = {+ direction: SortDirection;+ field: ServerlessFunctionSortFields;+ nulls?: InputMaybe<SortNulls>;+};++export enum ServerlessFunctionSortFields {+ Id = 'id'+}+/** SyncStatus of the serverlessFunction */export enum ServerlessFunctionSyncStatus {NotReady = 'NOT_READY',@@ -1171,6 +1242,14 @@ export type UpdateRemoteServerInput = {userMappingOptions?: InputMaybe<UserMappingOptionsUpdateInput>;};+export type UpdateServerlessFunctionInput = {+ code: Scalars['String']['input'];+ description?: InputMaybe<Scalars['String']['input']>;+ /** Id of the serverless function to execute */+ id: Scalars['UUID']['input'];+ name: Scalars['String']['input'];+};+export type UpdateWorkspaceInput = {allowImpersonation?: InputMaybe<Scalars['Boolean']['input']>;displayName?: InputMaybe<Scalars['String']['input']>;@@ -1413,40 +1492,6 @@ export type RelationEdge = {node: Relation;};-export type ServerlessFunction = {- __typename?: 'serverlessFunction';- createdAt: Scalars['DateTime']['output'];- id: Scalars['UUID']['output'];- name: Scalars['String']['output'];- sourceCodeHash: Scalars['String']['output'];- syncStatus: ServerlessFunctionSyncStatus;- updatedAt: Scalars['DateTime']['output'];-};--export type ServerlessFunctionEdge = {- __typename?: 'serverlessFunctionEdge';- /** Cursor for this node. */- cursor: Scalars['ConnectionCursor']['output'];- /** The node containing the serverlessFunction */- node: ServerlessFunction;-};--export type ServerlessFunctionFilter = {- and?: InputMaybe<Array<ServerlessFunctionFilter>>;- id?: InputMaybe<UuidFilterComparison>;- or?: InputMaybe<Array<ServerlessFunctionFilter>>;-};--export type ServerlessFunctionSort = {- direction: SortDirection;- field: ServerlessFunctionSortFields;- nulls?: InputMaybe<SortNulls>;-};--export enum ServerlessFunctionSortFields {- Id = 'id'-}-export type RemoteServerFieldsFragment = { __typename?: 'RemoteServer', id: string, createdAt: any, foreignDataWrapperId: string, foreignDataWrapperOptions?: any | null, foreignDataWrapperType: string, updatedAt: any, schema?: string | null, label: string, userMappingOptions?: { __typename?: 'UserMappingOptionsUser', user?: string | null } | null };export type RemoteTableFieldsFragment = { __typename?: 'RemoteTable', id?: any | null, name: string, schema?: string | null, status: RemoteTableStatus, schemaPendingUpdates?: Array<DistantTableUpdate> | null };@@ -1580,8 +1625,52 @@ 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, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, createdAt: any, updatedAt: any };++export type CreateOneServerlessFunctionItemMutationVariables = Exact<{+ input: CreateServerlessFunctionInput;+}>;+++export type CreateOneServerlessFunctionItemMutation = { __typename?: 'Mutation', createOneServerlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description: string, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, createdAt: any, updatedAt: any } };++export type DeleteOneServerlessFunctionMutationVariables = Exact<{+ input: DeleteServerlessFunctionInput;+}>;+++export type DeleteOneServerlessFunctionMutation = { __typename?: 'Mutation', deleteOneServerlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description: string, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, createdAt: any, updatedAt: any } };++export type ExecuteOneServerlessFunctionMutationVariables = Exact<{+ id: Scalars['UUID']['input'];+ payload: Scalars['JSON']['input'];+}>;+++export type ExecuteOneServerlessFunctionMutation = { __typename?: 'Mutation', executeOneServerlessFunction: { __typename?: 'ServerlessFunctionExecutionResult', result: any } };++export type UpdateOneServerlessFunctionMutationVariables = Exact<{+ input: UpdateServerlessFunctionInput;+}>;+++export type UpdateOneServerlessFunctionMutation = { __typename?: 'Mutation', updateOneServerlessFunction: { __typename?: 'ServerlessFunction', id: any, name: string, description: string, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, 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, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, 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, sourceCodeHash: string, sourceCodeFullPath: string, runtime: string, syncStatus: ServerlessFunctionSyncStatus, createdAt: any, updatedAt: any } };+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 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>;@@ -1599,4 +1688,10 @@ export const UpdateOneObjectMetadataItemDocument = {"kind":"Document","definitioexport const DeleteOneObjectMetadataItemDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteOneObjectMetadataItem"},"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":"deleteOneObject"},"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":"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":"isActive"}},{"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"}}]}}]}}]} as unknown as DocumentNode<DeleteOneObjectMetadataItemMutation, DeleteOneObjectMetadataItemMutationVariables>;export 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>;\ No newline at end of file+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":"result"}}]}}]}}]} 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>;diff --git a/packages/twenty-front/src/generated/graphql.tsx b/packages/twenty-front/src/generated/graphql.tsxindex 4bf49074e0f..20e35079ead 100644--- a/packages/twenty-front/src/generated/graphql.tsx+++ b/packages/twenty-front/src/generated/graphql.tsx@@ -692,6 +692,19 @@ export type Sentry = {release?: Maybe<Scalars['String']>;};+export type ServerlessFunction = {+ __typename?: 'ServerlessFunction';+ createdAt: Scalars['DateTime'];+ description: Scalars['String'];+ id: Scalars['UUID'];+ name: Scalars['String'];+ runtime: Scalars['String'];+ sourceCodeFullPath: Scalars['String'];+ sourceCodeHash: Scalars['String'];+ syncStatus: ServerlessFunctionSyncStatus;+ updatedAt: Scalars['DateTime'];+};+export type ServerlessFunctionConnection = {__typename?: 'ServerlessFunctionConnection';/** Array of edges. */@@ -700,6 +713,14 @@ export type ServerlessFunctionConnection = {pageInfo: PageInfo;};+export type ServerlessFunctionEdge = {+ __typename?: 'ServerlessFunctionEdge';+ /** Cursor for this node. */+ cursor: Scalars['ConnectionCursor'];+ /** The node containing the ServerlessFunction */+ node: ServerlessFunction;+};+export type ServerlessFunctionExecutionResult = {__typename?: 'ServerlessFunctionExecutionResult';/** Execution result in JSON format */@@ -1090,24 +1111,6 @@ export type RelationEdge = {node: Relation;};-export type ServerlessFunction = {- __typename?: 'serverlessFunction';- createdAt: Scalars['DateTime'];- id: Scalars['UUID'];- name: Scalars['String'];- sourceCodeHash: Scalars['String'];- syncStatus: ServerlessFunctionSyncStatus;- updatedAt: Scalars['DateTime'];-};--export type ServerlessFunctionEdge = {- __typename?: 'serverlessFunctionEdge';- /** Cursor for this node. */- cursor: Scalars['ConnectionCursor'];- /** The node containing the serverlessFunction */- node: ServerlessFunction;-};-export type TimelineCalendarEventFragmentFragment = { __typename?: 'TimelineCalendarEvent', id: any, title: string, description: string, location: string, startsAt: string, endsAt: string, isFullDay: boolean, visibility: CalendarChannelVisibility, participants: Array<{ __typename?: 'TimelineCalendarEventParticipant', personId?: any | null, workspaceMemberId?: any | null, firstName: string, lastName: string, displayName: string, avatarUrl: string, handle: string }> };export type TimelineCalendarEventParticipantFragmentFragment = { __typename?: 'TimelineCalendarEventParticipant', personId?: any | null, workspaceMemberId?: any | null, firstName: string, lastName: string, displayName: string, avatarUrl: string, handle: string };diff --git a/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx b/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsxindex 57f020cedb7..f28727eb5a8 100644--- a/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx+++ b/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx@@ -23,13 +23,13 @@ import { RightDrawerHotkeyScope } from '@/ui/layout/right-drawer/types/RightDrawimport { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';import { isNonTextWritingKey } from '@/ui/utilities/hotkey/utils/isNonTextWritingKey';-import { REACT_APP_SERVER_BASE_URL } from '~/config';import { FileFolder, useUploadFileMutation } from '~/generated/graphql';import { isDefined } from '~/utils/isDefined';import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';import { getFileType } from '../files/utils/getFileType';+import { getFileAbsoluteURI } from '~/utils/file/getFileAbsoluteURI';import '@blocknote/core/fonts/inter.css';import '@blocknote/mantine/style.css';@@ -127,9 +127,7 @@ export const ActivityBodyEditor = ({if (!result?.data?.uploadFile) {throw new Error("Couldn't upload Image");}- const imageUrl =- REACT_APP_SERVER_BASE_URL + '/files/' + result?.data?.uploadFile;- return imageUrl;+ return getFileAbsoluteURI(result.data.uploadFile);};const handlePersistBody = useCallback(diff --git a/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx b/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsxindex 68cd89335ca..691ebb74650 100644--- a/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx+++ b/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx@@ -13,8 +13,8 @@ import {FieldContext,GenericFieldContextType,} from '@/object-record/record-field/contexts/FieldContext';-import { REACT_APP_SERVER_BASE_URL } from '~/config';import { formatToHumanReadableDate } from '~/utils/date-utils';+import { getFileAbsoluteURI } from '~/utils/file/getFileAbsoluteURI';const StyledRow = styled.div`align-items: center;@@ -76,7 +76,7 @@ export const AttachmentRow = ({ attachment }: { attachment: Attachment }) => {<StyledLeftContent><AttachmentIcon attachmentType={attachment.type} /><StyledLink- href={REACT_APP_SERVER_BASE_URL + '/files/' + attachment.fullPath}+ href={getFileAbsoluteURI(attachment.fullPath)}target="__blank">{attachment.name}diff --git a/packages/twenty-front/src/modules/activities/files/utils/downloadFile.ts b/packages/twenty-front/src/modules/activities/files/utils/downloadFile.tsindex dc354264eea..5dd7e6c0015 100644--- a/packages/twenty-front/src/modules/activities/files/utils/downloadFile.ts+++ b/packages/twenty-front/src/modules/activities/files/utils/downloadFile.ts@@ -1,7 +1,7 @@-import { REACT_APP_SERVER_BASE_URL } from '~/config';+import { getFileAbsoluteURI } from '~/utils/file/getFileAbsoluteURI';export const downloadFile = (fullPath: string, fileName: string) => {- fetch(REACT_APP_SERVER_BASE_URL + '/files/' + fullPath)+ fetch(getFileAbsoluteURI(fullPath)).then((resp) =>resp.status === 200? resp.blob()diff --git a/packages/twenty-front/src/modules/settings/components/SettingsNavigationDrawerItems.tsx b/packages/twenty-front/src/modules/settings/components/SettingsNavigationDrawerItems.tsxindex 426eabe21ae..c87f636a66d 100644--- a/packages/twenty-front/src/modules/settings/components/SettingsNavigationDrawerItems.tsx+++ b/packages/twenty-front/src/modules/settings/components/SettingsNavigationDrawerItems.tsx@@ -13,6 +13,7 @@ import {IconSettings,IconUserCircle,IconUsers,+ IconFunction,} from 'twenty-ui';import { useAuth } from '@/auth/hooks/useAuth';@@ -29,6 +30,9 @@ export const SettingsNavigationDrawerItems = () => {const { signOut } = useAuth();const billing = useRecoilValue(billingState);+ const isFunctionSettingsEnabled = useIsFeatureEnabled(+ 'IS_FUNCTION_SETTINGS_ENABLED',+ );const isCRMMigrationEnabled = useIsFeatureEnabled('IS_CRM_MIGRATION_ENABLED');return (@@ -99,6 +103,13 @@ export const SettingsNavigationDrawerItems = () => {path={SettingsPath.Developers}Icon={IconCode}/>+ {isFunctionSettingsEnabled && (+ <SettingsNavigationDrawerItem+ label="Functions"+ path={SettingsPath.ServerlessFunctions}+ Icon={IconFunction}+ />+ )}<SettingsNavigationDrawerItemlabel="Integrations"path={SettingsPath.Integrations}diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionNewForm.tsx b/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionNewForm.tsxnew file mode 100644index 00000000000..b9ba77a74ce--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionNewForm.tsx@@ -0,0 +1,41 @@+import { H2Title } from 'twenty-ui';+import { Section } from '@/ui/layout/section/components/Section';+import { TextInput } from '@/ui/input/components/TextInput';+import { TextArea } from '@/ui/input/components/TextArea';+import styled from '@emotion/styled';+import { ServerlessFunctionNewFormValues } from '@/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState';++const StyledInputsContainer = styled.div`+ display: flex;+ flex-direction: column;+ gap: ${({ theme }) => theme.spacing(4)};+`;++export const SettingsServerlessFunctionNewForm = ({+ formValues,+ onChange,+}: {+ formValues: ServerlessFunctionNewFormValues;+ onChange: (key: string) => (value: string) => void;+}) => {+ return (+ <Section>+ <H2Title title="About" description="Name and set your function" />+ <StyledInputsContainer>+ <TextInput+ placeholder="Name"+ fullWidth+ focused+ value={formValues.name}+ onChange={onChange('name')}+ />+ <TextArea+ placeholder="Description"+ minRows={4}+ value={formValues.description}+ onChange={onChange('description')}+ />+ </StyledInputsContainer>+ </Section>+ );+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionsFieldItemTableRow.tsx b/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionsFieldItemTableRow.tsxnew file mode 100644index 00000000000..3dd14998814--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionsFieldItemTableRow.tsx@@ -0,0 +1,46 @@+import styled from '@emotion/styled';+import { TableRow } from '@/ui/layout/table/components/TableRow';+import { ServerlessFunction } from '~/generated-metadata/graphql';+import { TableCell } from '@/ui/layout/table/components/TableCell';+import { IconChevronRight } from 'twenty-ui';+import { useTheme } from '@emotion/react';++export const StyledApisFieldTableRow = styled(TableRow)`+ grid-template-columns: 312px 132px 68px;+`;++const StyledNameTableCell = styled(TableCell)`+ color: ${({ theme }) => theme.font.color.primary};+ gap: ${({ theme }) => theme.spacing(2)};+`;++const StyledIconTableCell = styled(TableCell)`+ justify-content: center;+ padding-right: ${({ theme }) => theme.spacing(1)};+`;++const StyledIconChevronRight = styled(IconChevronRight)`+ color: ${({ theme }) => theme.font.color.tertiary};+`;++export const SettingsServerlessFunctionsFieldItemTableRow = ({+ serverlessFunction,+ to,+}: {+ serverlessFunction: ServerlessFunction;+ to: string;+}) => {+ const theme = useTheme();+ return (+ <StyledApisFieldTableRow to={to}>+ <StyledNameTableCell>{serverlessFunction.name}</StyledNameTableCell>+ <StyledNameTableCell>{serverlessFunction.runtime}</StyledNameTableCell>+ <StyledIconTableCell>+ <StyledIconChevronRight+ size={theme.icon.size.md}+ stroke={theme.icon.stroke.sm}+ />+ </StyledIconTableCell>+ </StyledApisFieldTableRow>+ );+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionsTable.tsx b/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionsTable.tsxnew file mode 100644index 00000000000..a0afe897e86--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionsTable.tsx@@ -0,0 +1,51 @@+import { TableHeader } from '@/ui/layout/table/components/TableHeader';+import { Table } from '@/ui/layout/table/components/Table';+import styled from '@emotion/styled';+import { TableRow } from '@/ui/layout/table/components/TableRow';+import { TableBody } from '@/ui/layout/table/components/TableBody';+import { useGetManyServerlessFunctions } from '@/settings/serverless-functions/hooks/useGetManyServerlessFunctions';+import { SettingsServerlessFunctionsFieldItemTableRow } from '@/settings/serverless-functions/components/SettingsServerlessFunctionsFieldItemTableRow';+import { ServerlessFunction } from '~/generated-metadata/graphql';+import { SettingsServerlessFunctionsTableEmpty } from '@/settings/serverless-functions/components/SettingsServerlessFunctionsTableEmpty';+import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';+import { SettingsPath } from '@/types/SettingsPath';++const StyledTableRow = styled(TableRow)`+ grid-template-columns: 312px 132px 68px;+`;++const StyledTableBody = styled(TableBody)`+ border-bottom: 1px solid ${({ theme }) => theme.border.color.light};+`;++export const SettingsServerlessFunctionsTable = () => {+ const { serverlessFunctions } = useGetManyServerlessFunctions();+ return (+ <>+ {serverlessFunctions.length ? (+ <Table>+ <StyledTableRow>+ <TableHeader>Name</TableHeader>+ <TableHeader>Runtime</TableHeader>+ <TableHeader></TableHeader>+ </StyledTableRow>+ <StyledTableBody>+ {serverlessFunctions.map(+ (serverlessFunction: ServerlessFunction) => (+ <SettingsServerlessFunctionsFieldItemTableRow+ key={serverlessFunction.id}+ serverlessFunction={serverlessFunction}+ to={getSettingsPagePath(SettingsPath.ServerlessFunctions, {+ id: serverlessFunction.id,+ })}+ />+ ),+ )}+ </StyledTableBody>+ </Table>+ ) : (+ <SettingsServerlessFunctionsTableEmpty />+ )}+ </>+ );+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionsTableEmpty.tsx b/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionsTableEmpty.tsxnew file mode 100644index 00000000000..4f5744019f2--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/components/SettingsServerlessFunctionsTableEmpty.tsx@@ -0,0 +1,43 @@+import {+ AnimatedPlaceholderEmptyContainer,+ AnimatedPlaceholderEmptySubTitle,+ AnimatedPlaceholderEmptyTextContainer,+ AnimatedPlaceholderEmptyTitle,+ EMPTY_PLACEHOLDER_TRANSITION_PROPS,+} from '@/ui/layout/animated-placeholder/components/EmptyPlaceholderStyled';+import AnimatedPlaceholder from '@/ui/layout/animated-placeholder/components/AnimatedPlaceholder';+import { IconPlus } from 'twenty-ui';+import { Button } from '@/ui/input/button/components/Button';+import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';+import { SettingsPath } from '@/types/SettingsPath';+import styled from '@emotion/styled';++const StyledEmptyFunctionsContainer = styled.div`+ height: 60vh;+`;++export const SettingsServerlessFunctionsTableEmpty = () => {+ return (+ <StyledEmptyFunctionsContainer>+ <AnimatedPlaceholderEmptyContainer+ // eslint-disable-next-line react/jsx-props-no-spreading+ {...EMPTY_PLACEHOLDER_TRANSITION_PROPS}+ >+ <AnimatedPlaceholder type="emptyFunctions" />+ <AnimatedPlaceholderEmptyTextContainer>+ <AnimatedPlaceholderEmptyTitle>+ Add your first Function+ </AnimatedPlaceholderEmptyTitle>+ <AnimatedPlaceholderEmptySubTitle>+ Add your first Function to get started+ </AnimatedPlaceholderEmptySubTitle>+ </AnimatedPlaceholderEmptyTextContainer>+ <Button+ Icon={IconPlus}+ title="New function"+ to={getSettingsPagePath(SettingsPath.NewServerlessFunction)}+ />+ </AnimatedPlaceholderEmptyContainer>+ </StyledEmptyFunctionsContainer>+ );+};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.tsxnew file mode 100644index 00000000000..a74a0889dc2--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionCodeEditorTab.tsx@@ -0,0 +1,60 @@+import { H2Title, IconPlayerPlay } 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';+import { Button } from '@/ui/input/button/components/Button';+import { CoreEditorHeader } from '@/ui/input/code-editor/components/CodeEditorHeader';+import styled from '@emotion/styled';+import { TabList } from '@/ui/layout/tab/components/TabList';++const StyledTabList = styled(TabList)`+ border-bottom: none;+`;++export const SettingsServerlessFunctionCodeEditorTab = ({+ formValues,+ handleExecute,+ onChange,+}: {+ formValues: ServerlessFunctionFormValues;+ handleExecute: () => void;+ onChange: (key: string) => (value: string) => void;+}) => {+ const HeaderButton = (+ <Button+ title="Test"+ variant="primary"+ accent="blue"+ size="small"+ Icon={IconPlayerPlay}+ onClick={handleExecute}+ />+ );++ const TAB_LIST_COMPONENT_ID = 'serverless-function-editor';++ const HeaderTabList = (+ <StyledTabList+ tabListId={TAB_LIST_COMPONENT_ID}+ tabs={[{ id: 'index.ts', title: 'index.ts' }]}+ />+ );++ const Header = (+ <CoreEditorHeader leftNodes={[HeaderTabList]} rightNodes={[HeaderButton]} />+ );++ return (+ <Section>+ <H2Title+ title="Code your function"+ description="Write your function (in typescript) below"+ />+ <CodeEditor+ value={formValues.code}+ onChange={onChange('code')}+ header={Header}+ />+ </Section>+ );+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionSettingsTab.tsx b/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionSettingsTab.tsxnew file mode 100644index 00000000000..aeff1e71399--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionSettingsTab.tsx@@ -0,0 +1,62 @@+import { H2Title } from 'twenty-ui';+import { Section } from '@/ui/layout/section/components/Section';+import { ServerlessFunctionFormValues } from '@/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState';+import { Button } from '@/ui/input/button/components/Button';+import { useState } from 'react';+import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';+import { SettingsServerlessFunctionNewForm } from '@/settings/serverless-functions/components/SettingsServerlessFunctionNewForm';+import { useDeleteOneServerlessFunction } from '@/settings/serverless-functions/hooks/useDeleteOneServerlessFunction';+import { useNavigate } from 'react-router-dom';++export const SettingsServerlessFunctionSettingsTab = ({+ formValues,+ serverlessFunctionId,+ onChange,+}: {+ formValues: ServerlessFunctionFormValues;+ serverlessFunctionId: string;+ onChange: (key: string) => (value: string) => void;+}) => {+ const navigate = useNavigate();+ const [isDeleteFunctionModalOpen, setIsDeleteFunctionModalOpen] =+ useState(false);+ const { deleteOneServerlessFunction } = useDeleteOneServerlessFunction();++ const deleteFunction = async () => {+ await deleteOneServerlessFunction({ id: serverlessFunctionId });+ navigate('/settings/functions');+ };+ return (+ <>+ <SettingsServerlessFunctionNewForm+ formValues={formValues}+ onChange={onChange}+ />+ <Section>+ <H2Title title="Danger zone" description="Delete this function" />+ <Button+ accent="danger"+ onClick={() => setIsDeleteFunctionModalOpen(true)}+ variant="secondary"+ size="small"+ title="Delete function"+ />+ </Section>+ <ConfirmationModal+ confirmationValue={formValues.name}+ confirmationPlaceholder={formValues.name}+ isOpen={isDeleteFunctionModalOpen}+ setIsOpen={setIsDeleteFunctionModalOpen}+ title="Function Deletion"+ subtitle={+ <>+ This action cannot be undone. This will permanently delete your+ function. <br /> Please type in the function name to confirm.+ </>+ }+ onConfirmClick={deleteFunction}+ deleteButtonText="Delete function"+ />+ </>+ );+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTab.tsx b/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTab.tsxnew file mode 100644index 00000000000..d6209611243--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTab.tsx@@ -0,0 +1,81 @@+import { H2Title, IconPlayerPlay } from 'twenty-ui';+import { Section } from '@/ui/layout/section/components/Section';++import { CodeEditor } from '@/ui/input/code-editor/components/CodeEditor';+import styled from '@emotion/styled';+import { CoreEditorHeader } from '@/ui/input/code-editor/components/CodeEditorHeader';+import { Button } from '@/ui/input/button/components/Button';+import { LightCopyIconButton } from '@/object-record/record-field/components/LightCopyIconButton';+import { useRecoilState, useRecoilValue } from 'recoil';+import { settingsServerlessFunctionOutputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionOutputState';+import { settingsServerlessFunctionInputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionInputState';+import { settingsServerlessFunctionCodeEditorOutputParamsState } from '@/settings/serverless-functions/states/settingsServerlessFunctionCodeEditorOutputParamsState';++const StyledInputsContainer = styled.div`+ display: flex;+ flex-direction: column;+ gap: ${({ theme }) => theme.spacing(4)};+`;++export const SettingsServerlessFunctionTestTab = ({+ handleExecute,+}: {+ handleExecute: () => void;+}) => {+ const settingsServerlessFunctionCodeEditorOutputParams = useRecoilValue(+ settingsServerlessFunctionCodeEditorOutputParamsState,+ );+ const settingsServerlessFunctionOutput = useRecoilValue(+ settingsServerlessFunctionOutputState,+ );+ const [settingsServerlessFunctionInput, setSettingsServerlessFunctionInput] =+ useRecoilState(settingsServerlessFunctionInputState);++ const InputHeaderButton = (+ <Button+ title="Run Function"+ variant="primary"+ accent="blue"+ size="small"+ Icon={IconPlayerPlay}+ onClick={handleExecute}+ />+ );++ const InputHeader = (+ <CoreEditorHeader title={'Input'} rightNodes={[InputHeaderButton]} />+ );++ const OutputHeaderButton = (+ <LightCopyIconButton copyText={settingsServerlessFunctionOutput} />+ );++ const OutputHeader = (+ <CoreEditorHeader title={'Output'} rightNodes={[OutputHeaderButton]} />+ );++ return (+ <Section>+ <H2Title+ title="Test your function"+ description='Insert a JSON input, then press "Run" to test your function.'+ />+ <StyledInputsContainer>+ <CodeEditor+ value={settingsServerlessFunctionInput}+ height={200}+ onChange={setSettingsServerlessFunctionInput}+ language={'json'}+ header={InputHeader}+ />+ <CodeEditor+ value={settingsServerlessFunctionOutput}+ height={settingsServerlessFunctionCodeEditorOutputParams.height}+ language={settingsServerlessFunctionCodeEditorOutputParams.language}+ options={{ readOnly: true, domReadOnly: true }}+ header={OutputHeader}+ />+ </StyledInputsContainer>+ </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.tsxnew file mode 100644index 00000000000..67ac1e7ea84--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTabEffect.tsx@@ -0,0 +1,23 @@+import React from 'react';+import { useRecoilValue, useSetRecoilState } from 'recoil';+import { settingsServerlessFunctionOutputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionOutputState';+import { settingsServerlessFunctionCodeEditorOutputParamsState } from '@/settings/serverless-functions/states/settingsServerlessFunctionCodeEditorOutputParamsState';++export const SettingsServerlessFunctionTestTabEffect = () => {+ const settingsServerlessFunctionOutput = useRecoilValue(+ settingsServerlessFunctionOutputState,+ );+ const setSettingsServerlessFunctionCodeEditorOutputParams = useSetRecoilState(+ settingsServerlessFunctionCodeEditorOutputParamsState,+ );+ try {+ JSON.parse(settingsServerlessFunctionOutput);+ setSettingsServerlessFunctionCodeEditorOutputParams({+ language: 'json',+ height: 300,+ });+ } catch {+ return <></>;+ }+ 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.tsnew file mode 100644index 00000000000..dc48df97d08--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment.ts@@ -0,0 +1,15 @@+import { gql } from '@apollo/client';++export const SERVERLESS_FUNCTION_FRAGMENT = gql`+ fragment ServerlessFunctionFields on ServerlessFunction {+ id+ name+ description+ sourceCodeHash+ sourceCodeFullPath+ runtime+ syncStatus+ createdAt+ updatedAt+ }+`;diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/createOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/createOneServerlessFunction.tsnew file mode 100644index 00000000000..162eddff80a--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/createOneServerlessFunction.ts@@ -0,0 +1,13 @@+import { gql } from '@apollo/client';+import { SERVERLESS_FUNCTION_FRAGMENT } from '@/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment';++export const CREATE_ONE_SERVERLESS_FUNCTION = gql`+ ${SERVERLESS_FUNCTION_FRAGMENT}+ mutation CreateOneServerlessFunctionItem(+ $input: CreateServerlessFunctionInput!+ ) {+ createOneServerlessFunction(input: $input) {+ ...ServerlessFunctionFields+ }+ }+`;diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/deleteOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/deleteOneServerlessFunction.tsnew file mode 100644index 00000000000..5b2b0325b08--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/deleteOneServerlessFunction.ts@@ -0,0 +1,11 @@+import { gql } from '@apollo/client';+import { SERVERLESS_FUNCTION_FRAGMENT } from '@/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment';++export const DELETE_ONE_SERVERLESS_FUNCTION = gql`+ ${SERVERLESS_FUNCTION_FRAGMENT}+ mutation DeleteOneServerlessFunction($input: DeleteServerlessFunctionInput!) {+ deleteOneServerlessFunction(input: $input) {+ ...ServerlessFunctionFields+ }+ }+`;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.tsnew file mode 100644index 00000000000..050ac816e96--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/executeOneServerlessFunction.ts@@ -0,0 +1,9 @@+import { gql } from '@apollo/client';++export const EXECUTE_ONE_SERVERLESS_FUNCTION = gql`+ mutation ExecuteOneServerlessFunction($id: UUID!, $payload: JSON!) {+ executeOneServerlessFunction(id: $id, payload: $payload) {+ result+ }+ }+`;diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/updateOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/updateOneServerlessFunction.tsnew file mode 100644index 00000000000..bfa648a613d--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/mutations/updateOneServerlessFunction.ts@@ -0,0 +1,11 @@+import { gql } from '@apollo/client';+import { SERVERLESS_FUNCTION_FRAGMENT } from '@/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment';++export const UPDATE_ONE_SERVERLESS_FUNCTION = gql`+ ${SERVERLESS_FUNCTION_FRAGMENT}+ mutation UpdateOneServerlessFunction($input: UpdateServerlessFunctionInput!) {+ updateOneServerlessFunction(input: $input) {+ ...ServerlessFunctionFields+ }+ }+`;diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/queries/findManyServerlessFunctions.ts b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/queries/findManyServerlessFunctions.tsnew file mode 100644index 00000000000..dfa0ca15589--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/queries/findManyServerlessFunctions.ts@@ -0,0 +1,15 @@+import { gql } from '@apollo/client';+import { SERVERLESS_FUNCTION_FRAGMENT } from '@/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment';++export const FIND_MANY_SERVERLESS_FUNCTIONS = gql`+ ${SERVERLESS_FUNCTION_FRAGMENT}+ query GetManyServerlessFunctions {+ serverlessFunctions(paging: { first: 100 }) {+ edges {+ node {+ ...ServerlessFunctionFields+ }+ }+ }+ }+`;diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/graphql/queries/findOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/queries/findOneServerlessFunction.tsnew file mode 100644index 00000000000..f5ed4d3f273--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/graphql/queries/findOneServerlessFunction.ts@@ -0,0 +1,11 @@+import { gql } from '@apollo/client';+import { SERVERLESS_FUNCTION_FRAGMENT } from '@/settings/serverless-functions/graphql/fragments/serverlessFunctionFragment';++export const FIND_ONE_SERVERLESS_FUNCTION = gql`+ ${SERVERLESS_FUNCTION_FRAGMENT}+ query GetOneServerlessFunction($id: UUID!) {+ serverlessFunction(id: $id) {+ ...ServerlessFunctionFields+ }+ }+`;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.tsnew file mode 100644index 00000000000..e243fb4d860--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/__tests__/useServerlessFunctionUpdateFormState.test.ts@@ -0,0 +1,34 @@+import { renderHook } from '@testing-library/react';+import { useServerlessFunctionUpdateFormState } from '@/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState';+import { RecoilRoot } from 'recoil';++jest.mock(+ '@/settings/serverless-functions/hooks/useGetOneServerlessFunction',+ () => ({+ useGetOneServerlessFunction: jest.fn(),+ }),+);++describe('useServerlessFunctionUpdateFormState', () => {+ test('should return a form', () => {+ const serverlessFunctionId = 'serverlessFunctionId';+ const useGetOneServerlessFunctionMock = jest.requireMock(+ '@/settings/serverless-functions/hooks/useGetOneServerlessFunction',+ );+ useGetOneServerlessFunctionMock.useGetOneServerlessFunction.mockReturnValue(+ {+ serverlessFunction: { sourceCodeFullPath: undefined },+ },+ );+ const { result } = renderHook(+ () => useServerlessFunctionUpdateFormState(serverlessFunctionId),+ {+ wrapper: RecoilRoot,+ },+ );++ const [formValues] = result.current;++ expect(formValues).toEqual({ name: '', description: '', code: '' });+ });+});diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useCreateOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useCreateOneServerlessFunction.tsnew file mode 100644index 00000000000..427f98466e3--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useCreateOneServerlessFunction.ts@@ -0,0 +1,35 @@+import { ApolloClient, useMutation } from '@apollo/client';++import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';+import {+ CreateServerlessFunctionInput,+ CreateOneServerlessFunctionItemMutation,+ CreateOneServerlessFunctionItemMutationVariables,+} from '~/generated-metadata/graphql';+import { getOperationName } from '@apollo/client/utilities';+import { FIND_MANY_SERVERLESS_FUNCTIONS } from '@/settings/serverless-functions/graphql/queries/findManyServerlessFunctions';+import { CREATE_ONE_SERVERLESS_FUNCTION } from '@/settings/serverless-functions/graphql/mutations/createOneServerlessFunction';++export const useCreateOneServerlessFunction = () => {+ const apolloMetadataClient = useApolloMetadataClient();+ const [mutate] = useMutation<+ CreateOneServerlessFunctionItemMutation,+ CreateOneServerlessFunctionItemMutationVariables+ >(CREATE_ONE_SERVERLESS_FUNCTION, {+ client: apolloMetadataClient ?? ({} as ApolloClient<any>),+ });++ const createOneServerlessFunction = async (+ input: CreateServerlessFunctionInput,+ ) => {+ return await mutate({+ variables: {+ input,+ },+ awaitRefetchQueries: true,+ refetchQueries: [getOperationName(FIND_MANY_SERVERLESS_FUNCTIONS) ?? ''],+ });+ };++ return { createOneServerlessFunction };+};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.tsnew file mode 100644index 00000000000..1a4d66fdf9c--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useDeleteOneServerlessFunction.ts@@ -0,0 +1,34 @@+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';++export const useDeleteOneServerlessFunction = () => {+ const apolloMetadataClient = useApolloMetadataClient();+ const [mutate] = useMutation<+ DeleteOneServerlessFunctionMutation,+ DeleteOneServerlessFunctionMutationVariables+ >(DELETE_ONE_SERVERLESS_FUNCTION, {+ client: apolloMetadataClient ?? ({} as ApolloClient<any>),+ });++ const deleteOneServerlessFunction = async (+ input: DeleteServerlessFunctionInput,+ ) => {+ return await mutate({+ variables: {+ input,+ },+ awaitRefetchQueries: true,+ refetchQueries: [getOperationName(FIND_MANY_SERVERLESS_FUNCTIONS) ?? ''],+ });+ };++ return { deleteOneServerlessFunction };+};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.tsnew file mode 100644index 00000000000..84394ac20a6--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useExecuteOneServerlessFunction.ts@@ -0,0 +1,30 @@+import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';+import { ApolloClient, useMutation } from '@apollo/client';+import { EXECUTE_ONE_SERVERLESS_FUNCTION } from '@/settings/serverless-functions/graphql/mutations/executeOneServerlessFunction';+import {+ ExecuteOneServerlessFunctionMutation,+ ExecuteOneServerlessFunctionMutationVariables,+} from '~/generated-metadata/graphql';++export const useExecuteOneServerlessFunction = () => {+ const apolloMetadataClient = useApolloMetadataClient();+ const [mutate] = useMutation<+ ExecuteOneServerlessFunctionMutation,+ ExecuteOneServerlessFunctionMutationVariables+ >(EXECUTE_ONE_SERVERLESS_FUNCTION, {+ client: apolloMetadataClient ?? ({} as ApolloClient<any>),+ });++ const executeOneServerlessFunction = async (+ id: string,+ payload: object = {},+ ) => {+ return await mutate({+ variables: {+ id,+ payload,+ },+ });+ };+ return { executeOneServerlessFunction };+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useGetManyServerlessFunctions.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useGetManyServerlessFunctions.tsnew file mode 100644index 00000000000..eff46a628ed--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useGetManyServerlessFunctions.ts@@ -0,0 +1,21 @@+import { useQuery } from '@apollo/client';+import { FIND_MANY_SERVERLESS_FUNCTIONS } from '@/settings/serverless-functions/graphql/queries/findManyServerlessFunctions';+import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';+import {+ GetManyServerlessFunctionsQuery,+ GetManyServerlessFunctionsQueryVariables,+} from '~/generated-metadata/graphql';++export const useGetManyServerlessFunctions = () => {+ const apolloMetadataClient = useApolloMetadataClient();+ const { data } = useQuery<+ GetManyServerlessFunctionsQuery,+ GetManyServerlessFunctionsQueryVariables+ >(FIND_MANY_SERVERLESS_FUNCTIONS, {+ client: apolloMetadataClient ?? undefined,+ });+ return {+ serverlessFunctions:+ data?.serverlessFunctions?.edges.map(({ node }) => node) || [],+ };+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useGetOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useGetOneServerlessFunction.tsnew file mode 100644index 00000000000..8d22a217455--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useGetOneServerlessFunction.ts@@ -0,0 +1,23 @@+import { useQuery } from '@apollo/client';+import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';+import { FIND_ONE_SERVERLESS_FUNCTION } from '@/settings/serverless-functions/graphql/queries/findOneServerlessFunction';+import {+ GetOneServerlessFunctionQuery,+ GetOneServerlessFunctionQueryVariables,+} from '~/generated-metadata/graphql';++export const useGetOneServerlessFunction = (id: string) => {+ const apolloMetadataClient = useApolloMetadataClient();+ const { data } = useQuery<+ GetOneServerlessFunctionQuery,+ GetOneServerlessFunctionQueryVariables+ >(FIND_ONE_SERVERLESS_FUNCTION, {+ client: apolloMetadataClient ?? undefined,+ variables: {+ id,+ },+ });+ return {+ serverlessFunction: data?.serverlessFunction || null,+ };+};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.tsnew file mode 100644index 00000000000..f1055751879--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState.ts@@ -0,0 +1,57 @@+import { Dispatch, SetStateAction, useEffect, useState } from 'react';+import { getFileAbsoluteURI } from '~/utils/file/getFileAbsoluteURI';+import { isDefined } from '~/utils/isDefined';+import { useGetOneServerlessFunction } from '@/settings/serverless-functions/hooks/useGetOneServerlessFunction';++export type ServerlessFunctionNewFormValues = {+ name: string;+ description: string;+};++export type ServerlessFunctionFormValues = ServerlessFunctionNewFormValues & {+ code: string;+};++type SetServerlessFunctionFormValues = Dispatch<+ SetStateAction<ServerlessFunctionFormValues>+>;++export const useServerlessFunctionUpdateFormState = (+ serverlessFunctionId: string,+): [ServerlessFunctionFormValues, SetServerlessFunctionFormValues] => {+ const [formValues, setFormValues] = useState<ServerlessFunctionFormValues>({+ name: '',+ description: '',+ code: '',+ });++ 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]);++ return [formValues, setFormValues];+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useUpdateOneServerlessFunction.ts b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useUpdateOneServerlessFunction.tsnew file mode 100644index 00000000000..d75529ebcc9--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/hooks/useUpdateOneServerlessFunction.ts@@ -0,0 +1,34 @@+import { ApolloClient, useMutation } from '@apollo/client';+import { useApolloMetadataClient } from '@/object-metadata/hooks/useApolloMetadataClient';+import { UPDATE_ONE_SERVERLESS_FUNCTION } from '@/settings/serverless-functions/graphql/mutations/updateOneServerlessFunction';+import {+ UpdateServerlessFunctionInput,+ UpdateOneServerlessFunctionMutation,+ UpdateOneServerlessFunctionMutationVariables,+} from '~/generated-metadata/graphql';+import { getOperationName } from '@apollo/client/utilities';+import { FIND_MANY_SERVERLESS_FUNCTIONS } from '@/settings/serverless-functions/graphql/queries/findManyServerlessFunctions';++export const useUpdateOneServerlessFunction = () => {+ const apolloMetadataClient = useApolloMetadataClient();+ const [mutate] = useMutation<+ UpdateOneServerlessFunctionMutation,+ UpdateOneServerlessFunctionMutationVariables+ >(UPDATE_ONE_SERVERLESS_FUNCTION, {+ client: apolloMetadataClient ?? ({} as ApolloClient<any>),+ });++ const updateOneServerlessFunction = async (+ input: UpdateServerlessFunctionInput,+ ) => {+ return await mutate({+ variables: {+ input,+ },+ awaitRefetchQueries: true,+ refetchQueries: [getOperationName(FIND_MANY_SERVERLESS_FUNCTIONS) ?? ''],+ });+ };++ return { updateOneServerlessFunction };+};diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionCodeEditorOutputParamsState.ts b/packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionCodeEditorOutputParamsState.tsnew file mode 100644index 00000000000..e059de96931--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionCodeEditorOutputParamsState.ts@@ -0,0 +1,7 @@+import { createState } from 'twenty-ui';++export const settingsServerlessFunctionCodeEditorOutputParamsState =+ createState<{ language: string; height: number }>({+ key: 'settingsServerlessFunctionCodeEditorOutputParamsState',+ defaultValue: { language: 'plaintext', height: 64 },+ });diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionInputState.ts b/packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionInputState.tsnew file mode 100644index 00000000000..4038a6776bb--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionInputState.ts@@ -0,0 +1,6 @@+import { createState } from 'twenty-ui';++export const settingsServerlessFunctionInputState = createState<string>({+ key: 'settingsServerlessFunctionInputState',+ defaultValue: '{}',+});diff --git a/packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionOutputState.ts b/packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionOutputState.tsnew file mode 100644index 00000000000..40a3237dbb1--- /dev/null+++ b/packages/twenty-front/src/modules/settings/serverless-functions/states/settingsServerlessFunctionOutputState.ts@@ -0,0 +1,6 @@+import { createState } from 'twenty-ui';++export const settingsServerlessFunctionOutputState = createState<string>({+ key: 'settingsServerlessFunctionOutputState',+ defaultValue: 'Enter an input above then press "run Function"',+});diff --git a/packages/twenty-front/src/modules/settings/utils/__tests__/getSettingsPagePath.test.ts b/packages/twenty-front/src/modules/settings/utils/__tests__/getSettingsPagePath.test.tsnew file mode 100644index 00000000000..d27cd5ecc06--- /dev/null+++ b/packages/twenty-front/src/modules/settings/utils/__tests__/getSettingsPagePath.test.ts@@ -0,0 +1,15 @@+import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';+import { SettingsPath } from '@/types/SettingsPath';++describe('getSettingsPagePath', () => {+ test('should compute page path', () => {+ expect(getSettingsPagePath(SettingsPath.ServerlessFunctions)).toEqual(+ '/settings/functions',+ );+ });+ test('should compute page path with id', () => {+ expect(+ getSettingsPagePath(SettingsPath.ServerlessFunctions, { id: 'id' }),+ ).toEqual('/settings/functions/id');+ });+});diff --git a/packages/twenty-front/src/modules/settings/utils/getSettingsPagePath.ts b/packages/twenty-front/src/modules/settings/utils/getSettingsPagePath.tsindex 996d90a35d8..97fa703c218 100644--- a/packages/twenty-front/src/modules/settings/utils/getSettingsPagePath.ts+++ b/packages/twenty-front/src/modules/settings/utils/getSettingsPagePath.ts@@ -2,6 +2,7 @@ import { SettingsPath } from '@/types/SettingsPath';import { isDefined } from '~/utils/isDefined';type PathParams = {+ id?: string;objectSlug?: string;};@@ -15,5 +16,9 @@ export const getSettingsPagePath = <Path extends SettingsPath>(resultPath = resultPath.replace(':objectSlug', params.objectSlug);}+ if (isDefined(params?.id)) {+ resultPath = `${resultPath}/${params?.id}`;+ }+return resultPath;};diff --git a/packages/twenty-front/src/modules/types/SettingsPath.ts b/packages/twenty-front/src/modules/types/SettingsPath.tsindex a6edf83470d..92f152619c2 100644--- a/packages/twenty-front/src/modules/types/SettingsPath.ts+++ b/packages/twenty-front/src/modules/types/SettingsPath.ts@@ -16,10 +16,13 @@ export enum SettingsPath {ObjectNewFieldStep2 = 'objects/:objectSlug/new-field/step-2',ObjectFieldEdit = 'objects/:objectSlug/:fieldSlug',NewObject = 'objects/new',+ NewServerlessFunction = 'functions/new',+ ServerlessFunctionDetail = 'functions/:serverlessFunctionId',WorkspaceMembersPage = 'workspace-members',Workspace = 'workspace',CRMMigration = 'crm-migration',Developers = 'developers',+ ServerlessFunctions = 'functions',DevelopersNewApiKey = 'api-keys/new',DevelopersApiKeyDetail = 'api-keys/:apiKeyId',Integrations = 'integrations',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.tsxnew file mode 100644index 00000000000..ca73f277989--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/code-editor/components/CodeEditor.tsx@@ -0,0 +1,80 @@+import Editor, { Monaco, EditorProps } from '@monaco-editor/react';+import { editor } from 'monaco-editor';+import { codeEditorTheme } from '@/ui/input/code-editor/theme/CodeEditorTheme';+import { useTheme } from '@emotion/react';+import styled from '@emotion/styled';+import { useEffect } from 'react';++export const DEFAULT_CODE = `export const handler = async (+ event: object,+ context: object+): Promise<object> => {+ // Your code here+ return {};+}+`;++const StyledEditor = styled(Editor)`+ border: 1px solid ${({ theme }) => theme.border.color.medium};+ border-top: none;+ border-radius: 0 0 ${({ theme }) => theme.border.radius.sm}+ ${({ theme }) => theme.border.radius.sm};+`;++type CodeEditorProps = Omit<EditorProps, 'onChange'> & {+ header: React.ReactNode;+ onChange?: (value: string) => void;+};++export const CodeEditor = ({+ value = DEFAULT_CODE,+ onChange,+ language = 'typescript',+ height = 500,+ options = undefined,+ header,+}: CodeEditorProps) => {+ const theme = useTheme();+ const handleEditorDidMount = (+ editor: editor.IStandaloneCodeEditor,+ monaco: Monaco,+ ) => {+ monaco.editor.defineTheme('codeEditorTheme', codeEditorTheme(theme));+ monaco.editor.setTheme('codeEditorTheme');+ };+ useEffect(() => {+ const style = document.createElement('style');+ style.innerHTML = `+ .monaco-editor .margin .line-numbers {+ font-weight: bold;+ }+ `;+ document.head.appendChild(style);+ return () => {+ document.head.removeChild(style);+ };+ }, []);+ return (+ <div>+ {header}+ <StyledEditor+ height={height}+ language={language}+ value={value}+ onMount={handleEditorDidMount}+ onChange={(value?: string) => value && onChange?.(value)}+ options={{+ ...options,+ overviewRulerLanes: 0,+ scrollbar: {+ vertical: 'hidden',+ horizontal: 'hidden',+ },+ minimap: {+ enabled: false,+ },+ }}+ />+ </div>+ );+};diff --git a/packages/twenty-front/src/modules/ui/input/code-editor/components/CodeEditorHeader.tsx b/packages/twenty-front/src/modules/ui/input/code-editor/components/CodeEditorHeader.tsxnew file mode 100644index 00000000000..0ac5904784d--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/code-editor/components/CodeEditorHeader.tsx@@ -0,0 +1,51 @@+import styled from '@emotion/styled';++const StyledEditorHeader = styled.div`+ align-items: center;+ background-color: ${({ theme }) => theme.background.transparent.lighter};+ color: ${({ theme }) => theme.font.color.tertiary};+ font-weight: ${({ theme }) => theme.font.weight.medium};+ display: flex;+ height: ${({ theme }) => theme.spacing(10)};+ padding: ${({ theme }) => `0 ${theme.spacing(2)}`};+ border: 1px solid ${({ theme }) => theme.border.color.medium};+ border-top-left-radius: ${({ theme }) => theme.border.radius.sm};+ border-top-right-radius: ${({ theme }) => theme.border.radius.sm};+ justify-content: space-between;+`;++const StyledElementContainer = styled.div`+ align-content: flex-end;+ display: flex;+ gap: ${({ theme }) => theme.spacing(2)};+`;++export type CoreEditorHeaderProps = {+ title?: string;+ leftNodes?: React.ReactNode[];+ rightNodes?: React.ReactNode[];+};++export const CoreEditorHeader = ({+ title,+ leftNodes,+ rightNodes,+}: CoreEditorHeaderProps) => {+ return (+ <StyledEditorHeader>+ <StyledElementContainer>+ {leftNodes &&+ leftNodes.map((leftButton, index) => {+ return <div key={`left-${index}`}>{leftButton}</div>;+ })}+ {title}+ </StyledElementContainer>+ <StyledElementContainer>+ {rightNodes &&+ rightNodes.map((rightButton, index) => {+ return <div key={`right-${index}`}>{rightButton}</div>;+ })}+ </StyledElementContainer>+ </StyledEditorHeader>+ );+};diff --git a/packages/twenty-front/src/modules/ui/input/code-editor/theme/CodeEditorTheme.ts b/packages/twenty-front/src/modules/ui/input/code-editor/theme/CodeEditorTheme.tsnew file mode 100644index 00000000000..bb4bd909209--- /dev/null+++ b/packages/twenty-front/src/modules/ui/input/code-editor/theme/CodeEditorTheme.ts@@ -0,0 +1,33 @@+import { editor } from 'monaco-editor';+import { ThemeType } from 'twenty-ui';++export const codeEditorTheme = (theme: ThemeType) => {+ return {+ base: 'vs' as editor.BuiltinTheme,+ inherit: true,+ rules: [+ {+ token: '',+ foreground: theme.code.text.gray,+ fontStyle: 'bold',+ },+ { token: 'keyword', foreground: theme.code.text.sky },+ {+ token: 'delimiter',+ foreground: theme.code.text.gray,+ },+ { token: 'string', foreground: theme.code.text.pink },+ {+ token: 'comment',+ foreground: theme.code.text.orange,+ },+ ],+ colors: {+ 'editor.background': theme.background.secondary,+ 'editorCursor.foreground': theme.font.color.primary,+ 'editorLineNumber.foreground': theme.font.color.extraLight,+ 'editorLineNumber.activeForeground': theme.font.color.light,+ 'editor.lineHighlightBackground': theme.background.tertiary,+ },+ };+};diff --git a/packages/twenty-front/src/modules/ui/input/components/TextArea.tsx b/packages/twenty-front/src/modules/ui/input/components/TextArea.tsxindex 4d116a17348..aee5943e6e1 100644--- a/packages/twenty-front/src/modules/ui/input/components/TextArea.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/TextArea.tsx@@ -29,7 +29,6 @@ const StyledTextArea = styled(TextareaAutosize)`line-height: 16px;overflow: auto;padding: ${({ theme }) => theme.spacing(2)};- padding-top: ${({ theme }) => theme.spacing(3)};resize: none;width: 100%;diff --git a/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/Background.ts b/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/Background.tsindex 7498e144216..cbe6ee21af7 100644--- a/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/Background.ts+++ b/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/Background.ts@@ -8,6 +8,7 @@ export const BACKGROUND: Record<string, string> = {emptyTimeline: '/images/placeholders/background/empty_timeline_bg.png',loadingMessages: '/images/placeholders/background/loading_messages_bg.png',loadingAccounts: '/images/placeholders/background/loading_accounts_bg.png',+ emptyFunctions: '/images/placeholders/background/empty_functions_bg.png',emptyInbox: '/images/placeholders/background/empty_inbox_bg.png',error404: '/images/placeholders/background/404_bg.png',error500: '/images/placeholders/background/500_bg.png',diff --git a/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/DarkBackground.ts b/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/DarkBackground.tsindex 6fc5e701f60..c609745b5d9 100644--- a/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/DarkBackground.ts+++ b/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/DarkBackground.ts@@ -11,4 +11,5 @@ export const DARK_BACKGROUND: Record<string, string> = {error500: '/images/placeholders/dark-background/500_bg.png',loadingMessages: '/images/placeholders/background/loading_messages_bg.png',loadingAccounts: '/images/placeholders/background/loading_accounts_bg.png',+ emptyFunctions: '/images/placeholders/dark-background/empty_functions_bg.png',};diff --git a/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/DarkMovingImage.ts b/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/DarkMovingImage.tsindex d8173f6f5e1..f39ed95a6d5 100644--- a/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/DarkMovingImage.ts+++ b/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/DarkMovingImage.ts@@ -11,4 +11,5 @@ export const DARK_MOVING_IMAGE: Record<string, string> = {error500: '/images/placeholders/dark-moving-image/500.png',loadingMessages: '/images/placeholders/moving-image/loading_messages.png',loadingAccounts: '/images/placeholders/moving-image/loading_accounts.png',+ emptyFunctions: '/images/placeholders/dark-moving-image/empty_functions.png',};diff --git a/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/MovingImage.ts b/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/MovingImage.tsindex d08eac3e826..6b23d3f97b1 100644--- a/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/MovingImage.ts+++ b/packages/twenty-front/src/modules/ui/layout/animated-placeholder/constants/MovingImage.ts@@ -8,6 +8,7 @@ export const MOVING_IMAGE: Record<string, string> = {emptyTimeline: '/images/placeholders/moving-image/empty_timeline.png',loadingMessages: '/images/placeholders/moving-image/loading_messages.png',loadingAccounts: '/images/placeholders/moving-image/loading_accounts.png',+ emptyFunctions: '/images/placeholders/moving-image/empty_functions.png',emptyInbox: '/images/placeholders/moving-image/empty_inbox.png',error404: '/images/placeholders/moving-image/404.png',error500: '/images/placeholders/moving-image/500.png',diff --git a/packages/twenty-front/src/modules/ui/layout/tab/components/TabList.tsx b/packages/twenty-front/src/modules/ui/layout/tab/components/TabList.tsxindex 0cd5b4bccc1..120d5e72026 100644--- a/packages/twenty-front/src/modules/ui/layout/tab/components/TabList.tsx+++ b/packages/twenty-front/src/modules/ui/layout/tab/components/TabList.tsx@@ -22,6 +22,7 @@ type TabListProps = {tabListId: string;tabs: SingleTabProps[];loading?: boolean;+ className?: string;};const StyledContainer = styled.div`@@ -34,7 +35,12 @@ const StyledContainer = styled.div`user-select: none;`;-export const TabList = ({ tabs, tabListId, loading }: TabListProps) => {+export const TabList = ({+ tabs,+ tabListId,+ loading,+ className,+}: TabListProps) => {const initialActiveTabId = tabs.find((tab) => !tab.hide)?.id || '';const { activeTabIdState, setActiveTabId } = useTabList(tabListId);@@ -48,7 +54,7 @@ export const TabList = ({ tabs, tabListId, loading }: TabListProps) => {return (<TabListScope tabListScopeId={tabListId}><ScrollWrapper hideY>- <StyledContainer>+ <StyledContainer className={className}>{tabs.filter((tab) => !tab.hide).map((tab) => (diff --git a/packages/twenty-front/src/modules/workspace/types/FeatureFlagKey.ts b/packages/twenty-front/src/modules/workspace/types/FeatureFlagKey.tsindex 4334a6b9699..bbcca44a7c1 100644--- a/packages/twenty-front/src/modules/workspace/types/FeatureFlagKey.ts+++ b/packages/twenty-front/src/modules/workspace/types/FeatureFlagKey.ts@@ -5,5 +5,6 @@ export type FeatureFlagKey =| 'IS_AIRTABLE_INTEGRATION_ENABLED'| 'IS_POSTGRESQL_INTEGRATION_ENABLED'| 'IS_STRIPE_INTEGRATION_ENABLED'+ | 'IS_FUNCTION_SETTINGS_ENABLED'| 'IS_COPILOT_ENABLED'| 'IS_CRM_MIGRATION_ENABLED';diff --git a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsxindex a744030a69d..7199d871a13 100644--- a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx+++ b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx@@ -18,6 +18,7 @@ import { Section } from '@/ui/layout/section/components/Section';import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';import { useGenerateApiKeyTokenMutation } from '~/generated/graphql';import { isDefined } from '~/utils/isDefined';+import { Key } from 'ts-key-enum';export const SettingsDevelopersApiKeysNew = () => {const [generateOneApiKeyToken] = useGenerateApiKeyTokenMutation();@@ -85,7 +86,7 @@ export const SettingsDevelopersApiKeysNew = () => {placeholder="E.g. backoffice integration"value={formValues.name}onKeyDown={(e) => {- if (e.key === 'Enter') {+ if (e.key === Key.Enter) {handleSave();}}}diff --git a/packages/twenty-front/src/pages/settings/serverless-functions/ResetServerlessFunctionStatesEffect.tsx b/packages/twenty-front/src/pages/settings/serverless-functions/ResetServerlessFunctionStatesEffect.tsxnew file mode 100644index 00000000000..f158f69cb69--- /dev/null+++ b/packages/twenty-front/src/pages/settings/serverless-functions/ResetServerlessFunctionStatesEffect.tsx@@ -0,0 +1,20 @@+import { useResetRecoilState } from 'recoil';+import { settingsServerlessFunctionInputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionInputState';+import { settingsServerlessFunctionOutputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionOutputState';+import { settingsServerlessFunctionCodeEditorOutputParamsState } from '@/settings/serverless-functions/states/settingsServerlessFunctionCodeEditorOutputParamsState';++export const ResetServerlessFunctionStatesEffect = () => {+ const resetSettingsServerlessFunctionInput = useResetRecoilState(+ settingsServerlessFunctionInputState,+ );+ const resetSettingsServerlessFunctionOutput = useResetRecoilState(+ settingsServerlessFunctionOutputState,+ );+ const resetSettingsServerlessFunctionCodeEditorOutputParamsState =+ useResetRecoilState(settingsServerlessFunctionCodeEditorOutputParamsState);++ 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.tsxnew file mode 100644index 00000000000..b20dbd389d2--- /dev/null+++ b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionDetail.tsx@@ -0,0 +1,156 @@+import { useParams } from 'react-router-dom';+import { IconCode, IconSettings, IconTestPipe } from 'twenty-ui';+import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';+import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';+import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';+import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';+import { Section } from '@/ui/layout/section/components/Section';+import { TabList } from '@/ui/layout/tab/components/TabList';+import { useTabList } from '@/ui/layout/tab/hooks/useTabList';+import { useRecoilValue, useSetRecoilState } from 'recoil';+import { SettingsServerlessFunctionCodeEditorTab } from '@/settings/serverless-functions/components/tabs/SettingsServerlessFunctionCodeEditorTab';+import { SettingsServerlessFunctionSettingsTab } from '@/settings/serverless-functions/components/tabs/SettingsServerlessFunctionSettingsTab';+import { useServerlessFunctionUpdateFormState } from '@/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState';+import { SettingsServerlessFunctionTestTab } from '@/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTab';+import { useExecuteOneServerlessFunction } from '@/settings/serverless-functions/hooks/useExecuteOneServerlessFunction';+import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';+import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';+import { useUpdateOneServerlessFunction } from '@/settings/serverless-functions/hooks/useUpdateOneServerlessFunction';+import { useDebouncedCallback } from 'use-debounce';+import { SettingsServerlessFunctionTestTabEffect } from '@/settings/serverless-functions/components/tabs/SettingsServerlessFunctionTestTabEffect';+import { settingsServerlessFunctionOutputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionOutputState';+import { settingsServerlessFunctionInputState } from '@/settings/serverless-functions/states/settingsServerlessFunctionInputState';++const TAB_LIST_COMPONENT_ID = 'serverless-function-detail';++export const SettingsServerlessFunctionDetail = () => {+ const { serverlessFunctionId = '' } = useParams();+ const { enqueueSnackBar } = useSnackBar();+ const { activeTabIdState, setActiveTabId } = useTabList(+ TAB_LIST_COMPONENT_ID,+ );+ const activeTabId = useRecoilValue(activeTabIdState);+ const { executeOneServerlessFunction } = useExecuteOneServerlessFunction();+ const { updateOneServerlessFunction } = useUpdateOneServerlessFunction();+ const [formValues, setFormValues] =+ useServerlessFunctionUpdateFormState(serverlessFunctionId);+ const setSettingsServerlessFunctionOutput = useSetRecoilState(+ settingsServerlessFunctionOutputState,+ );+ const settingsServerlessFunctionInput = useRecoilValue(+ settingsServerlessFunctionInputState,+ );++ const save = async () => {+ try {+ await updateOneServerlessFunction({+ id: serverlessFunctionId,+ name: formValues.name,+ description: formValues.description,+ code: formValues.code,+ });+ } catch (err) {+ enqueueSnackBar(+ (err as Error)?.message || 'An error occurred while updating function',+ {+ variant: SnackBarVariant.Error,+ },+ );+ }+ };++ const handleSave = useDebouncedCallback(save, 500);++ const onChange = (key: string) => {+ return async (value: string | undefined) => {+ setFormValues((prevState) => ({+ ...prevState,+ [key]: value,+ }));+ await handleSave();+ };+ };++ const handleExecute = async () => {+ await handleSave();+ try {+ const result = await executeOneServerlessFunction(+ serverlessFunctionId,+ JSON.parse(settingsServerlessFunctionInput),+ );+ setSettingsServerlessFunctionOutput(+ JSON.stringify(+ result?.data?.executeOneServerlessFunction?.result,+ null,+ 4,+ ),+ );+ } catch (err) {+ enqueueSnackBar(+ (err as Error)?.message || 'An error occurred while executing function',+ {+ variant: SnackBarVariant.Error,+ },+ );+ setSettingsServerlessFunctionOutput(JSON.stringify(err, null, 4));+ }+ setActiveTabId('test');+ };++ const tabs = [+ { id: 'editor', title: 'Editor', Icon: IconCode },+ { id: 'test', title: 'Test', Icon: IconTestPipe },+ { id: 'settings', title: 'Settings', Icon: IconSettings },+ ];++ const renderActiveTabContent = () => {+ switch (activeTabId) {+ case 'editor':+ return (+ <SettingsServerlessFunctionCodeEditorTab+ formValues={formValues}+ handleExecute={handleExecute}+ onChange={onChange}+ />+ );+ case 'test':+ return (+ <>+ <SettingsServerlessFunctionTestTabEffect />+ <SettingsServerlessFunctionTestTab handleExecute={handleExecute} />+ </>+ );+ case 'settings':+ return (+ <SettingsServerlessFunctionSettingsTab+ formValues={formValues}+ serverlessFunctionId={serverlessFunctionId}+ onChange={onChange}+ />+ );+ default:+ return <></>;+ }+ };++ return (+ formValues.name && (+ <SubMenuTopBarContainer Icon={IconSettings} title="Settings">+ <SettingsPageContainer>+ <SettingsHeaderContainer>+ <Breadcrumb+ links={[+ { children: 'Functions', href: '/settings/functions' },+ { children: `${formValues.name}` },+ ]}+ />+ </SettingsHeaderContainer>+ <Section>+ <TabList tabListId={TAB_LIST_COMPONENT_ID} tabs={tabs} />+ </Section>+ {renderActiveTabContent()}+ </SettingsPageContainer>+ </SubMenuTopBarContainer>+ )+ );+};diff --git a/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionDetailWrapper.tsx b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionDetailWrapper.tsxnew file mode 100644index 00000000000..8671851e53e--- /dev/null+++ b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionDetailWrapper.tsx@@ -0,0 +1,11 @@+import { ResetServerlessFunctionStatesEffect } from '~/pages/settings/serverless-functions/ResetServerlessFunctionStatesEffect';+import { SettingsServerlessFunctionDetail } from '~/pages/settings/serverless-functions/SettingsServerlessFunctionDetail';++export const SettingsServerlessFunctionDetailWrapper = () => {+ return (+ <>+ <ResetServerlessFunctionStatesEffect />+ <SettingsServerlessFunctionDetail />+ </>+ );+};diff --git a/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctions.tsx b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctions.tsxnew file mode 100644index 00000000000..d186ffdec76--- /dev/null+++ b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctions.tsx@@ -0,0 +1,36 @@+import { IconPlus, IconSettings } from 'twenty-ui';+import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';+import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';+import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';+import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';+import { Section } from '@/ui/layout/section/components/Section';+import { SettingsServerlessFunctionsTable } from '@/settings/serverless-functions/components/SettingsServerlessFunctionsTable';+import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';+import { SettingsPath } from '@/types/SettingsPath';+import { Button } from '@/ui/input/button/components/Button';+import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink';++export const SettingsServerlessFunctions = () => {+ return (+ <SubMenuTopBarContainer Icon={IconSettings} title="Settings">+ <SettingsPageContainer>+ <SettingsHeaderContainer>+ <Breadcrumb links={[{ children: 'Functions' }]} />+ <UndecoratedLink+ to={getSettingsPagePath(SettingsPath.NewServerlessFunction)}+ >+ <Button+ Icon={IconPlus}+ title="New Function"+ accent="blue"+ size="small"+ />+ </UndecoratedLink>+ </SettingsHeaderContainer>+ <Section>+ <SettingsServerlessFunctionsTable />+ </Section>+ </SettingsPageContainer>+ </SubMenuTopBarContainer>+ );+};diff --git a/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionsNew.tsx b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionsNew.tsxnew file mode 100644index 00000000000..2f5dbce31bf--- /dev/null+++ b/packages/twenty-front/src/pages/settings/serverless-functions/SettingsServerlessFunctionsNew.tsx@@ -0,0 +1,81 @@+import { IconSettings } from 'twenty-ui';+import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';+import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';+import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';+import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';+import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';+import { useNavigate } from 'react-router-dom';++import { useCreateOneServerlessFunction } from '@/settings/serverless-functions/hooks/useCreateOneServerlessFunction';+import { DEFAULT_CODE } from '@/ui/input/code-editor/components/CodeEditor';+import { ServerlessFunctionNewFormValues } from '@/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState';+import { SettingsServerlessFunctionNewForm } from '@/settings/serverless-functions/components/SettingsServerlessFunctionNewForm';+import { isDefined } from '~/utils/isDefined';+import { useState } from 'react';+import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';+import { SettingsPath } from '@/types/SettingsPath';++export const SettingsServerlessFunctionsNew = () => {+ const navigate = useNavigate();+ const [formValues, setFormValues] = useState<ServerlessFunctionNewFormValues>(+ {+ name: '',+ description: '',+ },+ );++ const { createOneServerlessFunction } = useCreateOneServerlessFunction();+ const handleSave = async () => {+ const newServerlessFunction = await createOneServerlessFunction({+ name: formValues.name,+ description: formValues.description,+ code: DEFAULT_CODE,+ });++ if (!isDefined(newServerlessFunction?.data)) {+ return;+ }+ navigate(+ getSettingsPagePath(SettingsPath.ServerlessFunctions, {+ id: newServerlessFunction.data.createOneServerlessFunction.id,+ }),+ );+ };++ const onChange = (key: string) => {+ return (value: string | undefined) => {+ setFormValues((prevState) => ({+ ...prevState,+ [key]: value,+ }));+ };+ };++ const canSave = !!formValues.name && createOneServerlessFunction;++ return (+ <SubMenuTopBarContainer Icon={IconSettings} title="Settings">+ <SettingsPageContainer>+ <SettingsHeaderContainer>+ <Breadcrumb+ links={[+ { children: 'Functions', href: '/settings/functions' },+ { children: 'New' },+ ]}+ />+ <SaveAndCancelButtons+ isSaveDisabled={!canSave}+ onCancel={() => {+ navigate('/settings/functions');+ }}+ onSave={handleSave}+ />+ </SettingsHeaderContainer>+ <SettingsServerlessFunctionNewForm+ formValues={formValues}+ onChange={onChange}+ />+ </SettingsPageContainer>+ </SubMenuTopBarContainer>+ );+};diff --git a/packages/twenty-front/src/pages/settings/serverless-functions/__stories__/SettingsServerlessFunctionDetail.stories.tsx b/packages/twenty-front/src/pages/settings/serverless-functions/__stories__/SettingsServerlessFunctionDetail.stories.tsxnew file mode 100644index 00000000000..11257930e43--- /dev/null+++ b/packages/twenty-front/src/pages/settings/serverless-functions/__stories__/SettingsServerlessFunctionDetail.stories.tsx@@ -0,0 +1,69 @@+import { SettingsServerlessFunctionDetail } from '~/pages/settings/serverless-functions/SettingsServerlessFunctionDetail';+import { graphqlMocks } from '~/testing/graphqlMocks';+import { Meta, StoryObj } from '@storybook/react';+import {+ PageDecorator,+ PageDecoratorArgs,+} from '~/testing/decorators/PageDecorator';+import { graphql, http, HttpResponse } from 'msw';+import { getImageAbsoluteURIOrBase64 } from '~/utils/image/getImageAbsoluteURIOrBase64';+import { DEFAULT_CODE } from '@/ui/input/code-editor/components/CodeEditor';+import { within } from '@storybook/test';+import { sleep } from '~/utils/sleep';++const SOURCE_CODE_FULL_PATH =+ 'serverless-function/20202020-1c25-4d02-bf25-6aeccf7ea419/adb4bd21-7670-4c81-9f74-1fc196fe87ea/source.ts';++const meta: Meta<PageDecoratorArgs> = {+ title: 'Pages/Settings/ServerlessFunctions/SettingsServerlessFunctionDetail',+ component: SettingsServerlessFunctionDetail,+ decorators: [PageDecorator],+ args: {+ routePath: '/settings/function/',+ routeParams: {+ ':serverlessFunctionId': 'adb4bd21-7670-4c81-9f74-1fc196fe87ea',+ },+ },+ parameters: {+ msw: {+ handlers: [+ ...graphqlMocks.handlers,+ graphql.query('GetOneServerlessFunction', () => {+ return HttpResponse.json({+ data: {+ serverlessFunction: {+ __typename: 'ServerlessFunction',+ id: 'adb4bd21-7670-4c81-9f74-1fc196fe87ea',+ name: 'Serverless Function Name',+ description: '',+ syncStatus: 'READY',+ runtime: 'nodejs18.x',+ sourceCodeFullPath: SOURCE_CODE_FULL_PATH,+ sourceCodeHash: '42d2734b3dc8a7b45a16803ed7f417bc',+ updatedAt: '2024-02-24T10:23:10.673Z',+ createdAt: '2024-02-24T10:23:10.673Z',+ },+ },+ });+ }),+ http.get(+ getImageAbsoluteURIOrBase64(SOURCE_CODE_FULL_PATH) || '',+ () => {+ return HttpResponse.text(DEFAULT_CODE);+ },+ ),+ ],+ },+ },+};+export default meta;++export type Story = StoryObj<typeof SettingsServerlessFunctionDetail>;++export const Default: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await sleep(100);+ await canvas.findByText('Code your function');+ },+};diff --git a/packages/twenty-front/src/pages/settings/serverless-functions/__stories__/SettingsServerlessFunctions.stories.tsx b/packages/twenty-front/src/pages/settings/serverless-functions/__stories__/SettingsServerlessFunctions.stories.tsxnew file mode 100644index 00000000000..eb1474a8b12--- /dev/null+++ b/packages/twenty-front/src/pages/settings/serverless-functions/__stories__/SettingsServerlessFunctions.stories.tsx@@ -0,0 +1,32 @@+import { SettingsServerlessFunctions } from '~/pages/settings/serverless-functions/SettingsServerlessFunctions';+import { graphqlMocks } from '~/testing/graphqlMocks';+import { Meta, StoryObj } from '@storybook/react';+import {+ PageDecorator,+ PageDecoratorArgs,+} from '~/testing/decorators/PageDecorator';+import { sleep } from '~/utils/sleep';+import { within } from '@storybook/test';++const meta: Meta<PageDecoratorArgs> = {+ title: 'Pages/Settings/ServerlessFunctions/SettingsServerlessFunctions',+ component: SettingsServerlessFunctions,+ decorators: [PageDecorator],+ args: { routePath: '/settings/functions' },+ parameters: {+ msw: graphqlMocks,+ },+};+export default meta;++export type Story = StoryObj<typeof SettingsServerlessFunctions>;++export const Default: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await sleep(100);++ await canvas.findByText('Functions');+ await canvas.findByText('Add your first Function');+ },+};diff --git a/packages/twenty-front/src/pages/settings/serverless-functions/__stories__/SettingsServerlessFunctionsNew.stories.tsx b/packages/twenty-front/src/pages/settings/serverless-functions/__stories__/SettingsServerlessFunctionsNew.stories.tsxnew file mode 100644index 00000000000..2f2ac5c1a69--- /dev/null+++ b/packages/twenty-front/src/pages/settings/serverless-functions/__stories__/SettingsServerlessFunctionsNew.stories.tsx@@ -0,0 +1,37 @@+import { SettingsServerlessFunctionsNew } from '~/pages/settings/serverless-functions/SettingsServerlessFunctionsNew';+import { graphqlMocks } from '~/testing/graphqlMocks';+import { Meta, StoryObj } from '@storybook/react';+import {+ PageDecorator,+ PageDecoratorArgs,+} from '~/testing/decorators/PageDecorator';+import { userEvent, within } from '@storybook/test';+import { sleep } from '~/utils/sleep';++const meta: Meta<PageDecoratorArgs> = {+ title: 'Pages/Settings/ServerlessFunctions/SettingsServerlessFunctionsNew',+ component: SettingsServerlessFunctionsNew,+ decorators: [PageDecorator],+ args: { routePath: '/settings/functions/new' },+ parameters: {+ msw: graphqlMocks,+ },+};+export default meta;++export type Story = StoryObj<typeof SettingsServerlessFunctionsNew>;++export const Default: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await sleep(100);+ await canvas.findByText('Functions');+ await canvas.findByText('New');++ const input = await canvas.findByPlaceholderText('Name');+ await userEvent.type(input, 'Function Name');+ const saveButton = await canvas.findByText('Save');++ await userEvent.click(saveButton);+ },+};diff --git a/packages/twenty-front/src/utils/array/__tests__/sortByAscString.test.ts b/packages/twenty-front/src/utils/array/__tests__/sortByAscString.test.tsnew file mode 100644index 00000000000..c7577257864--- /dev/null+++ b/packages/twenty-front/src/utils/array/__tests__/sortByAscString.test.ts@@ -0,0 +1,9 @@+import { sortByAscString } from '~/utils/array/sortByAscString';++describe('sortByAscString', () => {+ test('should sort properly', () => {+ expect(sortByAscString('a', 'b')).toEqual(-1);+ expect(sortByAscString('b', 'a')).toEqual(1);+ expect(sortByAscString('a', 'a')).toEqual(0);+ });+});diff --git a/packages/twenty-front/src/utils/file/__tests__/getFileAbsoluteURI.test.ts b/packages/twenty-front/src/utils/file/__tests__/getFileAbsoluteURI.test.tsnew file mode 100644index 00000000000..01a75cecaa9--- /dev/null+++ b/packages/twenty-front/src/utils/file/__tests__/getFileAbsoluteURI.test.ts@@ -0,0 +1,10 @@+import { getFileAbsoluteURI } from '../getFileAbsoluteURI';+import { REACT_APP_SERVER_BASE_URL } from '~/config';++describe('getFileAbsoluteURI', () => {+ test('should return absolute uri', () => {+ expect(getFileAbsoluteURI('foo')).toEqual(+ `${REACT_APP_SERVER_BASE_URL}/files/foo`,+ );+ });+});diff --git a/packages/twenty-front/src/utils/file/getFileAbsoluteURI.ts b/packages/twenty-front/src/utils/file/getFileAbsoluteURI.tsnew file mode 100644index 00000000000..f3777e38a92--- /dev/null+++ b/packages/twenty-front/src/utils/file/getFileAbsoluteURI.ts@@ -0,0 +1,5 @@+import { REACT_APP_SERVER_BASE_URL } from '~/config';++export const getFileAbsoluteURI = (fileUrl?: string) => {+ return `${REACT_APP_SERVER_BASE_URL}/files/${fileUrl}`;+};diff --git a/packages/twenty-front/src/utils/title-utils.ts b/packages/twenty-front/src/utils/title-utils.tsindex 9d604c5eeb4..74213f0083d 100644--- a/packages/twenty-front/src/utils/title-utils.ts+++ b/packages/twenty-front/src/utils/title-utils.ts@@ -10,6 +10,7 @@ export enum SettingsPageTitles {Members = 'Members - Settings',Developers = 'Developers - Settings',Integration = 'Integrations - Settings',+ ServerlessFunctions = 'Functions - Settings',General = 'General - Settings',Default = 'Settings',}@@ -21,6 +22,7 @@ enum SettingsPathPrefixes {Objects = `${AppBasePath.Settings}/${SettingsPath.Objects}`,Members = `${AppBasePath.Settings}/${SettingsPath.WorkspaceMembersPage}`,Developers = `${AppBasePath.Settings}/${SettingsPath.Developers}`,+ ServerlessFunctions = `${AppBasePath.Settings}/${SettingsPath.ServerlessFunctions}`,Integration = `${AppBasePath.Settings}/${SettingsPath.Integrations}`,General = `${AppBasePath.Settings}/${SettingsPath.Workspace}`,}@@ -63,6 +65,8 @@ export const getPageTitleFromPath = (pathname: string): string => {return SettingsPageTitles.Objects;case SettingsPathPrefixes.Developers:return SettingsPageTitles.Developers;+ case SettingsPathPrefixes.ServerlessFunctions:+ return SettingsPageTitles.ServerlessFunctions;case SettingsPathPrefixes.Integration:return SettingsPageTitles.Integration;case SettingsPathPrefixes.General:diff --git a/packages/twenty-server/package.json b/packages/twenty-server/package.jsonindex 5cfb3d6b98c..19dbeabcff6 100644--- a/packages/twenty-server/package.json+++ b/packages/twenty-server/package.json@@ -17,6 +17,7 @@"@graphql-yoga/nestjs": "patch:@graphql-yoga/[email protected]#./patches/@graphql-yoga-nestjs-npm-2.1.0-cb509e6047.patch","@langchain/mistralai": "^0.0.24","@langchain/openai": "^0.1.3",+ "@monaco-editor/react": "^4.6.0","@nestjs/cache-manager": "^2.2.1","@nestjs/devtools-integration": "^0.1.6","@nestjs/graphql": "patch:@nestjs/[email protected]#./patches/@nestjs+graphql+12.1.1.patch",@@ -34,6 +35,7 @@"lodash.omitby": "^4.6.0","lodash.uniq": "^4.5.0","lodash.uniqby": "^4.7.0",+ "monaco-editor": "^0.50.0","passport": "^0.7.0","psl": "^1.9.0","tsconfig-paths": "^4.2.0",diff --git a/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts b/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.tsindex c4e42f81bc4..2e4b47c9f45 100644--- a/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts+++ b/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts@@ -50,6 +50,11 @@ export const seedFeatureFlags = async (workspaceId: workspaceId,value: true,},+ {+ key: FeatureFlagKeys.IsFunctionSettingsEnabled,+ workspaceId: workspaceId,+ value: true,+ },{key: FeatureFlagKeys.IsWorkflowEnabled,workspaceId: workspaceId,diff --git a/packages/twenty-server/src/database/typeorm/metadata/migrations/1721309629608-addRuntimeColumnToServerlessFunction.ts b/packages/twenty-server/src/database/typeorm/metadata/migrations/1721309629608-addRuntimeColumnToServerlessFunction.tsnew file mode 100644index 00000000000..c1ac579fcdd--- /dev/null+++ b/packages/twenty-server/src/database/typeorm/metadata/migrations/1721309629608-addRuntimeColumnToServerlessFunction.ts@@ -0,0 +1,25 @@+import { MigrationInterface, QueryRunner } from 'typeorm';++export class AddRuntimeColumnToServerlessFunction1721309629608+ implements MigrationInterface+{+ name = 'AddRuntimeColumnToServerlessFunction1721309629608';++ public async up(queryRunner: QueryRunner): Promise<void> {+ await queryRunner.query(+ `ALTER TABLE "metadata"."serverlessFunction" ADD "runtime" character varying NOT NULL DEFAULT 'nodejs18.x'`,+ );+ await queryRunner.query(+ `ALTER TABLE "metadata"."serverlessFunction" ADD "description" character varying`,+ );+ await queryRunner.query(+ `ALTER TABLE "metadata"."serverlessFunction" ADD "sourceCodeFullPath" character varying NOT NULL`,+ );+ }++ public async down(queryRunner: QueryRunner): Promise<void> {+ await queryRunner.query(+ `ALTER TABLE "metadata"."serverlessFunction" DROP COLUMN "runtime"`,+ );+ }+}diff --git a/packages/twenty-server/src/engine/core-modules/feature-flag/feature-flag.entity.ts b/packages/twenty-server/src/engine/core-modules/feature-flag/feature-flag.entity.tsindex 9ee46f1278f..8d79be8f02f 100644--- a/packages/twenty-server/src/engine/core-modules/feature-flag/feature-flag.entity.ts+++ b/packages/twenty-server/src/engine/core-modules/feature-flag/feature-flag.entity.ts@@ -25,6 +25,7 @@ export enum FeatureFlagKeys {IsMessagingAliasFetchingEnabled = 'IS_MESSAGING_ALIAS_FETCHING_ENABLED',IsGoogleCalendarSyncV2Enabled = 'IS_GOOGLE_CALENDAR_SYNC_V2_ENABLED',IsFreeAccessEnabled = 'IS_FREE_ACCESS_ENABLED',+ IsFunctionSettingsEnabled = 'IS_FUNCTION_SETTINGS_ENABLED',IsWorkflowEnabled = 'IS_WORKFLOW_ENABLED',}diff --git a/packages/twenty-server/src/engine/core-modules/file/file.utils.ts b/packages/twenty-server/src/engine/core-modules/file/file.utils.tsindex 8868e4bc220..ef05b9419bd 100644--- a/packages/twenty-server/src/engine/core-modules/file/file.utils.ts+++ b/packages/twenty-server/src/engine/core-modules/file/file.utils.ts@@ -23,7 +23,11 @@ export const checkFilePath = (filePath: string): string => {throw new BadRequestException(`Folder ${folder} is not allowed`);}- if (size && !settings.storage.imageCropSizes[folder]?.includes(size)) {+ if (+ folder !== kebabCase(FileFolder.ServerlessFunction) &&+ size &&+ !settings.storage.imageCropSizes[folder]?.includes(size)+ ) {throw new BadRequestException(`Size ${size} is not allowed`);}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 6f1280cd746..fb46892e760 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@@ -1,6 +1,7 @@import { Readable } from 'stream';export interface StorageDriver {+ delete(params: { folderPath: string; filename?: string }): Promise<void>;read(params: { folderPath: string; filename: string }): Promise<Readable>;write(params: {file: Buffer | Uint8Array | string;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 0f28eadd4e0..e61a9338aef 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@@ -42,6 +42,19 @@ export class LocalDriver implements StorageDriver {await fs.writeFile(filePath, params.file);}+ async delete(params: {+ folderPath: string;+ filename?: string;+ }): Promise<void> {+ const filePath = join(+ `${this.options.storagePath}/`,+ params.folderPath,+ params.filename || '',+ );++ await fs.rm(filePath, { recursive: true });+ }+async read(params: {folderPath: string;filename: string;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 a8bfc8d1e44..9d0627071a8 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@@ -2,8 +2,11 @@ import { Readable } from 'stream';import {CreateBucketCommandInput,+ DeleteObjectCommand,+ DeleteObjectsCommand,GetObjectCommand,HeadBucketCommandInput,+ ListObjectsV2Command,NotFound,PutObjectCommand,S3,@@ -53,6 +56,57 @@ export class S3Driver implements StorageDriver {await this.s3Client.send(command);}+ private async emptyS3Directory(folderPath) {+ const listParams = {+ Bucket: this.bucketName,+ Prefix: folderPath,+ };++ const listObjectsCommand = new ListObjectsV2Command(listParams);+ const listedObjects = await this.s3Client.send(listObjectsCommand);++ if (listedObjects.Contents?.length === 0) return;++ const deleteParams = {+ Bucket: this.bucketName,+ Delete: {+ Objects: listedObjects.Contents?.map(({ Key }) => {+ return { Key };+ }),+ },+ };++ const deleteObjectCommand = new DeleteObjectsCommand(deleteParams);++ await this.s3Client.send(deleteObjectCommand);++ if (listedObjects.IsTruncated) {+ await this.emptyS3Directory(folderPath);+ }+ }++ async delete(params: {+ folderPath: string;+ filename?: string;+ }): Promise<void> {+ if (params.filename) {+ const deleteCommand = new DeleteObjectCommand({+ Key: `${params.folderPath}/${params.filename}`,+ Bucket: this.bucketName,+ });++ await this.s3Client.send(deleteCommand);+ } else {+ await this.emptyS3Directory(params.folderPath);+ const deleteEmptyFolderCommand = new DeleteObjectCommand({+ Key: `${params.folderPath}`,+ Bucket: this.bucketName,+ });++ await this.s3Client.send(deleteEmptyFolderCommand);+ }+ }+async read(params: {folderPath: string;filename: string;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 9e4a93e8877..06317061405 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@@ -10,6 +10,10 @@ import { StorageDriver } from './drivers/interfaces/storage-driver.interface';export class FileStorageService implements StorageDriver {constructor(@Inject(STORAGE_DRIVER) private driver: StorageDriver) {}+ delete(params: { folderPath: string; filename?: string }): Promise<void> {+ return this.driver.delete(params);+ }+write(params: {file: string | Buffer | Uint8Array;name: string;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 4d1489bbe08..c15eb07ca45 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@@ -1,6 +1,7 @@import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverless-function/serverless-function.entity';export interface ServerlessDriver {+ delete(serverlessFunction: ServerlessFunctionEntity): Promise<void>;build(serverlessFunction: ServerlessFunctionEntity): Promise<void>;execute(serverlessFunction: ServerlessFunctionEntity,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 d115cd9a42b..241744b9212 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@@ -5,8 +5,12 @@ import {Lambda,LambdaClientConfig,InvokeCommand,+ GetFunctionCommand,+ UpdateFunctionCodeCommand,+ DeleteFunctionCommand,} 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';import { ServerlessDriver } from 'src/engine/integrations/serverless/drivers/interfaces/serverless-driver.interface';@@ -42,6 +46,18 @@ export class LambdaDriverthis.buildDirectoryManagerService = options.buildDirectoryManagerService;}+ async delete(serverlessFunction: ServerlessFunctionEntity) {+ try {+ const deleteFunctionCommand = new DeleteFunctionCommand({+ FunctionName: serverlessFunction.id,+ });++ await this.lambdaClient.send(deleteFunctionCommand);+ } catch {+ return;+ }+ }+async build(serverlessFunction: ServerlessFunctionEntity) {const javascriptCode = await this.getCompiledCode(serverlessFunction,@@ -59,21 +75,44 @@ export class LambdaDriverawait createZipFile(sourceTemporaryDir, lambdaZipPath);- const params: CreateFunctionCommandInput = {- Code: {+ let existingFunction = true;++ try {+ const getFunctionCommand = new GetFunctionCommand({+ FunctionName: serverlessFunction.id,+ });++ await this.lambdaClient.send(getFunctionCommand);+ } catch {+ existingFunction = false;+ }++ if (!existingFunction) {+ const params: CreateFunctionCommandInput = {+ Code: {+ ZipFile: await fs.promises.readFile(lambdaZipPath),+ },+ FunctionName: serverlessFunction.id,+ Handler: lambdaHandler,+ Role: this.lambdaRole,+ Runtime: serverlessFunction.runtime,+ Description: 'Lambda function to run user script',+ Timeout: 900,+ };++ const command = new CreateFunctionCommand(params);++ await this.lambdaClient.send(command);+ } else {+ const params: UpdateFunctionCodeCommandInput = {ZipFile: await fs.promises.readFile(lambdaZipPath),- },- FunctionName: serverlessFunction.id,- Handler: lambdaHandler,- Role: this.lambdaRole,- Runtime: 'nodejs18.x',- Description: 'Lambda function to run user script',- Timeout: 900,- };+ FunctionName: serverlessFunction.id,+ };- const command = new CreateFunctionCommand(params);+ const command = new UpdateFunctionCodeCommand(params);- await this.lambdaClient.send(command);+ await this.lambdaClient.send(command);+ }await this.buildDirectoryManagerService.clean();}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 15e5701e561..5f661b4938c 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@@ -28,6 +28,12 @@ export class LocalDriverthis.fileStorageService = options.fileStorageService;}+ async delete(serverlessFunction: ServerlessFunctionEntity) {+ await this.fileStorageService.delete({+ folderPath: this.getFolderPath(serverlessFunction),+ });+ }+async build(serverlessFunction: ServerlessFunctionEntity) {const javascriptCode = await this.getCompiledCode(serverlessFunction,@@ -57,8 +63,16 @@ export class LocalDriverconst modifiedContent = `process.on('message', async (message) => {const { event, context } = message;- const result = await handler(event, context);- process.send(result);+ try {+ const result = await handler(event, context);+ process.send(result);+ } catch (error) {+ process.send({+ errorType: error.name,+ errorMessage: error.message,+ stackTrace: error.stack.split('\\n').filter((line) => line.trim() !== ''),+ });+ }});${fileContent}@@ -67,7 +81,7 @@ export class LocalDriverawait fs.writeFile(tmpFilePath, modifiedContent);return await new Promise((resolve, reject) => {- const child = fork(tmpFilePath);+ const child = fork(tmpFilePath, { silent: true });child.on('message', (message: object) => {resolve(message);@@ -75,6 +89,32 @@ export class LocalDriverfs.unlink(tmpFilePath);});+ child.stderr?.on('data', (data) => {+ const stackTrace = data+ .toString()+ .split('\n')+ .filter((line) => line.trim() !== '');+ const errorTrace = stackTrace.filter((line) =>+ line.includes('Error: '),+ )?.[0];++ let errorType = 'Unknown';+ let errorMessage = '';++ if (errorTrace) {+ errorType = errorTrace.split(':')[0];+ errorMessage = errorTrace.split(': ')[1];+ }++ resolve({+ errorType,+ errorMessage,+ stackTrace: stackTrace,+ });+ child.kill();+ fs.unlink(tmpFilePath);+ });+child.on('error', (error) => {reject(error);child.kill();diff --git a/packages/twenty-server/src/engine/integrations/serverless/serverless.service.ts b/packages/twenty-server/src/engine/integrations/serverless/serverless.service.tsindex 72f003913a8..372b2cb3b55 100644--- a/packages/twenty-server/src/engine/integrations/serverless/serverless.service.ts+++ b/packages/twenty-server/src/engine/integrations/serverless/serverless.service.ts@@ -9,6 +9,10 @@ import { ServerlessFunctionEntity } from 'src/engine/metadata-modules/serverlessexport class ServerlessService implements ServerlessDriver {constructor(@Inject(SERVERLESS_DRIVER) private driver: ServerlessDriver) {}+ async delete(serverlessFunction: ServerlessFunctionEntity): Promise<void> {+ return this.driver.delete(serverlessFunction);+ }+async build(serverlessFunction: ServerlessFunctionEntity): Promise<void> {return this.driver.build(serverlessFunction);}diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/create-serverless-function-from-file.input.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/create-serverless-function-from-file.input.tsnew file mode 100644index 00000000000..0e9f2885d67--- /dev/null+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/create-serverless-function-from-file.input.ts@@ -0,0 +1,16 @@+import { Field, InputType } from '@nestjs/graphql';++import { IsNotEmpty, IsOptional, IsString } from 'class-validator';++@InputType()+export class CreateServerlessFunctionFromFileInput {+ @IsString()+ @IsNotEmpty()+ @Field()+ name: string;++ @IsString()+ @IsOptional()+ @Field({ nullable: true })+ description?: string;+}diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/create-serverless-function.input.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/create-serverless-function.input.tsnew file mode 100644index 00000000000..63431ad881f--- /dev/null+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/create-serverless-function.input.ts@@ -0,0 +1,13 @@+import { Field, InputType } from '@nestjs/graphql';++import { IsNotEmpty, IsString } from 'class-validator';++import { CreateServerlessFunctionFromFileInput } from 'src/engine/metadata-modules/serverless-function/dtos/create-serverless-function-from-file.input';++@InputType()+export class CreateServerlessFunctionInput extends CreateServerlessFunctionFromFileInput {+ @IsString()+ @IsNotEmpty()+ @Field()+ code: string;+}diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/delete-serverless-function.input.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/delete-serverless-function.input.tsnew file mode 100644index 00000000000..27cfe36fea3--- /dev/null+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/delete-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 DeleteServerlessFunctionInput {+ @IDField(() => ID, { description: 'The id of the function.' })+ id!: string;+}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 83674831400..08071b04f5e 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,14 +1,18 @@import { ArgsType, Field } from '@nestjs/graphql';-import { IsNotEmpty, IsObject, IsOptional, IsString } from 'class-validator';+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()export class ExecuteServerlessFunctionInput {- @Field({ description: 'Name of the serverless function to execute' })+ @Field(() => UUIDScalarType, {+ description: 'Id of the serverless function to execute',+ })@IsNotEmpty()- @IsString()- name: string;+ @IsUUID()+ id: string;@Field(() => graphqlTypeJson, {description: 'Payload in JSON format',diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/serverless-function-execution-result-d-t.o.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/serverless-function-execution-result.dto.tssimilarity index 86%rename from packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/serverless-function-execution-result-d-t.o.tsrename to packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/serverless-function-execution-result.dto.tsindex 4560c4371a3..06caa4042fe 100644--- a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/serverless-function-execution-result-d-t.o.ts+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/serverless-function-execution-result.dto.ts@@ -4,7 +4,7 @@ import { IsObject } from 'class-validator';import graphqlTypeJson from 'graphql-type-json';@ObjectType('ServerlessFunctionExecutionResult')-export class ServerlessFunctionExecutionResultDTO {+export class ServerlessFunctionExecutionResultDto {@IsObject()@Field(() => graphqlTypeJson, {description: 'Execution result in JSON format',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 cabebe263b8..7a145c631b1 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@@ -26,7 +26,7 @@ registerEnumType(ServerlessFunctionSyncStatus, {description: 'SyncStatus of the serverlessFunction',});-@ObjectType('serverlessFunction')+@ObjectType('ServerlessFunction')@Authorize({authorize: (context: any) => ({workspaceId: { eq: context?.req?.user?.workspace?.id },@@ -47,11 +47,25 @@ export class ServerlessFunctionDto {@Field()name: string;+ @IsString()+ @Field()+ description: string;+@IsString()@IsNotEmpty()@Field()sourceCodeHash: string;+ @IsString()+ @IsNotEmpty()+ @Field()+ sourceCodeFullPath: string;++ @IsString()+ @IsNotEmpty()+ @Field()+ runtime: string;+@IsEnum(ServerlessFunctionSyncStatus)@IsNotEmpty()@Field(() => ServerlessFunctionSyncStatus)diff --git a/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/update-serverless-function.input.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/update-serverless-function.input.tsnew file mode 100644index 00000000000..2955137196e--- /dev/null+++ b/packages/twenty-server/src/engine/metadata-modules/serverless-function/dtos/update-serverless-function.input.ts@@ -0,0 +1,29 @@+import { Field, InputType } from '@nestjs/graphql';++import { IsNotEmpty, IsString, IsUUID } from 'class-validator';++import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';++@InputType()+export class UpdateServerlessFunctionInput {+ @Field(() => UUIDScalarType, {+ description: 'Id of the serverless function to execute',+ })+ @IsNotEmpty()+ @IsUUID()+ id: string;++ @IsString()+ @IsNotEmpty()+ @Field()+ name: string;++ @IsString()+ @Field({ nullable: true })+ description?: string;++ @IsString()+ @IsNotEmpty()+ @Field()+ code: string;+}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 5ed76fefd44..a5893abe2ae 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@@ -12,6 +12,10 @@ export enum ServerlessFunctionSyncStatus {READY = 'READY',}+export enum ServerlessFunctionRuntime {+ NODE18 = 'nodejs18.x',+}+@Entity('serverlessFunction')@Unique('IndexOnNameAndWorkspaceIdUnique', ['name', 'workspaceId'])export class ServerlessFunctionEntity {@@ -21,9 +25,18 @@ export class ServerlessFunctionEntity {@Column({ nullable: false })name: string;+ @Column({ nullable: true })+ description: string;+@Column({ nullable: false })sourceCodeHash: string;+ @Column({ nullable: false })+ sourceCodeFullPath: string;++ @Column({ nullable: false, default: ServerlessFunctionRuntime.NODE18 })+ runtime: ServerlessFunctionRuntime;+@Column({nullable: false,default: ServerlessFunctionSyncStatus.NOT_READY,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 bc4266f08eb..6f0430431a3 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',+ 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.module.ts b/packages/twenty-server/src/engine/metadata-modules/serverless-function/serverless-function.module.tsindex 94ca8bedea0..25a4714103e 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@@ -1,4 +1,5 @@import { Module } from '@nestjs/common';+import { TypeOrmModule } from '@nestjs/typeorm';import {NestjsQueryGraphQLModule,@@ -14,6 +15,7 @@ import { ServerlessFunctionResolver } from 'src/engine/metadata-modules/serverleimport { JwtAuthGuard } from 'src/engine/guards/jwt.auth.guard';import { ServerlessFunctionDto } from 'src/engine/metadata-modules/serverless-function/dtos/serverless-function.dto';import { FileUploadModule } from 'src/engine/core-modules/file/file-upload/file-upload.module';+import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';@Module({imports: [@@ -24,6 +26,7 @@ import { FileUploadModule } from 'src/engine/core-modules/file/file-upload/file-[ServerlessFunctionEntity],'metadata',),+ TypeOrmModule.forFeature([FeatureFlagEntity], 'core'),],services: [ServerlessFunctionService],resolvers: [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 286ffc19254..76a4a476278 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,7 +1,9 @@import { UseGuards } from '@nestjs/common';import { Args, Mutation, Resolver } from '@nestjs/graphql';+import { InjectRepository } from '@nestjs/typeorm';import { FileUpload, GraphQLUpload } from 'graphql-upload';+import { Repository } from 'typeorm';import { JwtAuthGuard } from 'src/engine/guards/jwt.auth.guard';import { ServerlessFunctionService } from 'src/engine/metadata-modules/serverless-function/serverless-function.service';@@ -9,45 +11,136 @@ import { ExecuteServerlessFunctionInput } from 'src/engine/metadata-modules/servimport { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';import { ServerlessFunctionDto } from 'src/engine/metadata-modules/serverless-function/dtos/serverless-function.dto';-import { ServerlessFunctionExecutionResultDTO } from 'src/engine/metadata-modules/serverless-function/dtos/serverless-function-execution-result-d-t.o';+import { ServerlessFunctionExecutionResultDto } from 'src/engine/metadata-modules/serverless-function/dtos/serverless-function-execution-result.dto';import { serverlessFunctionGraphQLApiExceptionHandler } from 'src/engine/metadata-modules/serverless-function/utils/serverless-function-graphql-api-exception-handler.utils';+import { CreateServerlessFunctionInput } from 'src/engine/metadata-modules/serverless-function/dtos/create-serverless-function.input';+import { CreateServerlessFunctionFromFileInput } from 'src/engine/metadata-modules/serverless-function/dtos/create-serverless-function-from-file.input';+import { UpdateServerlessFunctionInput } from 'src/engine/metadata-modules/serverless-function/dtos/update-serverless-function.input';+import { DeleteServerlessFunctionInput } from 'src/engine/metadata-modules/serverless-function/dtos/delete-serverless-function.input';+import {+ FeatureFlagEntity,+ FeatureFlagKeys,+} from 'src/engine/core-modules/feature-flag/feature-flag.entity';+import {+ ServerlessFunctionException,+ ServerlessFunctionExceptionCode,+} from 'src/engine/metadata-modules/serverless-function/serverless-function.exception';@UseGuards(JwtAuthGuard)@Resolver()export class ServerlessFunctionResolver {constructor(private readonly serverlessFunctionService: ServerlessFunctionService,+ @InjectRepository(FeatureFlagEntity, 'core')+ private readonly featureFlagRepository: Repository<FeatureFlagEntity>,) {}+ async checkFeatureFlag(workspaceId: string) {+ const isFunctionSettingsEnabled =+ await this.featureFlagRepository.findOneBy({+ workspaceId,+ key: FeatureFlagKeys.IsFunctionSettingsEnabled,+ value: true,+ });++ if (!isFunctionSettingsEnabled) {+ throw new ServerlessFunctionException(+ `IS_FUNCTION_SETTINGS_ENABLED feature flag is not set to true for this workspace`,+ ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,+ );+ }+ }++ @Mutation(() => ServerlessFunctionDto)+ async deleteOneServerlessFunction(+ @Args('input') input: DeleteServerlessFunctionInput,+ @AuthWorkspace() { id: workspaceId }: Workspace,+ ) {+ try {+ await this.checkFeatureFlag(workspaceId);++ return await this.serverlessFunctionService.deleteOneServerlessFunction(+ input.id,+ workspaceId,+ );+ } catch (error) {+ serverlessFunctionGraphQLApiExceptionHandler(error);+ }+ }++ @Mutation(() => ServerlessFunctionDto)+ async updateOneServerlessFunction(+ @Args('input')+ input: UpdateServerlessFunctionInput,+ @AuthWorkspace() { id: workspaceId }: Workspace,+ ) {+ try {+ await this.checkFeatureFlag(workspaceId);++ return await this.serverlessFunctionService.updateOneServerlessFunction(+ input,+ workspaceId,+ );+ } catch (error) {+ serverlessFunctionGraphQLApiExceptionHandler(error);+ }+ }+@Mutation(() => ServerlessFunctionDto)async createOneServerlessFunction(+ @Args('input')+ input: CreateServerlessFunctionInput,+ @AuthWorkspace() { id: workspaceId }: Workspace,+ ) {+ try {+ await this.checkFeatureFlag(workspaceId);++ return await this.serverlessFunctionService.createOneServerlessFunction(+ {+ name: input.name,+ description: input.description,+ },+ input.code,+ workspaceId,+ );+ } catch (error) {+ serverlessFunctionGraphQLApiExceptionHandler(error);+ }+ }++ @Mutation(() => ServerlessFunctionDto)+ async createOneServerlessFunctionFromFile(@Args({ name: 'file', type: () => GraphQLUpload })file: FileUpload,- @Args('name', { type: () => String }) name: string,+ @Args('input')+ input: CreateServerlessFunctionFromFileInput,@AuthWorkspace() { id: workspaceId }: Workspace,) {try {- return await this.serverlessFunctionService.createOne(- name,- workspaceId,+ await this.checkFeatureFlag(workspaceId);++ return await this.serverlessFunctionService.createOneServerlessFunction(+ input,file,+ workspaceId,);} catch (error) {serverlessFunctionGraphQLApiExceptionHandler(error);}}- @Mutation(() => ServerlessFunctionExecutionResultDTO)+ @Mutation(() => ServerlessFunctionExecutionResultDto)async executeOneServerlessFunction(@Args() executeServerlessFunctionInput: ExecuteServerlessFunctionInput,@AuthWorkspace() { id: workspaceId }: Workspace,) {try {- const { name, payload } = executeServerlessFunctionInput;+ await this.checkFeatureFlag(workspaceId);+ const { id, payload } = executeServerlessFunctionInput;return {result: await this.serverlessFunctionService.executeOne(- name,+ id,workspaceId,payload,),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 5d9c22a912c..01881cfb1af 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@@ -5,6 +5,8 @@ import { join } from 'path';import { FileUpload } from 'graphql-upload';import { Repository } from 'typeorm';+import { TypeOrmQueryService } from '@ptc-org/nestjs-query-typeorm';+import { v4 } from 'uuid';import { FileFolder } from 'src/engine/core-modules/file/interfaces/file-folder.interface';@@ -21,24 +23,28 @@ import { readFileContent } from 'src/engine/integrations/file-storage/utils/readimport { FileStorageService } from 'src/engine/integrations/file-storage/file-storage.service';import { SOURCE_FILE_NAME } from 'src/engine/integrations/serverless/drivers/constants/source-file-name';import { serverlessFunctionCreateHash } from 'src/engine/metadata-modules/serverless-function/utils/serverless-function-create-hash.utils';+import { CreateServerlessFunctionFromFileInput } from 'src/engine/metadata-modules/serverless-function/dtos/create-serverless-function-from-file.input';+import { UpdateServerlessFunctionInput } from 'src/engine/metadata-modules/serverless-function/dtos/update-serverless-function.input';@Injectable()-export class ServerlessFunctionService {+export class ServerlessFunctionService extends TypeOrmQueryService<ServerlessFunctionEntity> {constructor(private readonly fileStorageService: FileStorageService,private readonly serverlessService: ServerlessService,@InjectRepository(ServerlessFunctionEntity, 'metadata')private readonly serverlessFunctionRepository: Repository<ServerlessFunctionEntity>,- ) {}+ ) {+ super(serverlessFunctionRepository);+ }async executeOne(- name: string,+ id: string,workspaceId: string,payload: object | undefined = undefined,) {const functionToExecute = await this.serverlessFunctionRepository.findOne({where: {- name,+ id,workspaceId,},});@@ -62,14 +68,82 @@ export class ServerlessFunctionService {return this.serverlessService.execute(functionToExecute, payload);}- async createOne(- name: string,+ async deleteOneServerlessFunction(id: string, workspaceId: string) {+ const existingServerlessFunction =+ await this.serverlessFunctionRepository.findOne({+ where: { id, workspaceId },+ });++ if (!existingServerlessFunction) {+ throw new ServerlessFunctionException(+ `Function does not exist`,+ ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,+ );+ }++ await super.deleteOne(id);++ await this.serverlessService.delete(existingServerlessFunction);++ return existingServerlessFunction;+ }++ async updateOneServerlessFunction(+ serverlessFunctionInput: UpdateServerlessFunctionInput,workspaceId: string,- { createReadStream, mimetype }: FileUpload,) {const existingServerlessFunction =await this.serverlessFunctionRepository.findOne({- where: { name, workspaceId },+ where: { id: serverlessFunctionInput.id, workspaceId },+ });++ if (!existingServerlessFunction) {+ throw new ServerlessFunctionException(+ `Function does not exist`,+ ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_FOUND,+ );+ }++ const codeHasChanged =+ serverlessFunctionCreateHash(serverlessFunctionInput.code) !==+ existingServerlessFunction.sourceCodeHash;++ await super.updateOne(existingServerlessFunction.id, {+ name: serverlessFunctionInput.name,+ description: serverlessFunctionInput.description,+ sourceCodeHash: serverlessFunctionCreateHash(+ serverlessFunctionInput.code,+ ),+ });++ if (codeHasChanged) {+ const fileFolder = join(+ FileFolder.ServerlessFunction,+ workspaceId,+ existingServerlessFunction.id,+ );++ await this.fileStorageService.write({+ file: serverlessFunctionInput.code,+ name: SOURCE_FILE_NAME,+ mimeType: undefined,+ folder: fileFolder,+ });++ await this.serverlessService.build(existingServerlessFunction);+ }++ return await this.findById(existingServerlessFunction.id);+ }++ async createOneServerlessFunction(+ serverlessFunctionInput: CreateServerlessFunctionFromFileInput,+ code: FileUpload | string,+ workspaceId: string,+ ) {+ const existingServerlessFunction =+ await this.serverlessFunctionRepository.findOne({+ where: { name: serverlessFunctionInput.name, workspaceId },});if (existingServerlessFunction) {@@ -79,34 +153,44 @@ export class ServerlessFunctionService {);}- const typescriptCode = await readFileContent(createReadStream());+ let typescriptCode: string;- const serverlessFunction = await this.serverlessFunctionRepository.save({- name,- workspaceId,- sourceCodeHash: serverlessFunctionCreateHash(typescriptCode),- });+ if (typeof code === 'string') {+ typescriptCode = code;+ } else {+ typescriptCode = await readFileContent(code.createReadStream());+ }++ const serverlessFunctionId = v4();const fileFolder = join(FileFolder.ServerlessFunction,workspaceId,- serverlessFunction.id,+ serverlessFunctionId,);+ const sourceCodeFullPath = fileFolder + '/' + SOURCE_FILE_NAME;++ const serverlessFunction = await super.createOne({+ ...serverlessFunctionInput,+ id: serverlessFunctionId,+ workspaceId,+ sourceCodeHash: serverlessFunctionCreateHash(typescriptCode),+ sourceCodeFullPath,+ });+await this.fileStorageService.write({file: typescriptCode,name: SOURCE_FILE_NAME,- mimeType: mimetype,+ mimeType: undefined,folder: fileFolder,});await this.serverlessService.build(serverlessFunction);- await this.serverlessFunctionRepository.update(serverlessFunction.id, {+ await super.updateOne(serverlessFunctionId, {syncStatus: ServerlessFunctionSyncStatus.READY,});- return await this.serverlessFunctionRepository.findOneByOrFail({- id: serverlessFunction.id,- });+ return await this.findById(serverlessFunctionId);}}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 0e00aa10390..8f4bc41c941 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@@ -17,6 +17,7 @@ export const serverlessFunctionGraphQLApiExceptionHandler = (error: any) => {case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_ALREADY_EXIST:throw new ConflictError(error.message);case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_NOT_READY:+ case ServerlessFunctionExceptionCode.FEATURE_FLAG_INVALID:throw new ForbiddenError(error.message);default:throw new InternalServerError(error.message);diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/add-standard-id.command.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/add-standard-id.command.tsindex 3f72b8dae22..07e5efc095a 100644--- a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/add-standard-id.command.ts+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/commands/add-standard-id.command.ts@@ -62,6 +62,7 @@ export class AddStandardIdCommand extends CommandRunner {IS_MESSAGING_ALIAS_FETCHING_ENABLED: true,IS_GOOGLE_CALENDAR_SYNC_V2_ENABLED: true,IS_FREE_ACCESS_ENABLED: false,+ IS_FUNCTION_SETTINGS_ENABLED: false,IS_WORKFLOW_ENABLED: false,},);@@ -81,6 +82,7 @@ export class AddStandardIdCommand extends CommandRunner {IS_MESSAGING_ALIAS_FETCHING_ENABLED: true,IS_GOOGLE_CALENDAR_SYNC_V2_ENABLED: true,IS_FREE_ACCESS_ENABLED: false,+ IS_FUNCTION_SETTINGS_ENABLED: false,IS_WORKFLOW_ENABLED: false,},);diff --git a/packages/twenty-ui/src/display/icon/components/TablerIcons.ts b/packages/twenty-ui/src/display/icon/components/TablerIcons.tsindex 8c1b94e4006..a73785be8fc 100644--- a/packages/twenty-ui/src/display/icon/components/TablerIcons.ts+++ b/packages/twenty-ui/src/display/icon/components/TablerIcons.ts@@ -84,6 +84,7 @@ export {IconFilter,IconFilterOff,IconFocusCentered,+ IconFunction,IconForbid,IconGripVertical,IconH1,@@ -127,6 +128,7 @@ export {IconPhone,IconPhoto,IconPilcrow,+ IconPlayerPlay,IconPlug,IconPlus,IconPresentation,@@ -153,6 +155,7 @@ export {IconTags,IconTarget,IconTargetArrow,+ IconTestPipe,IconTextSize,IconTimelineEvent,IconTrash,diff --git a/packages/twenty-ui/src/theme/constants/CodeDark.ts b/packages/twenty-ui/src/theme/constants/CodeDark.tsnew file mode 100644index 00000000000..dc675bf1f8e--- /dev/null+++ b/packages/twenty-ui/src/theme/constants/CodeDark.ts@@ -0,0 +1,10 @@+import { COLOR } from './Colors';++export const CODE_DARK = {+ text: {+ gray: COLOR.gray50,+ sky: COLOR.sky50,+ pink: COLOR.pink50,+ orange: COLOR.orange40,+ },+};diff --git a/packages/twenty-ui/src/theme/constants/CodeLight.ts b/packages/twenty-ui/src/theme/constants/CodeLight.tsnew file mode 100644index 00000000000..3f2f47fa5e9--- /dev/null+++ b/packages/twenty-ui/src/theme/constants/CodeLight.ts@@ -0,0 +1,10 @@+import { COLOR } from './Colors';++export const CODE_LIGHT = {+ text: {+ gray: COLOR.gray50,+ sky: COLOR.sky50,+ pink: COLOR.pink50,+ orange: COLOR.orange40,+ },+};diff --git a/packages/twenty-ui/src/theme/constants/ThemeDark.ts b/packages/twenty-ui/src/theme/constants/ThemeDark.tsindex b776131262d..6cbcf778723 100644--- a/packages/twenty-ui/src/theme/constants/ThemeDark.ts+++ b/packages/twenty-ui/src/theme/constants/ThemeDark.ts@@ -9,6 +9,7 @@ import { BOX_SHADOW_DARK } from './BoxShadowDark';import { FONT_DARK } from './FontDark';import { TAG_DARK } from './TagDark';import { THEME_COMMON } from './ThemeCommon';+import { CODE_DARK } from './CodeDark';export const THEME_DARK: ThemeType = {...THEME_COMMON,@@ -22,5 +23,6 @@ export const THEME_DARK: ThemeType = {name: 'dark',snackBar: SNACK_BAR_DARK,tag: TAG_DARK,+ code: CODE_DARK,},};diff --git a/packages/twenty-ui/src/theme/constants/ThemeLight.ts b/packages/twenty-ui/src/theme/constants/ThemeLight.tsindex cb89370c741..259552e3ca5 100644--- a/packages/twenty-ui/src/theme/constants/ThemeLight.ts+++ b/packages/twenty-ui/src/theme/constants/ThemeLight.ts@@ -8,6 +8,7 @@ import { BOX_SHADOW_LIGHT } from './BoxShadowLight';import { FONT_LIGHT } from './FontLight';import { TAG_LIGHT } from './TagLight';import { THEME_COMMON } from './ThemeCommon';+import { CODE_LIGHT } from './CodeLight';export const THEME_LIGHT = {...THEME_COMMON,@@ -21,5 +22,6 @@ export const THEME_LIGHT = {name: 'light',snackBar: SNACK_BAR_LIGHT,tag: TAG_LIGHT,+ code: CODE_LIGHT,},};diff --git a/packages/twenty-ui/src/theme/index.ts b/packages/twenty-ui/src/theme/index.tsindex b525f14ae4a..f1faaf6fcf0 100644--- a/packages/twenty-ui/src/theme/index.ts+++ b/packages/twenty-ui/src/theme/index.ts@@ -10,6 +10,8 @@ export * from './constants/BorderDark';export * from './constants/BorderLight';export * from './constants/BoxShadowDark';export * from './constants/BoxShadowLight';+export * from './constants/CodeDark';+export * from './constants/CodeLight';export * from './constants/Colors';export * from './constants/FontCommon';export * from './constants/FontDark';diff --git a/yarn.lock b/yarn.lockindex dc3df1fbfa1..1a4e436ca04 100644--- a/yarn.lock+++ b/yarn.lock@@ -8671,6 +8671,30 @@ __metadata:languageName: nodelinkType: hard+"@monaco-editor/loader@npm:^1.4.0":+ version: 1.4.0+ resolution: "@monaco-editor/loader@npm:1.4.0"+ dependencies:+ state-local: "npm:^1.0.6"+ peerDependencies:+ monaco-editor: ">= 0.21.0 < 1"+ checksum: 10c0/68938350adf2f42363a801d87f5d00c87d397d4cba7041141af10a9216bd35c85209b4723a26d56cb32e68eef61471deda2a450f8892891118fbdce7fa1d987d+ languageName: node+ linkType: hard++"@monaco-editor/react@npm:^4.6.0":+ version: 4.6.0+ resolution: "@monaco-editor/react@npm:4.6.0"+ dependencies:+ "@monaco-editor/loader": "npm:^1.4.0"+ peerDependencies:+ monaco-editor: ">= 0.25.0 < 1"+ react: ^16.8.0 || ^17.0.0 || ^18.0.0+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0+ checksum: 10c0/231e9a9b66a530db326f6732de0ebffcce6b79dcfaf4948923d78b9a3d5e2a04b7a06e1f85bbbca45a5ae15c107a124e4c5c46cabadc20a498fb5f2d05f7f379+ languageName: node+ linkType: hard+"@motionone/animation@npm:^10.12.0":version: 10.16.3resolution: "@motionone/animation@npm:10.16.3"@@ -39375,6 +39399,13 @@ __metadata:languageName: nodelinkType: hard+"monaco-editor@npm:^0.50.0":+ version: 0.50.0+ resolution: "monaco-editor@npm:0.50.0"+ checksum: 10c0/79189c926c2fc1e3a3b9118e80911599bf18108018fe176c7b47a27b4856b544129f9a59c9a5c321d154d6a30a8d9c231684246e9382f4f18329a548d11cb4d6+ languageName: node+ linkType: hard+"mri@npm:^1.1.0":version: 1.2.0resolution: "mri@npm:1.2.0"@@ -47161,6 +47192,13 @@ __metadata:languageName: nodelinkType: hard+"state-local@npm:^1.0.6":+ version: 1.0.7+ resolution: "state-local@npm:1.0.7"+ checksum: 10c0/8dc7daeac71844452fafb514a6d6b6f40d7e2b33df398309ea1c7b3948d6110c57f112b7196500a10c54fdde40291488c52c875575670fb5c819602deca48bd9+ languageName: node+ linkType: hard+"static-browser-server@npm:1.0.3":version: 1.0.3resolution: "static-browser-server@npm:1.0.3"@@ -49095,6 +49133,7 @@ __metadata:"@graphql-yoga/nestjs": "patch:@graphql-yoga/[email protected]#./patches/@graphql-yoga-nestjs-npm-2.1.0-cb509e6047.patch""@langchain/mistralai": "npm:^0.0.24""@langchain/openai": "npm:^0.1.3"+ "@monaco-editor/react": "npm:^4.6.0""@nestjs/cache-manager": "npm:^2.2.1""@nestjs/cli": "npm:10.3.0""@nestjs/devtools-integration": "npm:^0.1.6"@@ -49125,6 +49164,7 @@ __metadata:lodash.omitby: "npm:^4.6.0"lodash.uniq: "npm:^4.5.0"lodash.uniqby: "npm:^4.7.0"+ monaco-editor: "npm:^0.50.0"passport: "npm:^0.7.0"psl: "npm:^1.9.0"rimraf: "npm:^5.0.5"