Skip to content

The open alternative to Salesforce, designed for AI.

Settle app lifecycle jobs that ended while the event stream was down (#28029)

martmull3f629b0ce979
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
index 9097239ea8d..31b1a6d3398 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
@@ -3799,7 +3799,7 @@ type Query {
findApplicationRegistrationStats(id: String!): ApplicationRegistrationStats!
findApplicationRegistrationVariables(applicationRegistrationId: String!): [ApplicationRegistrationVariable!]!
findClaimableApplicationRegistration(sourcePackage: String, universalIdentifier: String): ClaimableApplicationRegistration
- findInstallApplicationJobStatus(universalIdentifier: String!): JobStatus
+ findInstallApplicationJobStatus(jobId: String, universalIdentifier: String!): JobStatus
findManyAgents: [Agent!]!
findManyApplicationRegistrations: [ApplicationRegistration!]!
findManyApplications: [Application!]!
@@ -3811,8 +3811,8 @@ type Query {
findOneApplication(id: UUID, universalIdentifier: UUID): Application!
findOneApplicationRegistration(id: String!): ApplicationRegistration!
findOneLogicFunction(input: LogicFunctionIdInput!): LogicFunction!
- findUninstallApplicationJobStatus(universalIdentifier: String!): JobStatus
- findUpgradeApplicationJobStatus(universalIdentifier: String!): JobStatus
+ findUninstallApplicationJobStatus(jobId: String, universalIdentifier: String!): JobStatus
+ findUpgradeApplicationJobStatus(jobId: String, universalIdentifier: String!): JobStatus
findWorkspaceAiStats: WorkspaceAiStats!
findWorkspaceFromInviteHash(inviteHash: String!): Workspace!
findWorkspaceInvitations: [WorkspaceInvitation!]!
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.ts b/packages/twenty-client-sdk/src/metadata/generated/schema.ts
index 5e310baa9df..f1ea9b2eb69 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/schema.ts
+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.ts
@@ -7013,7 +7013,7 @@ export interface QueryGenqlSelection{
findApplicationRegistrationStats?: (ApplicationRegistrationStatsGenqlSelection & { __args: {id: Scalars['String']} })
findApplicationRegistrationVariables?: (ApplicationRegistrationVariableGenqlSelection & { __args: {applicationRegistrationId: Scalars['String']} })
findClaimableApplicationRegistration?: (ClaimableApplicationRegistrationGenqlSelection & { __args?: {sourcePackage?: (Scalars['String'] | null), universalIdentifier?: (Scalars['String'] | null)} })
- findInstallApplicationJobStatus?: (JobStatusGenqlSelection & { __args: {universalIdentifier: Scalars['String']} })
+ findInstallApplicationJobStatus?: (JobStatusGenqlSelection & { __args: {jobId?: (Scalars['String'] | null), universalIdentifier: Scalars['String']} })
findManyAgents?: AgentGenqlSelection
findManyApplicationRegistrations?: ApplicationRegistrationGenqlSelection
findManyApplications?: ApplicationGenqlSelection
@@ -7025,8 +7025,8 @@ export interface QueryGenqlSelection{
findOneApplication?: (ApplicationGenqlSelection & { __args?: {id?: (Scalars['UUID'] | null), universalIdentifier?: (Scalars['UUID'] | null)} })
findOneApplicationRegistration?: (ApplicationRegistrationGenqlSelection & { __args: {id: Scalars['String']} })
findOneLogicFunction?: (LogicFunctionGenqlSelection & { __args: {input: LogicFunctionIdInput} })
- findUninstallApplicationJobStatus?: (JobStatusGenqlSelection & { __args: {universalIdentifier: Scalars['String']} })
- findUpgradeApplicationJobStatus?: (JobStatusGenqlSelection & { __args: {universalIdentifier: Scalars['String']} })
+ findUninstallApplicationJobStatus?: (JobStatusGenqlSelection & { __args: {jobId?: (Scalars['String'] | null), universalIdentifier: Scalars['String']} })
+ findUpgradeApplicationJobStatus?: (JobStatusGenqlSelection & { __args: {jobId?: (Scalars['String'] | null), universalIdentifier: Scalars['String']} })
findWorkspaceAiStats?: WorkspaceAiStatsGenqlSelection
findWorkspaceFromInviteHash?: (WorkspaceGenqlSelection & { __args: {inviteHash: Scalars['String']} })
findWorkspaceInvitations?: WorkspaceInvitationGenqlSelection
diff --git a/packages/twenty-client-sdk/src/metadata/generated/types.ts b/packages/twenty-client-sdk/src/metadata/generated/types.ts
index 90d5e9b41af..71fc3675144 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/types.ts
+++ b/packages/twenty-client-sdk/src/metadata/generated/types.ts
@@ -10022,6 +10022,9 @@ export default {
"findInstallApplicationJobStatus": [
292,
{
+ "jobId": [
+ 1
+ ],
"universalIdentifier": [
1,
"String!"
@@ -10102,6 +10105,9 @@ export default {
"findUninstallApplicationJobStatus": [
292,
{
+ "jobId": [
+ 1
+ ],
"universalIdentifier": [
1,
"String!"
@@ -10111,6 +10117,9 @@ export default {
"findUpgradeApplicationJobStatus": [
292,
{
+ "jobId": [
+ 1
+ ],
"universalIdentifier": [
1,
"String!"
diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts
index 90243532d4d..4751e1a213d 100644
--- a/packages/twenty-front/src/generated-metadata/graphql.ts
+++ b/packages/twenty-front/src/generated-metadata/graphql.ts
@@ -5635,6 +5635,7 @@ export type QueryFindClaimableApplicationRegistrationArgs = {
export type QueryFindInstallApplicationJobStatusArgs = {
+ jobId?: InputMaybe<Scalars['String']['input']>;
universalIdentifier: Scalars['String']['input'];
};
@@ -5671,11 +5672,13 @@ export type QueryFindOneLogicFunctionArgs = {
export type QueryFindUninstallApplicationJobStatusArgs = {
+ jobId?: InputMaybe<Scalars['String']['input']>;
universalIdentifier: Scalars['String']['input'];
};
export type QueryFindUpgradeApplicationJobStatusArgs = {
+ jobId?: InputMaybe<Scalars['String']['input']>;
universalIdentifier: Scalars['String']['input'];
};
@@ -9099,6 +9102,7 @@ export type TriggerUpgradeApplicationMutation = { __typename?: 'Mutation', trigg
export type FindInstallApplicationJobStatusQueryVariables = Exact<{
universalIdentifier: Scalars['String']['input'];
+ jobId?: InputMaybe<Scalars['String']['input']>;
}>;
@@ -9125,6 +9129,7 @@ export type FindMarketplaceAppManifestQuery = { __typename?: 'Query', findMarket
export type FindUpgradeApplicationJobStatusQueryVariables = Exact<{
universalIdentifier: Scalars['String']['input'];
+ jobId?: InputMaybe<Scalars['String']['input']>;
}>;
@@ -9913,6 +9918,7 @@ export type ApplicationConnectionProvidersQuery = { __typename?: 'Query', applic
export type FindUninstallApplicationJobStatusQueryVariables = Exact<{
universalIdentifier: Scalars['String']['input'];
+ jobId?: InputMaybe<Scalars['String']['input']>;
}>;
@@ -11011,11 +11017,11 @@ export const InstallApplicationDocument = {"kind":"Document","definitions":[{"ki
export const SyncMarketplaceCatalogDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"SyncMarketplaceCatalog"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"syncMarketplaceCatalog"}}]}}]} as unknown as DocumentNode<SyncMarketplaceCatalogMutation, SyncMarketplaceCatalogMutationVariables>;
export const TriggerInstallApplicationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"TriggerInstallApplication"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"TriggerInstallApplicationInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"triggerInstallApplication"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jobId"}}]}}]}}]} as unknown as DocumentNode<TriggerInstallApplicationMutation, TriggerInstallApplicationMutationVariables>;
export const TriggerUpgradeApplicationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"TriggerUpgradeApplication"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"TriggerUpgradeApplicationInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"triggerUpgradeApplication"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jobId"}}]}}]}}]} as unknown as DocumentNode<TriggerUpgradeApplicationMutation, TriggerUpgradeApplicationMutationVariables>;
-export const FindInstallApplicationJobStatusDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindInstallApplicationJobStatus"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findInstallApplicationJobStatus"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jobId"}},{"kind":"Field","name":{"kind":"Name","value":"state"}},{"kind":"Field","name":{"kind":"Name","value":"failedReason"}},{"kind":"Field","name":{"kind":"Name","value":"progress"}}]}}]}}]} as unknown as DocumentNode<FindInstallApplicationJobStatusQuery, FindInstallApplicationJobStatusQueryVariables>;
+export const FindInstallApplicationJobStatusDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindInstallApplicationJobStatus"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"jobId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findInstallApplicationJobStatus"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}},{"kind":"Argument","name":{"kind":"Name","value":"jobId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"jobId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jobId"}},{"kind":"Field","name":{"kind":"Name","value":"state"}},{"kind":"Field","name":{"kind":"Name","value":"failedReason"}},{"kind":"Field","name":{"kind":"Name","value":"progress"}}]}}]}}]} as unknown as DocumentNode<FindInstallApplicationJobStatusQuery, FindInstallApplicationJobStatusQueryVariables>;
export const FindManyMarketplaceAppsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindManyMarketplaceApps"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findManyMarketplaceApps"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"MarketplaceAppFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"MarketplaceAppFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"MarketplaceApp"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"author"}},{"kind":"Field","name":{"kind":"Name","value":"category"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"sourcePackage"}},{"kind":"Field","name":{"kind":"Name","value":"isVetted"}}]}}]} as unknown as DocumentNode<FindManyMarketplaceAppsQuery, FindManyMarketplaceAppsQueryVariables>;
export const FindMarketplaceAppDetailDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindMarketplaceAppDetail"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findMarketplaceAppDetail"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"MarketplaceAppDetailFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"MarketplaceAppDetailFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"MarketplaceAppDetail"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"sourceType"}},{"kind":"Field","name":{"kind":"Name","value":"sourcePackage"}},{"kind":"Field","name":{"kind":"Name","value":"latestAvailableVersion"}},{"kind":"Field","name":{"kind":"Name","value":"isListed"}},{"kind":"Field","name":{"kind":"Name","value":"isVetted"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"author"}},{"kind":"Field","name":{"kind":"Name","value":"category"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"websiteUrl"}},{"kind":"Field","name":{"kind":"Name","value":"aboutDescription"}},{"kind":"Field","name":{"kind":"Name","value":"pricingDescription"}},{"kind":"Field","name":{"kind":"Name","value":"termsUrl"}},{"kind":"Field","name":{"kind":"Name","value":"emailSupport"}},{"kind":"Field","name":{"kind":"Name","value":"issueReportUrl"}},{"kind":"Field","name":{"kind":"Name","value":"galleryImages"}},{"kind":"Field","name":{"kind":"Name","value":"installCount"}},{"kind":"Field","name":{"kind":"Name","value":"defaultRoleUniversalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"requestedCapabilities"}},{"kind":"Field","name":{"kind":"Name","value":"billsCredits"}},{"kind":"Field","name":{"kind":"Name","value":"objects"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}}]}},{"kind":"Field","name":{"kind":"Name","value":"roles"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"canUpdateAllSettings"}},{"kind":"Field","name":{"kind":"Name","value":"canAccessAllTools"}},{"kind":"Field","name":{"kind":"Name","value":"canReadAllObjectRecords"}},{"kind":"Field","name":{"kind":"Name","value":"canUpdateAllObjectRecords"}},{"kind":"Field","name":{"kind":"Name","value":"canSoftDeleteAllObjectRecords"}},{"kind":"Field","name":{"kind":"Name","value":"canDestroyAllObjectRecords"}},{"kind":"Field","name":{"kind":"Name","value":"permissionFlagUniversalIdentifiers"}},{"kind":"Field","name":{"kind":"Name","value":"objectPermissions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"objectUniversalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"canReadObjectRecords"}},{"kind":"Field","name":{"kind":"Name","value":"canUpdateObjectRecords"}},{"kind":"Field","name":{"kind":"Name","value":"canSoftDeleteObjectRecords"}},{"kind":"Field","name":{"kind":"Name","value":"canDestroyObjectRecords"}}]}},{"kind":"Field","name":{"kind":"Name","value":"fieldPermissions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"objectUniversalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"fieldUniversalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"canReadFieldValue"}},{"kind":"Field","name":{"kind":"Name","value":"canUpdateFieldValue"}}]}}]}}]}}]} as unknown as DocumentNode<FindMarketplaceAppDetailQuery, FindMarketplaceAppDetailQueryVariables>;
export const FindMarketplaceAppManifestDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindMarketplaceAppManifest"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findMarketplaceAppDetail"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"manifest"}}]}}]}}]} as unknown as DocumentNode<FindMarketplaceAppManifestQuery, FindMarketplaceAppManifestQueryVariables>;
-export const FindUpgradeApplicationJobStatusDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindUpgradeApplicationJobStatus"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findUpgradeApplicationJobStatus"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jobId"}},{"kind":"Field","name":{"kind":"Name","value":"state"}},{"kind":"Field","name":{"kind":"Name","value":"failedReason"}},{"kind":"Field","name":{"kind":"Name","value":"progress"}}]}}]}}]} as unknown as DocumentNode<FindUpgradeApplicationJobStatusQuery, FindUpgradeApplicationJobStatusQueryVariables>;
+export const FindUpgradeApplicationJobStatusDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindUpgradeApplicationJobStatus"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"jobId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findUpgradeApplicationJobStatus"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}},{"kind":"Argument","name":{"kind":"Name","value":"jobId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"jobId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jobId"}},{"kind":"Field","name":{"kind":"Name","value":"state"}},{"kind":"Field","name":{"kind":"Name","value":"failedReason"}},{"kind":"Field","name":{"kind":"Name","value":"progress"}}]}}]}}]} as unknown as DocumentNode<FindUpgradeApplicationJobStatusQuery, FindUpgradeApplicationJobStatusQueryVariables>;
export const FindMinimalMetadataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindMinimalMetadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"minimalMetadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"objectMetadataItems"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isSystem"}},{"kind":"Field","name":{"kind":"Name","value":"isRemote"}}]}},{"kind":"Field","name":{"kind":"Name","value":"views"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"objectMetadataId"}}]}},{"kind":"Field","name":{"kind":"Name","value":"collectionHashes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"collectionName"}},{"kind":"Field","name":{"kind":"Name","value":"hash"}}]}}]}}]}}]} as unknown as DocumentNode<FindMinimalMetadataQuery, FindMinimalMetadataQueryVariables>;
export const CreateManyNavigationMenuItemsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateManyNavigationMenuItems"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"inputs"}},"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateNavigationMenuItemInput"}}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createManyNavigationMenuItems"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"inputs"},"value":{"kind":"Variable","name":{"kind":"Name","value":"inputs"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"NavigationMenuItemQueryFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"NavigationMenuItemFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"NavigationMenuItem"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"userWorkspaceId"}},{"kind":"Field","name":{"kind":"Name","value":"targetRecordId"}},{"kind":"Field","name":{"kind":"Name","value":"targetObjectMetadataId"}},{"kind":"Field","name":{"kind":"Name","value":"viewId"}},{"kind":"Field","name":{"kind":"Name","value":"folderId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"link"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"color"}},{"kind":"Field","name":{"kind":"Name","value":"pageLayoutId"}},{"kind":"Field","name":{"kind":"Name","value":"position"}},{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"NavigationMenuItemQueryFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"NavigationMenuItem"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"NavigationMenuItemFields"}},{"kind":"Field","name":{"kind":"Name","value":"targetRecordIdentifier"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"labelIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"imageIdentifier"}}]}}]}}]} as unknown as DocumentNode<CreateManyNavigationMenuItemsMutation, CreateManyNavigationMenuItemsMutationVariables>;
export const DeleteManyNavigationMenuItemsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteManyNavigationMenuItems"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"ids"}},"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteManyNavigationMenuItems"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"ids"},"value":{"kind":"Variable","name":{"kind":"Name","value":"ids"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"NavigationMenuItemQueryFields"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"NavigationMenuItemFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"NavigationMenuItem"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"userWorkspaceId"}},{"kind":"Field","name":{"kind":"Name","value":"targetRecordId"}},{"kind":"Field","name":{"kind":"Name","value":"targetObjectMetadataId"}},{"kind":"Field","name":{"kind":"Name","value":"viewId"}},{"kind":"Field","name":{"kind":"Name","value":"folderId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"link"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"color"}},{"kind":"Field","name":{"kind":"Name","value":"pageLayoutId"}},{"kind":"Field","name":{"kind":"Name","value":"position"}},{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"NavigationMenuItemQueryFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"NavigationMenuItem"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"NavigationMenuItemFields"}},{"kind":"Field","name":{"kind":"Name","value":"targetRecordIdentifier"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"labelIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"imageIdentifier"}}]}}]}}]} as unknown as DocumentNode<DeleteManyNavigationMenuItemsMutation, DeleteManyNavigationMenuItemsMutationVariables>;
@@ -11092,7 +11098,7 @@ export const UpdateApplicationDocument = {"kind":"Document","definitions":[{"kin
export const UpdateOneApplicationVariableDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateOneApplicationVariable"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"key"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"value"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateOneApplicationVariable"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"key"},"value":{"kind":"Variable","name":{"kind":"Name","value":"key"}}},{"kind":"Argument","name":{"kind":"Name","value":"value"},"value":{"kind":"Variable","name":{"kind":"Name","value":"value"}}},{"kind":"Argument","name":{"kind":"Name","value":"applicationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}}}]}]}}]} as unknown as DocumentNode<UpdateOneApplicationVariableMutation, UpdateOneApplicationVariableMutationVariables>;
export const ApplicationConnectedAccountsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ApplicationConnectedAccounts"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"applicationConnectedAccounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"handle"}},{"kind":"Field","name":{"kind":"Name","value":"authFailedAt"}},{"kind":"Field","name":{"kind":"Name","value":"authFailedReason"}},{"kind":"Field","name":{"kind":"Name","value":"scopes"}},{"kind":"Field","name":{"kind":"Name","value":"lastSignedInAt"}},{"kind":"Field","name":{"kind":"Name","value":"connectionProviderId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"visibility"}},{"kind":"Field","name":{"kind":"Name","value":"lastCredentialsRefreshedAt"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<ApplicationConnectedAccountsQuery, ApplicationConnectedAccountsQueryVariables>;
export const ApplicationConnectionProvidersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ApplicationConnectionProviders"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"applicationConnectionProviders"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"oauth"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"scopes"}},{"kind":"Field","name":{"kind":"Name","value":"isClientCredentialsConfigured"}}]}}]}}]}}]} as unknown as DocumentNode<ApplicationConnectionProvidersQuery, ApplicationConnectionProvidersQueryVariables>;
-export const FindUninstallApplicationJobStatusDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindUninstallApplicationJobStatus"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findUninstallApplicationJobStatus"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jobId"}},{"kind":"Field","name":{"kind":"Name","value":"state"}},{"kind":"Field","name":{"kind":"Name","value":"failedReason"}},{"kind":"Field","name":{"kind":"Name","value":"progress"}}]}}]}}]} as unknown as DocumentNode<FindUninstallApplicationJobStatusQuery, FindUninstallApplicationJobStatusQueryVariables>;
+export const FindUninstallApplicationJobStatusDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindUninstallApplicationJobStatus"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"jobId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findUninstallApplicationJobStatus"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}},{"kind":"Argument","name":{"kind":"Name","value":"jobId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"jobId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jobId"}},{"kind":"Field","name":{"kind":"Name","value":"state"}},{"kind":"Field","name":{"kind":"Name","value":"failedReason"}},{"kind":"Field","name":{"kind":"Name","value":"progress"}}]}}]}}]} as unknown as DocumentNode<FindUninstallApplicationJobStatusQuery, FindUninstallApplicationJobStatusQueryVariables>;
export const CancelSwitchBillingIntervalDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CancelSwitchBillingInterval"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cancelSwitchBillingInterval"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentBillingSubscription"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CurrentBillingSubscriptionFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"billingSubscriptions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionFragment"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItemFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItem"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"price"}},{"kind":"Field","name":{"kind":"Name","value":"quantity"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhase"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"start_date"}},{"kind":"Field","name":{"kind":"Name","value":"end_date"}},{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItemFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CurrentBillingSubscriptionFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscription"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"interval"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}},{"kind":"Field","name":{"kind":"Name","value":"currentPeriodEnd"}},{"kind":"Field","name":{"kind":"Name","value":"cancelAt"}},{"kind":"Field","name":{"kind":"Name","value":"collectionMethod"}},{"kind":"Field","name":{"kind":"Name","value":"phases"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"billingSubscriptionItems"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"hasReachedCurrentPeriodCap"}},{"kind":"Field","name":{"kind":"Name","value":"quantity"}},{"kind":"Field","name":{"kind":"Name","value":"stripePriceId"}},{"kind":"Field","name":{"kind":"Name","value":"unitAmount"}},{"kind":"Field","name":{"kind":"Name","value":"creditAmount"}},{"kind":"Field","name":{"kind":"Name","value":"billingProduct"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"images"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productKey"}},{"kind":"Field","name":{"kind":"Name","value":"planKey"}},{"kind":"Field","name":{"kind":"Name","value":"priceUsageBased"}},{"kind":"Field","name":{"kind":"Name","value":"isLegacy"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscription"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}},{"kind":"Field","name":{"kind":"Name","value":"cancelAt"}},{"kind":"Field","name":{"kind":"Name","value":"phases"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"}}]}}]}}]} as unknown as DocumentNode<CancelSwitchBillingIntervalMutation, CancelSwitchBillingIntervalMutationVariables>;
export const CancelSwitchBillingPlanDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CancelSwitchBillingPlan"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cancelSwitchBillingPlan"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentBillingSubscription"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CurrentBillingSubscriptionFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"billingSubscriptions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionFragment"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItemFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItem"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"price"}},{"kind":"Field","name":{"kind":"Name","value":"quantity"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhase"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"start_date"}},{"kind":"Field","name":{"kind":"Name","value":"end_date"}},{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItemFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CurrentBillingSubscriptionFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscription"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"interval"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}},{"kind":"Field","name":{"kind":"Name","value":"currentPeriodEnd"}},{"kind":"Field","name":{"kind":"Name","value":"cancelAt"}},{"kind":"Field","name":{"kind":"Name","value":"collectionMethod"}},{"kind":"Field","name":{"kind":"Name","value":"phases"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"billingSubscriptionItems"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"hasReachedCurrentPeriodCap"}},{"kind":"Field","name":{"kind":"Name","value":"quantity"}},{"kind":"Field","name":{"kind":"Name","value":"stripePriceId"}},{"kind":"Field","name":{"kind":"Name","value":"unitAmount"}},{"kind":"Field","name":{"kind":"Name","value":"creditAmount"}},{"kind":"Field","name":{"kind":"Name","value":"billingProduct"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"images"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productKey"}},{"kind":"Field","name":{"kind":"Name","value":"planKey"}},{"kind":"Field","name":{"kind":"Name","value":"priceUsageBased"}},{"kind":"Field","name":{"kind":"Name","value":"isLegacy"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscription"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}},{"kind":"Field","name":{"kind":"Name","value":"cancelAt"}},{"kind":"Field","name":{"kind":"Name","value":"phases"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"}}]}}]}}]} as unknown as DocumentNode<CancelSwitchBillingPlanMutation, CancelSwitchBillingPlanMutationVariables>;
export const CancelSwitchResourceCreditPriceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CancelSwitchResourceCreditPrice"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cancelSwitchResourceCreditPrice"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentBillingSubscription"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CurrentBillingSubscriptionFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"billingSubscriptions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionFragment"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItemFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItem"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"price"}},{"kind":"Field","name":{"kind":"Name","value":"quantity"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhase"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"start_date"}},{"kind":"Field","name":{"kind":"Name","value":"end_date"}},{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItemFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CurrentBillingSubscriptionFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscription"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"interval"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}},{"kind":"Field","name":{"kind":"Name","value":"currentPeriodEnd"}},{"kind":"Field","name":{"kind":"Name","value":"cancelAt"}},{"kind":"Field","name":{"kind":"Name","value":"collectionMethod"}},{"kind":"Field","name":{"kind":"Name","value":"phases"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"billingSubscriptionItems"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"hasReachedCurrentPeriodCap"}},{"kind":"Field","name":{"kind":"Name","value":"quantity"}},{"kind":"Field","name":{"kind":"Name","value":"stripePriceId"}},{"kind":"Field","name":{"kind":"Name","value":"unitAmount"}},{"kind":"Field","name":{"kind":"Name","value":"creditAmount"}},{"kind":"Field","name":{"kind":"Name","value":"billingProduct"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"images"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productKey"}},{"kind":"Field","name":{"kind":"Name","value":"planKey"}},{"kind":"Field","name":{"kind":"Name","value":"priceUsageBased"}},{"kind":"Field","name":{"kind":"Name","value":"isLegacy"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscription"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}},{"kind":"Field","name":{"kind":"Name","value":"cancelAt"}},{"kind":"Field","name":{"kind":"Name","value":"phases"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"}}]}}]}}]} as unknown as DocumentNode<CancelSwitchResourceCreditPriceMutation, CancelSwitchResourceCreditPriceMutationVariables>;
diff --git a/packages/twenty-front/src/modules/marketplace/graphql/queries/findInstallApplicationJobStatus.ts b/packages/twenty-front/src/modules/marketplace/graphql/queries/findInstallApplicationJobStatus.ts
index 888a802928d..7ed6c7780ef 100644
--- a/packages/twenty-front/src/modules/marketplace/graphql/queries/findInstallApplicationJobStatus.ts
+++ b/packages/twenty-front/src/modules/marketplace/graphql/queries/findInstallApplicationJobStatus.ts
@@ -1,8 +1,14 @@
import gql from 'graphql-tag';
export const FIND_INSTALL_APPLICATION_JOB_STATUS = gql`
- query FindInstallApplicationJobStatus($universalIdentifier: String!) {
- findInstallApplicationJobStatus(universalIdentifier: $universalIdentifier) {
+ query FindInstallApplicationJobStatus(
+ $universalIdentifier: String!
+ $jobId: String
+ ) {
+ findInstallApplicationJobStatus(
+ universalIdentifier: $universalIdentifier
+ jobId: $jobId
+ ) {
jobId
state
failedReason
diff --git a/packages/twenty-front/src/modules/marketplace/graphql/queries/findUpgradeApplicationJobStatus.ts b/packages/twenty-front/src/modules/marketplace/graphql/queries/findUpgradeApplicationJobStatus.ts
index db1eb6384f9..6b6b0b8b0f2 100644
--- a/packages/twenty-front/src/modules/marketplace/graphql/queries/findUpgradeApplicationJobStatus.ts
+++ b/packages/twenty-front/src/modules/marketplace/graphql/queries/findUpgradeApplicationJobStatus.ts
@@ -1,8 +1,14 @@
import gql from 'graphql-tag';
export const FIND_UPGRADE_APPLICATION_JOB_STATUS = gql`
- query FindUpgradeApplicationJobStatus($universalIdentifier: String!) {
- findUpgradeApplicationJobStatus(universalIdentifier: $universalIdentifier) {
+ query FindUpgradeApplicationJobStatus(
+ $universalIdentifier: String!
+ $jobId: String
+ ) {
+ findUpgradeApplicationJobStatus(
+ universalIdentifier: $universalIdentifier
+ jobId: $jobId
+ ) {
jobId
state
failedReason
diff --git a/packages/twenty-front/src/modules/marketplace/hooks/__tests__/useInstallMarketplaceApp.test.tsx b/packages/twenty-front/src/modules/marketplace/hooks/__tests__/useInstallMarketplaceApp.test.tsx
index 6ac5c67bcc6..b8b3b45792d 100644
--- a/packages/twenty-front/src/modules/marketplace/hooks/__tests__/useInstallMarketplaceApp.test.tsx
+++ b/packages/twenty-front/src/modules/marketplace/hooks/__tests__/useInstallMarketplaceApp.test.tsx
@@ -6,6 +6,7 @@ import { type ReactNode } from 'react';
import { dispatchBrowserEvent } from '@/browser-event/utils/dispatchBrowserEvent';
import { useInstallMarketplaceApp } from '@/marketplace/hooks/useInstallMarketplaceApp';
import { QUEUE_JOB_BROWSER_EVENT_NAME } from '@/queue-job/constants/QueueJobBrowserEventName';
+import { SSE_CLIENT_RECONNECTED_EVENT_NAME } from '@/sse-db-event/constants/SseClientReconnectedEventName';
import {
FindInstallApplicationJobStatusDocument,
JobState,
@@ -35,10 +36,14 @@ const triggerInstallMock = {
const buildJobStatusMock = (
findInstallApplicationJobStatus: Partial<JobStatus> | null,
+ jobId?: string,
) => ({
request: {
query: FindInstallApplicationJobStatusDocument,
- variables: { universalIdentifier: UNIVERSAL_IDENTIFIER },
+ variables: {
+ universalIdentifier: UNIVERSAL_IDENTIFIER,
+ ...(jobId === undefined ? {} : { jobId }),
+ },
},
result: { data: { findInstallApplicationJobStatus } },
});
@@ -135,4 +140,45 @@ describe('useInstallMarketplaceApp', () => {
expect(result.current.installProgress).toBe(86);
});
+
+ it('settles an installation that ended while the event stream was down', async () => {
+ const { result } = renderHook(
+ () =>
+ useInstallMarketplaceApp({
+ universalIdentifier: UNIVERSAL_IDENTIFIER,
+ }),
+ {
+ wrapper: buildWrapper([
+ buildJobStatusMock(null),
+ triggerInstallMock,
+ buildJobStatusMock(
+ {
+ __typename: 'JobStatus',
+ jobId: JOB_ID,
+ state: JobState.FAILED,
+ failedReason: 'Manifest validation failed',
+ progress: 14,
+ },
+ JOB_ID,
+ ),
+ ]),
+ },
+ );
+
+ await act(async () => {
+ await result.current.install();
+ });
+
+ expect(result.current.isInstalling).toBe(true);
+
+ act(() => {
+ dispatchBrowserEvent(SSE_CLIENT_RECONNECTED_EVENT_NAME);
+ });
+
+ await waitFor(() => expect(result.current.isInstalling).toBe(false));
+ expect(mockEnqueueToast).toHaveBeenCalledWith({
+ status: 'error',
+ children: 'Manifest validation failed',
+ });
+ });
});
diff --git a/packages/twenty-front/src/modules/marketplace/hooks/useInstallMarketplaceApp.ts b/packages/twenty-front/src/modules/marketplace/hooks/useInstallMarketplaceApp.ts
index ecb594c1995..ea7c9184945 100644
--- a/packages/twenty-front/src/modules/marketplace/hooks/useInstallMarketplaceApp.ts
+++ b/packages/twenty-front/src/modules/marketplace/hooks/useInstallMarketplaceApp.ts
@@ -35,6 +35,10 @@ export const useInstallMarketplaceApp = ({
FindOneApplicationByUniversalIdentifierDocument,
{ fetchPolicy: 'network-only' },
);
+ const [findInstallApplicationJobStatus] = useLazyQuery(
+ FindInstallApplicationJobStatusDocument,
+ { fetchPolicy: 'network-only' },
+ );
const setCurrentWorkspace = useSetAtomState(currentWorkspaceState);
const { data: jobStatusData } = useQuery(
@@ -119,9 +123,21 @@ export const useInstallMarketplaceApp = ({
[enqueueToast, findInstalledApplication, onCompleted, setCurrentWorkspace],
);
+ const fetchInstallJobStatus = useCallback(
+ async (jobId: string, trackedUniversalIdentifier: string) => {
+ const { data } = await findInstallApplicationJobStatus({
+ variables: { universalIdentifier: trackedUniversalIdentifier, jobId },
+ });
+
+ return data?.findInstallApplicationJobStatus;
+ },
+ [findInstallApplicationJobStatus],
+ );
+
const { activeJobId, activeJobProgress, trackJob } = useTrackedQueueJob({
runningJob,
onQueueJobSettled: handleInstallJobSettled,
+ fetchJobStatus: fetchInstallJobStatus,
});
const install = async (): Promise<void> => {
diff --git a/packages/twenty-front/src/modules/marketplace/hooks/useUpgradeApplication.ts b/packages/twenty-front/src/modules/marketplace/hooks/useUpgradeApplication.ts
index 789d7a06536..9fa06aadef2 100644
--- a/packages/twenty-front/src/modules/marketplace/hooks/useUpgradeApplication.ts
+++ b/packages/twenty-front/src/modules/marketplace/hooks/useUpgradeApplication.ts
@@ -1,7 +1,7 @@
import { useTrackedQueueJob } from '@/queue-job/hooks/useTrackedQueueJob';
import { type TrackedJobStatus } from '@/queue-job/types/TrackedJobStatus';
import { isTerminalJobState } from '@/queue-job/utils/isTerminalJobState';
-import { useMutation, useQuery } from '@apollo/client/react';
+import { useLazyQuery, useMutation, useQuery } from '@apollo/client/react';
import { t } from '@lingui/core/macro';
import { isNonEmptyString } from '@sniptt/guards';
import { useCallback } from 'react';
@@ -25,6 +25,10 @@ export const useUpgradeApplication = ({
const { enqueueToast } = useToast();
const [triggerUpgradeApplication, { loading: isTriggeringUpgrade }] =
useMutation(TriggerUpgradeApplicationDocument);
+ const [findUpgradeApplicationJobStatus] = useLazyQuery(
+ FindUpgradeApplicationJobStatusDocument,
+ { fetchPolicy: 'network-only' },
+ );
const { data: jobStatusData } = useQuery(
FindUpgradeApplicationJobStatusDocument,
@@ -68,9 +72,21 @@ export const useUpgradeApplication = ({
[enqueueToast, onCompleted],
);
+ const fetchUpgradeJobStatus = useCallback(
+ async (jobId: string, trackedUniversalIdentifier: string) => {
+ const { data } = await findUpgradeApplicationJobStatus({
+ variables: { universalIdentifier: trackedUniversalIdentifier, jobId },
+ });
+
+ return data?.findUpgradeApplicationJobStatus;
+ },
+ [findUpgradeApplicationJobStatus],
+ );
+
const { activeJobId, activeJobProgress, trackJob } = useTrackedQueueJob({
runningJob,
onQueueJobSettled: handleUpgradeJobSettled,
+ fetchJobStatus: fetchUpgradeJobStatus,
});
const upgrade = async (targetVersion: string): Promise<void> => {
diff --git a/packages/twenty-front/src/modules/queue-job/hooks/__tests__/useTrackedQueueJob.test.tsx b/packages/twenty-front/src/modules/queue-job/hooks/__tests__/useTrackedQueueJob.test.tsx
index 73b8feccb2f..0d283b354cd 100644
--- a/packages/twenty-front/src/modules/queue-job/hooks/__tests__/useTrackedQueueJob.test.tsx
+++ b/packages/twenty-front/src/modules/queue-job/hooks/__tests__/useTrackedQueueJob.test.tsx
@@ -3,6 +3,7 @@ import { act, renderHook } from '@testing-library/react';
import { dispatchBrowserEvent } from '@/browser-event/utils/dispatchBrowserEvent';
import { QUEUE_JOB_BROWSER_EVENT_NAME } from '@/queue-job/constants/QueueJobBrowserEventName';
import { useTrackedQueueJob } from '@/queue-job/hooks/useTrackedQueueJob';
+import { SSE_CLIENT_RECONNECTED_EVENT_NAME } from '@/sse-db-event/constants/SseClientReconnectedEventName';
import { JobState, type JobStatus } from '~/generated-metadata/graphql';
type TrackedQueueJobProps = {
@@ -38,6 +39,12 @@ const dispatchJobStatus = (
});
};
+const dispatchEventStreamReconnected = async () => {
+ await act(async () => {
+ dispatchBrowserEvent(SSE_CLIENT_RECONNECTED_EVENT_NAME);
+ });
+};
+
describe('useTrackedQueueJob', () => {
it('settles a tracked job on its terminal browser event with its context', () => {
const onQueueJobSettled = jest.fn();
@@ -216,4 +223,130 @@ describe('useTrackedQueueJob', () => {
CONTEXT,
);
});
+
+ it('settles a job that ended while the event stream was down', async () => {
+ const onQueueJobSettled = jest.fn();
+ const fetchJobStatus = jest
+ .fn()
+ .mockResolvedValue(buildJobStatus(FIRST_JOB_ID, JobState.COMPLETED));
+
+ const { result } = renderHook(() =>
+ useTrackedQueueJob<string>({ onQueueJobSettled, fetchJobStatus }),
+ );
+
+ act(() => {
+ result.current.trackJob({ jobId: FIRST_JOB_ID, context: CONTEXT });
+ });
+
+ await dispatchEventStreamReconnected();
+
+ expect(fetchJobStatus).toHaveBeenCalledWith(FIRST_JOB_ID, CONTEXT);
+ expect(result.current.activeJobId).toBeUndefined();
+ expect(onQueueJobSettled).toHaveBeenCalledWith(
+ buildJobStatus(FIRST_JOB_ID, JobState.COMPLETED),
+ CONTEXT,
+ );
+ });
+
+ it('keeps tracking a job still running after the event stream reconnects', async () => {
+ const onQueueJobSettled = jest.fn();
+ const fetchJobStatus = jest
+ .fn()
+ .mockResolvedValue(buildJobStatus(FIRST_JOB_ID, JobState.ACTIVE, 50));
+
+ const { result } = renderHook(() =>
+ useTrackedQueueJob<string>({
+ runningJob: { jobId: FIRST_JOB_ID, context: CONTEXT },
+ onQueueJobSettled,
+ fetchJobStatus,
+ }),
+ );
+
+ await dispatchEventStreamReconnected();
+
+ expect(result.current.activeJobId).toBe(FIRST_JOB_ID);
+ expect(result.current.activeJobProgress).toBe(50);
+ expect(onQueueJobSettled).not.toHaveBeenCalled();
+ });
+
+ it('does not settle a job again when its status arrives after it settled', async () => {
+ const onQueueJobSettled = jest.fn();
+ let resolveJobStatus: (jobStatus: JobStatus) => void = () => {};
+ const fetchJobStatus = jest.fn(
+ () =>
+ new Promise<JobStatus>((resolve) => {
+ resolveJobStatus = resolve;
+ }),
+ );
+
+ const { result } = renderHook(() =>
+ useTrackedQueueJob<string>({ onQueueJobSettled, fetchJobStatus }),
+ );
+
+ act(() => {
+ result.current.trackJob({ jobId: FIRST_JOB_ID, context: CONTEXT });
+ });
+
+ await dispatchEventStreamReconnected();
+
+ dispatchJobStatus(FIRST_JOB_ID, JobState.COMPLETED);
+
+ await act(async () => {
+ resolveJobStatus(buildJobStatus(FIRST_JOB_ID, JobState.COMPLETED));
+ });
+
+ expect(onQueueJobSettled).toHaveBeenCalledTimes(1);
+ });
+
+ it('does not fetch any status on reconnection without an active job', async () => {
+ const fetchJobStatus = jest.fn();
+
+ renderHook(() =>
+ useTrackedQueueJob<string>({
+ onQueueJobSettled: jest.fn(),
+ fetchJobStatus,
+ }),
+ );
+
+ await dispatchEventStreamReconnected();
+
+ expect(fetchJobStatus).not.toHaveBeenCalled();
+ });
+
+ it('stops tracking a job the server no longer knows after the event stream reconnects', async () => {
+ const onQueueJobSettled = jest.fn();
+ const fetchJobStatus = jest.fn().mockResolvedValue(null);
+
+ const { result } = renderHook(() =>
+ useTrackedQueueJob<string>({ onQueueJobSettled, fetchJobStatus }),
+ );
+
+ act(() => {
+ result.current.trackJob({ jobId: FIRST_JOB_ID, context: CONTEXT });
+ });
+
+ await dispatchEventStreamReconnected();
+
+ expect(result.current.activeJobId).toBeUndefined();
+ expect(onQueueJobSettled).not.toHaveBeenCalled();
+ });
+
+ it('keeps tracking a job when its status cannot be fetched after the event stream reconnects', async () => {
+ const fetchJobStatus = jest.fn().mockRejectedValue(new Error('Network'));
+
+ const { result } = renderHook(() =>
+ useTrackedQueueJob<string>({
+ onQueueJobSettled: jest.fn(),
+ fetchJobStatus,
+ }),
+ );
+
+ act(() => {
+ result.current.trackJob({ jobId: FIRST_JOB_ID, context: CONTEXT });
+ });
+
+ await dispatchEventStreamReconnected();
+
+ expect(result.current.activeJobId).toBe(FIRST_JOB_ID);
+ });
});
diff --git a/packages/twenty-front/src/modules/queue-job/hooks/useTrackedQueueJob.ts b/packages/twenty-front/src/modules/queue-job/hooks/useTrackedQueueJob.ts
index deba870e59b..6d8304f8ba3 100644
--- a/packages/twenty-front/src/modules/queue-job/hooks/useTrackedQueueJob.ts
+++ b/packages/twenty-front/src/modules/queue-job/hooks/useTrackedQueueJob.ts
@@ -1,6 +1,11 @@
+import { useListenToBrowserEvent } from '@/browser-event/hooks/useListenToBrowserEvent';
+import { dispatchBrowserEvent } from '@/browser-event/utils/dispatchBrowserEvent';
+import { QUEUE_JOB_BROWSER_EVENT_NAME } from '@/queue-job/constants/QueueJobBrowserEventName';
import { useListenToQueueJob } from '@/queue-job/hooks/useListenToQueueJob';
import { type TrackedJobStatus } from '@/queue-job/types/TrackedJobStatus';
import { isTerminalJobState } from '@/queue-job/utils/isTerminalJobState';
+import { SSE_CLIENT_RECONNECTED_EVENT_NAME } from '@/sse-db-event/constants/SseClientReconnectedEventName';
+import { isNull } from '@sniptt/guards';
import { useCallback, useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
@@ -16,11 +21,16 @@ type UseTrackedQueueJobArgs<TContext> = {
jobStatus: TrackedJobStatus,
context: TContext,
) => void | Promise<void>;
+ fetchJobStatus?: (
+ jobId: string,
+ context: TContext,
+ ) => Promise<TrackedJobStatus | null | undefined>;
};
export const useTrackedQueueJob = <TContext>({
runningJob,
onQueueJobSettled,
+ fetchJobStatus,
}: UseTrackedQueueJobArgs<TContext>) => {
const [triggeredJob, setTriggeredJob] = useState<TrackedQueueJob<TContext>>();
const [settledJobIds, setSettledJobIds] = useState<string[]>([]);
@@ -39,6 +49,16 @@ export const useTrackedQueueJob = <TContext>({
? (progressByJobId[activeJob.jobId] ?? activeJob.progress)
: undefined;
+ const stopTrackingJob = useCallback((jobId: string) => {
+ setSettledJobIds((currentSettledJobIds) => [
+ ...currentSettledJobIds,
+ jobId,
+ ]);
+ setTriggeredJob((currentTriggeredJob) =>
+ currentTriggeredJob?.jobId === jobId ? undefined : currentTriggeredJob,
+ );
+ }, []);
+
const handleQueueJobEvent = useCallback(
(jobStatus: TrackedJobStatus) => {
if (!isDefined(activeJobId) || !isDefined(activeJobContext)) {
@@ -58,18 +78,10 @@ export const useTrackedQueueJob = <TContext>({
return;
}
- setSettledJobIds((currentSettledJobIds) => [
- ...currentSettledJobIds,
- jobStatus.jobId,
- ]);
- setTriggeredJob((currentTriggeredJob) =>
- currentTriggeredJob?.jobId === jobStatus.jobId
- ? undefined
- : currentTriggeredJob,
- );
+ stopTrackingJob(jobStatus.jobId);
void onQueueJobSettled(jobStatus, activeJobContext);
},
- [activeJobContext, activeJobId, onQueueJobSettled],
+ [activeJobContext, activeJobId, onQueueJobSettled, stopTrackingJob],
);
useListenToQueueJob({
@@ -77,6 +89,37 @@ export const useTrackedQueueJob = <TContext>({
onQueueJobEvent: handleQueueJobEvent,
});
+ const resyncActiveJob = useCallback(async () => {
+ if (
+ !isDefined(fetchJobStatus) ||
+ !isDefined(activeJobId) ||
+ !isDefined(activeJobContext)
+ ) {
+ return;
+ }
+
+ const jobStatus = await fetchJobStatus(activeJobId, activeJobContext).catch(
+ () => undefined,
+ );
+
+ if (isNull(jobStatus)) {
+ stopTrackingJob(activeJobId);
+ return;
+ }
+
+ if (isDefined(jobStatus)) {
+ dispatchBrowserEvent<TrackedJobStatus>(
+ QUEUE_JOB_BROWSER_EVENT_NAME,
+ jobStatus,
+ );
+ }
+ }, [activeJobContext, activeJobId, fetchJobStatus, stopTrackingJob]);
+
+ useListenToBrowserEvent({
+ eventName: SSE_CLIENT_RECONNECTED_EVENT_NAME,
+ onBrowserEvent: resyncActiveJob,
+ });
+
const trackJob = (job: TrackedQueueJob<TContext>) => {
setTriggeredJob(job);
};
diff --git a/packages/twenty-front/src/modules/settings/applications/graphql/queries/findUninstallApplicationJobStatus.ts b/packages/twenty-front/src/modules/settings/applications/graphql/queries/findUninstallApplicationJobStatus.ts
index 125786e9939..0f8a93344fa 100644
--- a/packages/twenty-front/src/modules/settings/applications/graphql/queries/findUninstallApplicationJobStatus.ts
+++ b/packages/twenty-front/src/modules/settings/applications/graphql/queries/findUninstallApplicationJobStatus.ts
@@ -1,9 +1,13 @@
import gql from 'graphql-tag';
export const FIND_UNINSTALL_APPLICATION_JOB_STATUS = gql`
- query FindUninstallApplicationJobStatus($universalIdentifier: String!) {
+ query FindUninstallApplicationJobStatus(
+ $universalIdentifier: String!
+ $jobId: String
+ ) {
findUninstallApplicationJobStatus(
universalIdentifier: $universalIdentifier
+ jobId: $jobId
) {
jobId
state
diff --git a/packages/twenty-front/src/modules/settings/applications/hooks/useUninstallApplication.ts b/packages/twenty-front/src/modules/settings/applications/hooks/useUninstallApplication.ts
index 10a577893e0..951a4e02a3e 100644
--- a/packages/twenty-front/src/modules/settings/applications/hooks/useUninstallApplication.ts
+++ b/packages/twenty-front/src/modules/settings/applications/hooks/useUninstallApplication.ts
@@ -3,7 +3,7 @@ import { useTrackedQueueJob } from '@/queue-job/hooks/useTrackedQueueJob';
import { type TrackedJobStatus } from '@/queue-job/types/TrackedJobStatus';
import { isTerminalJobState } from '@/queue-job/utils/isTerminalJobState';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
-import { useMutation, useQuery } from '@apollo/client/react';
+import { useLazyQuery, useMutation, useQuery } from '@apollo/client/react';
import { t } from '@lingui/core/macro';
import { isNonEmptyString } from '@sniptt/guards';
import { useCallback } from 'react';
@@ -27,6 +27,10 @@ export const useUninstallApplication = ({
const { enqueueToast } = useToast();
const [triggerUninstallApplication, { loading: isTriggeringUninstall }] =
useMutation(TriggerUninstallApplicationDocument);
+ const [findUninstallApplicationJobStatus] = useLazyQuery(
+ FindUninstallApplicationJobStatusDocument,
+ { fetchPolicy: 'network-only' },
+ );
const setCurrentWorkspace = useSetAtomState(currentWorkspaceState);
const { data: jobStatusData } = useQuery(
@@ -85,9 +89,21 @@ export const useUninstallApplication = ({
[enqueueToast, onCompleted, setCurrentWorkspace],
);
+ const fetchUninstallJobStatus = useCallback(
+ async (jobId: string, trackedUninstallIdentifier: string) => {
+ const { data } = await findUninstallApplicationJobStatus({
+ variables: { universalIdentifier: trackedUninstallIdentifier, jobId },
+ });
+
+ return data?.findUninstallApplicationJobStatus;
+ },
+ [findUninstallApplicationJobStatus],
+ );
+
const { activeJobId, activeJobProgress, trackJob } = useTrackedQueueJob({
runningJob,
onQueueJobSettled: handleUninstallJobSettled,
+ fetchJobStatus: fetchUninstallJobStatus,
});
const uninstall = async (): Promise<void> => {
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-install/application-install.resolver.ts b/packages/twenty-server/src/engine/core-modules/application/application-install/application-install.resolver.ts
index 1e3cc448de2..8d3b0ce5cd1 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-install/application-install.resolver.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-install/application-install.resolver.ts
@@ -327,11 +327,14 @@ export class ApplicationInstallResolver {
requireApplicationRegistrationOwnership: false,
})
universalIdentifier: string,
+ @Args('jobId', { type: () => String, nullable: true })
+ jobId: string | undefined,
@AuthWorkspace() workspace: WorkspaceEntity,
): Promise<JobStatusDTO | null> {
return this.applicationLifecycleJobService.findInstallApplicationJobStatus({
universalIdentifier,
workspaceId: workspace.id,
+ jobId,
});
}
@@ -346,10 +349,12 @@ export class ApplicationInstallResolver {
requireApplicationRegistrationOwnership: false,
})
universalIdentifier: string,
+ @Args('jobId', { type: () => String, nullable: true })
+ jobId: string | undefined,
@AuthWorkspace() workspace: WorkspaceEntity,
): Promise<JobStatusDTO | null> {
return this.applicationLifecycleJobService.findUninstallApplicationJobStatus(
- { universalIdentifier, workspaceId: workspace.id },
+ { universalIdentifier, workspaceId: workspace.id, jobId },
);
}
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-install/services/application-lifecycle-job.service.ts b/packages/twenty-server/src/engine/core-modules/application/application-install/services/application-lifecycle-job.service.ts
index d50f9600784..1508760b786 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-install/services/application-lifecycle-job.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-install/services/application-lifecycle-job.service.ts
@@ -39,6 +39,10 @@ type LifecycleJobTarget = {
workspaceId: string;
};
+type LifecycleJobStatusTarget = LifecycleJobTarget & {
+ jobId?: string;
+};
+
const CONFLICTING_OPERATIONS: Record<
ApplicationLifecycleOperation,
ApplicationLifecycleOperation[]
@@ -153,19 +157,19 @@ export class ApplicationLifecycleJobService {
}
findInstallApplicationJobStatus(
- target: LifecycleJobTarget,
+ target: LifecycleJobStatusTarget,
): Promise<JobStatusDTO | null> {
return this.findLifecycleJobStatus({ operation: 'install', ...target });
}
findUninstallApplicationJobStatus(
- target: LifecycleJobTarget,
+ target: LifecycleJobStatusTarget,
): Promise<JobStatusDTO | null> {
return this.findLifecycleJobStatus({ operation: 'uninstall', ...target });
}
findUpgradeApplicationJobStatus(
- target: LifecycleJobTarget,
+ target: LifecycleJobStatusTarget,
): Promise<JobStatusDTO | null> {
return this.findLifecycleJobStatus({ operation: 'upgrade', ...target });
}
@@ -268,16 +272,24 @@ export class ApplicationLifecycleJobService {
operation,
universalIdentifier,
workspaceId,
- }: LifecycleJobTarget & {
+ jobId: requestedJobId,
+ }: LifecycleJobStatusTarget & {
operation: ApplicationLifecycleOperation;
}): Promise<JobStatusDTO | null> {
- const jobId = await this.findInFlightJobId(
- buildApplicationLifecycleJobId({
- operation,
- workspaceId,
- universalIdentifier,
- }),
- );
+ const jobIdPrefix = buildApplicationLifecycleJobId({
+ operation,
+ workspaceId,
+ universalIdentifier,
+ });
+
+ if (
+ isDefined(requestedJobId) &&
+ getQueueJobIdPrefix(requestedJobId) !== jobIdPrefix
+ ) {
+ return null;
+ }
+
+ const jobId = requestedJobId ?? (await this.findInFlightJobId(jobIdPrefix));
if (!isDefined(jobId)) {
return null;
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-upgrade/application-upgrade.resolver.ts b/packages/twenty-server/src/engine/core-modules/application/application-upgrade/application-upgrade.resolver.ts
index 1f4a948f80e..85fb8c26231 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-upgrade/application-upgrade.resolver.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-upgrade/application-upgrade.resolver.ts
@@ -100,11 +100,14 @@ export class ApplicationUpgradeResolver {
requireApplicationRegistrationOwnership: false,
})
universalIdentifier: string,
+ @Args('jobId', { type: () => String, nullable: true })
+ jobId: string | undefined,
@AuthWorkspace() workspace: WorkspaceEntity,
): Promise<JobStatusDTO | null> {
return this.applicationLifecycleJobService.findUpgradeApplicationJobStatus({
universalIdentifier,
workspaceId: workspace.id,
+ jobId,
});
}
}
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/application-lifecycle-job.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/application-lifecycle-job.integration-spec.ts
index 2a2e44cdf99..e35a6a825e8 100644
--- a/packages/twenty-server/test/integration/metadata/suites/application/application-lifecycle-job.integration-spec.ts
+++ b/packages/twenty-server/test/integration/metadata/suites/application/application-lifecycle-job.integration-spec.ts
@@ -52,9 +52,13 @@ const FIND_UPGRADE_APPLICATION_JOB_STATUS = gql`
`;
const FIND_UNINSTALL_APPLICATION_JOB_STATUS = gql`
- query FindUninstallApplicationJobStatus($universalIdentifier: String!) {
+ query FindUninstallApplicationJobStatus(
+ $universalIdentifier: String!
+ $jobId: String
+ ) {
findUninstallApplicationJobStatus(
universalIdentifier: $universalIdentifier
+ jobId: $jobId
) {
jobId
state
@@ -80,10 +84,13 @@ describe('Application lifecycle jobs', () => {
return response.body.data.triggerUninstallApplication.jobId as string;
};
- const findUninstallApplicationJobStatus = async () => {
+ const findUninstallApplicationJobStatus = async ({
+ universalIdentifier = appId,
+ jobId,
+ }: { universalIdentifier?: string; jobId?: string } = {}) => {
const response = await makeMetadataApiRequest({
query: FIND_UNINSTALL_APPLICATION_JOB_STATUS,
- variables: { universalIdentifier: appId },
+ variables: { universalIdentifier, jobId },
});
expect(response.body.errors).toBeUndefined();
@@ -163,6 +170,18 @@ describe('Application lifecycle jobs', () => {
expect(await findUninstallApplicationJobStatus()).toBeNull();
+ expect(await findUninstallApplicationJobStatus({ jobId })).toMatchObject({
+ jobId,
+ state: JobStateEnum.COMPLETED,
+ });
+
+ expect(
+ await findUninstallApplicationJobStatus({
+ universalIdentifier: uuidv4(),
+ jobId,
+ }),
+ ).toBeNull();
+
const { data } = await findManyApplications({ expectToFail: false });
expect(