Skip to content

The open alternative to Salesforce, designed for AI.

feat(workflow): read the workflow show page through the core API (#25669)

Thomas Trompetteb1d38632206f
diff --git a/packages/twenty-front/src/generated/graphql.ts b/packages/twenty-front/src/generated/graphql.ts
index 9175c8beb0f..a2fa9b030cf 100644
--- a/packages/twenty-front/src/generated/graphql.ts
+++ b/packages/twenty-front/src/generated/graphql.ts
@@ -60,6 +60,7 @@ export type CoreWorkflowDto = {
__typename?: 'CoreWorkflowDTO';
applicationId?: Maybe<Scalars['UUID']['output']>;
id: Scalars['UUID']['output'];
+ lastPublishedVersionId?: Maybe<Scalars['UUID']['output']>;
name?: Maybe<Scalars['String']['output']>;
statuses: Array<CoreWorkflowStatus>;
updatedAt: Scalars['String']['output'];
@@ -140,6 +141,7 @@ export type CoreWorkflowVersionDto = {
status: CoreWorkflowVersionStatus;
steps?: Maybe<Scalars['JSON']['output']>;
trigger?: Maybe<Scalars['JSON']['output']>;
+ updatedAt: Scalars['String']['output'];
workspaceWorkflowId: Scalars['UUID']['output'];
workspaceWorkflowVersionId?: Maybe<Scalars['UUID']['output']>;
};
@@ -477,6 +479,7 @@ export type ObjectRecordFilterInput = {
export type Query = {
__typename?: 'Query';
+ coreWorkflow?: Maybe<CoreWorkflowDto>;
coreWorkflowVersion?: Maybe<CoreWorkflowVersionDto>;
coreWorkflowVersions: Array<CoreWorkflowVersionDto>;
coreWorkflows: CoreWorkflowConnection;
@@ -503,6 +506,11 @@ export type Query = {
};
+export type QueryCoreWorkflowArgs = {
+ workspaceWorkflowId: Scalars['UUID']['input'];
+};
+
+
export type QueryCoreWorkflowVersionArgs = {
workspaceWorkflowVersionId: Scalars['UUID']['input'];
};
@@ -952,6 +960,13 @@ export type DeleteCoreWorkflowsMutationVariables = Exact<{
export type DeleteCoreWorkflowsMutation = { __typename?: 'Mutation', deleteCoreWorkflows: Array<{ __typename?: 'DeletedCoreWorkflowDTO', id: any, workspaceWorkflowId: any }> };
+export type GetCoreWorkflowQueryVariables = Exact<{
+ workspaceWorkflowId: Scalars['UUID']['input'];
+}>;
+
+
+export type GetCoreWorkflowQuery = { __typename?: 'Query', coreWorkflow?: { __typename?: 'CoreWorkflowDTO', id: any, name?: string | null, statuses: Array<CoreWorkflowStatus>, lastPublishedVersionId?: any | null, workspaceWorkflowId?: any | null, updatedAt: string } | null };
+
export type GetCoreWorkflowsQueryVariables = Exact<{
first?: InputMaybe<Scalars['Int']['input']>;
after?: InputMaybe<Scalars['String']['input']>;
@@ -968,14 +983,14 @@ export type GetCoreWorkflowVersionQueryVariables = Exact<{
}>;
-export type GetCoreWorkflowVersionQuery = { __typename?: 'Query', coreWorkflowVersion?: { __typename?: 'CoreWorkflowVersionDTO', id: any, label: string, status: CoreWorkflowVersionStatus, workspaceWorkflowVersionId?: any | null, workspaceWorkflowId: any, trigger?: any | null, steps?: any | null, createdAt: string } | null };
+export type GetCoreWorkflowVersionQuery = { __typename?: 'Query', coreWorkflowVersion?: { __typename?: 'CoreWorkflowVersionDTO', id: any, label: string, status: CoreWorkflowVersionStatus, workspaceWorkflowVersionId?: any | null, workspaceWorkflowId: any, trigger?: any | null, steps?: any | null, createdAt: string, updatedAt: string } | null };
export type GetCoreWorkflowVersionsQueryVariables = Exact<{
workspaceWorkflowId: Scalars['UUID']['input'];
}>;
-export type GetCoreWorkflowVersionsQuery = { __typename?: 'Query', coreWorkflowVersions: Array<{ __typename?: 'CoreWorkflowVersionDTO', id: any, label: string, status: CoreWorkflowVersionStatus, workspaceWorkflowVersionId?: any | null, workspaceWorkflowId: any, createdAt: string }> };
+export type GetCoreWorkflowVersionsQuery = { __typename?: 'Query', coreWorkflowVersions: Array<{ __typename?: 'CoreWorkflowVersionDTO', id: any, label: string, status: CoreWorkflowVersionStatus, workspaceWorkflowVersionId?: any | null, workspaceWorkflowId: any, createdAt: string, updatedAt: string }> };
export type WorkflowDiffFragmentFragment = { __typename?: 'WorkflowVersionStepChanges', triggerDiff?: any | null, stepsDiff?: any | null };
@@ -1139,9 +1154,10 @@ export const GetTimelineThreadsFromObjectRecordDocument = {"kind":"Document","de
export const SearchDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Search"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"searchInput"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"limit"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"excludedObjectNameSingulars"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"includedObjectNameSingulars"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"ObjectRecordFilterInput"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"search"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"searchInput"},"value":{"kind":"Variable","name":{"kind":"Name","value":"searchInput"}}},{"kind":"Argument","name":{"kind":"Name","value":"limit"},"value":{"kind":"Variable","name":{"kind":"Name","value":"limit"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}},{"kind":"Argument","name":{"kind":"Name","value":"excludedObjectNameSingulars"},"value":{"kind":"Variable","name":{"kind":"Name","value":"excludedObjectNameSingulars"}}},{"kind":"Argument","name":{"kind":"Name","value":"includedObjectNameSingulars"},"value":{"kind":"Variable","name":{"kind":"Name","value":"includedObjectNameSingulars"}}},{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}],"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":"recordId"}},{"kind":"Field","name":{"kind":"Name","value":"objectNameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"objectLabelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"imageUrl"}},{"kind":"Field","name":{"kind":"Name","value":"tsRankCD"}},{"kind":"Field","name":{"kind":"Name","value":"tsRank"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}}]}}]}}]} as unknown as DocumentNode<SearchQuery, SearchQueryVariables>;
export const CreateCoreWorkflowDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateCoreWorkflow"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateCoreWorkflowInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createCoreWorkflow"},"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"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"statuses"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<CreateCoreWorkflowMutation, CreateCoreWorkflowMutationVariables>;
export const DeleteCoreWorkflowsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteCoreWorkflows"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DeleteCoreWorkflowsInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteCoreWorkflows"},"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"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}}]}}]}}]} as unknown as DocumentNode<DeleteCoreWorkflowsMutation, DeleteCoreWorkflowsMutationVariables>;
+export const GetCoreWorkflowDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoreWorkflow"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coreWorkflow"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceWorkflowId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"statuses"}},{"kind":"Field","name":{"kind":"Name","value":"lastPublishedVersionId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<GetCoreWorkflowQuery, GetCoreWorkflowQueryVariables>;
export const GetCoreWorkflowsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoreWorkflows"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"orderBy"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"CoreWorkflowOrderByField"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"orderByDirection"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"CoreWorkflowOrderByDirection"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"CoreWorkflowFilterInput"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coreWorkflows"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}},{"kind":"Argument","name":{"kind":"Name","value":"orderBy"},"value":{"kind":"Variable","name":{"kind":"Name","value":"orderBy"}}},{"kind":"Argument","name":{"kind":"Name","value":"orderByDirection"},"value":{"kind":"Variable","name":{"kind":"Name","value":"orderByDirection"}}},{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}],"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":"name"}},{"kind":"Field","name":{"kind":"Name","value":"statuses"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"cursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"endCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]} as unknown as DocumentNode<GetCoreWorkflowsQuery, GetCoreWorkflowsQueryVariables>;
-export const GetCoreWorkflowVersionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoreWorkflowVersion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coreWorkflowVersion"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceWorkflowVersionId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}},{"kind":"Field","name":{"kind":"Name","value":"trigger"}},{"kind":"Field","name":{"kind":"Name","value":"steps"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]}}]} as unknown as DocumentNode<GetCoreWorkflowVersionQuery, GetCoreWorkflowVersionQueryVariables>;
-export const GetCoreWorkflowVersionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoreWorkflowVersions"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coreWorkflowVersions"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceWorkflowId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]}}]} as unknown as DocumentNode<GetCoreWorkflowVersionsQuery, GetCoreWorkflowVersionsQueryVariables>;
+export const GetCoreWorkflowVersionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoreWorkflowVersion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coreWorkflowVersion"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceWorkflowVersionId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}},{"kind":"Field","name":{"kind":"Name","value":"trigger"}},{"kind":"Field","name":{"kind":"Name","value":"steps"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<GetCoreWorkflowVersionQuery, GetCoreWorkflowVersionQueryVariables>;
+export const GetCoreWorkflowVersionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetCoreWorkflowVersions"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coreWorkflowVersions"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceWorkflowId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceWorkflowId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowVersionId"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceWorkflowId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<GetCoreWorkflowVersionsQuery, GetCoreWorkflowVersionsQueryVariables>;
export const ActivateWorkflowVersionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ActivateWorkflowVersion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workflowVersionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"activateWorkflowVersion"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workflowVersionId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workflowVersionId"}}}]}]}}]} as unknown as DocumentNode<ActivateWorkflowVersionMutation, ActivateWorkflowVersionMutationVariables>;
export const ComputeStepOutputSchemaDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ComputeStepOutputSchema"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ComputeStepOutputSchemaInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"computeStepOutputSchema"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}]}]}}]} as unknown as DocumentNode<ComputeStepOutputSchemaMutation, ComputeStepOutputSchemaMutationVariables>;
export const CreateDraftFromWorkflowVersionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateDraftFromWorkflowVersion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateDraftFromWorkflowVersionInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createDraftFromWorkflowVersion"},"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"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"trigger"}},{"kind":"Field","name":{"kind":"Name","value":"steps"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<CreateDraftFromWorkflowVersionMutation, CreateDraftFromWorkflowVersionMutationVariables>;
diff --git a/packages/twenty-front/src/modules/object-core/workflows/graphql/queries/getCoreWorkflow.ts b/packages/twenty-front/src/modules/object-core/workflows/graphql/queries/getCoreWorkflow.ts
new file mode 100644
index 00000000000..026a16f15b4
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-core/workflows/graphql/queries/getCoreWorkflow.ts
@@ -0,0 +1,14 @@
+import { gql } from '@apollo/client';
+
+export const GET_CORE_WORKFLOW = gql`
+ query GetCoreWorkflow($workspaceWorkflowId: UUID!) {
+ coreWorkflow(workspaceWorkflowId: $workspaceWorkflowId) {
+ id
+ name
+ statuses
+ lastPublishedVersionId
+ workspaceWorkflowId
+ updatedAt
+ }
+ }
+`;
diff --git a/packages/twenty-front/src/modules/object-core/workflows/hooks/useCoreWorkflowForShowPage.ts b/packages/twenty-front/src/modules/object-core/workflows/hooks/useCoreWorkflowForShowPage.ts
new file mode 100644
index 00000000000..83f8cda75f0
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-core/workflows/hooks/useCoreWorkflowForShowPage.ts
@@ -0,0 +1,87 @@
+import { useQuery } from '@apollo/client/react';
+import { isDefined } from 'twenty-shared/utils';
+
+import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
+import { type Workflow, type WorkflowVersion } from '@/workflow/types/Workflow';
+import {
+ CoreWorkflowVersionStatus,
+ GetCoreWorkflowDocument,
+ GetCoreWorkflowVersionsDocument,
+} from '~/generated/graphql';
+
+type CoreWorkflowShowPageVersion = Pick<
+ WorkflowVersion,
+ 'id' | 'name' | 'status' | 'createdAt'
+>;
+
+type CoreWorkflowShowPageWorkflow = Pick<
+ Workflow,
+ 'id' | 'name' | 'statuses' | 'lastPublishedVersionId'
+>;
+
+export const useCoreWorkflowForShowPage = ({
+ workspaceWorkflowId,
+ skip,
+}: {
+ workspaceWorkflowId: string | undefined;
+ skip: boolean;
+}): {
+ coreWorkflow: CoreWorkflowShowPageWorkflow | undefined;
+ versions: CoreWorkflowShowPageVersion[];
+ draftVersionIdFromServer: string | undefined;
+} => {
+ const apolloCoreClient = useApolloCoreClient();
+
+ const shouldSkip = skip || !isDefined(workspaceWorkflowId);
+
+ const { data: coreWorkflowData } = useQuery(GetCoreWorkflowDocument, {
+ client: apolloCoreClient,
+ fetchPolicy: 'cache-and-network',
+ variables: { workspaceWorkflowId: workspaceWorkflowId ?? '' },
+ skip: shouldSkip,
+ });
+
+ const { data: coreWorkflowVersionsData } = useQuery(
+ GetCoreWorkflowVersionsDocument,
+ {
+ client: apolloCoreClient,
+ fetchPolicy: 'cache-and-network',
+ variables: { workspaceWorkflowId: workspaceWorkflowId ?? '' },
+ skip: shouldSkip,
+ },
+ );
+
+ const coreWorkflow = coreWorkflowData?.coreWorkflow;
+
+ const versions = (
+ coreWorkflowVersionsData?.coreWorkflowVersions ?? []
+ ).flatMap((coreWorkflowVersion) =>
+ isDefined(coreWorkflowVersion.workspaceWorkflowVersionId)
+ ? [
+ {
+ id: coreWorkflowVersion.workspaceWorkflowVersionId,
+ name: coreWorkflowVersion.label,
+ status: coreWorkflowVersion.status,
+ createdAt: coreWorkflowVersion.createdAt,
+ },
+ ]
+ : [],
+ );
+
+ const draftVersionIdFromServer = versions.find(
+ (version) => version.status === CoreWorkflowVersionStatus.DRAFT,
+ )?.id;
+
+ return {
+ coreWorkflow: isDefined(coreWorkflow)
+ ? {
+ id: coreWorkflow.workspaceWorkflowId,
+ name: coreWorkflow.name ?? '',
+ statuses: coreWorkflow.statuses,
+ lastPublishedVersionId: coreWorkflow.lastPublishedVersionId,
+ }
+ : undefined,
+ versions,
+ draftVersionIdFromServer,
+ };
+};
diff --git a/packages/twenty-front/src/modules/object-core/workflows/hooks/useCoreWorkflowVersionContent.ts b/packages/twenty-front/src/modules/object-core/workflows/hooks/useCoreWorkflowVersionContent.ts
new file mode 100644
index 00000000000..fecf0b63424
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-core/workflows/hooks/useCoreWorkflowVersionContent.ts
@@ -0,0 +1,55 @@
+import { useQuery } from '@apollo/client/react';
+import { isDefined } from 'twenty-shared/utils';
+
+import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
+import { type WorkflowVersion } from '@/workflow/types/Workflow';
+import { GetCoreWorkflowVersionDocument } from '~/generated/graphql';
+
+export const useCoreWorkflowVersionContent = ({
+ workspaceWorkflowId,
+ workspaceWorkflowVersionId,
+ skip,
+}: {
+ workspaceWorkflowId: string | undefined;
+ workspaceWorkflowVersionId: string | undefined;
+ skip: boolean;
+}): WorkflowVersion | undefined => {
+ const apolloCoreClient = useApolloCoreClient();
+
+ const { data } = useQuery(GetCoreWorkflowVersionDocument, {
+ client: apolloCoreClient,
+ fetchPolicy: 'cache-and-network',
+ variables: {
+ workspaceWorkflowVersionId: workspaceWorkflowVersionId ?? '',
+ },
+ skip:
+ skip ||
+ !isDefined(workspaceWorkflowVersionId) ||
+ !isDefined(workspaceWorkflowId),
+ });
+
+ const coreWorkflowVersion = data?.coreWorkflowVersion;
+
+ if (
+ !isDefined(coreWorkflowVersion) ||
+ !isDefined(workspaceWorkflowId) ||
+ !isDefined(workspaceWorkflowVersionId) ||
+ coreWorkflowVersion.workspaceWorkflowVersionId !==
+ workspaceWorkflowVersionId ||
+ coreWorkflowVersion.workspaceWorkflowId !== workspaceWorkflowId
+ ) {
+ return undefined;
+ }
+
+ return {
+ __typename: 'WorkflowVersion',
+ id: workspaceWorkflowVersionId,
+ name: coreWorkflowVersion.label,
+ status: coreWorkflowVersion.status,
+ workflowId: workspaceWorkflowId,
+ createdAt: coreWorkflowVersion.createdAt,
+ updatedAt: coreWorkflowVersion.updatedAt,
+ trigger: coreWorkflowVersion.trigger,
+ steps: coreWorkflowVersion.steps,
+ };
+};
diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersion.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersion.ts
index cbae12dc9d1..80567157e18 100644
--- a/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersion.ts
+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersion.ts
@@ -13,6 +13,7 @@ export const GET_CORE_WORKFLOW_VERSION = gql`
trigger
steps
createdAt
+ updatedAt
}
}
`;
diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersions.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersions.ts
index bdf934fee47..d1618d8fc4c 100644
--- a/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersions.ts
+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/graphql/queries/getCoreWorkflowVersions.ts
@@ -9,6 +9,7 @@ export const GET_CORE_WORKFLOW_VERSIONS = gql`
workspaceWorkflowVersionId
workspaceWorkflowId
createdAt
+ updatedAt
}
}
`;
diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions.ts b/packages/twenty-front/src/modules/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions.ts
index b7809baf9b3..c062b6a79a0 100644
--- a/packages/twenty-front/src/modules/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions.ts
+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/utils/invalidateCoreWorkflowVersions.ts
@@ -1,15 +1,27 @@
import { type ApolloClient } from '@apollo/client';
-import { GetCoreWorkflowVersionsDocument } from '~/generated/graphql';
+import {
+ GetCoreWorkflowDocument,
+ GetCoreWorkflowVersionDocument,
+ GetCoreWorkflowVersionsDocument,
+} from '~/generated/graphql';
export const invalidateCoreWorkflowVersions = async (
apolloCoreClient: ApolloClient,
) => {
- apolloCoreClient.cache.evict({
- id: 'ROOT_QUERY',
- fieldName: 'coreWorkflowVersions',
- });
+ for (const fieldName of [
+ 'coreWorkflow',
+ 'coreWorkflowVersion',
+ 'coreWorkflowVersions',
+ ]) {
+ apolloCoreClient.cache.evict({ id: 'ROOT_QUERY', fieldName });
+ }
+
await apolloCoreClient.refetchQueries({
- include: [GetCoreWorkflowVersionsDocument],
+ include: [
+ GetCoreWorkflowVersionsDocument,
+ GetCoreWorkflowVersionDocument,
+ GetCoreWorkflowDocument,
+ ],
});
};
diff --git a/packages/twenty-front/src/modules/workflow/hooks/useWorkflowWithCurrentVersion.ts b/packages/twenty-front/src/modules/workflow/hooks/useWorkflowWithCurrentVersion.ts
index 7ad05219b5d..c2c135e87bf 100644
--- a/packages/twenty-front/src/modules/workflow/hooks/useWorkflowWithCurrentVersion.ts
+++ b/packages/twenty-front/src/modules/workflow/hooks/useWorkflowWithCurrentVersion.ts
@@ -1,3 +1,5 @@
+import { useCoreWorkflowForShowPage } from '@/object-core/workflows/hooks/useCoreWorkflowForShowPage';
+import { useCoreWorkflowVersionContent } from '@/object-core/workflows/hooks/useCoreWorkflowVersionContent';
import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';
import { useEffectiveDraftVersionId } from '@/workflow/hooks/useEffectiveDraftVersionId';
import {
@@ -5,7 +7,8 @@ import {
type WorkflowVersion,
type WorkflowWithCurrentVersion,
} from '@/workflow/types/Workflow';
-import { CoreObjectNameSingular } from 'twenty-shared/types';
+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
+import { CoreObjectNameSingular, FeatureFlagKey } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
type WorkflowWithAllVersions = Omit<Workflow, 'versions'> & {
@@ -17,41 +20,69 @@ type WorkflowWithAllVersions = Omit<Workflow, 'versions'> & {
export const useWorkflowWithCurrentVersion = (
workflowId: string | undefined,
): WorkflowWithCurrentVersion | undefined => {
- const { record: workflow } = useFindOneRecord<WorkflowWithAllVersions>({
- objectNameSingular: CoreObjectNameSingular.Workflow,
- objectRecordId: workflowId,
- recordGqlFields: {
- id: true,
- name: true,
- statuses: true,
- lastPublishedVersionId: true,
- versions: {
+ const isWorkflowCoreIndexPageEnabled = useIsFeatureEnabled(
+ FeatureFlagKey.IS_WORKFLOW_CORE_INDEX_PAGE_ENABLED,
+ );
+
+ const { record: workspaceWorkflow } =
+ useFindOneRecord<WorkflowWithAllVersions>({
+ objectNameSingular: CoreObjectNameSingular.Workflow,
+ objectRecordId: workflowId,
+ recordGqlFields: {
id: true,
- status: true,
name: true,
- createdAt: true,
+ statuses: true,
+ lastPublishedVersionId: true,
+ versions: {
+ id: true,
+ status: true,
+ name: true,
+ createdAt: true,
+ },
},
- },
- skip: !isDefined(workflowId),
+ skip: !isDefined(workflowId) || isWorkflowCoreIndexPageEnabled,
+ });
+
+ const {
+ coreWorkflow,
+ versions: coreVersions,
+ draftVersionIdFromServer,
+ } = useCoreWorkflowForShowPage({
+ workspaceWorkflowId: workflowId,
+ skip: !isWorkflowCoreIndexPageEnabled,
});
- const draftVersionFromServer = workflow?.versions.find(
- (workflowVersion) => workflowVersion.status === 'DRAFT',
+ const workflow = isWorkflowCoreIndexPageEnabled
+ ? coreWorkflow
+ : workspaceWorkflow;
+
+ const allVersions = isWorkflowCoreIndexPageEnabled
+ ? coreVersions
+ : (workspaceWorkflow?.versions ?? []);
+
+ const coreDraftVersion = isDefined(draftVersionIdFromServer)
+ ? { id: draftVersionIdFromServer }
+ : undefined;
+
+ const workspaceDraftVersion = workspaceWorkflow?.versions.find(
+ (version) => version.status === 'DRAFT',
);
+ const draftVersionFromServer = isWorkflowCoreIndexPageEnabled
+ ? coreDraftVersion
+ : workspaceDraftVersion;
+
const { effectiveDraftId, lastDiscardedDraftId } = useEffectiveDraftVersionId(
draftVersionFromServer,
);
- const workflowVersions = [...(workflow?.versions ?? [])]
+ const workflowVersions = [...allVersions]
.filter((version) => version.id !== lastDiscardedDraftId)
.sort((a, b) => (a.createdAt > b.createdAt ? -1 : 1));
- const latestVersion = workflowVersions[0];
-
- const currentVersionId = effectiveDraftId ?? latestVersion?.id;
+ const currentVersionId = effectiveDraftId ?? workflowVersions[0]?.id;
- const { record: currentVersionWithSteps } = useFindOneRecord<WorkflowVersion>(
+ const { record: workspaceCurrentVersion } = useFindOneRecord<WorkflowVersion>(
{
objectNameSingular: CoreObjectNameSingular.WorkflowVersion,
objectRecordId: currentVersionId,
@@ -63,16 +94,28 @@ export const useWorkflowWithCurrentVersion = (
createdAt: true,
updatedAt: true,
},
- skip: !isDefined(currentVersionId),
+ skip: !isDefined(currentVersionId) || isWorkflowCoreIndexPageEnabled,
},
);
- if (!isDefined(workflow) || !isDefined(currentVersionWithSteps)) {
+ const coreCurrentVersion = useCoreWorkflowVersionContent({
+ workspaceWorkflowId: workflowId,
+ workspaceWorkflowVersionId: currentVersionId,
+ skip: !isWorkflowCoreIndexPageEnabled,
+ });
+
+ const currentVersion = isWorkflowCoreIndexPageEnabled
+ ? coreCurrentVersion
+ : workspaceCurrentVersion;
+
+ if (!isDefined(workflow) || !isDefined(currentVersion)) {
return undefined;
}
return {
...workflow,
- currentVersion: currentVersionWithSteps,
+ __typename: 'Workflow',
+ versions: workflowVersions,
+ currentVersion,
};
};
diff --git a/packages/twenty-front/src/modules/workflow/types/Workflow.ts b/packages/twenty-front/src/modules/workflow/types/Workflow.ts
index 38e9b56f82a..3a816d106af 100644
--- a/packages/twenty-front/src/modules/workflow/types/Workflow.ts
+++ b/packages/twenty-front/src/modules/workflow/types/Workflow.ts
@@ -163,7 +163,7 @@ export type Workflow = {
versions: Array<
Pick<WorkflowVersion, 'id' | 'status' | 'name' | 'createdAt'>
>;
- lastPublishedVersionId: string;
+ lastPublishedVersionId: string | null;
statuses: Array<WorkflowStatus> | null;
};
diff --git a/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-version.dto.ts b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-version.dto.ts
index 2b4aee390d9..590524b005e 100644
--- a/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-version.dto.ts
+++ b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow-version.dto.ts
@@ -36,4 +36,7 @@ export class CoreWorkflowVersionDTO {
@Field(() => String)
createdAt: string;
+
+ @Field(() => String)
+ updatedAt: string;
}
diff --git a/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow.dto.ts b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow.dto.ts
index 5a6821cb845..634de3898fa 100644
--- a/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow.dto.ts
+++ b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow.dto.ts
@@ -18,6 +18,9 @@ export class CoreWorkflowDTO {
@Field(() => [WorkflowStatus])
statuses: WorkflowStatus[];
+ @Field(() => UUIDScalarType, { nullable: true })
+ lastPublishedVersionId: string | null;
+
@Field(() => UUIDScalarType, { nullable: true })
applicationId: string | null;
diff --git a/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow.input.ts b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow.input.ts
new file mode 100644
index 00000000000..215317ecd19
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/workflow/dtos/core-workflow.input.ts
@@ -0,0 +1,12 @@
+import { ArgsType, Field } from '@nestjs/graphql';
+
+import { IsUUID } from 'class-validator';
+
+import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
+
+@ArgsType()
+export class CoreWorkflowArgs {
+ @Field(() => UUIDScalarType)
+ @IsUUID()
+ workspaceWorkflowId: string;
+}
diff --git a/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow.resolver.ts b/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow.resolver.ts
index 6e8cc2470fd..383e3cf78b0 100644
--- a/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow.resolver.ts
+++ b/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow.resolver.ts
@@ -14,6 +14,7 @@ import { DeleteCoreWorkflowsInput } from 'src/engine/core-modules/workflow/dtos/
import { CoreWorkflowVersionDTO } from 'src/engine/core-modules/workflow/dtos/core-workflow-version.dto';
import { CoreWorkflowVersionArgs } from 'src/engine/core-modules/workflow/dtos/core-workflow-version.input';
import { CoreWorkflowVersionsArgs } from 'src/engine/core-modules/workflow/dtos/core-workflow-versions.input';
+import { CoreWorkflowArgs } from 'src/engine/core-modules/workflow/dtos/core-workflow.input';
import { CoreWorkflowsArgs } from 'src/engine/core-modules/workflow/dtos/core-workflows.input';
import { CoreWorkflowListService } from 'src/engine/core-modules/workflow/services/core-workflow-list.service';
import { CoreWorkflowMutationWorkspaceService } from 'src/engine/core-modules/workflow/services/core-workflow-mutation.workspace-service';
@@ -80,6 +81,17 @@ export class CoreWorkflowResolver {
);
}
+ @Query(() => CoreWorkflowDTO, { nullable: true })
+ async coreWorkflow(
+ @AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
+ @Args() { workspaceWorkflowId }: CoreWorkflowArgs,
+ ): Promise<CoreWorkflowDTO | null> {
+ return this.coreWorkflowListService.findOneByWorkspaceWorkflowId({
+ workspaceId,
+ workspaceWorkflowId,
+ });
+ }
+
@Query(() => [CoreWorkflowVersionDTO])
async coreWorkflowVersions(
@AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
diff --git a/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-list.service.ts b/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-list.service.ts
index 3d440632b02..47fb3fac3fc 100644
--- a/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-list.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-list.service.ts
@@ -9,6 +9,7 @@ import {
encodeCursorData,
} from 'src/engine/api/graphql/graphql-query-runner/utils/cursors.util';
import { type CoreWorkflowConnectionDTO } from 'src/engine/core-modules/workflow/dtos/core-workflow-connection.dto';
+import { type CoreWorkflowDTO } from 'src/engine/core-modules/workflow/dtos/core-workflow.dto';
import {
CoreWorkflowOrderByDirection,
CoreWorkflowOrderByField,
@@ -24,6 +25,7 @@ type CoreWorkflowRow = {
id: string;
cursorSortValue: string | null;
name: string | null;
+ lastPublishedVersionId: string | null;
applicationId: string | null;
workspaceWorkflowId: string | null;
updatedAt: Date;
@@ -60,6 +62,29 @@ const SORT_COLUMN_BY_FIELD: Record<
const GROUPED_WORKFLOW_COLUMNS = `c.id, c.name, c."updatedAt"`;
+const CORE_WORKFLOW_AGGREGATE_COLUMNS = `
+ c.name,
+ c."lastPublishedVersionId",
+ c."applicationId",
+ c."updatedAt",
+ coalesce(bool_or(v.status = 'DRAFT'), false) AS "hasDraftVersion",
+ coalesce(bool_or(v.status = 'ACTIVE'), false) AS "hasActiveVersion",
+ coalesce(bool_or(v.status = 'DEACTIVATED'), false) AS "hasDeactivatedVersion"`;
+
+const toCoreWorkflowDTO = (row: CoreWorkflowRow): CoreWorkflowDTO => ({
+ id: row.id,
+ name: row.name,
+ statuses: computeCoreWorkflowStatuses({
+ hasDraftVersion: row.hasDraftVersion,
+ hasActiveVersion: row.hasActiveVersion,
+ hasDeactivatedVersion: row.hasDeactivatedVersion,
+ }),
+ lastPublishedVersionId: row.lastPublishedVersionId,
+ applicationId: row.applicationId,
+ workspaceWorkflowId: row.workspaceWorkflowId,
+ updatedAt: row.updatedAt.toISOString(),
+});
+
const buildWorkflowVersionsJoinClause = (schemaName: string) =>
`LEFT JOIN ${schemaName}."workflow" wf
ON wf."coreWorkflowId" = c.id AND wf."deletedAt" IS NULL
@@ -129,18 +154,13 @@ export class CoreWorkflowListService {
`SELECT
c.id,
${cursorExpression} AS "cursorSortValue",
- c.name,
- c."applicationId",
min(wf.id::text) AS "workspaceWorkflowId",
- c."updatedAt",
- coalesce(bool_or(v.status = 'DRAFT'), false) AS "hasDraftVersion",
- coalesce(bool_or(v.status = 'ACTIVE'), false) AS "hasActiveVersion",
- coalesce(bool_or(v.status = 'DEACTIVATED'), false) AS "hasDeactivatedVersion"
+ ${CORE_WORKFLOW_AGGREGATE_COLUMNS}
FROM core."workflow" c
${buildWorkflowVersionsJoinClause(schemaName)}
WHERE c."workspaceId" = $1
${keysetCondition}
- GROUP BY ${GROUPED_WORKFLOW_COLUMNS}, c."applicationId"
+ GROUP BY ${GROUPED_WORKFLOW_COLUMNS}, c."lastPublishedVersionId", c."applicationId"
${havingClause}
ORDER BY ${column} ${direction}${nullsClause}, c.id ${direction}
LIMIT ${limitParameter}`,
@@ -158,18 +178,7 @@ export class CoreWorkflowListService {
const pageRows = hasNextPage ? rows.slice(0, first) : rows;
const edges = pageRows.map((row) => ({
- node: {
- id: row.id,
- name: row.name,
- statuses: computeCoreWorkflowStatuses({
- hasDraftVersion: row.hasDraftVersion,
- hasActiveVersion: row.hasActiveVersion,
- hasDeactivatedVersion: row.hasDeactivatedVersion,
- }),
- applicationId: row.applicationId,
- workspaceWorkflowId: row.workspaceWorkflowId,
- updatedAt: row.updatedAt.toISOString(),
- },
+ node: toCoreWorkflowDTO(row),
cursor: encodeCursorData({
sortValue: row.cursorSortValue,
id: row.id,
@@ -186,6 +195,42 @@ export class CoreWorkflowListService {
};
}
+ async findOneByWorkspaceWorkflowId({
+ workspaceId,
+ workspaceWorkflowId,
+ }: {
+ workspaceId: string;
+ workspaceWorkflowId: string;
+ }): Promise<CoreWorkflowDTO | null> {
+ const schemaName = escapeIdentifier(getWorkspaceSchemaName(workspaceId));
+
+ const rows: CoreWorkflowRow[] = await this.coreDataSource.query(
+ `SELECT
+ c.id,
+ null AS "cursorSortValue",
+ wf.id::text AS "workspaceWorkflowId",
+ ${CORE_WORKFLOW_AGGREGATE_COLUMNS}
+ FROM core."workflow" c
+ JOIN ${schemaName}."workflow" wf
+ ON wf."coreWorkflowId" = c.id
+ AND wf."deletedAt" IS NULL
+ AND wf.id = $2
+ LEFT JOIN core."workflowVersion" v
+ ON v."workflowId" = wf.id AND v."workspaceId" = $1
+ WHERE c."workspaceId" = $1
+ GROUP BY ${GROUPED_WORKFLOW_COLUMNS}, c."lastPublishedVersionId", c."applicationId", wf.id`,
+ [workspaceId, workspaceWorkflowId],
+ );
+
+ const [row] = rows;
+
+ if (!isDefined(row)) {
+ return null;
+ }
+
+ return toCoreWorkflowDTO(row);
+ }
+
private async countByWorkspaceId({
workspaceId,
schemaName,
diff --git a/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-mutation.workspace-service.ts b/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-mutation.workspace-service.ts
index 0de3008c145..cb1141cbda7 100644
--- a/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-mutation.workspace-service.ts
+++ b/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-mutation.workspace-service.ts
@@ -137,6 +137,7 @@ export class CoreWorkflowMutationWorkspaceService {
id: coreWorkflow.id,
name: coreWorkflow.name,
statuses: [WorkflowStatus.DRAFT],
+ lastPublishedVersionId: null,
applicationId,
workspaceWorkflowId,
updatedAt: coreWorkflow.updatedAt.toISOString(),
diff --git a/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-version-list.service.ts b/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-version-list.service.ts
index f455b2f265a..a1502857ecb 100644
--- a/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-version-list.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-version-list.service.ts
@@ -32,7 +32,7 @@ export class CoreWorkflowVersionListService {
{
where: { workflowId: workspaceWorkflowId },
order: { createdAt: 'ASC', id: 'ASC' },
- select: { id: true, status: true, createdAt: true },
+ select: { id: true, status: true, createdAt: true, updatedAt: true },
},
);
@@ -56,6 +56,7 @@ export class CoreWorkflowVersionListService {
trigger: null,
steps: null,
createdAt: coreWorkflowVersion.createdAt.toISOString(),
+ updatedAt: coreWorkflowVersion.updatedAt.toISOString(),
}))
.reverse();
}
diff --git a/packages/twenty-server/test/integration/graphql/suites/workflow/core-workflow-read.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/workflow/core-workflow-read.integration-spec.ts
new file mode 100644
index 00000000000..60fea596aac
--- /dev/null
+++ b/packages/twenty-server/test/integration/graphql/suites/workflow/core-workflow-read.integration-spec.ts
@@ -0,0 +1,171 @@
+import { isDefined } from 'twenty-shared/utils';
+
+import { pollWorkflowGraphqlRequest } from 'test/integration/graphql/suites/workflow/utils/poll-workflow-graphql-request.util';
+import { workflowGraphqlRequest } from 'test/integration/graphql/suites/workflow/utils/workflow-graphql-request.util';
+
+const CORE_WORKFLOW_QUERY = `
+ query CoreWorkflow($workspaceWorkflowId: UUID!) {
+ coreWorkflow(workspaceWorkflowId: $workspaceWorkflowId) {
+ id
+ name
+ statuses
+ lastPublishedVersionId
+ workspaceWorkflowId
+ updatedAt
+ }
+ }
+`;
+
+const CORE_WORKFLOW_VERSIONS_QUERY = `
+ query CoreWorkflowVersions($workspaceWorkflowId: UUID!) {
+ coreWorkflowVersions(workspaceWorkflowId: $workspaceWorkflowId) {
+ id
+ label
+ status
+ workspaceWorkflowVersionId
+ createdAt
+ updatedAt
+ }
+ }
+`;
+
+const CORE_WORKFLOW_VERSION_QUERY = `
+ query CoreWorkflowVersion($workspaceWorkflowVersionId: UUID!) {
+ coreWorkflowVersion(
+ workspaceWorkflowVersionId: $workspaceWorkflowVersionId
+ ) {
+ id
+ label
+ status
+ workspaceWorkflowVersionId
+ trigger
+ steps
+ createdAt
+ updatedAt
+ }
+ }
+`;
+
+type CoreWorkflowResult = {
+ id: string;
+ name: string | null;
+ statuses: string[];
+ lastPublishedVersionId: string | null;
+ workspaceWorkflowId: string | null;
+ updatedAt: string;
+};
+
+type CoreWorkflowVersionResult = {
+ id: string;
+ label: string;
+ status: string;
+ workspaceWorkflowVersionId: string | null;
+ createdAt: string;
+ updatedAt: string;
+};
+
+describe('coreWorkflow (e2e)', () => {
+ let workspaceWorkflowId: string;
+
+ beforeAll(async () => {
+ const createResponse = await workflowGraphqlRequest(`
+ mutation {
+ createWorkflow(data: { name: "Core Workflow Read" }) {
+ id
+ }
+ }
+ `);
+
+ expect(createResponse.body.errors).toBeUndefined();
+
+ workspaceWorkflowId = createResponse.body.data.createWorkflow.id;
+ });
+
+ afterAll(async () => {
+ if (!isDefined(workspaceWorkflowId)) {
+ return;
+ }
+
+ await workflowGraphqlRequest(
+ `
+ mutation DestroyWorkflow($id: UUID!) {
+ destroyWorkflow(id: $id) {
+ id
+ }
+ }
+ `,
+ { id: workspaceWorkflowId },
+ );
+ });
+
+ it('should read one workflow by its workspace id', async () => {
+ const coreWorkflow = await pollWorkflowGraphqlRequest<
+ { coreWorkflow: CoreWorkflowResult | null },
+ CoreWorkflowResult | null | undefined
+ >({
+ query: CORE_WORKFLOW_QUERY,
+ variables: { workspaceWorkflowId },
+ extract: (data) => data?.coreWorkflow,
+ until: isDefined,
+ });
+
+ expect(coreWorkflow).toEqual({
+ id: expect.any(String),
+ name: 'Core Workflow Read',
+ statuses: ['DRAFT'],
+ lastPublishedVersionId: null,
+ workspaceWorkflowId,
+ updatedAt: expect.any(String),
+ });
+ });
+
+ it('should return null for a workflow that does not exist', async () => {
+ const response = await workflowGraphqlRequest(CORE_WORKFLOW_QUERY, {
+ workspaceWorkflowId: '00000000-0000-4000-8000-000000000000',
+ });
+
+ expect(response.body.errors).toBeUndefined();
+ expect(response.body.data.coreWorkflow).toBeNull();
+ });
+
+ it('should expose the version content the show page renders', async () => {
+ const versions = await pollWorkflowGraphqlRequest<
+ { coreWorkflowVersions: CoreWorkflowVersionResult[] },
+ CoreWorkflowVersionResult[]
+ >({
+ query: CORE_WORKFLOW_VERSIONS_QUERY,
+ variables: { workspaceWorkflowId },
+ extract: (data) => data?.coreWorkflowVersions ?? [],
+ until: (polledVersions) =>
+ polledVersions.length === 1 &&
+ isDefined(polledVersions[0].workspaceWorkflowVersionId),
+ });
+
+ expect(versions).toEqual([
+ {
+ id: expect.any(String),
+ label: 'v1',
+ status: 'DRAFT',
+ workspaceWorkflowVersionId: expect.any(String),
+ createdAt: expect.any(String),
+ updatedAt: expect.any(String),
+ },
+ ]);
+
+ const versionResponse = await workflowGraphqlRequest(
+ CORE_WORKFLOW_VERSION_QUERY,
+ {
+ workspaceWorkflowVersionId: versions[0].workspaceWorkflowVersionId,
+ },
+ );
+
+ expect(versionResponse.body.errors).toBeUndefined();
+ expect(versionResponse.body.data.coreWorkflowVersion).toEqual(
+ expect.objectContaining({
+ workspaceWorkflowVersionId: versions[0].workspaceWorkflowVersionId,
+ status: 'DRAFT',
+ updatedAt: expect.any(String),
+ }),
+ );
+ });
+});
diff --git a/packages/twenty-server/test/integration/graphql/suites/workflow/utils/poll-workflow-graphql-request.util.ts b/packages/twenty-server/test/integration/graphql/suites/workflow/utils/poll-workflow-graphql-request.util.ts
new file mode 100644
index 00000000000..0d9b7fec37f
--- /dev/null
+++ b/packages/twenty-server/test/integration/graphql/suites/workflow/utils/poll-workflow-graphql-request.util.ts
@@ -0,0 +1,34 @@
+import { workflowGraphqlRequest } from 'test/integration/graphql/suites/workflow/utils/workflow-graphql-request.util';
+
+const POLL_ATTEMPTS = 20;
+const POLL_INTERVAL_MS = 250;
+
+export const pollWorkflowGraphqlRequest = async <TData, TResult>({
+ query,
+ variables,
+ extract,
+ until,
+}: {
+ query: string;
+ variables?: object;
+ extract: (data: TData | undefined) => TResult;
+ until: (result: TResult) => boolean;
+}): Promise<TResult> => {
+ let result: TResult = extract(undefined);
+
+ for (let attempt = 0; attempt < POLL_ATTEMPTS; attempt++) {
+ const response = await workflowGraphqlRequest(query, variables);
+
+ expect(response.body.errors).toBeUndefined();
+
+ result = extract(response.body.data as TData | undefined);
+
+ if (until(result)) {
+ return result;
+ }
+
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
+ }
+
+ return result;
+};
diff --git a/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-graphql-request.util.ts b/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-graphql-request.util.ts
new file mode 100644
index 00000000000..129ff422b7b
--- /dev/null
+++ b/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-graphql-request.util.ts
@@ -0,0 +1,9 @@
+import request from 'supertest';
+
+const client = request(`http://localhost:${APP_PORT}`);
+
+export const workflowGraphqlRequest = (query: string, variables?: object) =>
+ client
+ .post('/graphql')
+ .set('Authorization', `Bearer ${APPLE_JANE_ADMIN_ACCESS_TOKEN}`)
+ .send({ query, variables });