The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Run application workflows with the owning application's permissions (#27055)
Thomas Trompette616ab5c31b1b
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql b/packages/twenty-client-sdk/src/metadata/generated/schema.graphqlindex 96c4c6e45f7..cfd43bbd906 100644--- a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql@@ -3860,24 +3860,25 @@ type Query {commandMenuItem(id: UUID!): CommandMenuItemfrontComponents: [FrontComponent!]!frontComponent(id: UUID!): FrontComponent+ getInviteSuggestions: [InviteSuggestion!]!+ applicationConnectionProviders(applicationId: UUID!): [ApplicationConnectionProvider!]!+ getUsageAnalytics(input: UsageAnalyticsInput): UsageAnalytics!billingPortalSession(returnUrlPath: String, forPaymentMethodUpdate: Boolean): BillingSession!listPlans: [BillingPlan!]!getResourceCreditUsage: [BillingResourceCreditUsage!]!- getUsageAnalytics(input: UsageAnalyticsInput): UsageAnalytics!- myConnectedAccounts: [ConnectedAccountPublicDTO!]!- applicationConnectedAccounts(applicationId: UUID!): [ApplicationConnectedAccountDTO!]!- applicationConnectionProviders(applicationId: UUID!): [ApplicationConnectionProvider!]!- currentWorkspace: Workspace!- getPublicWorkspaceDataByDomain(origin: String): PublicWorkspaceData!- getPublicWorkspaceDataById(id: UUID!): PublicWorkspaceDataSummary!- getInviteSuggestions: [InviteSuggestion!]!findWorkspaceInvitations: [WorkspaceInvitation!]!getApprovedAccessDomains: [ApprovedAccessDomain!]!- getViewFilterGroups(viewId: String): [ViewFilterGroup!]!- getViewFilterGroup(id: String!): ViewFilterGroup+ getRoles: [Role!]!apiKeys: [ApiKey!]!getApiKeyRoles: [Role!]!apiKey(input: GetApiKeyInput!): ApiKey+ getViewFilterGroups(viewId: String): [ViewFilterGroup!]!+ getViewFilterGroup(id: String!): ViewFilterGroup+ myConnectedAccounts: [ConnectedAccountPublicDTO!]!+ applicationConnectedAccounts(applicationId: UUID!): [ApplicationConnectedAccountDTO!]!+ currentWorkspace: Workspace!+ getPublicWorkspaceDataByDomain(origin: String): PublicWorkspaceData!+ getPublicWorkspaceDataById(id: UUID!): PublicWorkspaceDataSummary!findApplicationRegistrationByClientId(clientId: String!): PublicApplicationRegistrationfindApplicationRegistrationByUniversalIdentifier(universalIdentifier: String!): ApplicationRegistrationfindManyApplicationRegistrations: [ApplicationRegistration!]!@@ -3908,7 +3909,6 @@ type Query {): Field!getViewGroups(viewId: String): [ViewGroup!]!getViewGroup(id: String!): ViewGroup- getRoles: [Role!]!previewMessageCampaignAudience(input: PreviewMessageCampaignAudienceInput!): CampaignAudiencePreviewDTO!messageSuppressions(input: FindMessageSuppressionsInput!): MessageSuppressionList!unsubscribeTopics: [UnsubscribeTopic!]!@@ -4184,6 +4184,10 @@ type Mutation {updateFrontComponent(input: UpdateFrontComponentInput!): FrontComponent!deleteFrontComponent(id: UUID!): FrontComponent!updateOneApplicationVariable(key: String!, value: String!, applicationId: UUID): Boolean!+ skipSyncEmailOnboardingStep(isAutoSkipped: Boolean! = false): OnboardingStepSuccess!+ completeBookCallOnboardingStep(hasBookedCall: Boolean! = false, isAutoSkipped: Boolean! = false): OnboardingStepSuccess!+ triggerInstallAppsOnboardingStep(universalIdentifiers: [String!]!, isAutoSkipped: Boolean! = false): OnboardingStepSuccess!+ goBackToPreviousOnboardingStep: OnboardingStepNavigation!checkoutSession(recurringInterval: SubscriptionInterval!, plan: BillingPlanKey! = PRO, requirePaymentMethod: Boolean! = true, successUrlPath: String): BillingSession!createSubscriptionPaymentIntent(recurringInterval: SubscriptionInterval!, plan: BillingPlanKey! = PRO, requirePaymentMethod: Boolean! = true, successUrlPath: String, idempotencyKey: String!): BillingPaymentIntent!createBillingPaymentMethodSetupIntent: BillingPaymentIntent!@@ -4194,32 +4198,38 @@ type Mutation {setResourceCreditSubscriptionPrice(priceId: String!): BillingUpdate!endSubscriptionTrialPeriod: BillingEndTrialPeriod!cancelSwitchResourceCreditPrice: BillingUpdate!- deleteConnectedAccount(id: UUID!): ConnectedAccountPublicDTO!- disconnectConnectedAccount(id: UUID!): ConnectedAccountPublicDTO!- activateWorkspace(data: ActivateWorkspaceInput!): Workspace!- updateWorkspace(data: UpdateWorkspaceInput!): Workspace!- updateWorkspaceAllowedIframeOrigins(data: UpdateWorkspaceAllowedIframeOriginsInput!): Workspace!- deleteCurrentWorkspace: Workspace!- checkCustomDomainValidRecords: DomainValidRecords- enrichWorkspaceCompany: WorkspaceCompanyEnrichmentResult!- skipSyncEmailOnboardingStep(isAutoSkipped: Boolean! = false): OnboardingStepSuccess!- completeBookCallOnboardingStep(hasBookedCall: Boolean! = false, isAutoSkipped: Boolean! = false): OnboardingStepSuccess!- triggerInstallAppsOnboardingStep(universalIdentifiers: [String!]!, isAutoSkipped: Boolean! = false): OnboardingStepSuccess!- goBackToPreviousOnboardingStep: OnboardingStepNavigation!deleteWorkspaceInvitation(appTokenId: String!): String!resendWorkspaceInvitation(appTokenId: String!): SendInvitations!sendInvitations(emails: [String!]!, roleId: UUID): SendInvitations!createApprovedAccessDomain(input: CreateApprovedAccessDomainInput!): ApprovedAccessDomain!deleteApprovedAccessDomain(input: DeleteApprovedAccessDomainInput!): Boolean!validateApprovedAccessDomain(input: ValidateApprovedAccessDomainInput!): ApprovedAccessDomain!- createViewFilterGroup(input: CreateViewFilterGroupInput!): ViewFilterGroup!- updateViewFilterGroup(id: String!, input: UpdateViewFilterGroupInput!): ViewFilterGroup!- deleteViewFilterGroup(id: String!): Boolean!- destroyViewFilterGroup(id: String!): Boolean!+ updateWorkspaceMemberRole(workspaceMemberId: UUID!, roleId: UUID!): WorkspaceMember!+ createOneRole(createRoleInput: CreateRoleInput!): Role!+ updateOneRole(updateRoleInput: UpdateRoleInput!): Role!+ deleteOneRole(roleId: UUID!): String!+ upsertObjectPermissions(upsertObjectPermissionsInput: UpsertObjectPermissionsInput!): [ObjectPermission!]!+ upsertPermissionFlags(upsertPermissionFlagsInput: UpsertPermissionFlagsInput!): [RolePermissionFlag!]!+ upsertFieldPermissions(upsertFieldPermissionsInput: UpsertFieldPermissionsInput!): [FieldPermission!]!+ upsertRowLevelPermissionPredicates(input: UpsertRowLevelPermissionPredicatesInput!): UpsertRowLevelPermissionPredicatesResult!+ assignRoleToAgent(agentId: UUID!, roleId: UUID!): Boolean!+ removeRoleFromAgent(agentId: UUID!): Boolean!createApiKey(input: CreateApiKeyInput!): ApiKey!updateApiKey(input: UpdateApiKeyInput!): ApiKeyrevokeApiKey(input: RevokeApiKeyInput!): ApiKeyassignRoleToApiKey(apiKeyId: UUID!, roleId: UUID!): Boolean!+ createViewFilterGroup(input: CreateViewFilterGroupInput!): ViewFilterGroup!+ updateViewFilterGroup(id: String!, input: UpdateViewFilterGroupInput!): ViewFilterGroup!+ deleteViewFilterGroup(id: String!): Boolean!+ destroyViewFilterGroup(id: String!): Boolean!+ deleteConnectedAccount(id: UUID!): ConnectedAccountPublicDTO!+ disconnectConnectedAccount(id: UUID!): ConnectedAccountPublicDTO!+ activateWorkspace(data: ActivateWorkspaceInput!): Workspace!+ updateWorkspace(data: UpdateWorkspaceInput!): Workspace!+ updateWorkspaceAllowedIframeOrigins(data: UpdateWorkspaceAllowedIframeOriginsInput!): Workspace!+ deleteCurrentWorkspace: Workspace!+ checkCustomDomainValidRecords: DomainValidRecords+ enrichWorkspaceCompany: WorkspaceCompanyEnrichmentResult!upgradeApplication(appRegistrationId: String!, targetVersion: String!): Boolean!createApplicationRegistration(input: CreateApplicationRegistrationInput!): CreateApplicationRegistration!updateApplicationRegistration(input: UpdateApplicationRegistrationInput!): ApplicationRegistration!@@ -4248,16 +4258,6 @@ type Mutation {updateManyViewGroups(inputs: [UpdateViewGroupInput!]!): [ViewGroup!]!deleteViewGroup(input: DeleteViewGroupInput!): ViewGroup!destroyViewGroup(input: DestroyViewGroupInput!): ViewGroup!- updateWorkspaceMemberRole(workspaceMemberId: UUID!, roleId: UUID!): WorkspaceMember!- createOneRole(createRoleInput: CreateRoleInput!): Role!- updateOneRole(updateRoleInput: UpdateRoleInput!): Role!- deleteOneRole(roleId: UUID!): String!- upsertObjectPermissions(upsertObjectPermissionsInput: UpsertObjectPermissionsInput!): [ObjectPermission!]!- upsertPermissionFlags(upsertPermissionFlagsInput: UpsertPermissionFlagsInput!): [RolePermissionFlag!]!- upsertFieldPermissions(upsertFieldPermissionsInput: UpsertFieldPermissionsInput!): [FieldPermission!]!- upsertRowLevelPermissionPredicates(input: UpsertRowLevelPermissionPredicatesInput!): UpsertRowLevelPermissionPredicatesResult!- assignRoleToAgent(agentId: UUID!, roleId: UUID!): Boolean!- removeRoleFromAgent(agentId: UUID!): Boolean!sendMessageCampaign(input: SendMessageCampaignInput!): SendMessageCampaignOutputDTO!cancelMessageCampaign(input: CancelMessageCampaignInput!): CancelMessageCampaignOutputDTO!sendMessageCampaignTest(input: SendMessageCampaignTestInput!): SendEmailViaDomainOutput!@@ -5028,6 +5028,149 @@ input UpdateFrontComponentInputUpdates {description: String}+input CreateApprovedAccessDomainInput {+ domain: String!+ email: String!+}++input DeleteApprovedAccessDomainInput {+ id: UUID!+}++input ValidateApprovedAccessDomainInput {+ validationToken: String!+ approvedAccessDomainId: UUID!+}++input CreateRoleInput {+ id: String+ label: String!+ description: String+ icon: String+ canUpdateAllSettings: Boolean+ canAccessAllTools: Boolean+ canReadAllObjectRecords: Boolean+ canUpdateAllObjectRecords: Boolean+ canSoftDeleteAllObjectRecords: Boolean+ canDestroyAllObjectRecords: Boolean+ canBeAssignedToUsers: Boolean+ canBeAssignedToAgents: Boolean+ canBeAssignedToApiKeys: Boolean+}++input UpdateRoleInput {+ update: UpdateRolePayload!++ """The id of the role to update"""+ id: UUID!+}++input UpdateRolePayload {+ label: String+ description: String+ icon: String+ canUpdateAllSettings: Boolean+ canAccessAllTools: Boolean+ canReadAllObjectRecords: Boolean+ canUpdateAllObjectRecords: Boolean+ canSoftDeleteAllObjectRecords: Boolean+ canDestroyAllObjectRecords: Boolean+ canBeAssignedToUsers: Boolean+ canBeAssignedToAgents: Boolean+ canBeAssignedToApiKeys: Boolean+}++input UpsertObjectPermissionsInput {+ roleId: UUID!+ objectPermissions: [ObjectPermissionInput!]!+}++input ObjectPermissionInput {+ objectMetadataId: UUID!+ canReadObjectRecords: Boolean+ canUpdateObjectRecords: Boolean+ canSoftDeleteObjectRecords: Boolean+ canDestroyObjectRecords: Boolean+}++input UpsertPermissionFlagsInput {+ roleId: UUID!+ permissionFlagKeys: [String!]!+}++input UpsertFieldPermissionsInput {+ roleId: UUID!+ fieldPermissions: [FieldPermissionInput!]!+}++input FieldPermissionInput {+ objectMetadataId: UUID!+ fieldMetadataId: UUID!+ canReadFieldValue: Boolean+ canUpdateFieldValue: Boolean+}++input UpsertRowLevelPermissionPredicatesInput {+ roleId: UUID!+ objectMetadataId: UUID!+ predicates: [RowLevelPermissionPredicateInput!]!+ predicateGroups: [RowLevelPermissionPredicateGroupInput!]!+}++input RowLevelPermissionPredicateInput {+ id: UUID+ fieldMetadataId: UUID!+ operand: RowLevelPermissionPredicateOperand!+ value: JSON+ subFieldName: String+ workspaceMemberFieldMetadataId: String+ workspaceMemberSubFieldName: String+ rowLevelPermissionPredicateGroupId: UUID+ positionInRowLevelPermissionPredicateGroup: Float+}++input RowLevelPermissionPredicateGroupInput {+ id: UUID+ objectMetadataId: UUID!+ parentRowLevelPermissionPredicateGroupId: UUID+ logicalOperator: RowLevelPermissionPredicateGroupLogicalOperator!+ positionInRowLevelPermissionPredicateGroup: Float+}++input CreateApiKeyInput {+ name: String!+ expiresAt: String!+ revokedAt: String+ roleId: UUID!+}++input UpdateApiKeyInput {+ id: UUID!+ name: String+ expiresAt: String+ revokedAt: String+}++input RevokeApiKeyInput {+ id: UUID!+}++input CreateViewFilterGroupInput {+ id: UUID+ parentViewFilterGroupId: UUID+ logicalOperator: ViewFilterGroupLogicalOperator = AND+ positionInViewFilterGroup: Float+ viewId: UUID!+}++input UpdateViewFilterGroupInput {+ id: UUID+ parentViewFilterGroupId: UUID+ logicalOperator: ViewFilterGroupLogicalOperator = AND+ positionInViewFilterGroup: Float+ viewId: UUID+}+input ActivateWorkspaceInput {"""Deprecated: the workspace name is set at creation (signUpInNewWorkspace) and this field is ignored during activation. Kept for backward compatibility.@@ -5070,54 +5213,6 @@ input UpdateWorkspaceAllowedIframeOriginsInput {origin: String!}-input CreateApprovedAccessDomainInput {- domain: String!- email: String!-}--input DeleteApprovedAccessDomainInput {- id: UUID!-}--input ValidateApprovedAccessDomainInput {- validationToken: String!- approvedAccessDomainId: UUID!-}--input CreateViewFilterGroupInput {- id: UUID- parentViewFilterGroupId: UUID- logicalOperator: ViewFilterGroupLogicalOperator = AND- positionInViewFilterGroup: Float- viewId: UUID!-}--input UpdateViewFilterGroupInput {- id: UUID- parentViewFilterGroupId: UUID- logicalOperator: ViewFilterGroupLogicalOperator = AND- positionInViewFilterGroup: Float- viewId: UUID-}--input CreateApiKeyInput {- name: String!- expiresAt: String!- revokedAt: String- roleId: UUID!-}--input UpdateApiKeyInput {- id: UUID!- name: String- expiresAt: String- revokedAt: String-}--input RevokeApiKeyInput {- id: UUID!-}-input CreateApplicationRegistrationInput {name: String!universalIdentifier: String@@ -5262,101 +5357,6 @@ input DestroyViewGroupInput {id: UUID!}-input CreateRoleInput {- id: String- label: String!- description: String- icon: String- canUpdateAllSettings: Boolean- canAccessAllTools: Boolean- canReadAllObjectRecords: Boolean- canUpdateAllObjectRecords: Boolean- canSoftDeleteAllObjectRecords: Boolean- canDestroyAllObjectRecords: Boolean- canBeAssignedToUsers: Boolean- canBeAssignedToAgents: Boolean- canBeAssignedToApiKeys: Boolean-}--input UpdateRoleInput {- update: UpdateRolePayload!-- """The id of the role to update"""- id: UUID!-}--input UpdateRolePayload {- label: String- description: String- icon: String- canUpdateAllSettings: Boolean- canAccessAllTools: Boolean- canReadAllObjectRecords: Boolean- canUpdateAllObjectRecords: Boolean- canSoftDeleteAllObjectRecords: Boolean- canDestroyAllObjectRecords: Boolean- canBeAssignedToUsers: Boolean- canBeAssignedToAgents: Boolean- canBeAssignedToApiKeys: Boolean-}--input UpsertObjectPermissionsInput {- roleId: UUID!- objectPermissions: [ObjectPermissionInput!]!-}--input ObjectPermissionInput {- objectMetadataId: UUID!- canReadObjectRecords: Boolean- canUpdateObjectRecords: Boolean- canSoftDeleteObjectRecords: Boolean- canDestroyObjectRecords: Boolean-}--input UpsertPermissionFlagsInput {- roleId: UUID!- permissionFlagKeys: [String!]!-}--input UpsertFieldPermissionsInput {- roleId: UUID!- fieldPermissions: [FieldPermissionInput!]!-}--input FieldPermissionInput {- objectMetadataId: UUID!- fieldMetadataId: UUID!- canReadFieldValue: Boolean- canUpdateFieldValue: Boolean-}--input UpsertRowLevelPermissionPredicatesInput {- roleId: UUID!- objectMetadataId: UUID!- predicates: [RowLevelPermissionPredicateInput!]!- predicateGroups: [RowLevelPermissionPredicateGroupInput!]!-}--input RowLevelPermissionPredicateInput {- id: UUID- fieldMetadataId: UUID!- operand: RowLevelPermissionPredicateOperand!- value: JSON- subFieldName: String- workspaceMemberFieldMetadataId: String- workspaceMemberSubFieldName: String- rowLevelPermissionPredicateGroupId: UUID- positionInRowLevelPermissionPredicateGroup: Float-}--input RowLevelPermissionPredicateGroupInput {- id: UUID- objectMetadataId: UUID!- parentRowLevelPermissionPredicateGroupId: UUID- logicalOperator: RowLevelPermissionPredicateGroupLogicalOperator!- positionInRowLevelPermissionPredicateGroup: Float-}-input SendMessageCampaignInput {campaignId: String!scheduledAt: DateTimediff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.ts b/packages/twenty-client-sdk/src/metadata/generated/schema.tsindex 9baeef40015..956bdf50d9d 100644--- a/packages/twenty-client-sdk/src/metadata/generated/schema.ts+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.ts@@ -3390,24 +3390,25 @@ export interface Query {commandMenuItem?: CommandMenuItemfrontComponents: FrontComponent[]frontComponent?: FrontComponent+ getInviteSuggestions: InviteSuggestion[]+ applicationConnectionProviders: ApplicationConnectionProvider[]+ getUsageAnalytics: UsageAnalyticsbillingPortalSession: BillingSessionlistPlans: BillingPlan[]getResourceCreditUsage: BillingResourceCreditUsage[]- getUsageAnalytics: UsageAnalytics- myConnectedAccounts: ConnectedAccountPublicDTO[]- applicationConnectedAccounts: ApplicationConnectedAccountDTO[]- applicationConnectionProviders: ApplicationConnectionProvider[]- currentWorkspace: Workspace- getPublicWorkspaceDataByDomain: PublicWorkspaceData- getPublicWorkspaceDataById: PublicWorkspaceDataSummary- getInviteSuggestions: InviteSuggestion[]findWorkspaceInvitations: WorkspaceInvitation[]getApprovedAccessDomains: ApprovedAccessDomain[]- getViewFilterGroups: ViewFilterGroup[]- getViewFilterGroup?: ViewFilterGroup+ getRoles: Role[]apiKeys: ApiKey[]getApiKeyRoles: Role[]apiKey?: ApiKey+ getViewFilterGroups: ViewFilterGroup[]+ getViewFilterGroup?: ViewFilterGroup+ myConnectedAccounts: ConnectedAccountPublicDTO[]+ applicationConnectedAccounts: ApplicationConnectedAccountDTO[]+ currentWorkspace: Workspace+ getPublicWorkspaceDataByDomain: PublicWorkspaceData+ getPublicWorkspaceDataById: PublicWorkspaceDataSummaryfindApplicationRegistrationByClientId?: PublicApplicationRegistrationfindApplicationRegistrationByUniversalIdentifier?: ApplicationRegistrationfindManyApplicationRegistrations: ApplicationRegistration[]@@ -3429,7 +3430,6 @@ export interface Query {field: FieldgetViewGroups: ViewGroup[]getViewGroup?: ViewGroup- getRoles: Role[]previewMessageCampaignAudience: CampaignAudiencePreviewDTOmessageSuppressions: MessageSuppressionListunsubscribeTopics: UnsubscribeTopic[]@@ -3575,6 +3575,10 @@ export interface Mutation {updateFrontComponent: FrontComponentdeleteFrontComponent: FrontComponentupdateOneApplicationVariable: Scalars['Boolean']+ skipSyncEmailOnboardingStep: OnboardingStepSuccess+ completeBookCallOnboardingStep: OnboardingStepSuccess+ triggerInstallAppsOnboardingStep: OnboardingStepSuccess+ goBackToPreviousOnboardingStep: OnboardingStepNavigationcheckoutSession: BillingSessioncreateSubscriptionPaymentIntent: BillingPaymentIntentcreateBillingPaymentMethodSetupIntent: BillingPaymentIntent@@ -3585,32 +3589,38 @@ export interface Mutation {setResourceCreditSubscriptionPrice: BillingUpdateendSubscriptionTrialPeriod: BillingEndTrialPeriodcancelSwitchResourceCreditPrice: BillingUpdate- deleteConnectedAccount: ConnectedAccountPublicDTO- disconnectConnectedAccount: ConnectedAccountPublicDTO- activateWorkspace: Workspace- updateWorkspace: Workspace- updateWorkspaceAllowedIframeOrigins: Workspace- deleteCurrentWorkspace: Workspace- checkCustomDomainValidRecords?: DomainValidRecords- enrichWorkspaceCompany: WorkspaceCompanyEnrichmentResult- skipSyncEmailOnboardingStep: OnboardingStepSuccess- completeBookCallOnboardingStep: OnboardingStepSuccess- triggerInstallAppsOnboardingStep: OnboardingStepSuccess- goBackToPreviousOnboardingStep: OnboardingStepNavigationdeleteWorkspaceInvitation: Scalars['String']resendWorkspaceInvitation: SendInvitationssendInvitations: SendInvitationscreateApprovedAccessDomain: ApprovedAccessDomaindeleteApprovedAccessDomain: Scalars['Boolean']validateApprovedAccessDomain: ApprovedAccessDomain- createViewFilterGroup: ViewFilterGroup- updateViewFilterGroup: ViewFilterGroup- deleteViewFilterGroup: Scalars['Boolean']- destroyViewFilterGroup: Scalars['Boolean']+ updateWorkspaceMemberRole: WorkspaceMember+ createOneRole: Role+ updateOneRole: Role+ deleteOneRole: Scalars['String']+ upsertObjectPermissions: ObjectPermission[]+ upsertPermissionFlags: RolePermissionFlag[]+ upsertFieldPermissions: FieldPermission[]+ upsertRowLevelPermissionPredicates: UpsertRowLevelPermissionPredicatesResult+ assignRoleToAgent: Scalars['Boolean']+ removeRoleFromAgent: Scalars['Boolean']createApiKey: ApiKeyupdateApiKey?: ApiKeyrevokeApiKey?: ApiKeyassignRoleToApiKey: Scalars['Boolean']+ createViewFilterGroup: ViewFilterGroup+ updateViewFilterGroup: ViewFilterGroup+ deleteViewFilterGroup: Scalars['Boolean']+ destroyViewFilterGroup: Scalars['Boolean']+ deleteConnectedAccount: ConnectedAccountPublicDTO+ disconnectConnectedAccount: ConnectedAccountPublicDTO+ activateWorkspace: Workspace+ updateWorkspace: Workspace+ updateWorkspaceAllowedIframeOrigins: Workspace+ deleteCurrentWorkspace: Workspace+ checkCustomDomainValidRecords?: DomainValidRecords+ enrichWorkspaceCompany: WorkspaceCompanyEnrichmentResultupgradeApplication: Scalars['Boolean']createApplicationRegistration: CreateApplicationRegistrationupdateApplicationRegistration: ApplicationRegistration@@ -3641,16 +3651,6 @@ export interface Mutation {updateManyViewGroups: ViewGroup[]deleteViewGroup: ViewGroupdestroyViewGroup: ViewGroup- updateWorkspaceMemberRole: WorkspaceMember- createOneRole: Role- updateOneRole: Role- deleteOneRole: Scalars['String']- upsertObjectPermissions: ObjectPermission[]- upsertPermissionFlags: RolePermissionFlag[]- upsertFieldPermissions: FieldPermission[]- upsertRowLevelPermissionPredicates: UpsertRowLevelPermissionPredicatesResult- assignRoleToAgent: Scalars['Boolean']- removeRoleFromAgent: Scalars['Boolean']sendMessageCampaign: SendMessageCampaignOutputDTOcancelMessageCampaign: CancelMessageCampaignOutputDTOsendMessageCampaignTest: SendEmailViaDomainOutput@@ -7316,24 +7316,25 @@ export interface QueryGenqlSelection{commandMenuItem?: (CommandMenuItemGenqlSelection & { __args: {id: Scalars['UUID']} })frontComponents?: FrontComponentGenqlSelectionfrontComponent?: (FrontComponentGenqlSelection & { __args: {id: Scalars['UUID']} })+ getInviteSuggestions?: InviteSuggestionGenqlSelection+ applicationConnectionProviders?: (ApplicationConnectionProviderGenqlSelection & { __args: {applicationId: Scalars['UUID']} })+ getUsageAnalytics?: (UsageAnalyticsGenqlSelection & { __args?: {input?: (UsageAnalyticsInput | null)} })billingPortalSession?: (BillingSessionGenqlSelection & { __args?: {returnUrlPath?: (Scalars['String'] | null), forPaymentMethodUpdate?: (Scalars['Boolean'] | null)} })listPlans?: BillingPlanGenqlSelectiongetResourceCreditUsage?: BillingResourceCreditUsageGenqlSelection- getUsageAnalytics?: (UsageAnalyticsGenqlSelection & { __args?: {input?: (UsageAnalyticsInput | null)} })- myConnectedAccounts?: ConnectedAccountPublicDTOGenqlSelection- applicationConnectedAccounts?: (ApplicationConnectedAccountDTOGenqlSelection & { __args: {applicationId: Scalars['UUID']} })- applicationConnectionProviders?: (ApplicationConnectionProviderGenqlSelection & { __args: {applicationId: Scalars['UUID']} })- currentWorkspace?: WorkspaceGenqlSelection- getPublicWorkspaceDataByDomain?: (PublicWorkspaceDataGenqlSelection & { __args?: {origin?: (Scalars['String'] | null)} })- getPublicWorkspaceDataById?: (PublicWorkspaceDataSummaryGenqlSelection & { __args: {id: Scalars['UUID']} })- getInviteSuggestions?: InviteSuggestionGenqlSelectionfindWorkspaceInvitations?: WorkspaceInvitationGenqlSelectiongetApprovedAccessDomains?: ApprovedAccessDomainGenqlSelection- getViewFilterGroups?: (ViewFilterGroupGenqlSelection & { __args?: {viewId?: (Scalars['String'] | null)} })- getViewFilterGroup?: (ViewFilterGroupGenqlSelection & { __args: {id: Scalars['String']} })+ getRoles?: RoleGenqlSelectionapiKeys?: ApiKeyGenqlSelectiongetApiKeyRoles?: RoleGenqlSelectionapiKey?: (ApiKeyGenqlSelection & { __args: {input: GetApiKeyInput} })+ getViewFilterGroups?: (ViewFilterGroupGenqlSelection & { __args?: {viewId?: (Scalars['String'] | null)} })+ getViewFilterGroup?: (ViewFilterGroupGenqlSelection & { __args: {id: Scalars['String']} })+ myConnectedAccounts?: ConnectedAccountPublicDTOGenqlSelection+ applicationConnectedAccounts?: (ApplicationConnectedAccountDTOGenqlSelection & { __args: {applicationId: Scalars['UUID']} })+ currentWorkspace?: WorkspaceGenqlSelection+ getPublicWorkspaceDataByDomain?: (PublicWorkspaceDataGenqlSelection & { __args?: {origin?: (Scalars['String'] | null)} })+ getPublicWorkspaceDataById?: (PublicWorkspaceDataSummaryGenqlSelection & { __args: {id: Scalars['UUID']} })findApplicationRegistrationByClientId?: (PublicApplicationRegistrationGenqlSelection & { __args: {clientId: Scalars['String']} })findApplicationRegistrationByUniversalIdentifier?: (ApplicationRegistrationGenqlSelection & { __args: {universalIdentifier: Scalars['String']} })findManyApplicationRegistrations?: ApplicationRegistrationGenqlSelection@@ -7361,7 +7362,6 @@ export interface QueryGenqlSelection{id: Scalars['UUID']} })getViewGroups?: (ViewGroupGenqlSelection & { __args?: {viewId?: (Scalars['String'] | null)} })getViewGroup?: (ViewGroupGenqlSelection & { __args: {id: Scalars['String']} })- getRoles?: RoleGenqlSelectionpreviewMessageCampaignAudience?: (CampaignAudiencePreviewDTOGenqlSelection & { __args: {input: PreviewMessageCampaignAudienceInput} })messageSuppressions?: (MessageSuppressionListGenqlSelection & { __args: {input: FindMessageSuppressionsInput} })unsubscribeTopics?: UnsubscribeTopicGenqlSelection@@ -7548,6 +7548,10 @@ export interface MutationGenqlSelection{updateFrontComponent?: (FrontComponentGenqlSelection & { __args: {input: UpdateFrontComponentInput} })deleteFrontComponent?: (FrontComponentGenqlSelection & { __args: {id: Scalars['UUID']} })updateOneApplicationVariable?: { __args: {key: Scalars['String'], value: Scalars['String'], applicationId?: (Scalars['UUID'] | null)} }+ skipSyncEmailOnboardingStep?: (OnboardingStepSuccessGenqlSelection & { __args: {isAutoSkipped: Scalars['Boolean']} })+ completeBookCallOnboardingStep?: (OnboardingStepSuccessGenqlSelection & { __args: {hasBookedCall: Scalars['Boolean'], isAutoSkipped: Scalars['Boolean']} })+ triggerInstallAppsOnboardingStep?: (OnboardingStepSuccessGenqlSelection & { __args: {universalIdentifiers: Scalars['String'][], isAutoSkipped: Scalars['Boolean']} })+ goBackToPreviousOnboardingStep?: OnboardingStepNavigationGenqlSelectioncheckoutSession?: (BillingSessionGenqlSelection & { __args: {recurringInterval: SubscriptionInterval, plan: BillingPlanKey, requirePaymentMethod: Scalars['Boolean'], successUrlPath?: (Scalars['String'] | null)} })createSubscriptionPaymentIntent?: (BillingPaymentIntentGenqlSelection & { __args: {recurringInterval: SubscriptionInterval, plan: BillingPlanKey, requirePaymentMethod: Scalars['Boolean'], successUrlPath?: (Scalars['String'] | null), idempotencyKey: Scalars['String']} })createBillingPaymentMethodSetupIntent?: BillingPaymentIntentGenqlSelection@@ -7558,32 +7562,38 @@ export interface MutationGenqlSelection{setResourceCreditSubscriptionPrice?: (BillingUpdateGenqlSelection & { __args: {priceId: Scalars['String']} })endSubscriptionTrialPeriod?: BillingEndTrialPeriodGenqlSelectioncancelSwitchResourceCreditPrice?: BillingUpdateGenqlSelection- deleteConnectedAccount?: (ConnectedAccountPublicDTOGenqlSelection & { __args: {id: Scalars['UUID']} })- disconnectConnectedAccount?: (ConnectedAccountPublicDTOGenqlSelection & { __args: {id: Scalars['UUID']} })- activateWorkspace?: (WorkspaceGenqlSelection & { __args: {data: ActivateWorkspaceInput} })- updateWorkspace?: (WorkspaceGenqlSelection & { __args: {data: UpdateWorkspaceInput} })- updateWorkspaceAllowedIframeOrigins?: (WorkspaceGenqlSelection & { __args: {data: UpdateWorkspaceAllowedIframeOriginsInput} })- deleteCurrentWorkspace?: WorkspaceGenqlSelection- checkCustomDomainValidRecords?: DomainValidRecordsGenqlSelection- enrichWorkspaceCompany?: WorkspaceCompanyEnrichmentResultGenqlSelection- skipSyncEmailOnboardingStep?: (OnboardingStepSuccessGenqlSelection & { __args: {isAutoSkipped: Scalars['Boolean']} })- completeBookCallOnboardingStep?: (OnboardingStepSuccessGenqlSelection & { __args: {hasBookedCall: Scalars['Boolean'], isAutoSkipped: Scalars['Boolean']} })- triggerInstallAppsOnboardingStep?: (OnboardingStepSuccessGenqlSelection & { __args: {universalIdentifiers: Scalars['String'][], isAutoSkipped: Scalars['Boolean']} })- goBackToPreviousOnboardingStep?: OnboardingStepNavigationGenqlSelectiondeleteWorkspaceInvitation?: { __args: {appTokenId: Scalars['String']} }resendWorkspaceInvitation?: (SendInvitationsGenqlSelection & { __args: {appTokenId: Scalars['String']} })sendInvitations?: (SendInvitationsGenqlSelection & { __args: {emails: Scalars['String'][], roleId?: (Scalars['UUID'] | null)} })createApprovedAccessDomain?: (ApprovedAccessDomainGenqlSelection & { __args: {input: CreateApprovedAccessDomainInput} })deleteApprovedAccessDomain?: { __args: {input: DeleteApprovedAccessDomainInput} }validateApprovedAccessDomain?: (ApprovedAccessDomainGenqlSelection & { __args: {input: ValidateApprovedAccessDomainInput} })- createViewFilterGroup?: (ViewFilterGroupGenqlSelection & { __args: {input: CreateViewFilterGroupInput} })- updateViewFilterGroup?: (ViewFilterGroupGenqlSelection & { __args: {id: Scalars['String'], input: UpdateViewFilterGroupInput} })- deleteViewFilterGroup?: { __args: {id: Scalars['String']} }- destroyViewFilterGroup?: { __args: {id: Scalars['String']} }+ updateWorkspaceMemberRole?: (WorkspaceMemberGenqlSelection & { __args: {workspaceMemberId: Scalars['UUID'], roleId: Scalars['UUID']} })+ createOneRole?: (RoleGenqlSelection & { __args: {createRoleInput: CreateRoleInput} })+ updateOneRole?: (RoleGenqlSelection & { __args: {updateRoleInput: UpdateRoleInput} })+ deleteOneRole?: { __args: {roleId: Scalars['UUID']} }+ upsertObjectPermissions?: (ObjectPermissionGenqlSelection & { __args: {upsertObjectPermissionsInput: UpsertObjectPermissionsInput} })+ upsertPermissionFlags?: (RolePermissionFlagGenqlSelection & { __args: {upsertPermissionFlagsInput: UpsertPermissionFlagsInput} })+ upsertFieldPermissions?: (FieldPermissionGenqlSelection & { __args: {upsertFieldPermissionsInput: UpsertFieldPermissionsInput} })+ upsertRowLevelPermissionPredicates?: (UpsertRowLevelPermissionPredicatesResultGenqlSelection & { __args: {input: UpsertRowLevelPermissionPredicatesInput} })+ assignRoleToAgent?: { __args: {agentId: Scalars['UUID'], roleId: Scalars['UUID']} }+ removeRoleFromAgent?: { __args: {agentId: Scalars['UUID']} }createApiKey?: (ApiKeyGenqlSelection & { __args: {input: CreateApiKeyInput} })updateApiKey?: (ApiKeyGenqlSelection & { __args: {input: UpdateApiKeyInput} })revokeApiKey?: (ApiKeyGenqlSelection & { __args: {input: RevokeApiKeyInput} })assignRoleToApiKey?: { __args: {apiKeyId: Scalars['UUID'], roleId: Scalars['UUID']} }+ createViewFilterGroup?: (ViewFilterGroupGenqlSelection & { __args: {input: CreateViewFilterGroupInput} })+ updateViewFilterGroup?: (ViewFilterGroupGenqlSelection & { __args: {id: Scalars['String'], input: UpdateViewFilterGroupInput} })+ deleteViewFilterGroup?: { __args: {id: Scalars['String']} }+ destroyViewFilterGroup?: { __args: {id: Scalars['String']} }+ deleteConnectedAccount?: (ConnectedAccountPublicDTOGenqlSelection & { __args: {id: Scalars['UUID']} })+ disconnectConnectedAccount?: (ConnectedAccountPublicDTOGenqlSelection & { __args: {id: Scalars['UUID']} })+ activateWorkspace?: (WorkspaceGenqlSelection & { __args: {data: ActivateWorkspaceInput} })+ updateWorkspace?: (WorkspaceGenqlSelection & { __args: {data: UpdateWorkspaceInput} })+ updateWorkspaceAllowedIframeOrigins?: (WorkspaceGenqlSelection & { __args: {data: UpdateWorkspaceAllowedIframeOriginsInput} })+ deleteCurrentWorkspace?: WorkspaceGenqlSelection+ checkCustomDomainValidRecords?: DomainValidRecordsGenqlSelection+ enrichWorkspaceCompany?: WorkspaceCompanyEnrichmentResultGenqlSelectionupgradeApplication?: { __args: {appRegistrationId: Scalars['String'], targetVersion: Scalars['String']} }createApplicationRegistration?: (CreateApplicationRegistrationGenqlSelection & { __args: {input: CreateApplicationRegistrationInput} })updateApplicationRegistration?: (ApplicationRegistrationGenqlSelection & { __args: {input: UpdateApplicationRegistrationInput} })@@ -7614,16 +7624,6 @@ export interface MutationGenqlSelection{updateManyViewGroups?: (ViewGroupGenqlSelection & { __args: {inputs: UpdateViewGroupInput[]} })deleteViewGroup?: (ViewGroupGenqlSelection & { __args: {input: DeleteViewGroupInput} })destroyViewGroup?: (ViewGroupGenqlSelection & { __args: {input: DestroyViewGroupInput} })- updateWorkspaceMemberRole?: (WorkspaceMemberGenqlSelection & { __args: {workspaceMemberId: Scalars['UUID'], roleId: Scalars['UUID']} })- createOneRole?: (RoleGenqlSelection & { __args: {createRoleInput: CreateRoleInput} })- updateOneRole?: (RoleGenqlSelection & { __args: {updateRoleInput: UpdateRoleInput} })- deleteOneRole?: { __args: {roleId: Scalars['UUID']} }- upsertObjectPermissions?: (ObjectPermissionGenqlSelection & { __args: {upsertObjectPermissionsInput: UpsertObjectPermissionsInput} })- upsertPermissionFlags?: (RolePermissionFlagGenqlSelection & { __args: {upsertPermissionFlagsInput: UpsertPermissionFlagsInput} })- upsertFieldPermissions?: (FieldPermissionGenqlSelection & { __args: {upsertFieldPermissionsInput: UpsertFieldPermissionsInput} })- upsertRowLevelPermissionPredicates?: (UpsertRowLevelPermissionPredicatesResultGenqlSelection & { __args: {input: UpsertRowLevelPermissionPredicatesInput} })- assignRoleToAgent?: { __args: {agentId: Scalars['UUID'], roleId: Scalars['UUID']} }- removeRoleFromAgent?: { __args: {agentId: Scalars['UUID']} }sendMessageCampaign?: (SendMessageCampaignOutputDTOGenqlSelection & { __args: {input: SendMessageCampaignInput} })cancelMessageCampaign?: (CancelMessageCampaignOutputDTOGenqlSelection & { __args: {input: CancelMessageCampaignInput} })sendMessageCampaignTest?: (SendEmailViaDomainOutputGenqlSelection & { __args: {input: SendMessageCampaignTestInput} })@@ -7966,23 +7966,35 @@ update: UpdateFrontComponentInputUpdates}export interface UpdateFrontComponentInputUpdates {name?: (Scalars['String'] | null),description?: (Scalars['String'] | null)}-export interface ActivateWorkspaceInput {-/** Deprecated: the workspace name is set at creation (signUpInNewWorkspace) and this field is ignored during activation. Kept for backward compatibility. */-displayName?: (Scalars['String'] | null)}--export interface UpdateWorkspaceInput {subdomain?: (Scalars['String'] | null),customDomain?: (Scalars['String'] | null),displayName?: (Scalars['String'] | null),logo?: (Scalars['String'] | null),inviteHash?: (Scalars['String'] | null),isPublicInviteLinkEnabled?: (Scalars['Boolean'] | null),isCampaignClickTrackingEnabled?: (Scalars['Boolean'] | null),workspaceDiscoverability?: (WorkspaceDiscoverability | null),allowImpersonation?: (Scalars['Boolean'] | null),isGoogleAuthEnabled?: (Scalars['Boolean'] | null),isMicrosoftAuthEnabled?: (Scalars['Boolean'] | null),isPasswordAuthEnabled?: (Scalars['Boolean'] | null),isGoogleAuthBypassEnabled?: (Scalars['Boolean'] | null),isMicrosoftAuthBypassEnabled?: (Scalars['Boolean'] | null),isPasswordAuthBypassEnabled?: (Scalars['Boolean'] | null),defaultRoleId?: (Scalars['UUID'] | null),isTwoFactorAuthenticationEnforced?: (Scalars['Boolean'] | null),trashRetentionDays?: (Scalars['Float'] | null),eventLogRetentionDays?: (Scalars['Float'] | null),aiChatModelTier?: (AiModelTier | null),aiAgentModelTier?: (AiModelTier | null),isAutoModelSelectionEnabled?: (Scalars['Boolean'] | null),aiModelIdByTier?: (Scalars['JSON'] | null),aiEvaluationModelId?: (Scalars['String'] | null),aiAdditionalInstructions?: (Scalars['String'] | null),editableProfileFields?: (Scalars['String'][] | null),isInternalMessagesImportEnabled?: (Scalars['Boolean'] | null)}--export interface UpdateWorkspaceAllowedIframeOriginsInput {operation: Scalars['String'],origin: Scalars['String']}-export interface CreateApprovedAccessDomainInput {domain: Scalars['String'],email: Scalars['String']}export interface DeleteApprovedAccessDomainInput {id: Scalars['UUID']}export interface ValidateApprovedAccessDomainInput {validationToken: Scalars['String'],approvedAccessDomainId: Scalars['UUID']}-export interface CreateViewFilterGroupInput {id?: (Scalars['UUID'] | null),parentViewFilterGroupId?: (Scalars['UUID'] | null),logicalOperator?: (ViewFilterGroupLogicalOperator | null),positionInViewFilterGroup?: (Scalars['Float'] | null),viewId: Scalars['UUID']}+export interface CreateRoleInput {id?: (Scalars['String'] | null),label: Scalars['String'],description?: (Scalars['String'] | null),icon?: (Scalars['String'] | null),canUpdateAllSettings?: (Scalars['Boolean'] | null),canAccessAllTools?: (Scalars['Boolean'] | null),canReadAllObjectRecords?: (Scalars['Boolean'] | null),canUpdateAllObjectRecords?: (Scalars['Boolean'] | null),canSoftDeleteAllObjectRecords?: (Scalars['Boolean'] | null),canDestroyAllObjectRecords?: (Scalars['Boolean'] | null),canBeAssignedToUsers?: (Scalars['Boolean'] | null),canBeAssignedToAgents?: (Scalars['Boolean'] | null),canBeAssignedToApiKeys?: (Scalars['Boolean'] | null)}-export interface UpdateViewFilterGroupInput {id?: (Scalars['UUID'] | null),parentViewFilterGroupId?: (Scalars['UUID'] | null),logicalOperator?: (ViewFilterGroupLogicalOperator | null),positionInViewFilterGroup?: (Scalars['Float'] | null),viewId?: (Scalars['UUID'] | null)}+export interface UpdateRoleInput {update: UpdateRolePayload,+/** The id of the role to update */+id: Scalars['UUID']}++export interface UpdateRolePayload {label?: (Scalars['String'] | null),description?: (Scalars['String'] | null),icon?: (Scalars['String'] | null),canUpdateAllSettings?: (Scalars['Boolean'] | null),canAccessAllTools?: (Scalars['Boolean'] | null),canReadAllObjectRecords?: (Scalars['Boolean'] | null),canUpdateAllObjectRecords?: (Scalars['Boolean'] | null),canSoftDeleteAllObjectRecords?: (Scalars['Boolean'] | null),canDestroyAllObjectRecords?: (Scalars['Boolean'] | null),canBeAssignedToUsers?: (Scalars['Boolean'] | null),canBeAssignedToAgents?: (Scalars['Boolean'] | null),canBeAssignedToApiKeys?: (Scalars['Boolean'] | null)}++export interface UpsertObjectPermissionsInput {roleId: Scalars['UUID'],objectPermissions: ObjectPermissionInput[]}++export interface ObjectPermissionInput {objectMetadataId: Scalars['UUID'],canReadObjectRecords?: (Scalars['Boolean'] | null),canUpdateObjectRecords?: (Scalars['Boolean'] | null),canSoftDeleteObjectRecords?: (Scalars['Boolean'] | null),canDestroyObjectRecords?: (Scalars['Boolean'] | null)}++export interface UpsertPermissionFlagsInput {roleId: Scalars['UUID'],permissionFlagKeys: Scalars['String'][]}++export interface UpsertFieldPermissionsInput {roleId: Scalars['UUID'],fieldPermissions: FieldPermissionInput[]}++export interface FieldPermissionInput {objectMetadataId: Scalars['UUID'],fieldMetadataId: Scalars['UUID'],canReadFieldValue?: (Scalars['Boolean'] | null),canUpdateFieldValue?: (Scalars['Boolean'] | null)}++export interface UpsertRowLevelPermissionPredicatesInput {roleId: Scalars['UUID'],objectMetadataId: Scalars['UUID'],predicates: RowLevelPermissionPredicateInput[],predicateGroups: RowLevelPermissionPredicateGroupInput[]}++export interface RowLevelPermissionPredicateInput {id?: (Scalars['UUID'] | null),fieldMetadataId: Scalars['UUID'],operand: RowLevelPermissionPredicateOperand,value?: (Scalars['JSON'] | null),subFieldName?: (Scalars['String'] | null),workspaceMemberFieldMetadataId?: (Scalars['String'] | null),workspaceMemberSubFieldName?: (Scalars['String'] | null),rowLevelPermissionPredicateGroupId?: (Scalars['UUID'] | null),positionInRowLevelPermissionPredicateGroup?: (Scalars['Float'] | null)}++export interface RowLevelPermissionPredicateGroupInput {id?: (Scalars['UUID'] | null),objectMetadataId: Scalars['UUID'],parentRowLevelPermissionPredicateGroupId?: (Scalars['UUID'] | null),logicalOperator: RowLevelPermissionPredicateGroupLogicalOperator,positionInRowLevelPermissionPredicateGroup?: (Scalars['Float'] | null)}export interface CreateApiKeyInput {name: Scalars['String'],expiresAt: Scalars['String'],revokedAt?: (Scalars['String'] | null),roleId: Scalars['UUID']}@@ -7990,6 +8002,18 @@ export interface UpdateApiKeyInput {id: Scalars['UUID'],name?: (Scalars['String'export interface RevokeApiKeyInput {id: Scalars['UUID']}+export interface CreateViewFilterGroupInput {id?: (Scalars['UUID'] | null),parentViewFilterGroupId?: (Scalars['UUID'] | null),logicalOperator?: (ViewFilterGroupLogicalOperator | null),positionInViewFilterGroup?: (Scalars['Float'] | null),viewId: Scalars['UUID']}++export interface UpdateViewFilterGroupInput {id?: (Scalars['UUID'] | null),parentViewFilterGroupId?: (Scalars['UUID'] | null),logicalOperator?: (ViewFilterGroupLogicalOperator | null),positionInViewFilterGroup?: (Scalars['Float'] | null),viewId?: (Scalars['UUID'] | null)}++export interface ActivateWorkspaceInput {+/** Deprecated: the workspace name is set at creation (signUpInNewWorkspace) and this field is ignored during activation. Kept for backward compatibility. */+displayName?: (Scalars['String'] | null)}++export interface UpdateWorkspaceInput {subdomain?: (Scalars['String'] | null),customDomain?: (Scalars['String'] | null),displayName?: (Scalars['String'] | null),logo?: (Scalars['String'] | null),inviteHash?: (Scalars['String'] | null),isPublicInviteLinkEnabled?: (Scalars['Boolean'] | null),isCampaignClickTrackingEnabled?: (Scalars['Boolean'] | null),workspaceDiscoverability?: (WorkspaceDiscoverability | null),allowImpersonation?: (Scalars['Boolean'] | null),isGoogleAuthEnabled?: (Scalars['Boolean'] | null),isMicrosoftAuthEnabled?: (Scalars['Boolean'] | null),isPasswordAuthEnabled?: (Scalars['Boolean'] | null),isGoogleAuthBypassEnabled?: (Scalars['Boolean'] | null),isMicrosoftAuthBypassEnabled?: (Scalars['Boolean'] | null),isPasswordAuthBypassEnabled?: (Scalars['Boolean'] | null),defaultRoleId?: (Scalars['UUID'] | null),isTwoFactorAuthenticationEnforced?: (Scalars['Boolean'] | null),trashRetentionDays?: (Scalars['Float'] | null),eventLogRetentionDays?: (Scalars['Float'] | null),aiChatModelTier?: (AiModelTier | null),aiAgentModelTier?: (AiModelTier | null),isAutoModelSelectionEnabled?: (Scalars['Boolean'] | null),aiModelIdByTier?: (Scalars['JSON'] | null),aiEvaluationModelId?: (Scalars['String'] | null),aiAdditionalInstructions?: (Scalars['String'] | null),editableProfileFields?: (Scalars['String'][] | null),isInternalMessagesImportEnabled?: (Scalars['Boolean'] | null)}++export interface UpdateWorkspaceAllowedIframeOriginsInput {operation: Scalars['String'],origin: Scalars['String']}+export interface CreateApplicationRegistrationInput {name: Scalars['String'],universalIdentifier?: (Scalars['String'] | null),oAuthRedirectUris?: (Scalars['String'][] | null),oAuthScopes?: (Scalars['String'][] | null)}export interface UpdateApplicationRegistrationInput {id: Scalars['String'],update: UpdateApplicationRegistrationPayload}@@ -8044,30 +8068,6 @@ export interface DestroyViewGroupInput {/** The id of the view group to destroy. */id: Scalars['UUID']}-export interface CreateRoleInput {id?: (Scalars['String'] | null),label: Scalars['String'],description?: (Scalars['String'] | null),icon?: (Scalars['String'] | null),canUpdateAllSettings?: (Scalars['Boolean'] | null),canAccessAllTools?: (Scalars['Boolean'] | null),canReadAllObjectRecords?: (Scalars['Boolean'] | null),canUpdateAllObjectRecords?: (Scalars['Boolean'] | null),canSoftDeleteAllObjectRecords?: (Scalars['Boolean'] | null),canDestroyAllObjectRecords?: (Scalars['Boolean'] | null),canBeAssignedToUsers?: (Scalars['Boolean'] | null),canBeAssignedToAgents?: (Scalars['Boolean'] | null),canBeAssignedToApiKeys?: (Scalars['Boolean'] | null)}--export interface UpdateRoleInput {update: UpdateRolePayload,-/** The id of the role to update */-id: Scalars['UUID']}--export interface UpdateRolePayload {label?: (Scalars['String'] | null),description?: (Scalars['String'] | null),icon?: (Scalars['String'] | null),canUpdateAllSettings?: (Scalars['Boolean'] | null),canAccessAllTools?: (Scalars['Boolean'] | null),canReadAllObjectRecords?: (Scalars['Boolean'] | null),canUpdateAllObjectRecords?: (Scalars['Boolean'] | null),canSoftDeleteAllObjectRecords?: (Scalars['Boolean'] | null),canDestroyAllObjectRecords?: (Scalars['Boolean'] | null),canBeAssignedToUsers?: (Scalars['Boolean'] | null),canBeAssignedToAgents?: (Scalars['Boolean'] | null),canBeAssignedToApiKeys?: (Scalars['Boolean'] | null)}--export interface UpsertObjectPermissionsInput {roleId: Scalars['UUID'],objectPermissions: ObjectPermissionInput[]}--export interface ObjectPermissionInput {objectMetadataId: Scalars['UUID'],canReadObjectRecords?: (Scalars['Boolean'] | null),canUpdateObjectRecords?: (Scalars['Boolean'] | null),canSoftDeleteObjectRecords?: (Scalars['Boolean'] | null),canDestroyObjectRecords?: (Scalars['Boolean'] | null)}--export interface UpsertPermissionFlagsInput {roleId: Scalars['UUID'],permissionFlagKeys: Scalars['String'][]}--export interface UpsertFieldPermissionsInput {roleId: Scalars['UUID'],fieldPermissions: FieldPermissionInput[]}--export interface FieldPermissionInput {objectMetadataId: Scalars['UUID'],fieldMetadataId: Scalars['UUID'],canReadFieldValue?: (Scalars['Boolean'] | null),canUpdateFieldValue?: (Scalars['Boolean'] | null)}--export interface UpsertRowLevelPermissionPredicatesInput {roleId: Scalars['UUID'],objectMetadataId: Scalars['UUID'],predicates: RowLevelPermissionPredicateInput[],predicateGroups: RowLevelPermissionPredicateGroupInput[]}--export interface RowLevelPermissionPredicateInput {id?: (Scalars['UUID'] | null),fieldMetadataId: Scalars['UUID'],operand: RowLevelPermissionPredicateOperand,value?: (Scalars['JSON'] | null),subFieldName?: (Scalars['String'] | null),workspaceMemberFieldMetadataId?: (Scalars['String'] | null),workspaceMemberSubFieldName?: (Scalars['String'] | null),rowLevelPermissionPredicateGroupId?: (Scalars['UUID'] | null),positionInRowLevelPermissionPredicateGroup?: (Scalars['Float'] | null)}--export interface RowLevelPermissionPredicateGroupInput {id?: (Scalars['UUID'] | null),objectMetadataId: Scalars['UUID'],parentRowLevelPermissionPredicateGroupId?: (Scalars['UUID'] | null),logicalOperator: RowLevelPermissionPredicateGroupLogicalOperator,positionInRowLevelPermissionPredicateGroup?: (Scalars['Float'] | null)}-export interface SendMessageCampaignInput {campaignId: Scalars['String'],scheduledAt?: (Scalars['DateTime'] | null)}export interface CancelMessageCampaignInput {campaignId: Scalars['String']}diff --git a/packages/twenty-client-sdk/src/metadata/generated/types.ts b/packages/twenty-client-sdk/src/metadata/generated/types.tsindex a924e8c02cf..ec48ba64559 100644--- a/packages/twenty-client-sdk/src/metadata/generated/types.ts+++ b/packages/twenty-client-sdk/src/metadata/generated/types.ts@@ -7793,6 +7793,26 @@ export default {]}],+ "getInviteSuggestions": [+ 195+ ],+ "applicationConnectionProviders": [+ 150,+ {+ "applicationId": [+ 3,+ "UUID!"+ ]+ }+ ],+ "getUsageAnalytics": [+ 193,+ {+ "input": [+ 425+ ]+ }+ ],"billingPortalSession": [188,{@@ -7810,28 +7830,52 @@ export default {"getResourceCreditUsage": [185],- "getUsageAnalytics": [- 193,+ "findWorkspaceInvitations": [+ 198+ ],+ "getApprovedAccessDomains": [+ 194+ ],+ "getRoles": [+ 50+ ],+ "apiKeys": [+ 2+ ],+ "getApiKeyRoles": [+ 50+ ],+ "apiKey": [+ 2,{"input": [- 425+ 426,+ "GetApiKeyInput!"]}],- "myConnectedAccounts": [- 203+ "getViewFilterGroups": [+ 57,+ {+ "viewId": [+ 1+ ]+ }],- "applicationConnectedAccounts": [- 204,+ "getViewFilterGroup": [+ 57,{- "applicationId": [- 3,- "UUID!"+ "id": [+ 1,+ "String!"]}],- "applicationConnectionProviders": [- 150,+ "myConnectedAccounts": [+ 203+ ],+ "applicationConnectedAccounts": [+ 204,{"applicationId": [3,@@ -7859,47 +7903,6 @@ export default {]}],- "getInviteSuggestions": [- 195- ],- "findWorkspaceInvitations": [- 198- ],- "getApprovedAccessDomains": [- 194- ],- "getViewFilterGroups": [- 57,- {- "viewId": [- 1- ]- }- ],- "getViewFilterGroup": [- 57,- {- "id": [- 1,- "String!"- ]- }- ],- "apiKeys": [- 2- ],- "getApiKeyRoles": [- 50- ],- "apiKey": [- 2,- {- "input": [- 426,- "GetApiKeyInput!"- ]- }- ],"findApplicationRegistrationByClientId": [237,{@@ -8084,9 +8087,6 @@ export default {]}],- "getRoles": [- 50- ],"previewMessageCampaignAudience": [342,{@@ -9546,6 +9546,44 @@ export default {]}],+ "skipSyncEmailOnboardingStep": [+ 197,+ {+ "isAutoSkipped": [+ 8,+ "Boolean!"+ ]+ }+ ],+ "completeBookCallOnboardingStep": [+ 197,+ {+ "hasBookedCall": [+ 8,+ "Boolean!"+ ],+ "isAutoSkipped": [+ 8,+ "Boolean!"+ ]+ }+ ],+ "triggerInstallAppsOnboardingStep": [+ 197,+ {+ "universalIdentifiers": [+ 1,+ "[String!]!"+ ],+ "isAutoSkipped": [+ 8,+ "Boolean!"+ ]+ }+ ],+ "goBackToPreviousOnboardingStep": [+ 196+ ],"checkoutSession": [188,{@@ -9620,98 +9658,6 @@ export default {"cancelSwitchResourceCreditPrice": [189],- "deleteConnectedAccount": [- 203,- {- "id": [- 3,- "UUID!"- ]- }- ],- "disconnectConnectedAccount": [- 203,- {- "id": [- 3,- "UUID!"- ]- }- ],- "activateWorkspace": [- 71,- {- "data": [- 513,- "ActivateWorkspaceInput!"- ]- }- ],- "updateWorkspace": [- 71,- {- "data": [- 514,- "UpdateWorkspaceInput!"- ]- }- ],- "updateWorkspaceAllowedIframeOrigins": [- 71,- {- "data": [- 515,- "UpdateWorkspaceAllowedIframeOriginsInput!"- ]- }- ],- "deleteCurrentWorkspace": [- 71- ],- "checkCustomDomainValidRecords": [- 284- ],- "enrichWorkspaceCompany": [- 261- ],- "skipSyncEmailOnboardingStep": [- 197,- {- "isAutoSkipped": [- 8,- "Boolean!"- ]- }- ],- "completeBookCallOnboardingStep": [- 197,- {- "hasBookedCall": [- 8,- "Boolean!"- ],- "isAutoSkipped": [- 8,- "Boolean!"- ]- }- ],- "triggerInstallAppsOnboardingStep": [- 197,- {- "universalIdentifiers": [- 1,- "[String!]!"- ],- "isAutoSkipped": [- 8,- "Boolean!"- ]- }- ],- "goBackToPreviousOnboardingStep": [- 196- ],"deleteWorkspaceInvitation": [1,{@@ -9746,7 +9692,7 @@ export default {194,{"input": [- 516,+ 513,"CreateApprovedAccessDomainInput!"]}@@ -9755,7 +9701,7 @@ export default {8,{"input": [- 517,+ 514,"DeleteApprovedAccessDomainInput!"]}@@ -9764,48 +9710,106 @@ export default {194,{"input": [- 518,+ 515,"ValidateApprovedAccessDomainInput!"]}],- "createViewFilterGroup": [- 57,+ "updateWorkspaceMemberRole": [+ 37,{- "input": [- 519,- "CreateViewFilterGroupInput!"- ]- }+ "workspaceMemberId": [+ 3,+ "UUID!"+ ],+ "roleId": [+ 3,+ "UUID!"+ ]+ }],- "updateViewFilterGroup": [- 57,+ "createOneRole": [+ 50,+ {+ "createRoleInput": [+ 516,+ "CreateRoleInput!"+ ]+ }+ ],+ "updateOneRole": [+ 50,+ {+ "updateRoleInput": [+ 517,+ "UpdateRoleInput!"+ ]+ }+ ],+ "deleteOneRole": [+ 1,+ {+ "roleId": [+ 3,+ "UUID!"+ ]+ }+ ],+ "upsertObjectPermissions": [+ 47,+ {+ "upsertObjectPermissionsInput": [+ 519,+ "UpsertObjectPermissionsInput!"+ ]+ }+ ],+ "upsertPermissionFlags": [+ 48,+ {+ "upsertPermissionFlagsInput": [+ 521,+ "UpsertPermissionFlagsInput!"+ ]+ }+ ],+ "upsertFieldPermissions": [+ 42,+ {+ "upsertFieldPermissionsInput": [+ 522,+ "UpsertFieldPermissionsInput!"+ ]+ }+ ],+ "upsertRowLevelPermissionPredicates": [+ 285,{- "id": [- 1,- "String!"- ],"input": [- 520,- "UpdateViewFilterGroupInput!"+ 524,+ "UpsertRowLevelPermissionPredicatesInput!"]}],- "deleteViewFilterGroup": [+ "assignRoleToAgent": [8,{- "id": [- 1,- "String!"+ "agentId": [+ 3,+ "UUID!"+ ],+ "roleId": [+ 3,+ "UUID!"]}],- "destroyViewFilterGroup": [+ "removeRoleFromAgent": [8,{- "id": [- 1,- "String!"+ "agentId": [+ 3,+ "UUID!"]}],@@ -9813,7 +9817,7 @@ export default {2,{"input": [- 521,+ 527,"CreateApiKeyInput!"]}@@ -9822,7 +9826,7 @@ export default {2,{"input": [- 522,+ 528,"UpdateApiKeyInput!"]}@@ -9831,7 +9835,7 @@ export default {2,{"input": [- 523,+ 529,"RevokeApiKeyInput!"]}@@ -9849,6 +9853,100 @@ export default {]}],+ "createViewFilterGroup": [+ 57,+ {+ "input": [+ 530,+ "CreateViewFilterGroupInput!"+ ]+ }+ ],+ "updateViewFilterGroup": [+ 57,+ {+ "id": [+ 1,+ "String!"+ ],+ "input": [+ 531,+ "UpdateViewFilterGroupInput!"+ ]+ }+ ],+ "deleteViewFilterGroup": [+ 8,+ {+ "id": [+ 1,+ "String!"+ ]+ }+ ],+ "destroyViewFilterGroup": [+ 8,+ {+ "id": [+ 1,+ "String!"+ ]+ }+ ],+ "deleteConnectedAccount": [+ 203,+ {+ "id": [+ 3,+ "UUID!"+ ]+ }+ ],+ "disconnectConnectedAccount": [+ 203,+ {+ "id": [+ 3,+ "UUID!"+ ]+ }+ ],+ "activateWorkspace": [+ 71,+ {+ "data": [+ 532,+ "ActivateWorkspaceInput!"+ ]+ }+ ],+ "updateWorkspace": [+ 71,+ {+ "data": [+ 533,+ "UpdateWorkspaceInput!"+ ]+ }+ ],+ "updateWorkspaceAllowedIframeOrigins": [+ 71,+ {+ "data": [+ 534,+ "UpdateWorkspaceAllowedIframeOriginsInput!"+ ]+ }+ ],+ "deleteCurrentWorkspace": [+ 71+ ],+ "checkCustomDomainValidRecords": [+ 284+ ],+ "enrichWorkspaceCompany": [+ 261+ ],"upgradeApplication": [8,{@@ -9866,7 +9964,7 @@ export default {236,{"input": [- 524,+ 535,"CreateApplicationRegistrationInput!"]}@@ -9875,7 +9973,7 @@ export default {78,{"input": [- 525,+ 536,"UpdateApplicationRegistrationInput!"]}@@ -9902,7 +10000,7 @@ export default {208,{"input": [- 527,+ 538,"UpdateApplicationRegistrationVariableInput!"]}@@ -9954,7 +10052,7 @@ export default {260,{"input": [- 529,+ 540,"GrantApplicationCapabilitiesInput!"]}@@ -9987,7 +10085,7 @@ export default {258,{"input": [- 530,+ 541,"TriggerInstallApplicationJobInput!"]}@@ -9996,7 +10094,7 @@ export default {259,{"input": [- 531,+ 542,"TriggerUninstallApplicationJobInput!"]}@@ -10009,7 +10107,7 @@ export default {"UUID!"],"input": [- 532,+ 543,"UpdateApplicationInput!"]}@@ -10039,7 +10137,7 @@ export default {264,{"input": [- 533,+ 544,"CreateOneFieldMetadataInput!"]}@@ -10048,7 +10146,7 @@ export default {264,{"input": [- 535,+ 546,"UpdateOneFieldMetadataInput!"]}@@ -10057,7 +10155,7 @@ export default {264,{"input": [- 537,+ 548,"DeleteOneFieldInput!"]}@@ -10066,7 +10164,7 @@ export default {61,{"input": [- 538,+ 549,"CreateViewGroupInput!"]}@@ -10075,7 +10173,7 @@ export default {61,{"inputs": [- 538,+ 549,"[CreateViewGroupInput!]!"]}@@ -10084,7 +10182,7 @@ export default {61,{"input": [- 539,+ 550,"UpdateViewGroupInput!"]}@@ -10093,7 +10191,7 @@ export default {61,{"inputs": [- 539,+ 550,"[UpdateViewGroupInput!]!"]}@@ -10102,7 +10200,7 @@ export default {61,{"input": [- 541,+ 552,"DeleteViewGroupInput!"]}@@ -10111,140 +10209,42 @@ export default {61,{"input": [- 542,+ 553,"DestroyViewGroupInput!"]}],- "updateWorkspaceMemberRole": [- 37,+ "sendMessageCampaign": [+ 345,{- "workspaceMemberId": [- 3,- "UUID!"- ],- "roleId": [- 3,- "UUID!"+ "input": [+ 554,+ "SendMessageCampaignInput!"]}],- "createOneRole": [- 50,+ "cancelMessageCampaign": [+ 343,{- "createRoleInput": [- 543,- "CreateRoleInput!"+ "input": [+ 555,+ "CancelMessageCampaignInput!"]}],- "updateOneRole": [- 50,+ "sendMessageCampaignTest": [+ 344,{- "updateRoleInput": [- 544,- "UpdateRoleInput!"+ "input": [+ 556,+ "SendMessageCampaignTestInput!"]}],- "deleteOneRole": [- 1,+ "duplicateMessageList": [+ 346,{- "roleId": [- 3,- "UUID!"- ]- }- ],- "upsertObjectPermissions": [- 47,- {- "upsertObjectPermissionsInput": [- 546,- "UpsertObjectPermissionsInput!"- ]- }- ],- "upsertPermissionFlags": [- 48,- {- "upsertPermissionFlagsInput": [- 548,- "UpsertPermissionFlagsInput!"- ]- }- ],- "upsertFieldPermissions": [- 42,- {- "upsertFieldPermissionsInput": [- 549,- "UpsertFieldPermissionsInput!"- ]- }- ],- "upsertRowLevelPermissionPredicates": [- 285,- {- "input": [- 551,- "UpsertRowLevelPermissionPredicatesInput!"- ]- }- ],- "assignRoleToAgent": [- 8,- {- "agentId": [- 3,- "UUID!"- ],- "roleId": [- 3,- "UUID!"- ]- }- ],- "removeRoleFromAgent": [- 8,- {- "agentId": [- 3,- "UUID!"- ]- }- ],- "sendMessageCampaign": [- 345,- {- "input": [- 554,- "SendMessageCampaignInput!"- ]- }- ],- "cancelMessageCampaign": [- 343,- {- "input": [- 555,- "CancelMessageCampaignInput!"- ]- }- ],- "sendMessageCampaignTest": [- 344,- {- "input": [- 556,- "SendMessageCampaignTestInput!"- ]- }- ],- "duplicateMessageList": [- 346,- {- "id": [+ "id": [3,"UUID!"]@@ -12825,135 +12825,307 @@ export default {1]},- "ActivateWorkspaceInput": {- "displayName": [+ "CreateApprovedAccessDomainInput": {+ "domain": [+ 1+ ],+ "email": [1],"__typename": [1]},- "UpdateWorkspaceInput": {- "subdomain": [+ "DeleteApprovedAccessDomainInput": {+ "id": [+ 3+ ],+ "__typename": [+ 1+ ]+ },+ "ValidateApprovedAccessDomainInput": {+ "validationToken": [1],- "customDomain": [+ "approvedAccessDomainId": [+ 3+ ],+ "__typename": [+ 1+ ]+ },+ "CreateRoleInput": {+ "id": [1],- "displayName": [+ "label": [1],- "logo": [+ "description": [1],- "inviteHash": [+ "icon": [1],- "isPublicInviteLinkEnabled": [+ "canUpdateAllSettings": [8],- "isCampaignClickTrackingEnabled": [+ "canAccessAllTools": [8],- "workspaceDiscoverability": [- 72- ],- "allowImpersonation": [+ "canReadAllObjectRecords": [8],- "isGoogleAuthEnabled": [+ "canUpdateAllObjectRecords": [8],- "isMicrosoftAuthEnabled": [+ "canSoftDeleteAllObjectRecords": [8],- "isPasswordAuthEnabled": [+ "canDestroyAllObjectRecords": [8],- "isGoogleAuthBypassEnabled": [+ "canBeAssignedToUsers": [8],- "isMicrosoftAuthBypassEnabled": [+ "canBeAssignedToAgents": [8],- "isPasswordAuthBypassEnabled": [+ "canBeAssignedToApiKeys": [8],- "defaultRoleId": [+ "__typename": [+ 1+ ]+ },+ "UpdateRoleInput": {+ "update": [+ 518+ ],+ "id": [3],- "isTwoFactorAuthenticationEnforced": [+ "__typename": [+ 1+ ]+ },+ "UpdateRolePayload": {+ "label": [+ 1+ ],+ "description": [+ 1+ ],+ "icon": [+ 1+ ],+ "canUpdateAllSettings": [8],- "trashRetentionDays": [- 15+ "canAccessAllTools": [+ 8],- "eventLogRetentionDays": [- 15+ "canReadAllObjectRecords": [+ 8],- "aiChatModelTier": [- 74+ "canUpdateAllObjectRecords": [+ 8],- "aiAgentModelTier": [- 74+ "canSoftDeleteAllObjectRecords": [+ 8],- "isAutoModelSelectionEnabled": [+ "canDestroyAllObjectRecords": [8],- "aiModelIdByTier": [- 9+ "canBeAssignedToUsers": [+ 8],- "aiEvaluationModelId": [- 1+ "canBeAssignedToAgents": [+ 8],- "aiAdditionalInstructions": [+ "canBeAssignedToApiKeys": [+ 8+ ],+ "__typename": [1+ ]+ },+ "UpsertObjectPermissionsInput": {+ "roleId": [+ 3],- "editableProfileFields": [+ "objectPermissions": [+ 520+ ],+ "__typename": [1+ ]+ },+ "ObjectPermissionInput": {+ "objectMetadataId": [+ 3],- "isInternalMessagesImportEnabled": [+ "canReadObjectRecords": [+ 8+ ],+ "canUpdateObjectRecords": [+ 8+ ],+ "canSoftDeleteObjectRecords": [+ 8+ ],+ "canDestroyObjectRecords": [8],"__typename": [1]},- "UpdateWorkspaceAllowedIframeOriginsInput": {- "operation": [+ "UpsertPermissionFlagsInput": {+ "roleId": [+ 3+ ],+ "permissionFlagKeys": [1],- "origin": [+ "__typename": [1+ ]+ },+ "UpsertFieldPermissionsInput": {+ "roleId": [+ 3+ ],+ "fieldPermissions": [+ 523],"__typename": [1]},- "CreateApprovedAccessDomainInput": {- "domain": [+ "FieldPermissionInput": {+ "objectMetadataId": [+ 3+ ],+ "fieldMetadataId": [+ 3+ ],+ "canReadFieldValue": [+ 8+ ],+ "canUpdateFieldValue": [+ 8+ ],+ "__typename": [1+ ]+ },+ "UpsertRowLevelPermissionPredicatesInput": {+ "roleId": [+ 3],- "email": [+ "objectMetadataId": [+ 3+ ],+ "predicates": [+ 525+ ],+ "predicateGroups": [+ 526+ ],+ "__typename": [+ 1+ ]+ },+ "RowLevelPermissionPredicateInput": {+ "id": [+ 3+ ],+ "fieldMetadataId": [+ 3+ ],+ "operand": [+ 46+ ],+ "value": [+ 9+ ],+ "subFieldName": [+ 1+ ],+ "workspaceMemberFieldMetadataId": [+ 1+ ],+ "workspaceMemberSubFieldName": [1],+ "rowLevelPermissionPredicateGroupId": [+ 3+ ],+ "positionInRowLevelPermissionPredicateGroup": [+ 15+ ],"__typename": [1]},- "DeleteApprovedAccessDomainInput": {+ "RowLevelPermissionPredicateGroupInput": {"id": [3],+ "objectMetadataId": [+ 3+ ],+ "parentRowLevelPermissionPredicateGroupId": [+ 3+ ],+ "logicalOperator": [+ 44+ ],+ "positionInRowLevelPermissionPredicateGroup": [+ 15+ ],"__typename": [1]},- "ValidateApprovedAccessDomainInput": {- "validationToken": [+ "CreateApiKeyInput": {+ "name": [1],- "approvedAccessDomainId": [+ "expiresAt": [+ 1+ ],+ "revokedAt": [+ 1+ ],+ "roleId": [+ 3+ ],+ "__typename": [+ 1+ ]+ },+ "UpdateApiKeyInput": {+ "id": [+ 3+ ],+ "name": [+ 1+ ],+ "expiresAt": [+ 1+ ],+ "revokedAt": [+ 1+ ],+ "__typename": [+ 1+ ]+ },+ "RevokeApiKeyInput": {+ "id": [3],"__typename": [@@ -13000,43 +13172,106 @@ export default {1]},- "CreateApiKeyInput": {- "name": [+ "ActivateWorkspaceInput": {+ "displayName": [1],- "expiresAt": [+ "__typename": [+ 1+ ]+ },+ "UpdateWorkspaceInput": {+ "subdomain": [1],- "revokedAt": [+ "customDomain": [1],- "roleId": [- 3+ "displayName": [+ 1],- "__typename": [+ "logo": [1- ]- },- "UpdateApiKeyInput": {- "id": [+ ],+ "inviteHash": [+ 1+ ],+ "isPublicInviteLinkEnabled": [+ 8+ ],+ "isCampaignClickTrackingEnabled": [+ 8+ ],+ "workspaceDiscoverability": [+ 72+ ],+ "allowImpersonation": [+ 8+ ],+ "isGoogleAuthEnabled": [+ 8+ ],+ "isMicrosoftAuthEnabled": [+ 8+ ],+ "isPasswordAuthEnabled": [+ 8+ ],+ "isGoogleAuthBypassEnabled": [+ 8+ ],+ "isMicrosoftAuthBypassEnabled": [+ 8+ ],+ "isPasswordAuthBypassEnabled": [+ 8+ ],+ "defaultRoleId": [3],- "name": [+ "isTwoFactorAuthenticationEnforced": [+ 8+ ],+ "trashRetentionDays": [+ 15+ ],+ "eventLogRetentionDays": [+ 15+ ],+ "aiChatModelTier": [+ 74+ ],+ "aiAgentModelTier": [+ 74+ ],+ "isAutoModelSelectionEnabled": [+ 8+ ],+ "aiModelIdByTier": [+ 9+ ],+ "aiEvaluationModelId": [1],- "expiresAt": [+ "aiAdditionalInstructions": [1],- "revokedAt": [+ "editableProfileFields": [1],+ "isInternalMessagesImportEnabled": [+ 8+ ],"__typename": [1]},- "RevokeApiKeyInput": {- "id": [- 3+ "UpdateWorkspaceAllowedIframeOriginsInput": {+ "operation": [+ 1+ ],+ "origin": [+ 1],"__typename": [1@@ -13064,7 +13299,7 @@ export default {1],"update": [- 526+ 537],"__typename": [1@@ -13089,7 +13324,7 @@ export default {1],"update": [- 528+ 539],"__typename": [1@@ -13146,7 +13381,7 @@ export default {},"CreateOneFieldMetadataInput": {"field": [- 534+ 545],"__typename": [1@@ -13225,7 +13460,7 @@ export default {3],"update": [- 536+ 547],"__typename": [1@@ -13329,7 +13564,7 @@ export default {3],"update": [- 540+ 551],"__typename": [1@@ -13368,241 +13603,6 @@ export default {1]},- "CreateRoleInput": {- "id": [- 1- ],- "label": [- 1- ],- "description": [- 1- ],- "icon": [- 1- ],- "canUpdateAllSettings": [- 8- ],- "canAccessAllTools": [- 8- ],- "canReadAllObjectRecords": [- 8- ],- "canUpdateAllObjectRecords": [- 8- ],- "canSoftDeleteAllObjectRecords": [- 8- ],- "canDestroyAllObjectRecords": [- 8- ],- "canBeAssignedToUsers": [- 8- ],- "canBeAssignedToAgents": [- 8- ],- "canBeAssignedToApiKeys": [- 8- ],- "__typename": [- 1- ]- },- "UpdateRoleInput": {- "update": [- 545- ],- "id": [- 3- ],- "__typename": [- 1- ]- },- "UpdateRolePayload": {- "label": [- 1- ],- "description": [- 1- ],- "icon": [- 1- ],- "canUpdateAllSettings": [- 8- ],- "canAccessAllTools": [- 8- ],- "canReadAllObjectRecords": [- 8- ],- "canUpdateAllObjectRecords": [- 8- ],- "canSoftDeleteAllObjectRecords": [- 8- ],- "canDestroyAllObjectRecords": [- 8- ],- "canBeAssignedToUsers": [- 8- ],- "canBeAssignedToAgents": [- 8- ],- "canBeAssignedToApiKeys": [- 8- ],- "__typename": [- 1- ]- },- "UpsertObjectPermissionsInput": {- "roleId": [- 3- ],- "objectPermissions": [- 547- ],- "__typename": [- 1- ]- },- "ObjectPermissionInput": {- "objectMetadataId": [- 3- ],- "canReadObjectRecords": [- 8- ],- "canUpdateObjectRecords": [- 8- ],- "canSoftDeleteObjectRecords": [- 8- ],- "canDestroyObjectRecords": [- 8- ],- "__typename": [- 1- ]- },- "UpsertPermissionFlagsInput": {- "roleId": [- 3- ],- "permissionFlagKeys": [- 1- ],- "__typename": [- 1- ]- },- "UpsertFieldPermissionsInput": {- "roleId": [- 3- ],- "fieldPermissions": [- 550- ],- "__typename": [- 1- ]- },- "FieldPermissionInput": {- "objectMetadataId": [- 3- ],- "fieldMetadataId": [- 3- ],- "canReadFieldValue": [- 8- ],- "canUpdateFieldValue": [- 8- ],- "__typename": [- 1- ]- },- "UpsertRowLevelPermissionPredicatesInput": {- "roleId": [- 3- ],- "objectMetadataId": [- 3- ],- "predicates": [- 552- ],- "predicateGroups": [- 553- ],- "__typename": [- 1- ]- },- "RowLevelPermissionPredicateInput": {- "id": [- 3- ],- "fieldMetadataId": [- 3- ],- "operand": [- 46- ],- "value": [- 9- ],- "subFieldName": [- 1- ],- "workspaceMemberFieldMetadataId": [- 1- ],- "workspaceMemberSubFieldName": [- 1- ],- "rowLevelPermissionPredicateGroupId": [- 3- ],- "positionInRowLevelPermissionPredicateGroup": [- 15- ],- "__typename": [- 1- ]- },- "RowLevelPermissionPredicateGroupInput": {- "id": [- 3- ],- "objectMetadataId": [- 3- ],- "parentRowLevelPermissionPredicateGroupId": [- 3- ],- "logicalOperator": [- 44- ],- "positionInRowLevelPermissionPredicateGroup": [- 15- ],- "__typename": [- 1- ]- },"SendMessageCampaignInput": {"campaignId": [1diff --git a/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow-version-mutation.resolver.ts b/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow-version-mutation.resolver.tsindex 6d342deaeb6..d07f570edd0 100644--- a/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow-version-mutation.resolver.ts+++ b/packages/twenty-server/src/engine/core-modules/workflow/resolvers/core-workflow-version-mutation.resolver.ts@@ -5,6 +5,7 @@ import { PermissionFlagType } from 'twenty-shared/constants';import { CoreResolver } from 'src/engine/api/graphql/graphql-config/decorators/core-resolver.decorator';import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';+import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';import { type AuthContextUser } from 'src/engine/core-modules/auth/types/auth-context.type';import { PreventNestToAutoLogGraphqlErrorsFilter } from 'src/engine/core-modules/graphql/filters/prevent-nest-to-auto-log-graphql-errors.filter';import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';@@ -31,6 +32,7 @@ import { WorkflowVersionValidationGraphqlApiExceptionFilter } from 'src/engine/cimport { CoreWorkflowLifecycleWorkspaceService } from 'src/engine/core-modules/workflow/services/core-workflow-lifecycle.workspace-service';import { CoreWorkflowVersionMutationWorkspaceService } from 'src/engine/core-modules/workflow/services/core-workflow-version-mutation.workspace-service';import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';+import { AuthApplication } from 'src/engine/decorators/auth/auth-application.decorator';import { AuthUser } from 'src/engine/decorators/auth/auth-user.decorator';import { CoreWorkflowAccessService } from 'src/engine/core-modules/workflow/services/core-workflow-access.service';import { AuthUserWorkspaceId } from 'src/engine/decorators/auth/auth-user-workspace-id.decorator';@@ -133,6 +135,8 @@ export class CoreWorkflowVersionMutationResolver {@AuthWorkspace() { id: workspaceId }: WorkspaceEntity,@AuthUserWorkspaceId({ allowUndefined: true })userWorkspaceId: string | undefined,+ @AuthApplication({ allowUndefined: true })+ callerApplication: FlatApplication | undefined,@Args('input'){coreWorkflowVersionId,@@ -161,8 +165,20 @@ export class CoreWorkflowVersionMutationResolver {},);+ await this.coreWorkflowAccessService.assertCoreWorkflowVersionsAreStartableByApplicationOrThrow(+ {+ workspaceId,+ callerApplicationId: callerApplication?.id,+ coreWorkflowVersionIds: [coreWorkflowVersionId],+ },+ );+const { payload: triggerPayload, createdBy } =- buildWorkflowRunTriggerContext({ workspaceMember, payload });+ buildWorkflowRunTriggerContext({+ workspaceMember,+ payload,+ startingApplicationId: callerApplication?.id,+ });return this.coreWorkflowRunnerService.run({workspaceId,diff --git a/packages/twenty-server/src/engine/core-modules/workflow/resolvers/workflow-trigger.resolver.ts b/packages/twenty-server/src/engine/core-modules/workflow/resolvers/workflow-trigger.resolver.tsindex edd96fbdd76..e8594f838ef 100644--- a/packages/twenty-server/src/engine/core-modules/workflow/resolvers/workflow-trigger.resolver.ts+++ b/packages/twenty-server/src/engine/core-modules/workflow/resolvers/workflow-trigger.resolver.ts@@ -7,14 +7,17 @@ import { CoreResolver } from 'src/engine/api/graphql/graphql-config/decorators/cimport { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';import { PreventNestToAutoLogGraphqlErrorsFilter } from 'src/engine/core-modules/graphql/filters/prevent-nest-to-auto-log-graphql-errors.filter';import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';+import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';import { type AuthContextUser } from 'src/engine/core-modules/auth/types/auth-context.type';import { AuthGraphqlApiExceptionFilter } from 'src/engine/core-modules/auth/filters/auth-graphql-api-exception.filter';import { RunWorkflowVersionInput } from 'src/engine/core-modules/workflow/dtos/run-workflow-version.input';import { RunWorkflowVersionDTO } from 'src/engine/core-modules/workflow/dtos/run-workflow-version.dto';import { WorkflowRunDTO } from 'src/engine/core-modules/workflow/dtos/workflow-run.dto';+import { WorkflowQueryValidationGraphqlApiExceptionFilter } from 'src/engine/core-modules/workflow/filters/workflow-query-validation-graphql-api-exception.filter';import { WorkflowTriggerGraphqlApiExceptionFilter } from 'src/engine/core-modules/workflow/filters/workflow-trigger-graphql-api-exception.filter';import { WorkflowVersionValidationGraphqlApiExceptionFilter } from 'src/engine/core-modules/workflow/filters/workflow-version-validation-graphql-api-exception.filter';import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';+import { AuthApplication } from 'src/engine/decorators/auth/auth-application.decorator';import { AuthUser } from 'src/engine/decorators/auth/auth-user.decorator';import { AuthUserWorkspaceId } from 'src/engine/decorators/auth/auth-user-workspace-id.decorator';import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';@@ -46,6 +49,7 @@ import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/sta@UsePipes(ResolverValidationPipe)@UseFilters(WorkflowTriggerGraphqlApiExceptionFilter,+ WorkflowQueryValidationGraphqlApiExceptionFilter,WorkflowVersionValidationGraphqlApiExceptionFilter,PermissionsGraphqlApiExceptionFilter,PreventNestToAutoLogGraphqlErrorsFilter,@@ -121,6 +125,8 @@ export class WorkflowTriggerResolver {userWorkspaceId: string | undefined,@AuthUser() user: AuthContextUser,@AuthWorkspace() workspace: WorkspaceEntity,+ @AuthApplication({ allowUndefined: true })+ callerApplication: FlatApplication | undefined,@Args('input'){ workflowVersionId, workflowRunId, payload }: RunWorkflowVersionInput,) {@@ -132,6 +138,14 @@ export class WorkflowTriggerResolver {},);+ await this.coreWorkflowAccessService.assertWorkspaceWorkflowVersionsAreStartableByApplicationOrThrow(+ {+ workspaceId: workspace.id,+ callerApplicationId: callerApplication?.id,+ workspaceWorkflowVersionIds: [workflowVersionId],+ },+ );+const authContext = buildSystemAuthContext(workspace.id);const workspaceMember =@@ -150,7 +164,11 @@ export class WorkflowTriggerResolver {}, authContext);const { payload: triggerPayload, createdBy } =- buildWorkflowRunTriggerContext({ workspaceMember, payload });+ buildWorkflowRunTriggerContext({+ workspaceMember,+ payload,+ startingApplicationId: callerApplication?.id,+ });return this.workflowTriggerWorkspaceService.runWorkflowVersion({workflowVersionId,diff --git a/packages/twenty-server/src/engine/core-modules/workflow/resolvers/workflow-version-step.resolver.ts b/packages/twenty-server/src/engine/core-modules/workflow/resolvers/workflow-version-step.resolver.tsindex c4d7cfb6276..901a64065c3 100644--- a/packages/twenty-server/src/engine/core-modules/workflow/resolvers/workflow-version-step.resolver.ts+++ b/packages/twenty-server/src/engine/core-modules/workflow/resolvers/workflow-version-step.resolver.ts@@ -1,6 +1,7 @@import { UseFilters, UseGuards, UsePipes } from '@nestjs/common';import { Args, Mutation, Query } from '@nestjs/graphql';+import { msg } from '@lingui/core/macro';import { PermissionFlagType } from 'twenty-shared/constants';import { CoreResolver } from 'src/engine/api/graphql/graphql-config/decorators/core-resolver.decorator';@@ -30,7 +31,12 @@ import { ConnectedAccountMetadataService } from 'src/engine/metadata-modules/conimport { ConnectedAccountHandleDTO } from 'src/engine/metadata-modules/connected-account/dtos/connected-account-handle.dto';import { PermissionsGraphqlApiExceptionFilter } from 'src/engine/metadata-modules/permissions/utils/permissions-graphql-api-exception.filter';import { CoreWorkflowAccessService } from 'src/engine/core-modules/workflow/services/core-workflow-access.service';+import {+ WorkflowVersionStepException,+ WorkflowVersionStepExceptionCode,+} from 'src/modules/workflow/common/exceptions/workflow-version-step.exception';import { WorkflowVersionStepWorkspaceService } from 'src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step.workspace-service';+import { canUpdateWorkflowRunStep } from 'src/modules/workflow/workflow-runner/utils/can-update-workflow-run-step.util';import { WorkflowRunWorkspaceService } from 'src/modules/workflow/workflow-runner/workflow-run/workflow-run.workspace-service';import { AuthGraphqlApiExceptionFilter } from 'src/engine/core-modules/auth/filters/auth-graphql-api-exception.filter';@@ -188,6 +194,22 @@ export class WorkflowVersionStepResolver {@Args('input'){ workflowRunId, step }: UpdateWorkflowRunStepInput,): Promise<WorkflowActionDTO> {+ const workflowRun =+ await this.workflowRunWorkspaceService.getWorkflowRunOrFail({+ workflowRunId,+ workspaceId,+ });++ if (!canUpdateWorkflowRunStep({ workflowRun, step })) {+ throw new WorkflowVersionStepException(+ 'Only the values of a form step can change on a workflow run bound to an application',+ WorkflowVersionStepExceptionCode.INVALID_REQUEST,+ {+ userFriendlyMessage: msg`Only the values of this form can be changed.`,+ },+ );+ }+await this.workflowRunWorkspaceService.updateWorkflowRunStep({workspaceId,workflowRunId,diff --git a/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-access.service.ts b/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-access.service.tsindex 173793ae323..d901926d395 100644--- a/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-access.service.ts+++ b/packages/twenty-server/src/engine/core-modules/workflow/services/core-workflow-access.service.ts@@ -8,6 +8,7 @@ import { In } from 'typeorm';import { WorkflowVersionEntity } from 'src/engine/core-modules/workflow/entities/workflow-version.entity';import { WorkflowEntity } from 'src/engine/core-modules/workflow/entities/workflow.entity';+import { canApplicationStartCoreWorkflow } from 'src/engine/core-modules/workflow/utils/can-application-start-core-workflow.util';import { canChangeCoreWorkflowVisibility } from 'src/engine/core-modules/workflow/utils/can-change-core-workflow-visibility.util';import { InjectWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspace-scoped-repository/inject-workspace-scoped-repository.decorator';import { WorkspaceScopedRepository } from 'src/engine/twenty-orm/workspace-scoped-repository/workspace-scoped-repository';@@ -63,6 +64,108 @@ export class CoreWorkflowAccessService {}}+ async assertCoreWorkflowVersionsAreStartableByApplicationOrThrow({+ workspaceId,+ callerApplicationId,+ coreWorkflowVersionIds,+ }: {+ workspaceId: string;+ callerApplicationId: string | undefined;+ coreWorkflowVersionIds: string[];+ }): Promise<void> {+ if (+ !isDefined(callerApplicationId) ||+ coreWorkflowVersionIds.length === 0+ ) {+ return;+ }++ const coreWorkflowVersions = await this.coreWorkflowVersionRepository.find(+ workspaceId,+ {+ where: { id: In(coreWorkflowVersionIds) },+ select: { id: true, coreWorkflowId: true },+ },+ );++ const coreWorkflowIds = [+ ...new Set(+ coreWorkflowVersions+ .map(({ coreWorkflowId }) => coreWorkflowId)+ .filter(isDefined),+ ),+ ];++ if (coreWorkflowIds.length === 0) {+ return;+ }++ const [+ workflows,+ { workspaceCustomFlatApplication, twentyStandardFlatApplication },+ ] = await Promise.all([+ this.coreWorkflowRepository.find(workspaceId, {+ where: { id: In(coreWorkflowIds) },+ select: { id: true, applicationId: true },+ }),+ this.applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow(+ { workspaceId },+ ),+ ]);++ const isStartable = workflows.every((workflow) =>+ canApplicationStartCoreWorkflow({+ callerApplicationId,+ workflowApplicationId: workflow.applicationId,+ workspaceOwnedApplicationIds: [+ workspaceCustomFlatApplication.id,+ twentyStandardFlatApplication.id,+ ],+ }),+ );++ if (!isStartable) {+ throw new WorkflowQueryValidationException(+ `Application '${callerApplicationId}' cannot start a workflow owned by another application`,+ WorkflowQueryValidationExceptionCode.FORBIDDEN,+ {+ userFriendlyMessage: msg`An application can only start its own workflows.`,+ },+ );+ }+ }++ async assertWorkspaceWorkflowVersionsAreStartableByApplicationOrThrow({+ workspaceId,+ callerApplicationId,+ workspaceWorkflowVersionIds,+ }: {+ workspaceId: string;+ callerApplicationId: string | undefined;+ workspaceWorkflowVersionIds: string[];+ }): Promise<void> {+ if (+ !isDefined(callerApplicationId) ||+ workspaceWorkflowVersionIds.length === 0+ ) {+ return;+ }++ const coreWorkflowVersions = await this.coreWorkflowVersionRepository.find(+ workspaceId,+ {+ where: { workspaceWorkflowVersionId: In(workspaceWorkflowVersionIds) },+ select: { id: true },+ },+ );++ await this.assertCoreWorkflowVersionsAreStartableByApplicationOrThrow({+ workspaceId,+ callerApplicationId,+ coreWorkflowVersionIds: coreWorkflowVersions.map(({ id }) => id),+ });+ }+async assertCoreWorkflowsAreAccessibleOrThrow({workspaceId,userWorkspaceId,diff --git a/packages/twenty-server/src/engine/core-modules/workflow/utils/__tests__/can-application-start-core-workflow.util.spec.ts b/packages/twenty-server/src/engine/core-modules/workflow/utils/__tests__/can-application-start-core-workflow.util.spec.tsnew file mode 100644index 00000000000..ea291c5a6a3--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/workflow/utils/__tests__/can-application-start-core-workflow.util.spec.ts@@ -0,0 +1,45 @@+import { canApplicationStartCoreWorkflow } from 'src/engine/core-modules/workflow/utils/can-application-start-core-workflow.util';++const WORKSPACE_OWNED_APPLICATION_IDS = ['custom-app-id', 'standard-app-id'];++describe('canApplicationStartCoreWorkflow', () => {+ it('lets a request without an application start any workflow it can reach', () => {+ expect(+ canApplicationStartCoreWorkflow({+ callerApplicationId: undefined,+ workflowApplicationId: 'installed-app-id',+ workspaceOwnedApplicationIds: WORKSPACE_OWNED_APPLICATION_IDS,+ }),+ ).toBe(true);+ });++ it('keeps letting applications start workspace workflows', () => {+ expect(+ canApplicationStartCoreWorkflow({+ callerApplicationId: 'installed-app-id',+ workflowApplicationId: 'custom-app-id',+ workspaceOwnedApplicationIds: WORKSPACE_OWNED_APPLICATION_IDS,+ }),+ ).toBe(true);+ });++ it('lets an application start its own workflows', () => {+ expect(+ canApplicationStartCoreWorkflow({+ callerApplicationId: 'installed-app-id',+ workflowApplicationId: 'installed-app-id',+ workspaceOwnedApplicationIds: WORKSPACE_OWNED_APPLICATION_IDS,+ }),+ ).toBe(true);+ });++ it('refuses an application starting the workflow of another application', () => {+ expect(+ canApplicationStartCoreWorkflow({+ callerApplicationId: 'other-app-id',+ workflowApplicationId: 'installed-app-id',+ workspaceOwnedApplicationIds: WORKSPACE_OWNED_APPLICATION_IDS,+ }),+ ).toBe(false);+ });+});diff --git a/packages/twenty-server/src/engine/core-modules/workflow/utils/can-application-start-core-workflow.util.ts b/packages/twenty-server/src/engine/core-modules/workflow/utils/can-application-start-core-workflow.util.tsnew file mode 100644index 00000000000..ae135796137--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/workflow/utils/can-application-start-core-workflow.util.ts@@ -0,0 +1,14 @@+import { isDefined } from 'twenty-shared/utils';++export const canApplicationStartCoreWorkflow = ({+ callerApplicationId,+ workflowApplicationId,+ workspaceOwnedApplicationIds,+}: {+ callerApplicationId: string | undefined;+ workflowApplicationId: string;+ workspaceOwnedApplicationIds: string[];+}): boolean =>+ !isDefined(callerApplicationId) ||+ workspaceOwnedApplicationIds.includes(workflowApplicationId) ||+ workflowApplicationId === callerApplicationId;diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.tsindex f2c89349b62..2d3f4b1a4f1 100644--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts@@ -1,5 +1,6 @@import { Injectable } from '@nestjs/common';+import { msg } from '@lingui/core/macro';import { AUTO_SELECT_WORKSPACE_DEFAULT_MODEL_ID } from 'twenty-shared/ai';import { inputSchemaToOutputSchema } from 'twenty-shared/logic-function';import {@@ -17,6 +18,7 @@ import {import { v4 } from 'uuid';import { getFlatFieldsFromFlatObjectMetadata } from 'src/engine/api/graphql/workspace-schema-builder/utils/get-flat-fields-for-flat-object-metadata.util';+import { FindRecordsService } from 'src/engine/core-modules/record-crud/services/find-records.service';import { type WorkflowStepPositionInput } from 'src/engine/core-modules/workflow/dtos/update-workflow-step-position.input';import { WorkflowVersionCoreSyncService } from 'src/engine/core-modules/workflow/services/workflow-version-core-sync.service';import { AiAgentRoleService } from 'src/engine/metadata-modules/ai/ai-agent-role/ai-agent-role.service';@@ -42,6 +44,7 @@ import {import { WorkflowCommonWorkspaceService } from 'src/modules/workflow/common/workspace-services/workflow-common.workspace-service';import { type OutputSchema } from 'src/modules/workflow/workflow-builder/workflow-schema/types/output-schema.type';import { CodeStepBuildService } from 'src/modules/workflow/workflow-builder/workflow-version-step/code-step/services/code-step-build.service';+import { type WorkflowExecutionContext } from 'src/modules/workflow/workflow-executor/types/workflow-execution-context.type';import { type BaseWorkflowActionSettings } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action-settings.type';import {type WorkflowAction,@@ -83,6 +86,7 @@ export class WorkflowVersionStepOperationsWorkspaceService {private readonly workspaceCacheService: WorkspaceCacheService,private readonly flatEntityMapsCacheService: WorkspaceManyOrAllFlatEntityMapsCacheService,private readonly workflowVersionCoreSyncService: WorkflowVersionCoreSyncService,+ private readonly findRecordsService: FindRecordsService,) {}async runWorkflowVersionStepDeletionSideEffects({@@ -713,10 +717,15 @@ export class WorkflowVersionStepOperationsWorkspaceService {workspaceId,step,response,+ recordReadContext,}: {workspaceId: string;step: WorkflowFormAction;response: object;+ recordReadContext?: Pick<+ WorkflowExecutionContext,+ 'authContext' | 'rolePermissionConfig'+ >;}) {const authContext = buildSystemAuthContext(workspaceId);@@ -741,6 +750,18 @@ export class WorkflowVersionStepOperationsWorkspaceService {// @ts-expect-error legacy noImplicitAnyisValidUuid(response[key].id)) {+ if (isDefined(recordReadContext)) {+ return {+ key,+ value: await this.findSelectedRecordOrThrow({+ objectName: field.settings.objectName,+ // @ts-expect-error legacy noImplicitAny+ recordId: response[key].id,+ recordReadContext,+ }),+ };+ }+const { flatObjectMetadata, flatFieldMetadataMaps } =await this.workflowCommonWorkspaceService.getObjectMetadataInfo(field.settings.objectName,@@ -782,6 +803,42 @@ export class WorkflowVersionStepOperationsWorkspaceService {}, authContext);}+ private async findSelectedRecordOrThrow({+ objectName,+ recordId,+ recordReadContext,+ }: {+ objectName: string;+ recordId: string;+ recordReadContext: Pick<+ WorkflowExecutionContext,+ 'authContext' | 'rolePermissionConfig'+ >;+ }) {+ const { success, result } = await this.findRecordsService.execute({+ objectName,+ filter: { id: { eq: recordId } },+ limit: 1,+ authContext: recordReadContext.authContext,+ rolePermissionConfig: recordReadContext.rolePermissionConfig,+ shouldBuildEffectiveSelectFields: false,+ });++ const record = success ? result?.records[0] : undefined;++ if (!isDefined(record)) {+ throw new WorkflowVersionStepException(+ `Record ${recordId} of ${objectName} cannot be read with the permissions of this run`,+ WorkflowVersionStepExceptionCode.INVALID_REQUEST,+ {+ userFriendlyMessage: msg`You cannot select this record in this form.`,+ },+ );+ }++ return record;+ }+async cloneStep({step,workspaceId,diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step.module.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step.module.tsindex 4f4fb2c04af..8be48a6f83b 100644--- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step.module.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step.module.ts@@ -20,6 +20,7 @@ import { WorkflowVersionStepHelpersWorkspaceService } from 'src/modules/workflowimport { WorkflowVersionStepOperationsWorkspaceService } from 'src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service';import { WorkflowVersionStepUpdateWorkspaceService } from 'src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-update.workspace-service';import { WorkflowVersionStepWorkspaceService } from 'src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step.workspace-service';+import { RecordCrudModule } from 'src/engine/core-modules/record-crud/record-crud.module';@Module({imports: [@@ -37,6 +38,7 @@ import { WorkflowVersionStepWorkspaceService } from 'src/modules/workflow/workfl]),WorkspaceManyOrAllFlatEntityMapsCacheModule,WorkflowVersionCoreModule,+ RecordCrudModule,],providers: [WorkflowVersionStepWorkspaceService,diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/exceptions/workflow-step-executor.exception.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/exceptions/workflow-step-executor.exception.tsindex b1c723779a0..e575efbb04b 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/exceptions/workflow-step-executor.exception.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/exceptions/workflow-step-executor.exception.ts@@ -10,6 +10,7 @@ export enum WorkflowStepExecutorExceptionCode {INVALID_STEP_TYPE = 'INVALID_STEP_TYPE',INVALID_STEP_INPUT = 'INVALID_STEP_INPUT',STEP_NOT_FOUND = 'STEP_NOT_FOUND',+ FORBIDDEN = 'FORBIDDEN',INTERNAL_ERROR = 'INTERNAL_ERROR',}@@ -25,6 +26,8 @@ const getWorkflowStepExecutorExceptionUserFriendlyMessage = (return msg`Workflow step not found.`;case WorkflowStepExecutorExceptionCode.INVALID_STEP_INPUT:return msg`Invalid workflow step input.`;+ case WorkflowStepExecutorExceptionCode.FORBIDDEN:+ return msg`This workflow step is not allowed with the permissions of the workflow.`;case WorkflowStepExecutorExceptionCode.INTERNAL_ERROR:return STANDARD_ERROR_MESSAGE;default:diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/services/workflow-execution-context.module.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/services/workflow-execution-context.module.tsnew file mode 100644index 00000000000..4240bdcaf48--- /dev/null+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/services/workflow-execution-context.module.ts@@ -0,0 +1,24 @@+import { Module } from '@nestjs/common';+import { TypeOrmModule } from '@nestjs/typeorm';++import { ApplicationModule } from 'src/engine/core-modules/application/application.module';+import { UserWorkspaceModule } from 'src/engine/core-modules/user-workspace/user-workspace.module';+import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';+import { RoleModule } from 'src/engine/metadata-modules/role/role.module';+import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.module';+import { WorkflowExecutionContextService } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.service';+import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflow-run/workflow-run.module';++@Module({+ imports: [+ ApplicationModule,+ RoleModule,+ UserWorkspaceModule,+ WorkflowRunModule,+ WorkspaceCacheModule,+ TypeOrmModule.forFeature([WorkspaceEntity]),+ ],+ providers: [WorkflowExecutionContextService],+ exports: [WorkflowExecutionContextService],+})+export class WorkflowExecutionContextModule {}diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/services/workflow-execution-context.service.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/services/workflow-execution-context.service.tsindex 9e1000b597e..61c3202288d 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/services/workflow-execution-context.service.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/services/workflow-execution-context.service.ts@@ -1,20 +1,32 @@import { Injectable } from '@nestjs/common';+import { InjectRepository } from '@nestjs/typeorm';import { FieldActorSource } from 'twenty-shared/types';import { isDefined } from 'twenty-shared/utils';+import { Repository } from 'typeorm';import { ApplicationService } from 'src/engine/core-modules/application/application.service';+import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';import { type WorkspaceAuthContext } from 'src/engine/core-modules/auth/types/workspace-auth-context.type';import { buildApplicationAuthContext } from 'src/engine/core-modules/auth/utils/build-application-auth-context.util';import { buildUserAuthContext } from 'src/engine/core-modules/auth/utils/build-user-auth-context.util';import { fromUserEntityToFlat } from 'src/engine/core-modules/user/utils/from-user-entity-to-flat.util';import { fromWorkspaceEntityToFlat } from 'src/engine/core-modules/workspace/utils/from-workspace-entity-to-flat.util';+import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';import { UserWorkspaceService } from 'src/engine/core-modules/user-workspace/user-workspace.service';import { RoleService } from 'src/engine/metadata-modules/role/role.service';-import { UserRoleService } from 'src/engine/metadata-modules/user-role/user-role.service';+import { resolveRolePermissionConfig } from 'src/engine/twenty-orm/utils/resolve-role-permission-config.util';+import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';import { STANDARD_ROLE } from 'src/engine/workspace-manager/twenty-standard-application/constants/standard-role.constant';import { type WorkflowRunWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';+import {+ WorkflowStepExecutorException,+ WorkflowStepExecutorExceptionCode,+} from 'src/modules/workflow/workflow-executor/exceptions/workflow-step-executor.exception';+import { type WorkflowRunInfo } from 'src/modules/workflow/workflow-executor/types/workflow-action-input.type';import { type WorkflowExecutionContext } from 'src/modules/workflow/workflow-executor/types/workflow-execution-context.type';+import { assertStepTargetBelongsToRunApplication } from 'src/modules/workflow/workflow-executor/utils/assert-step-target-belongs-to-run-application.util';+import { resolveWorkflowRunApplicationOrThrow } from 'src/modules/workflow/workflow-executor/utils/resolve-workflow-run-application-or-throw.util';import { WorkflowRunWorkspaceService as WorkflowRunService } from 'src/modules/workflow/workflow-runner/workflow-run/workflow-run.workspace-service';@Injectable()@@ -23,38 +35,159 @@ export class WorkflowExecutionContextService {constructor(private readonly workflowRunService: WorkflowRunService,private readonly userWorkspaceService: UserWorkspaceService,- private readonly userRoleService: UserRoleService,private readonly applicationService: ApplicationService,private readonly roleService: RoleService,+ private readonly workspaceCacheService: WorkspaceCacheService,+ @InjectRepository(WorkspaceEntity)+ private readonly workspaceRepository: Repository<WorkspaceEntity>,) {}- async getExecutionContext(runInfo: {- workflowRunId: string;- workspaceId: string;- }): Promise<WorkflowExecutionContext> {+ async getExecutionContext(+ runInfo: WorkflowRunInfo,+ ): Promise<WorkflowExecutionContext> {const workflowRun = await this.workflowRunService.getWorkflowRunOrFail({workflowRunId: runInfo.workflowRunId,workspaceId: runInfo.workspaceId,});+ return this.buildExecutionContext(workflowRun, runInfo.workspaceId);+ }++ async getApplicationBoundExecutionContext({+ workflowRun,+ workspaceId,+ }: {+ workflowRun: WorkflowRunWorkspaceEntity;+ workspaceId: string;+ }): Promise<WorkflowExecutionContext | null> {+ if (!isDefined(workflowRun.createdBy.context?.applicationId)) {+ return null;+ }++ return this.buildExecutionContext(workflowRun, workspaceId);+ }++ async assertStepTargetBelongsToRunApplicationOrThrow({+ application,+ workspaceId,+ targetApplicationId,+ targetLabel,+ }: {+ application: FlatApplication | null;+ workspaceId: string;+ targetApplicationId: string;+ targetLabel: string;+ }): Promise<void> {+ if (!isDefined(application) || targetApplicationId === application.id) {+ return;+ }++ const { workspaceCustomFlatApplication, twentyStandardFlatApplication } =+ await this.applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow(+ { workspaceId },+ );++ assertStepTargetBelongsToRunApplication({+ application,+ targetApplicationId,+ workspaceOwnedApplicationIds: [+ workspaceCustomFlatApplication.id,+ twentyStandardFlatApplication.id,+ ],+ targetLabel,+ });+ }++ private async buildExecutionContext(+ workflowRun: WorkflowRunWorkspaceEntity,+ workspaceId: string,+ ): Promise<WorkflowExecutionContext> {+ const application = await this.findRunApplication(workflowRun, workspaceId);+const isActingOnBehalfOfUser =workflowRun.createdBy.source === FieldActorSource.MANUAL &&isDefined(workflowRun.createdBy.workspaceMemberId);- if (isActingOnBehalfOfUser) {- return this.buildUserExecutionContext(workflowRun, runInfo.workspaceId);+ const authContext = await this.buildAuthContext({+ workflowRun,+ workspaceId,+ application,+ isActingOnBehalfOfUser,+ });++ const { userWorkspaceRoleMap } =+ await this.workspaceCacheService.getOrRecompute(workspaceId, [+ 'userWorkspaceRoleMap',+ ]);++ const rolePermissionConfig = resolveRolePermissionConfig({+ authContext,+ userWorkspaceRoleMap,+ apiKeyRoleMap: {},+ });++ if (!isDefined(rolePermissionConfig)) {+ throw new WorkflowStepExecutorException(+ 'No role is left to run this step with',+ WorkflowStepExecutorExceptionCode.FORBIDDEN,+ );+ }++ return {+ isActingOnBehalfOfUser,+ initiator: workflowRun.createdBy,+ rolePermissionConfig,+ authContext,+ application,+ };+ }++ private async findRunApplication(+ workflowRun: WorkflowRunWorkspaceEntity,+ workspaceId: string,+ ): Promise<FlatApplication | null> {+ if (!isDefined(workflowRun.createdBy.context?.applicationId)) {+ return null;}- return this.buildApplicationExecutionContext(+ const { flatApplicationMaps } =+ await this.workspaceCacheService.getOrRecompute(workspaceId, [+ 'flatApplicationMaps',+ ]);++ return resolveWorkflowRunApplicationOrThrow({workflowRun,- runInfo.workspaceId,- );+ applicationsById: flatApplicationMaps.byId,+ });}- private async buildUserExecutionContext(+ private buildAuthContext({+ workflowRun,+ workspaceId,+ application,+ isActingOnBehalfOfUser,+ }: {+ workflowRun: WorkflowRunWorkspaceEntity;+ workspaceId: string;+ application: FlatApplication | null;+ isActingOnBehalfOfUser: boolean;+ }): Promise<WorkspaceAuthContext> {+ if (isActingOnBehalfOfUser) {+ return this.buildMemberAuthContext(workflowRun, workspaceId, application);+ }++ if (isDefined(application)) {+ return this.buildBoundApplicationAuthContext(workspaceId, application);+ }++ return this.buildStandardApplicationAuthContext(workspaceId);+ }++ private async buildMemberAuthContext(workflowRun: WorkflowRunWorkspaceEntity,workspaceId: string,- ): Promise<WorkflowExecutionContext> {+ application: FlatApplication | null,+ ): Promise<WorkspaceAuthContext> {const workspaceMember =await this.userWorkspaceService.getWorkspaceMemberOrThrow({workspaceMemberId: workflowRun.createdBy.workspaceMemberId!,@@ -68,31 +201,33 @@ export class WorkflowExecutionContextService {relations: ['workspace', 'user'],});- const roleId = await this.userRoleService.getRoleIdForUserWorkspace({- userWorkspaceId: userWorkspace.id,- workspaceId,- });-- const authContext: WorkspaceAuthContext = buildUserAuthContext({+ return buildUserAuthContext({workspace: fromWorkspaceEntityToFlat(userWorkspace.workspace),userWorkspaceId: userWorkspace.id,user: fromUserEntityToFlat(userWorkspace.user),workspaceMemberId: workspaceMember.id,workspaceMember,+ application,});+ }- return {- isActingOnBehalfOfUser: true,- initiator: workflowRun.createdBy,- rolePermissionConfig: { unionOf: [roleId] },- authContext,- };+ private async buildBoundApplicationAuthContext(+ workspaceId: string,+ application: FlatApplication,+ ): Promise<WorkspaceAuthContext> {+ const workspace = await this.workspaceRepository.findOneOrFail({+ where: { id: workspaceId },+ });++ return buildApplicationAuthContext({+ workspace: fromWorkspaceEntityToFlat(workspace),+ application,+ });}- private async buildApplicationExecutionContext(- workflowRun: WorkflowRunWorkspaceEntity,+ private async buildStandardApplicationAuthContext(workspaceId: string,- ): Promise<WorkflowExecutionContext> {+ ): Promise<WorkspaceAuthContext> {const { application, workspace } =await this.applicationService.findTwentyStandardApplicationOrThrow(workspaceId,@@ -111,23 +246,12 @@ export class WorkflowExecutionContextService {roleId = adminRole?.id ?? null;}- const rolePermissionConfig = isDefined(roleId)- ? { unionOf: [roleId] }- : { shouldBypassPermissionChecks: true as const };-- const authContext: WorkspaceAuthContext = buildApplicationAuthContext({+ return buildApplicationAuthContext({workspace: fromWorkspaceEntityToFlat(workspace),application: {...application,defaultRoleId: roleId,},});-- return {- isActingOnBehalfOfUser: false,- initiator: workflowRun.createdBy,- rolePermissionConfig,- authContext,- };}}diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/types/workflow-execution-context.type.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/types/workflow-execution-context.type.tsindex 3a828719008..fdcf01c3565 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/types/workflow-execution-context.type.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/types/workflow-execution-context.type.ts@@ -1,5 +1,6 @@import { type ActorMetadata } from 'twenty-shared/types';+import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';import { type WorkspaceAuthContext } from 'src/engine/core-modules/auth/types/workspace-auth-context.type';import { type RolePermissionConfig } from 'src/engine/twenty-orm/types/role-permission-config.type';@@ -8,4 +9,5 @@ export type WorkflowExecutionContext = {initiator: ActorMetadata;rolePermissionConfig: RolePermissionConfig;authContext: WorkspaceAuthContext;+ application: FlatApplication | null;};diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/assert-step-target-belongs-to-run-application.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/assert-step-target-belongs-to-run-application.util.spec.tsnew file mode 100644index 00000000000..201fc783299--- /dev/null+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/assert-step-target-belongs-to-run-application.util.spec.ts@@ -0,0 +1,31 @@+import { assertStepTargetBelongsToRunApplication } from 'src/modules/workflow/workflow-executor/utils/assert-step-target-belongs-to-run-application.util';++const RUN_APPLICATION = { id: 'installed-app-id', name: 'Installed app' };++const assertTarget = (targetApplicationId: string) =>+ assertStepTargetBelongsToRunApplication({+ application: RUN_APPLICATION,+ targetApplicationId,+ workspaceOwnedApplicationIds: [+ 'workspace-custom-app-id',+ 'twenty-standard-app-id',+ ],+ targetLabel: 'Logic function "greet"',+ });++describe('assertStepTargetBelongsToRunApplication', () => {+ it('lets a run use the functions and agents of its application', () => {+ expect(() => assertTarget('installed-app-id')).not.toThrow();+ });++ it('lets a run use the functions and agents of the workspace', () => {+ expect(() => assertTarget('workspace-custom-app-id')).not.toThrow();+ expect(() => assertTarget('twenty-standard-app-id')).not.toThrow();+ });++ it('refuses a run crossing into another installed application', () => {+ expect(() => assertTarget('other-app-id')).toThrow(+ 'Logic function "greet" belongs to another application than "Installed app"',+ );+ });+});diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/build-workflow-run-created-by.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/build-workflow-run-created-by.util.spec.tsnew file mode 100644index 00000000000..85e0c0bd751--- /dev/null+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/build-workflow-run-created-by.util.spec.ts@@ -0,0 +1,73 @@+import { type ActorMetadata, FieldActorSource } from 'twenty-shared/types';++import { buildWorkflowRunCreatedBy } from 'src/modules/workflow/workflow-executor/utils/build-workflow-run-created-by.util';++const CUSTOM_APPLICATION_ID = 'custom-app-id';+const STANDARD_APPLICATION_ID = 'standard-app-id';+const INSTALLED_APPLICATION_ID = 'installed-app-id';++const buildSource = (applicationId?: string): ActorMetadata => ({+ source: FieldActorSource.MANUAL,+ workspaceMemberId: 'member-id',+ name: 'Tim Apple',+ context: { applicationId },+});++const build = ({+ workflowApplicationId,+ startingApplicationId,+}: {+ workflowApplicationId: string;+ startingApplicationId?: string;+}) =>+ buildWorkflowRunCreatedBy({+ source: buildSource(startingApplicationId),+ workflowApplicationId,+ workspaceOwnedApplicationIds: [+ CUSTOM_APPLICATION_ID,+ STANDARD_APPLICATION_ID,+ ],+ });++describe('buildWorkflowRunCreatedBy', () => {+ it('binds a run of an installed application workflow to that application', () => {+ expect(+ build({ workflowApplicationId: INSTALLED_APPLICATION_ID }).context+ .applicationId,+ ).toBe(INSTALLED_APPLICATION_ID);+ });++ it('keeps the application that started its own workflow', () => {+ expect(+ build({+ workflowApplicationId: INSTALLED_APPLICATION_ID,+ startingApplicationId: INSTALLED_APPLICATION_ID,+ }).context.applicationId,+ ).toBe(INSTALLED_APPLICATION_ID);+ });++ it('binds a workspace workflow started by an application token to that application', () => {+ expect(+ build({+ workflowApplicationId: CUSTOM_APPLICATION_ID,+ startingApplicationId: INSTALLED_APPLICATION_ID,+ }).context.applicationId,+ ).toBe(INSTALLED_APPLICATION_ID);+ });++ it('leaves a workspace workflow started without an application unbound', () => {+ expect(+ build({ workflowApplicationId: STANDARD_APPLICATION_ID }).context+ .applicationId,+ ).toBeUndefined();+ });++ it('never binds a run to a workspace-owned application', () => {+ expect(+ build({+ workflowApplicationId: CUSTOM_APPLICATION_ID,+ startingApplicationId: STANDARD_APPLICATION_ID,+ }).context.applicationId,+ ).toBeUndefined();+ });+});diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/is-user-facing-workflow-executor-error.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/is-user-facing-workflow-executor-error.util.spec.tsindex dd63ec02d75..5fb877a6547 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/is-user-facing-workflow-executor-error.util.spec.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/is-user-facing-workflow-executor-error.util.spec.ts@@ -52,6 +52,7 @@ describe('isUserFacingWorkflowExecutorError', () => {WorkflowStepExecutorExceptionCode.INVALID_STEP_TYPE,WorkflowStepExecutorExceptionCode.INVALID_STEP_INPUT,WorkflowStepExecutorExceptionCode.STEP_NOT_FOUND,+ WorkflowStepExecutorExceptionCode.FORBIDDEN,])('returns true for user-facing workflow step executor code %s', (code) => {const error = new WorkflowStepExecutorException('User error', code);diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/resolve-workflow-run-application-or-throw.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/resolve-workflow-run-application-or-throw.util.spec.tsnew file mode 100644index 00000000000..5f29d07c705--- /dev/null+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/resolve-workflow-run-application-or-throw.util.spec.ts@@ -0,0 +1,71 @@+import { FieldActorSource } from 'twenty-shared/types';++import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';+import { resolveWorkflowRunApplicationOrThrow } from 'src/modules/workflow/workflow-executor/utils/resolve-workflow-run-application-or-throw.util';++type TestApplication = Pick<+ FlatApplication,+ 'id' | 'name' | 'deletedAt' | 'defaultRoleId'+>;++const INSTALLED_APPLICATION_ID = 'installed-app-id';++const INSTALLED_APPLICATION: TestApplication = {+ id: INSTALLED_APPLICATION_ID,+ name: 'Installed app',+ defaultRoleId: 'installed-app-role-id',+ deletedAt: null,+};++const resolve = ({+ applicationId,+ application = INSTALLED_APPLICATION,+}: {+ applicationId?: string;+ application?: TestApplication | null;+}) =>+ resolveWorkflowRunApplicationOrThrow({+ workflowRun: {+ createdBy: {+ source: FieldActorSource.MANUAL,+ workspaceMemberId: 'member-id',+ name: 'Tim Apple',+ context: { applicationId },+ },+ },+ applicationsById: application ? { [application.id]: application } : {},+ });++describe('resolveWorkflowRunApplicationOrThrow', () => {+ it('leaves a run that no application bounds unbound', () => {+ expect(resolve({})).toBeNull();+ });++ it('returns the application the run was bound to', () => {+ expect(resolve({ applicationId: INSTALLED_APPLICATION_ID })).toBe(+ INSTALLED_APPLICATION,+ );+ });++ it('refuses a run whose application is no longer installed', () => {+ expect(() =>+ resolve({ applicationId: INSTALLED_APPLICATION_ID, application: null }),+ ).toThrow('no longer installed');++ expect(() =>+ resolve({+ applicationId: INSTALLED_APPLICATION_ID,+ application: { ...INSTALLED_APPLICATION, deletedAt: new Date() },+ }),+ ).toThrow('no longer installed');+ });++ it('refuses a run whose application has no role rather than widening it', () => {+ expect(() =>+ resolve({+ applicationId: INSTALLED_APPLICATION_ID,+ application: { ...INSTALLED_APPLICATION, defaultRoleId: null },+ }),+ ).toThrow('has no role');+ });+});diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/assert-step-target-belongs-to-run-application.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/assert-step-target-belongs-to-run-application.util.tsnew file mode 100644index 00000000000..5c2c17c1447--- /dev/null+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/assert-step-target-belongs-to-run-application.util.ts@@ -0,0 +1,29 @@+import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';+import {+ WorkflowStepExecutorException,+ WorkflowStepExecutorExceptionCode,+} from 'src/modules/workflow/workflow-executor/exceptions/workflow-step-executor.exception';++export const assertStepTargetBelongsToRunApplication = ({+ application,+ targetApplicationId,+ workspaceOwnedApplicationIds,+ targetLabel,+}: {+ application: Pick<FlatApplication, 'id' | 'name'>;+ targetApplicationId: string;+ workspaceOwnedApplicationIds: string[];+ targetLabel: string;+}): void => {+ if (+ targetApplicationId === application.id ||+ workspaceOwnedApplicationIds.includes(targetApplicationId)+ ) {+ return;+ }++ throw new WorkflowStepExecutorException(+ `${targetLabel} belongs to another application than "${application.name}", so this run cannot use it`,+ WorkflowStepExecutorExceptionCode.FORBIDDEN,+ );+};diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/build-workflow-run-created-by.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/build-workflow-run-created-by.util.tsnew file mode 100644index 00000000000..f9db0f41df9--- /dev/null+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/build-workflow-run-created-by.util.ts@@ -0,0 +1,39 @@+import { type ActorMetadata } from 'twenty-shared/types';+import { isDefined } from 'twenty-shared/utils';++export const buildWorkflowRunCreatedBy = ({+ source,+ workflowApplicationId,+ workspaceOwnedApplicationIds,+}: {+ source: ActorMetadata;+ workflowApplicationId: string;+ workspaceOwnedApplicationIds: string[];+}): ActorMetadata => {+ const startingApplicationId = source.context?.applicationId;++ const isInstalledApplicationId = (+ applicationId: string | undefined,+ ): applicationId is string =>+ isDefined(applicationId) &&+ !workspaceOwnedApplicationIds.includes(applicationId);++ if (isInstalledApplicationId(workflowApplicationId)) {+ return {+ ...source,+ context: { ...source.context, applicationId: workflowApplicationId },+ };+ }++ if (+ !isDefined(startingApplicationId) ||+ isInstalledApplicationId(startingApplicationId)+ ) {+ return source;+ }++ return {+ ...source,+ context: { ...source.context, applicationId: undefined },+ };+};diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/is-user-facing-workflow-executor-error.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/is-user-facing-workflow-executor-error.util.tsindex cc115be2ae8..b5f8bc67a4d 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/is-user-facing-workflow-executor-error.util.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/is-user-facing-workflow-executor-error.util.ts@@ -16,6 +16,7 @@ const USER_FACING_STEP_EXECUTOR_EXCEPTION_CODES = [WorkflowStepExecutorExceptionCode.INVALID_STEP_TYPE,WorkflowStepExecutorExceptionCode.INVALID_STEP_INPUT,WorkflowStepExecutorExceptionCode.STEP_NOT_FOUND,+ WorkflowStepExecutorExceptionCode.FORBIDDEN,];// Author misconfigurations: no retry produces a model, and reporting them as system errors buries real ones.diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/resolve-workflow-run-application-or-throw.util.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/resolve-workflow-run-application-or-throw.util.tsnew file mode 100644index 00000000000..4a3be3346ae--- /dev/null+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/resolve-workflow-run-application-or-throw.util.ts@@ -0,0 +1,45 @@+import { isDefined } from 'twenty-shared/utils';++import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';+import { type WorkflowRunWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';+import {+ WorkflowStepExecutorException,+ WorkflowStepExecutorExceptionCode,+} from 'src/modules/workflow/workflow-executor/exceptions/workflow-step-executor.exception';++export const resolveWorkflowRunApplicationOrThrow = <+ TApplication extends Pick<+ FlatApplication,+ 'name' | 'deletedAt' | 'defaultRoleId'+ >,+>({+ workflowRun,+ applicationsById,+}: {+ workflowRun: Pick<WorkflowRunWorkspaceEntity, 'createdBy'>;+ applicationsById: Partial<Record<string, TApplication>>;+}): TApplication | null => {+ const applicationId = workflowRun.createdBy.context?.applicationId;++ if (!isDefined(applicationId)) {+ return null;+ }++ const application = applicationsById[applicationId];++ if (!isDefined(application) || isDefined(application.deletedAt)) {+ throw new WorkflowStepExecutorException(+ 'The application this run acts through is no longer installed',+ WorkflowStepExecutorExceptionCode.FORBIDDEN,+ );+ }++ if (!isDefined(application.defaultRoleId)) {+ throw new WorkflowStepExecutorException(+ `Application "${application.name}" has no role, so its workflow steps cannot run`,+ WorkflowStepExecutorExceptionCode.FORBIDDEN,+ );+ }++ return application;+};diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/ai-agent-action.module.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/ai-agent-action.module.tsindex 7132208e0ef..100612bea8d 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/ai-agent-action.module.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/ai-agent-action.module.ts@@ -8,7 +8,7 @@ import { AgentEntity } from 'src/engine/metadata-modules/ai/ai-agent/entities/agimport { RoleModule } from 'src/engine/metadata-modules/role/role.module';import { provideWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspace-scoped-repository/provide-workspace-scoped-repository';import { UserRoleModule } from 'src/engine/metadata-modules/user-role/user-role.module';-import { WorkflowExecutionContextService } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.service';+import { WorkflowExecutionContextModule } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.module';import { WorkflowAgentConversationModule } from 'src/modules/workflow/workflow-executor/workflow-actions/ai-agent/workflow-agent-conversation.module';import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflow-run/workflow-run.module';@@ -16,6 +16,7 @@ import { AiAgentWorkflowAction } from './ai-agent.workflow-action';@Module({imports: [+ WorkflowExecutionContextModule,ApplicationModule,AiAgentExecutionModule,TypeOrmModule.forFeature([AgentEntity]),@@ -26,7 +27,6 @@ import { AiAgentWorkflowAction } from './ai-agent.workflow-action';WorkflowAgentConversationModule,],providers: [- WorkflowExecutionContextService,AiAgentWorkflowAction,provideWorkspaceScopedRepository(AgentEntity),],diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/ai-agent.workflow-action.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/ai-agent.workflow-action.tsindex 121809ed74f..fc39bc45c9a 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/ai-agent.workflow-action.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/ai-agent.workflow-action.ts@@ -93,6 +93,19 @@ export class AiAgentWorkflowAction implements WorkflowAction {const executionContext =await this.workflowExecutionContextService.getExecutionContext(runInfo);+ const { application } = executionContext;++ if (isDefined(agent)) {+ await this.workflowExecutionContextService.assertStepTargetBelongsToRunApplicationOrThrow(+ {+ application,+ workspaceId,+ targetApplicationId: agent.applicationId,+ targetLabel: `Agent "${agent.name}"`,+ },+ );+ }+const userWorkspaceId =executionContext.authContext.type === 'user'? executionContext.authContext.userWorkspaceIddiff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/classify/classify-action.module.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/classify/classify-action.module.tsindex 6113cf0e56d..638e45169a5 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/classify/classify-action.module.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/classify/classify-action.module.ts@@ -5,12 +5,13 @@ import { UserWorkspaceModule } from 'src/engine/core-modules/user-workspace/userimport { AiEvaluationModule } from 'src/engine/metadata-modules/ai/ai-evaluation/ai-evaluation.module';import { RoleModule } from 'src/engine/metadata-modules/role/role.module';import { UserRoleModule } from 'src/engine/metadata-modules/user-role/user-role.module';-import { WorkflowExecutionContextService } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.service';+import { WorkflowExecutionContextModule } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.module';import { ClassifyWorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/classify/classify.workflow-action';import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflow-run/workflow-run.module';@Module({imports: [+ WorkflowExecutionContextModule,AiEvaluationModule,WorkflowRunModule,UserWorkspaceModule,@@ -18,7 +19,7 @@ import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflowRoleModule,ApplicationModule,],- providers: [WorkflowExecutionContextService, ClassifyWorkflowAction],+ providers: [ClassifyWorkflowAction],exports: [ClassifyWorkflowAction],})export class ClassifyActionModule {}diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/code/code-action.module.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/code/code-action.module.tsindex a163bc98be1..2e6272d2935 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/code/code-action.module.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/code/code-action.module.ts@@ -7,12 +7,13 @@ import { LogicFunctionModule as LogicFunctionMetadataModule } from 'src/engine/mimport { RoleModule } from 'src/engine/metadata-modules/role/role.module';import { UserRoleModule } from 'src/engine/metadata-modules/user-role/user-role.module';import { WorkflowCommonModule } from 'src/modules/workflow/common/workflow-common.module';-import { WorkflowExecutionContextService } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.service';+import { WorkflowExecutionContextModule } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.module';import { CodeWorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/code/code.workflow-action';import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflow-run/workflow-run.module';@Module({imports: [+ WorkflowExecutionContextModule,ApplicationModule,LogicFunctionModule,LogicFunctionMetadataModule,@@ -22,7 +23,7 @@ import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflowRoleModule,WorkflowCommonModule,],- providers: [WorkflowExecutionContextService, CodeWorkflowAction],+ providers: [CodeWorkflowAction],exports: [CodeWorkflowAction],})export class CodeActionModule {}diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/code/code.workflow-action.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/code/code.workflow-action.tsindex 2c058157ac1..cd49a9ca067 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/code/code.workflow-action.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/code/code.workflow-action.ts@@ -57,16 +57,26 @@ export class CodeWorkflowAction implements WorkflowAction {const { workspaceId } = runInfo;- await this.logicFunctionFromSourceHelperService.findLogicFunctionRunnableOnDemandOrThrow(+ const { flatLogicFunction } =+ await this.logicFunctionFromSourceHelperService.findLogicFunctionRunnableOnDemandOrThrow(+ {+ id: workflowActionInput.logicFunctionId,+ workspaceId,+ },+ );++ const { authContext, application } =+ await this.workflowExecutionContextService.getExecutionContext(runInfo);++ await this.workflowExecutionContextService.assertStepTargetBelongsToRunApplicationOrThrow({- id: workflowActionInput.logicFunctionId,+ application,workspaceId,+ targetApplicationId: flatLogicFunction.applicationId,+ targetLabel: `Logic function "${flatLogicFunction.name}"`,},);- const { authContext } =- await this.workflowExecutionContextService.getExecutionContext(runInfo);-const result = await this.logicFunctionExecutorService.execute({logicFunctionId: workflowActionInput.logicFunctionId,workspaceId,diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/logic-function/logic-function-action.module.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/logic-function/logic-function-action.module.tsindex e850e1d42f0..ceac364b77b 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/logic-function/logic-function-action.module.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/logic-function/logic-function-action.module.ts@@ -7,12 +7,13 @@ import { WorkspaceManyOrAllFlatEntityMapsCacheModule } from 'src/engine/metadataimport { RoleModule } from 'src/engine/metadata-modules/role/role.module';import { UserRoleModule } from 'src/engine/metadata-modules/user-role/user-role.module';import { WorkflowCommonModule } from 'src/modules/workflow/common/workflow-common.module';-import { WorkflowExecutionContextService } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.service';+import { WorkflowExecutionContextModule } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.module';import { LogicFunctionWorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/logic-function/logic-function.workflow-action';import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflow-run/workflow-run.module';@Module({imports: [+ WorkflowExecutionContextModule,ApplicationModule,LogicFunctionModule,WorkspaceManyOrAllFlatEntityMapsCacheModule,@@ -22,7 +23,7 @@ import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflowRoleModule,WorkflowCommonModule,],- providers: [WorkflowExecutionContextService, LogicFunctionWorkflowAction],+ providers: [LogicFunctionWorkflowAction],exports: [LogicFunctionWorkflowAction],})export class LogicFunctionActionModule {}diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/logic-function/logic-function.workflow-action.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/logic-function/logic-function.workflow-action.tsindex cfe2f614aee..3e9a09d34c6 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/logic-function/logic-function.workflow-action.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/logic-function/logic-function.workflow-action.ts@@ -79,9 +79,18 @@ export class LogicFunctionWorkflowAction implements WorkflowAction {);}- const { authContext } =+ const { authContext, application } =await this.workflowExecutionContextService.getExecutionContext(runInfo);+ await this.workflowExecutionContextService.assertStepTargetBelongsToRunApplicationOrThrow(+ {+ application,+ workspaceId,+ targetApplicationId: logicFunction.applicationId,+ targetLabel: `Logic function "${logicFunction.name}"`,+ },+ );+const result = await this.logicFunctionExecutorService.execute({logicFunctionId: workflowActionInput.logicFunctionId,workspaceId,diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/mail-sender-action.module.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/mail-sender-action.module.tsindex 78bd4fbb592..9ab597df78f 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/mail-sender-action.module.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/mail-sender/mail-sender-action.module.ts@@ -8,13 +8,14 @@ import { UserWorkspaceModule } from 'src/engine/core-modules/user-workspace/userimport { ConnectedAccountEntity } from 'src/engine/metadata-modules/connected-account/entities/connected-account.entity';import { RoleModule } from 'src/engine/metadata-modules/role/role.module';import { UserRoleModule } from 'src/engine/metadata-modules/user-role/user-role.module';-import { WorkflowExecutionContextService } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.service';+import { WorkflowExecutionContextModule } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.module';import { DraftEmailWorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/mail-sender/draft-email.workflow-action';import { SendEmailWorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/mail-sender/send-email.workflow-action';import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflow-run/workflow-run.module';@Module({imports: [+ WorkflowExecutionContextModule,ApplicationModule,RoleModule,ToolModule,@@ -23,11 +24,7 @@ import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflowWorkflowRunModule,TypeOrmModule.forFeature([ConnectedAccountEntity, UserWorkspaceEntity]),],- providers: [- WorkflowExecutionContextService,- SendEmailWorkflowAction,- DraftEmailWorkflowAction,- ],+ providers: [SendEmailWorkflowAction, DraftEmailWorkflowAction],exports: [SendEmailWorkflowAction, DraftEmailWorkflowAction],})export class MailSenderActionModule {}diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/record-crud/record-crud-action.module.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/record-crud/record-crud-action.module.tsindex 1571b707e6f..fcb99e18fb6 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/record-crud/record-crud-action.module.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/record-crud/record-crud-action.module.ts@@ -6,7 +6,7 @@ import { UserWorkspaceModule } from 'src/engine/core-modules/user-workspace/userimport { RoleModule } from 'src/engine/metadata-modules/role/role.module';import { UserRoleModule } from 'src/engine/metadata-modules/user-role/user-role.module';import { WorkflowCommonModule } from 'src/modules/workflow/common/workflow-common.module';-import { WorkflowExecutionContextService } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.service';+import { WorkflowExecutionContextModule } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.module';import { CreateRecordWorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/record-crud/create-record.workflow-action';import { DeleteRecordWorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/record-crud/delete-record.workflow-action';import { FindRecordsWorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/record-crud/find-records.workflow-action';@@ -17,6 +17,7 @@ import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflow@Module({imports: [+ WorkflowExecutionContextModule,ApplicationModule,RecordCrudModule,WorkflowRunModule,@@ -26,7 +27,6 @@ import { WorkflowRunModule } from 'src/modules/workflow/workflow-runner/workflowWorkflowCommonModule,],providers: [- WorkflowExecutionContextService,CreateRecordWorkflowAction,UpsertRecordWorkflowAction,UpdateRecordWorkflowAction,diff --git a/packages/twenty-server/src/modules/workflow/workflow-runner/services/core-workflow-runner.service.ts b/packages/twenty-server/src/modules/workflow/workflow-runner/services/core-workflow-runner.service.tsindex 738911fd71e..1dad6407f41 100644--- a/packages/twenty-server/src/modules/workflow/workflow-runner/services/core-workflow-runner.service.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-runner/services/core-workflow-runner.service.ts@@ -3,6 +3,7 @@ import { Injectable, Logger } from '@nestjs/common';import { type ActorMetadata } from 'twenty-shared/types';import { isDefined } from 'twenty-shared/utils';+import { ApplicationService } from 'src/engine/core-modules/application/application.service';import { BillingUsageService } from 'src/engine/core-modules/billing/services/billing-usage.service';import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';@@ -12,6 +13,7 @@ import { MetricsKeys } from 'src/engine/core-modules/metrics/types/metrics-keys.import { WorkflowCoreSyncService } from 'src/engine/core-modules/workflow/services/workflow-core-sync.service';import { WorkflowVersionCoreSyncService } from 'src/engine/core-modules/workflow/services/workflow-version-core-sync.service';import { WorkflowRunStatus } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';+import { buildWorkflowRunCreatedBy } from 'src/modules/workflow/workflow-executor/utils/build-workflow-run-created-by.util';import {WorkflowRunException,WorkflowRunExceptionCode,@@ -38,6 +40,7 @@ export class CoreWorkflowRunnerService {private readonly billingUsageService: BillingUsageService,private readonly workflowThrottlingWorkspaceService: WorkflowThrottlingWorkspaceService,private readonly metricsService: MetricsService,+ private readonly applicationService: ApplicationService,@InjectMessageQueue(MessageQueue.workflowQueue)private readonly messageQueueService: MessageQueueService,) {}@@ -116,6 +119,18 @@ export class CoreWorkflowRunnerService {: isManualTrigger? WorkflowRunStatus.ENQUEUED: WorkflowRunStatus.NOT_STARTED;+ const { workspaceCustomFlatApplication, twentyStandardFlatApplication } =+ await this.applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow(+ { workspaceId },+ );+ const createdBy = buildWorkflowRunCreatedBy({+ source,+ workflowApplicationId: workflow.applicationId,+ workspaceOwnedApplicationIds: [+ workspaceCustomFlatApplication.id,+ twentyStandardFlatApplication.id,+ ],+ });const createdWorkflowRunId =await this.workflowRunWorkspaceService.createCoreWorkflowRun({coreWorkflowId: workflow.id,@@ -125,7 +140,7 @@ export class CoreWorkflowRunnerService {workflowName: workflow.name,trigger: workflowVersion.triggers[0],steps: workflowVersion.steps,- createdBy: source,+ createdBy,workflowRunId,status,triggerPayload: payload,diff --git a/packages/twenty-server/src/modules/workflow/workflow-runner/utils/__tests__/can-update-workflow-run-step.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-runner/utils/__tests__/can-update-workflow-run-step.util.spec.tsnew file mode 100644index 00000000000..e73dbe1a33a--- /dev/null+++ b/packages/twenty-server/src/modules/workflow/workflow-runner/utils/__tests__/can-update-workflow-run-step.util.spec.ts@@ -0,0 +1,146 @@+import { FieldMetadataType } from 'twenty-shared/types';+import { WorkflowActionType } from 'twenty-shared/workflow';++import {+ type WorkflowAction,+ type WorkflowCodeAction,+ type WorkflowCreateRecordAction,+ type WorkflowDeleteRecordAction,+ type WorkflowFormAction,+} from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';+import { canUpdateWorkflowRunStep } from 'src/modules/workflow/workflow-runner/utils/can-update-workflow-run-step.util';++const ERROR_HANDLING_OPTIONS = {+ retryOnFailure: { value: 0 },+ continueOnFailure: { value: false },+};++const FORM_STEP: WorkflowFormAction = {+ id: 'form-step',+ name: 'Ask',+ type: WorkflowActionType.FORM,+ valid: true,+ nextStepIds: ['record-step'],+ settings: {+ input: [+ {+ id: 'field',+ name: 'name',+ label: 'Name',+ type: FieldMetadataType.TEXT,+ },+ ],+ outputSchema: {},+ errorHandlingOptions: ERROR_HANDLING_OPTIONS,+ },+};++const RECORD_STEP: WorkflowCreateRecordAction = {+ id: 'record-step',+ name: 'Create company',+ type: WorkflowActionType.CREATE_RECORD,+ valid: true,+ nextStepIds: [],+ settings: {+ input: { objectName: 'company', objectRecord: {} },+ outputSchema: {},+ errorHandlingOptions: ERROR_HANDLING_OPTIONS,+ },+};++const buildWorkflowRun = (applicationId?: string) => ({+ createdBy: { context: { applicationId } },+ state: { flow: { steps: [FORM_STEP, RECORD_STEP] } },+});++describe('canUpdateWorkflowRunStep', () => {+ it('keeps the steps of a run no application bounds editable', () => {+ const deleteStep: WorkflowDeleteRecordAction = {+ ...RECORD_STEP,+ type: WorkflowActionType.DELETE_RECORD,+ settings: {+ ...RECORD_STEP.settings,+ input: { objectName: 'company', objectRecordId: 'company-id' },+ },+ };++ expect(+ canUpdateWorkflowRunStep({+ workflowRun: buildWorkflowRun(),+ step: deleteStep,+ }),+ ).toBe(true);+ });++ it('lets the values of a form step of an application-bound run be filled', () => {+ expect(+ canUpdateWorkflowRunStep({+ workflowRun: buildWorkflowRun('installed-app-id'),+ step: {+ ...FORM_STEP,+ settings: {+ ...FORM_STEP.settings,+ input: [{ ...FORM_STEP.settings.input[0], value: 'Acme' }],+ },+ },+ }),+ ).toBe(true);+ });++ it('refuses a change to the fields of a form step of an application-bound run', () => {+ const textFieldTurnedIntoRecordPicker: WorkflowFormAction = {+ ...FORM_STEP,+ settings: {+ ...FORM_STEP.settings,+ input: [+ {+ ...FORM_STEP.settings.input[0],+ type: 'RECORD',+ settings: { objectName: 'opportunity' },+ value: { id: 'opportunity-id' },+ },+ ],+ },+ };++ expect(+ canUpdateWorkflowRunStep({+ workflowRun: buildWorkflowRun('installed-app-id'),+ step: textFieldTurnedIntoRecordPicker,+ }),+ ).toBe(false);+ });++ const codeStepReplacingForm: WorkflowCodeAction = {+ ...FORM_STEP,+ type: WorkflowActionType.CODE,+ settings: {+ ...FORM_STEP.settings,+ input: { logicFunctionId: 'function-id', logicFunctionInput: {} },+ },+ };+ const formStepReplacingRecord: WorkflowFormAction = {+ ...FORM_STEP,+ id: RECORD_STEP.id,+ };+ const reroutedFormStep: WorkflowFormAction = {+ ...FORM_STEP,+ nextStepIds: [],+ };++ it.each<{ change: string; step: WorkflowAction }>([+ { change: 'a code step replacing the form', step: codeStepReplacingForm },+ {+ change: 'a form step taking over another step id',+ step: formStepReplacingRecord,+ },+ { change: 'a rerouted form step', step: reroutedFormStep },+ ])('refuses $change on an application-bound run', ({ step }) => {+ expect(+ canUpdateWorkflowRunStep({+ workflowRun: buildWorkflowRun('installed-app-id'),+ step,+ }),+ ).toBe(false);+ });+});diff --git a/packages/twenty-server/src/modules/workflow/workflow-runner/utils/can-update-workflow-run-step.util.ts b/packages/twenty-server/src/modules/workflow/workflow-runner/utils/can-update-workflow-run-step.util.tsnew file mode 100644index 00000000000..79ad91db75d--- /dev/null+++ b/packages/twenty-server/src/modules/workflow/workflow-runner/utils/can-update-workflow-run-step.util.ts@@ -0,0 +1,46 @@+import isEqual from 'lodash.isequal';+import { type ActorMetadata } from 'twenty-shared/types';+import { isDefined } from 'twenty-shared/utils';+import { WorkflowActionType } from 'twenty-shared/workflow';++import {+ type WorkflowAction,+ type WorkflowFormAction,+} from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';++export const canUpdateWorkflowRunStep = ({+ workflowRun,+ step,+}: {+ workflowRun: {+ createdBy: Pick<ActorMetadata, 'context'>;+ state: { flow?: { steps?: WorkflowAction[] } } | null;+ };+ step: WorkflowAction;+}): boolean => {+ if (!isDefined(workflowRun.createdBy.context?.applicationId)) {+ return true;+ }++ const existingStep = workflowRun.state?.flow?.steps?.find(+ ({ id }) => id === step.id,+ );++ if (+ existingStep?.type !== WorkflowActionType.FORM ||+ step.type !== WorkflowActionType.FORM ||+ !Array.isArray(step.settings?.input)+ ) {+ return false;+ }++ return isEqual(withoutFormValues(existingStep), withoutFormValues(step));+};++const withoutFormValues = (step: WorkflowFormAction) => ({+ ...step,+ settings: {+ ...step.settings,+ input: step.settings.input.map((field) => ({ ...field, value: undefined })),+ },+});diff --git a/packages/twenty-server/src/modules/workflow/workflow-runner/workflow-runner.module.ts b/packages/twenty-server/src/modules/workflow/workflow-runner/workflow-runner.module.tsindex 1a80e5b9aa9..7587fc75c30 100644--- a/packages/twenty-server/src/modules/workflow/workflow-runner/workflow-runner.module.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-runner/workflow-runner.module.ts@@ -1,5 +1,6 @@import { Module } from '@nestjs/common';+import { ApplicationModule } from 'src/engine/core-modules/application/application.module';import { BillingModule } from 'src/engine/core-modules/billing/billing.module';import { MetricsModule } from 'src/engine/core-modules/metrics/metrics.module';import { WorkflowCommonModule } from 'src/modules/workflow/common/workflow-common.module';@@ -13,9 +14,11 @@ import { WorkflowRunnerWorkspaceService } from 'src/modules/workflow/workflow-ruimport { CoreWorkflowRunnerService } from 'src/modules/workflow/workflow-runner/services/core-workflow-runner.service';import { WorkflowCoreModule } from 'src/engine/core-modules/workflow/workflow-core.module';import { WorkflowVersionCoreModule } from 'src/engine/core-modules/workflow/workflow-version-core.module';+import { WorkflowExecutionContextModule } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.module';@Module({imports: [+ ApplicationModule,WorkflowCommonModule,WorkflowExecutorModule,BillingModule,@@ -26,6 +29,7 @@ import { WorkflowVersionCoreModule } from 'src/engine/core-modules/workflow/workCodeStepBuildModule,WorkflowCoreModule,WorkflowVersionCoreModule,+ WorkflowExecutionContextModule,],providers: [WorkflowRunnerWorkspaceService,diff --git a/packages/twenty-server/src/modules/workflow/workflow-runner/workspace-services/workflow-runner.workspace-service.ts b/packages/twenty-server/src/modules/workflow/workflow-runner/workspace-services/workflow-runner.workspace-service.tsindex 448b8317b90..6f6127a61c4 100644--- a/packages/twenty-server/src/modules/workflow/workflow-runner/workspace-services/workflow-runner.workspace-service.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-runner/workspace-services/workflow-runner.workspace-service.ts@@ -3,14 +3,25 @@ import { Injectable } from '@nestjs/common';import { type ActorMetadata } from 'twenty-shared/types';import { isDefined } from 'twenty-shared/utils';import { StepStatus } from 'twenty-shared/workflow';+import { msg } from '@lingui/core/macro';import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';import { WorkflowRunStatus } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';import { workflowHasRunningSteps } from 'src/modules/workflow/common/utils/workflow-has-running-steps.util';+import {+ WorkflowVersionStepException,+ WorkflowVersionStepExceptionCode,+} from 'src/modules/workflow/common/exceptions/workflow-version-step.exception';import { WorkflowVersionStepOperationsWorkspaceService } from 'src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service';-import { type WorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';+import { WorkflowStepExecutorException } from 'src/modules/workflow/workflow-executor/exceptions/workflow-step-executor.exception';+import { WorkflowExecutionContextService } from 'src/modules/workflow/workflow-executor/services/workflow-execution-context.service';+import { type WorkflowExecutionContext } from 'src/modules/workflow/workflow-executor/types/workflow-execution-context.type';+import {+ type WorkflowFormAction,+ type WorkflowAction,+} from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';import { isWorkflowFormAction } from 'src/modules/workflow/workflow-executor/workflow-actions/form/guards/is-workflow-form-action.guard';import {WorkflowRunException,@@ -36,6 +47,7 @@ export class WorkflowRunnerWorkspaceService {private readonly workflowThrottlingWorkspaceService: WorkflowThrottlingWorkspaceService,private readonly coreWorkflowRunnerService: CoreWorkflowRunnerService,private readonly workflowVersionCoreSyncService: WorkflowVersionCoreSyncService,+ private readonly workflowExecutionContextService: WorkflowExecutionContextService,) {}async run({@@ -127,6 +139,11 @@ export class WorkflowRunnerWorkspaceService {workspaceId,step,response,+ recordReadContext: await this.findFormRecordReadContext({+ workspaceId,+ workflowRunId,+ step,+ }),},);@@ -151,6 +168,45 @@ export class WorkflowRunnerWorkspaceService {}}+ private async findFormRecordReadContext({+ workspaceId,+ workflowRunId,+ step,+ }: {+ workspaceId: string;+ workflowRunId: string;+ step: WorkflowFormAction;+ }): Promise<WorkflowExecutionContext | undefined> {+ if (!step.settings.input.some((field) => field.type === 'RECORD')) {+ return undefined;+ }++ const workflowRun =+ await this.workflowRunWorkspaceService.getWorkflowRunOrFail({+ workflowRunId,+ workspaceId,+ });++ const applicationBoundExecutionContext =+ await this.workflowExecutionContextService+ .getApplicationBoundExecutionContext({ workflowRun, workspaceId })+ .catch((error: unknown) => {+ if (error instanceof WorkflowStepExecutorException) {+ throw new WorkflowVersionStepException(+ error.message,+ WorkflowVersionStepExceptionCode.INVALID_REQUEST,+ {+ userFriendlyMessage: msg`The permissions of this run no longer allow submitting this form.`,+ },+ );+ }++ throw error;+ });++ return applicationBoundExecutionContext ?? undefined;+ }+async stopWorkflowRun(workspaceId: string, workflowRunId: string) {const workflowRun =await this.workflowRunWorkspaceService.getWorkflowRunOrFail({diff --git a/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/__tests__/build-workflow-run-trigger-context.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/__tests__/build-workflow-run-trigger-context.util.spec.tsnew file mode 100644index 00000000000..07a76985fc0--- /dev/null+++ b/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/__tests__/build-workflow-run-trigger-context.util.spec.ts@@ -0,0 +1,36 @@+import { FieldActorSource } from 'twenty-shared/types';++import { buildWorkflowRunTriggerContext } from 'src/modules/workflow/workflow-trigger/utils/build-workflow-run-trigger-context.util';++const WORKSPACE_MEMBER = {+ id: 'member-id',+ name: { firstName: 'Jane', lastName: 'Austen' },+};++describe('buildWorkflowRunTriggerContext', () => {+ it('records a member who starts a run directly', () => {+ expect(+ buildWorkflowRunTriggerContext({ workspaceMember: WORKSPACE_MEMBER })+ .createdBy,+ ).toEqual({+ source: FieldActorSource.MANUAL,+ workspaceMemberId: 'member-id',+ name: 'Jane Austen',+ context: {},+ });+ });++ it('records the application a member starts a run through', () => {+ expect(+ buildWorkflowRunTriggerContext({+ workspaceMember: WORKSPACE_MEMBER,+ startingApplicationId: 'installed-app-id',+ }).createdBy,+ ).toEqual({+ source: FieldActorSource.MANUAL,+ workspaceMemberId: 'member-id',+ name: 'Jane Austen',+ context: { applicationId: 'installed-app-id' },+ });+ });+});diff --git a/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/build-workflow-run-trigger-context.util.ts b/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/build-workflow-run-trigger-context.util.tsindex e796e691dd3..142c45a66ba 100644--- a/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/build-workflow-run-trigger-context.util.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-trigger/utils/build-workflow-run-trigger-context.util.ts@@ -1,3 +1,4 @@+import { isDefined } from 'twenty-shared/utils';import {WORKFLOW_TRIGGER_METADATA_KEY,WORKFLOW_TRIGGER_METADATA_WORKSPACE_MEMBER_ID_KEY,@@ -10,9 +11,11 @@ import { type WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-membeexport const buildWorkflowRunTriggerContext = ({workspaceMember,payload,+ startingApplicationId,}: {workspaceMember: Pick<WorkspaceMemberWorkspaceEntity, 'id' | 'name'>;payload?: object | null;+ startingApplicationId?: string;}) => ({payload: {...payload,@@ -21,11 +24,16 @@ export const buildWorkflowRunTriggerContext = ({[WORKFLOW_TRIGGER_METADATA_WORKSPACE_MEMBER_ID_KEY]: workspaceMember.id,},},- createdBy: buildCreatedByFromFullNameMetadata({- fullNameMetadata: {- firstName: workspaceMember.name.firstName,- lastName: workspaceMember.name.lastName,- },- workspaceMemberId: workspaceMember.id,- }),+ createdBy: {+ ...buildCreatedByFromFullNameMetadata({+ fullNameMetadata: {+ firstName: workspaceMember.name.firstName,+ lastName: workspaceMember.name.lastName,+ },+ workspaceMemberId: workspaceMember.id,+ }),+ ...(isDefined(startingApplicationId)+ ? { context: { applicationId: startingApplicationId } }+ : {}),+ },});diff --git a/packages/twenty-server/test/integration/graphql/suites/workflow/application-workflow-execution-permissions.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/workflow/application-workflow-execution-permissions.integration-spec.tsnew file mode 100644index 00000000000..e282dd30498--- /dev/null+++ b/packages/twenty-server/test/integration/graphql/suites/workflow/application-workflow-execution-permissions.integration-spec.ts@@ -0,0 +1,674 @@+import { randomUUID } from 'node:crypto';++import request from 'supertest';+import { answerToolCall } from 'test/integration/graphql/suites/workflow/utils/answer-tool-call.util';+import { runWorkflowActionStep } from 'test/integration/graphql/suites/workflow/utils/run-workflow-action-step.util';+import { workflowGraphqlRequest } from 'test/integration/graphql/suites/workflow/utils/workflow-graphql-request.util';+import { buildBaseManifest } from 'test/integration/metadata/suites/application/utils/build-base-manifest.util';+import { cleanupApplicationAndAppRegistration } from 'test/integration/metadata/suites/application/utils/cleanup-application-and-app-registration.util';+import { setupApplicationForSync } from 'test/integration/metadata/suites/application/utils/setup-application-for-sync.util';+import { syncApplication } from 'test/integration/metadata/suites/application/utils/sync-application.util';+import { updateFeatureFlag } from 'test/integration/metadata/suites/utils/update-feature-flag.util';+import { generateApplicationTokenPair } from 'test/integration/utils/generate-application-token-pair.util';+import { getAppProviderByClassName } from 'test/integration/utils/get-app-provider-by-class-name.util';+import {+ getWorkflowVersionUniversalIdentifier,+ type Manifest,+} from 'twenty-shared/application';+import { SystemPermissionFlag } from 'twenty-shared/constants';+import { STANDARD_OBJECTS } from 'twenty-shared/metadata';+import { FeatureFlagKey } from 'twenty-shared/types';++import { type LogicFunctionExecutorService } from 'src/engine/core-modules/logic-function/logic-function-executor/logic-function-executor.service';+import { LogicFunctionExecutionStatus } from 'src/engine/metadata-modules/logic-function/dtos/logic-function-execution-result.dto';+import { getWorkspaceSchemaName } from 'src/engine/workspace-datasource/utils/get-workspace-schema-name.util';+import { USER_WORKSPACE_DATA_SEED_IDS } from 'src/engine/workspace-manager/dev-seeder/core/utils/seed-user-workspaces.util';+import { USER_DATA_SEED_IDS } from 'src/engine/workspace-manager/dev-seeder/core/utils/seed-users.util';+import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';++const SCHEMA = getWorkspaceSchemaName(SEED_APPLE_WORKSPACE_ID);+const RUN_PREFIX = `App workflow permissions ${randomUUID()}`;++const APP_ID = randomUUID();+const ROLE_ID = randomUUID();+const COMPANY_PERMISSION_ID = randomUUID();+const FUNCTION_ID = randomUUID();+const OTHER_APP_ID = randomUUID();+const OTHER_ROLE_ID = randomUUID();++const COMPANY_NAME = `${RUN_PREFIX} company`;+const DELAYED_COMPANY_NAME = `${RUN_PREFIX} delayed company`;+const OPPORTUNITY_NAME = `${RUN_PREFIX} opportunity`;+const WORKSPACE_OPPORTUNITY_NAME = `${RUN_PREFIX} workspace opportunity`;+const NESTED_OPPORTUNITY_NAME = `${RUN_PREFIX} nested opportunity`;++type WorkflowStepManifest = NonNullable<+ Manifest['workflows']+>[number]['version']['steps'][number];++type WithoutEdges<TStep> = TStep extends unknown+ ? Omit<TStep, 'universalIdentifier' | 'nextStepIds'>+ : never;++type WorkflowStepManifestWithoutEdges = WithoutEdges<WorkflowStepManifest>;++type TestWorkflow = {+ universalIdentifier: string;+ steps: WorkflowStepManifest[];+};++const buildTestWorkflow = (+ steps: WorkflowStepManifestWithoutEdges[],+): TestWorkflow => {+ const stepIds = steps.map(() => randomUUID());++ return {+ universalIdentifier: randomUUID(),+ steps: steps.map(+ (step, index) =>+ ({+ ...step,+ universalIdentifier: stepIds[index],+ nextStepIds: index + 1 < stepIds.length ? [stepIds[index + 1]] : [],+ }) as WorkflowStepManifest,+ ),+ };+};++const CREATE_COMPANY_WORKFLOW = buildTestWorkflow([+ {+ name: 'Create company',+ type: 'CREATE_RECORD',+ input: {+ objectUniversalIdentifier: STANDARD_OBJECTS.company.universalIdentifier,+ objectRecord: { name: COMPANY_NAME },+ },+ } as WorkflowStepManifestWithoutEdges,+]);++const CREATE_OPPORTUNITY_WORKFLOW = buildTestWorkflow([+ {+ name: 'Create opportunity',+ type: 'CREATE_RECORD',+ input: {+ objectUniversalIdentifier:+ STANDARD_OBJECTS.opportunity.universalIdentifier,+ objectRecord: { name: OPPORTUNITY_NAME },+ },+ } as WorkflowStepManifestWithoutEdges,+]);++const LOGIC_FUNCTION_WORKFLOW = buildTestWorkflow([+ {+ name: 'Call the application function',+ type: 'LOGIC_FUNCTION',+ logicFunctionUniversalIdentifier: FUNCTION_ID,+ input: { greeting: 'Hello' },+ } as WorkflowStepManifestWithoutEdges,+]);++const DELAYED_CREATE_COMPANY_WORKFLOW = buildTestWorkflow([+ {+ name: 'Wait',+ type: 'DELAY',+ input: { delayType: 'DURATION', duration: { seconds: 10 } },+ } as WorkflowStepManifestWithoutEdges,+ {+ name: 'Create company after the delay',+ type: 'CREATE_RECORD',+ input: {+ objectUniversalIdentifier: STANDARD_OBJECTS.company.universalIdentifier,+ objectRecord: { name: DELAYED_COMPANY_NAME },+ },+ } as WorkflowStepManifestWithoutEdges,+]);++const FORM_WORKFLOW = buildTestWorkflow([+ {+ name: 'Pick records',+ type: 'FORM',+ input: [+ {+ id: randomUUID(),+ name: 'company',+ label: 'Company',+ type: 'RECORD',+ settings: {+ objectUniversalIdentifier:+ STANDARD_OBJECTS.company.universalIdentifier,+ },+ },+ {+ id: randomUUID(),+ name: 'opportunity',+ label: 'Opportunity',+ type: 'RECORD',+ settings: {+ objectUniversalIdentifier:+ STANDARD_OBJECTS.opportunity.universalIdentifier,+ },+ },+ ],+ } as WorkflowStepManifestWithoutEdges,+]);++const TEST_WORKFLOWS = [+ CREATE_COMPANY_WORKFLOW,+ CREATE_OPPORTUNITY_WORKFLOW,+ LOGIC_FUNCTION_WORKFLOW,+ DELAYED_CREATE_COMPANY_WORKFLOW,+ FORM_WORKFLOW,+];++const buildManifest = ({+ canManageCompanies,+}: {+ canManageCompanies: boolean;+}): Manifest =>+ buildBaseManifest({+ appId: APP_ID,+ roleId: ROLE_ID,+ overrides: {+ roles: [+ {+ universalIdentifier: ROLE_ID,+ label: 'Application workflow role',+ description: 'Role the application workflows run with',+ canUpdateAllSettings: false,+ canReadAllObjectRecords: false,+ canUpdateAllObjectRecords: false,+ canSoftDeleteAllObjectRecords: false,+ canDestroyAllObjectRecords: false,+ objectPermissions: canManageCompanies+ ? [+ {+ universalIdentifier: COMPANY_PERMISSION_ID,+ objectUniversalIdentifier:+ STANDARD_OBJECTS.company.universalIdentifier,+ canReadObjectRecords: true,+ canUpdateObjectRecords: true,+ },+ ]+ : [],+ permissionFlagUniversalIdentifiers: [SystemPermissionFlag.WORKFLOWS],+ },+ ],+ logicFunctions: [+ {+ universalIdentifier: FUNCTION_ID,+ name: 'Application workflow permissions function',+ sourceHandlerPath: 'greet.ts',+ builtHandlerPath: 'greet.mjs',+ builtHandlerChecksum: '',+ handlerName: 'handler',+ workflowActionTriggerSettings: {+ label: 'Greet',+ icon: 'IconHandStop',+ },+ },+ ],+ workflows: TEST_WORKFLOWS.map((workflow, index) => ({+ universalIdentifier: workflow.universalIdentifier,+ name: `${RUN_PREFIX} ${index}`,+ version: {+ trigger: {+ universalIdentifier: randomUUID(),+ type: 'MANUAL',+ nextStepIds: [workflow.steps[0].universalIdentifier],+ },+ steps: workflow.steps,+ },+ })),+ },+ });++const OTHER_APPLICATION_MANIFEST = buildBaseManifest({+ appId: OTHER_APP_ID,+ roleId: OTHER_ROLE_ID,+ overrides: {+ roles: [+ {+ universalIdentifier: OTHER_ROLE_ID,+ label: 'Other application role',+ description: 'Role of an application that owns no workflow',+ canUpdateAllSettings: false,+ canReadAllObjectRecords: true,+ canUpdateAllObjectRecords: true,+ permissionFlagUniversalIdentifiers: [SystemPermissionFlag.WORKFLOWS],+ },+ ],+ },+});++const RUN_CORE_WORKFLOW_VERSION = `+ mutation RunCoreWorkflowVersion($input: RunCoreWorkflowVersionInput!) {+ runCoreWorkflowVersion(input: $input) {+ workflowRunId+ }+ }+`;++const UPDATE_WORKFLOW_RUN_STEP = `+ mutation UpdateWorkflowRunStep($input: UpdateWorkflowRunStepInput!) {+ updateWorkflowRunStep(input: $input) {+ id+ }+ }+`;++const graphqlAs = (token: string, query: string, variables?: object) =>+ request(`http://localhost:${APP_PORT}`)+ .post('/graphql')+ .set('Authorization', `Bearer ${token}`)+ .send({ query, variables });++const buildJaneTokenThroughApplication = async (+ applicationUniversalIdentifier: string,+): Promise<string> => {+ const [{ id: applicationId }] = await globalThis.testDataSource.query(+ `SELECT id FROM core.application WHERE "universalIdentifier" = $1 AND "workspaceId" = $2`,+ [applicationUniversalIdentifier, SEED_APPLE_WORKSPACE_ID],+ );+ const { applicationAccessToken } = await generateApplicationTokenPair({+ workspaceId: SEED_APPLE_WORKSPACE_ID,+ applicationId,+ userId: USER_DATA_SEED_IDS.JANE,+ userWorkspaceId: USER_WORKSPACE_DATA_SEED_IDS.JANE,+ });++ return applicationAccessToken.token;+};++const findVersionId = async (workflow: TestWorkflow): Promise<string> => {+ const [version] = await globalThis.testDataSource.query(+ `SELECT id FROM core."workflowVersion"+ WHERE "workspaceId" = $1 AND "universalIdentifier" = $2`,+ [+ SEED_APPLE_WORKSPACE_ID,+ getWorkflowVersionUniversalIdentifier({+ applicationUniversalIdentifier: APP_ID,+ workflowUniversalIdentifier: workflow.universalIdentifier,+ }),+ ],+ );++ return version.id;+};++const runWorkflow = async (workflow: TestWorkflow): Promise<string> => {+ const response = await workflowGraphqlRequest(RUN_CORE_WORKFLOW_VERSION, {+ input: { coreWorkflowVersionId: await findVersionId(workflow) },+ });++ expect(response.body.errors).toBeUndefined();++ return response.body.data.runCoreWorkflowVersion.workflowRunId;+};++type TestWorkflowRun = {+ status: string;+ state: {+ flow?: {+ steps: {+ id: string;+ name: string;+ settings: { input: Record<string, unknown>[] };+ }[];+ };+ stepInfos: Record<+ string,+ { status: string; error?: string; result?: Record<string, unknown> }+ >;+ };+};++const findRun = async (workflowRunId: string): Promise<TestWorkflowRun> => {+ const [workflowRun] = await globalThis.testDataSource.query(+ `SELECT status, state FROM "${SCHEMA}"."workflowRun" WHERE id = $1`,+ [workflowRunId],+ );++ return workflowRun;+};++const waitForRun = async (+ workflowRunId: string,+ isDone: (workflowRun: TestWorkflowRun) => boolean,+): Promise<TestWorkflowRun> => {+ for (let attempt = 0; attempt < 600; attempt++) {+ const workflowRun = await findRun(workflowRunId);++ if (isDone(workflowRun)) {+ return workflowRun;+ }++ await new Promise((resolve) => setTimeout(resolve, 100));+ }++ return findRun(workflowRunId);+};++const waitForRunToEnd = (workflowRunId: string) =>+ waitForRun(workflowRunId, ({ status }) =>+ ['COMPLETED', 'FAILED', 'STOPPED'].includes(status),+ );++const countRecordsByName = async (+ objectTable: 'company' | 'opportunity',+ name: string,+): Promise<number> => {+ const [{ count }] = await globalThis.testDataSource.query(+ `SELECT COUNT(*)::int AS count FROM "${SCHEMA}"."${objectTable}"+ WHERE name = $1 AND "deletedAt" IS NULL`,+ [name],+ );++ return count;+};++describe('application workflow execution permissions', () => {+ beforeAll(async () => {+ await updateFeatureFlag({+ featureFlag: FeatureFlagKey.IS_APPLICATION_WORKFLOWS_ENABLED,+ value: true,+ expectToFail: false,+ });++ await setupApplicationForSync({+ applicationUniversalIdentifier: APP_ID,+ name: 'Application workflow permissions',+ description: 'Application whose workflows run with its role',+ sourcePath: 'application-workflow-permissions',+ });+ await setupApplicationForSync({+ applicationUniversalIdentifier: OTHER_APP_ID,+ name: 'Other application',+ description: 'Application that tries to start another one workflows',+ sourcePath: 'application-workflow-permissions-other',+ });+ jest.useRealTimers();++ const installation = await syncApplication({+ manifest: buildManifest({ canManageCompanies: true }),+ });++ expect(installation.errors).toBeUndefined();++ const otherInstallation = await syncApplication({+ manifest: OTHER_APPLICATION_MANIFEST,+ });++ expect(otherInstallation.errors).toBeUndefined();+ }, 120000);++ afterAll(async () => {+ await globalThis.testDataSource.query(+ `DELETE FROM "${SCHEMA}"."workflowRun" WHERE "coreWorkflowId" IN (+ SELECT id FROM core.workflow+ WHERE "workspaceId" = $1 AND "universalIdentifier" = ANY($2)+ )`,+ [+ SEED_APPLE_WORKSPACE_ID,+ TEST_WORKFLOWS.map(({ universalIdentifier }) => universalIdentifier),+ ],+ );+ await globalThis.testDataSource.query(+ `DELETE FROM "${SCHEMA}"."company" WHERE name LIKE $1`,+ [`${RUN_PREFIX}%`],+ );+ await globalThis.testDataSource.query(+ `DELETE FROM "${SCHEMA}"."opportunity" WHERE name LIKE $1`,+ [`${RUN_PREFIX}%`],+ );+ await cleanupApplicationAndAppRegistration({+ applicationUniversalIdentifier: APP_ID,+ });+ await cleanupApplicationAndAppRegistration({+ applicationUniversalIdentifier: OTHER_APP_ID,+ });+ await updateFeatureFlag({+ featureFlag: FeatureFlagKey.IS_APPLICATION_WORKFLOWS_ENABLED,+ value: false,+ expectToFail: false,+ });+ });++ it('runs a record step the application role allows', async () => {+ const workflowRun = await waitForRunToEnd(+ await runWorkflow(CREATE_COMPANY_WORKFLOW),+ );++ expect(workflowRun.status).toBe('COMPLETED');+ expect(await countRecordsByName('company', COMPANY_NAME)).toBe(1);+ }, 120000);++ it('refuses a record step the application role does not allow, even for an admin', async () => {+ const workflowRun = await waitForRunToEnd(+ await runWorkflow(CREATE_OPPORTUNITY_WORKFLOW),+ );+ const [createStep] = CREATE_OPPORTUNITY_WORKFLOW.steps;++ expect(workflowRun.status).toBe('FAILED');+ expect(+ workflowRun.state.stepInfos[createStep.universalIdentifier].status,+ ).toBe('FAILED');+ expect(await countRecordsByName('opportunity', OPPORTUNITY_NAME)).toBe(0);+ }, 120000);++ it('keeps running workspace workflows with the permissions of the member who started them', async () => {+ const { status, stepStatus } = await runWorkflowActionStep({+ name: `${RUN_PREFIX} workspace workflow`,+ stepType: 'CREATE_RECORD',+ input: {+ objectName: 'opportunity',+ objectRecord: { name: WORKSPACE_OPPORTUNITY_NAME },+ },+ });++ expect(status).toBe('COMPLETED');+ expect(stepStatus).toBe('SUCCESS');+ expect(+ await countRecordsByName('opportunity', WORKSPACE_OPPORTUNITY_NAME),+ ).toBe(1);+ }, 120000);++ it('runs the application function for the member who started the run', async () => {+ const executeSpy = jest+ .spyOn(+ getAppProviderByClassName<LogicFunctionExecutorService>(+ 'LogicFunctionExecutorService',+ ),+ 'execute',+ )+ .mockResolvedValue({+ data: { greeted: true },+ duration: 1,+ billedDurationMs: 1,+ logs: '',+ status: LogicFunctionExecutionStatus.SUCCESS,+ });++ try {+ const workflowRun = await waitForRunToEnd(+ await runWorkflow(LOGIC_FUNCTION_WORKFLOW),+ );++ expect(workflowRun.status).toBe('COMPLETED');+ expect(executeSpy).toHaveBeenCalledTimes(1);+ expect(executeSpy).toHaveBeenCalledWith(+ expect.objectContaining({+ workspaceId: SEED_APPLE_WORKSPACE_ID,+ userWorkspaceId: USER_WORKSPACE_DATA_SEED_IDS.JANE,+ }),+ );+ } finally {+ executeSpy.mockRestore();+ }+ }, 120000);++ it('only lets an application token start that application workflows', async () => {+ const coreWorkflowVersionId = await findVersionId(CREATE_COMPANY_WORKFLOW);++ const crossApplicationStart = await graphqlAs(+ await buildJaneTokenThroughApplication(OTHER_APP_ID),+ RUN_CORE_WORKFLOW_VERSION,+ { input: { coreWorkflowVersionId } },+ );++ expect(crossApplicationStart.body.errors?.[0]?.message).toContain(+ 'cannot start a workflow owned by another application',+ );++ const ownApplicationStart = await graphqlAs(+ await buildJaneTokenThroughApplication(APP_ID),+ RUN_CORE_WORKFLOW_VERSION,+ { input: { coreWorkflowVersionId } },+ );++ expect(ownApplicationStart.body.errors).toBeUndefined();++ const ownApplicationRun = await waitForRunToEnd(+ ownApplicationStart.body.data.runCoreWorkflowVersion.workflowRunId,+ );++ expect(ownApplicationRun.status).toBe('COMPLETED');+ }, 120000);++ it('keeps the application bound when its token starts a workspace workflow', async () => {+ const { status, stepStatus } = await runWorkflowActionStep({+ name: `${RUN_PREFIX} workspace workflow started by the application`,+ stepType: 'CREATE_RECORD',+ input: {+ objectName: 'opportunity',+ objectRecord: { name: NESTED_OPPORTUNITY_NAME },+ },+ runToken: await buildJaneTokenThroughApplication(APP_ID),+ });++ expect(status).toBe('FAILED');+ expect(stepStatus).toBe('FAILED');+ expect(+ await countRecordsByName('opportunity', NESTED_OPPORTUNITY_NAME),+ ).toBe(0);+ }, 120000);++ it('only lets the values of a form step change on an application workflow run', async () => {+ const workflowRunId = await runWorkflow(FORM_WORKFLOW);+ const [formStep] = FORM_WORKFLOW.steps;++ const pendingRun = await waitForRun(+ workflowRunId,+ ({ state }) =>+ state?.stepInfos?.[formStep.universalIdentifier]?.status === 'PENDING',+ );+ const runFormStep = pendingRun.state.flow?.steps.find(+ ({ id }) => id === formStep.universalIdentifier,+ );++ expect(runFormStep).toBeDefined();++ const renamedStep = await workflowGraphqlRequest(UPDATE_WORKFLOW_RUN_STEP, {+ input: { workflowRunId, step: { ...runFormStep, name: 'Renamed' } },+ });++ expect(renamedStep.body.errors?.[0]?.message).toContain(+ 'Only the values of a form step can change',+ );++ const filledStep = await workflowGraphqlRequest(UPDATE_WORKFLOW_RUN_STEP, {+ input: {+ workflowRunId,+ step: {+ ...runFormStep,+ settings: {+ ...runFormStep?.settings,+ input: runFormStep?.settings.input.map((field) => ({+ ...field,+ value: null,+ })),+ },+ },+ },+ });++ expect(filledStep.body.errors).toBeUndefined();+ }, 120000);++ it('reads the records picked in a form with the permissions of the run', async () => {+ const [formStep] = FORM_WORKFLOW.steps;+ const startFormRun = async () => {+ const workflowRunId = await runWorkflow(FORM_WORKFLOW);++ await waitForRun(+ workflowRunId,+ ({ state }) =>+ state?.stepInfos?.[formStep.universalIdentifier]?.status ===+ 'PENDING',+ );++ return workflowRunId;+ };++ const [opportunity] = await globalThis.testDataSource.query(+ `SELECT id FROM "${SCHEMA}"."opportunity" WHERE "deletedAt" IS NULL LIMIT 1`,+ );+ const [company] = await globalThis.testDataSource.query(+ `SELECT id FROM "${SCHEMA}"."company" WHERE "deletedAt" IS NULL LIMIT 1`,+ );++ const unreadableRunId = await startFormRun();+ const unreadableSelection = await answerToolCall({+ toolCall: {+ workflowRunId: unreadableRunId,+ stepId: formStep.universalIdentifier,+ },+ response: { opportunity: { id: opportunity.id } },+ });++ expect(unreadableSelection.body.errors).toBeDefined();+ expect((await waitForRunToEnd(unreadableRunId)).status).toBe('FAILED');++ const readableRunId = await startFormRun();+ const readableSelection = await answerToolCall({+ toolCall: {+ workflowRunId: readableRunId,+ stepId: formStep.universalIdentifier,+ },+ response: { company: { id: company.id } },+ });++ expect(readableSelection.body.errors).toBeUndefined();++ const workflowRun = await waitForRunToEnd(readableRunId);++ expect(workflowRun.status).toBe('COMPLETED');+ expect(+ workflowRun.state.stepInfos[formStep.universalIdentifier].result,+ ).toMatchObject({ company: { id: company.id } });+ }, 120000);++ it('checks the current application permissions again when a delayed run resumes', async () => {+ const workflowRunId = await runWorkflow(DELAYED_CREATE_COMPANY_WORKFLOW);+ const [delayStep, createStep] = DELAYED_CREATE_COMPANY_WORKFLOW.steps;++ await waitForRun(+ workflowRunId,+ ({ state }) =>+ state?.stepInfos?.[delayStep.universalIdentifier]?.status === 'PENDING',+ );++ const revocation = await syncApplication({+ manifest: buildManifest({ canManageCompanies: false }),+ });++ expect(revocation.errors).toBeUndefined();++ const workflowRun = await waitForRunToEnd(workflowRunId);++ expect(workflowRun.status).toBe('FAILED');+ expect(+ workflowRun.state.stepInfos[createStep.universalIdentifier].status,+ ).toBe('FAILED');+ expect(await countRecordsByName('company', DELAYED_COMPANY_NAME)).toBe(0);+ }, 150000);+});diff --git a/packages/twenty-server/test/integration/graphql/suites/workflow/utils/run-workflow-action-step.util.ts b/packages/twenty-server/test/integration/graphql/suites/workflow/utils/run-workflow-action-step.util.tsindex 1de521f6f16..89741e1908f 100644--- a/packages/twenty-server/test/integration/graphql/suites/workflow/utils/run-workflow-action-step.util.ts+++ b/packages/twenty-server/test/integration/graphql/suites/workflow/utils/run-workflow-action-step.util.ts@@ -13,6 +13,7 @@ type WorkflowActionStepType =| 'SEND_EMAIL'| 'DRAFT_EMAIL'| 'CREATE_CALENDAR_EVENT'+ | 'CREATE_RECORD'| 'UPDATE_RECORD'| 'CODE';@@ -185,11 +186,13 @@ export const runWorkflowActionStep = async ({stepType,input,payload,+ runToken,}: {name: string;stepType: WorkflowActionStepType;input: Record<string, unknown>;payload?: object;+ runToken?: string;}): Promise<WorkflowActionStepRun> => {const workflowId = await createWorkflow(name);@@ -215,7 +218,11 @@ export const runWorkflowActionStep = async ({await updateWorkflowVersionStepInput({ workflowVersionId, step, input });- workflowRunId = await runWorkflowVersion({ workflowVersionId, payload });+ workflowRunId = await runWorkflowVersion({+ workflowVersionId,+ payload,+ token: runToken,+ });const workflowRun = await waitForWorkflowCompletion(workflowRunId);const stepInfo = workflowRun?.state?.stepInfos?.[step.id];diff --git a/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-run-test.util.ts b/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-run-test.util.tsindex 53c084b40f0..70cf65092ab 100644--- a/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-run-test.util.ts+++ b/packages/twenty-server/test/integration/graphql/suites/workflow/utils/workflow-run-test.util.ts@@ -69,13 +69,15 @@ export const getWorkflowRun = async (export const runWorkflowVersion = async ({workflowVersionId,payload,+ token = APPLE_JANE_ADMIN_ACCESS_TOKEN,}: {workflowVersionId: string;payload?: object;+ token?: string;}): Promise<string> => {const response = await client.post('/graphql')- .set('Authorization', `Bearer ${APPLE_JANE_ADMIN_ACCESS_TOKEN}`)+ .set('Authorization', `Bearer ${token}`).send({query: `mutation RunWorkflowVersion($input: RunWorkflowVersionInput!) {diff --git a/packages/twenty-shared/src/types/composite-types/actor.composite-type.ts b/packages/twenty-shared/src/types/composite-types/actor.composite-type.tsindex 1d3c3dbcc29..bf2b7ba01fe 100644--- a/packages/twenty-shared/src/types/composite-types/actor.composite-type.ts+++ b/packages/twenty-shared/src/types/composite-types/actor.composite-type.ts@@ -64,5 +64,6 @@ export type ActorMetadata = {name: string;context: {provider?: ConnectedAccountProvider;+ applicationId?: string;};};