Skip to content

The open alternative to Salesforce, designed for AI.

feat(files): upload workspace logos and profile pictures with direct upload (#26382)

martmullb070767bf703
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
index cbb32bf544e..562c13b362e 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
@@ -3735,11 +3735,11 @@ type MinimalMetadata {
type Query {
navigationMenuItems: [NavigationMenuItem!]!
navigationMenuItem(id: UUID!): NavigationMenuItem
- applicationSdkClientChecksums(applicationId: UUID!): SdkClientChecksums
- isApplicationStopped(applicationUniversalIdentifier: String!): Boolean!
enterprisePortalSession(returnUrlPath: String): String
enterpriseCheckoutSession(billingInterval: String): String
enterpriseSubscriptionStatus: EnterpriseSubscriptionStatusDTO
+ applicationSdkClientChecksums(applicationId: UUID!): SdkClientChecksums
+ isApplicationStopped(applicationUniversalIdentifier: String!): Boolean!
usageLimits: [UsageLimit!]!
usageQuotasWithConsumption: [UsageQuotaWithConsumption!]!
usageQuotaDefinitions: UsageQuotaDefinitions!
@@ -4015,8 +4015,10 @@ type Mutation {
refreshEnterpriseValidityToken: Boolean!
releaseEnterpriseServerBinding: EnterpriseLicenseInfoDTO!
setEnterpriseKey(enterpriseKey: String!): EnterpriseLicenseInfoDTO!
- uploadWorkspaceLogo(file: Upload!): FileWithSignedUrl!
- uploadWorkspaceMemberProfilePicture(file: Upload!): FileWithSignedUrl!
+ uploadWorkspaceLogo(file: Upload!): FileWithSignedUrl! @deprecated(reason: "Use createFileUpload with the CorePicture folder and completeWorkspaceLogoUpload, which send the logo straight to file storage.")
+ uploadWorkspaceMemberProfilePicture(file: Upload!): FileWithSignedUrl! @deprecated(reason: "Use createFileUpload with the CorePicture folder and completeWorkspaceMemberProfilePictureUpload, which send the picture straight to file storage.")
+ completeWorkspaceLogoUpload(fileId: String!): FileWithSignedUrl!
+ completeWorkspaceMemberProfilePictureUpload(fileId: String!): FileWithSignedUrl!
uploadFilesFieldFileByUniversalIdentifier(file: Upload!, fieldMetadataUniversalIdentifier: String!): FileWithSignedUrl!
createUsageLimit(input: CreateUsageLimitInput!): UsageLimit!
updateUsageLimit(input: UpdateUsageLimitInput!): UsageLimit!
@@ -4219,7 +4221,9 @@ type Mutation {
signUp(email: String!, password: String!, captchaToken: String, locale: String, verifyEmailRedirectPath: String): AvailableWorkspacesAndAccessTokens!
signUpInWorkspace(email: String!, password: String!, workspaceId: UUID, workspaceInviteHash: String, workspacePersonalInviteToken: String, captchaToken: String, locale: String, verifyEmailRedirectPath: String): SignUp!
signUpInNewWorkspace(input: SignUpInNewWorkspaceInput): SignUp!
- uploadNewWorkspaceLogo(workspaceId: String!, file: Upload!): FileWithSignedUrl!
+ uploadNewWorkspaceLogo(workspaceId: String!, file: Upload!): FileWithSignedUrl! @deprecated(reason: "Use createNewWorkspaceLogoUpload and completeNewWorkspaceLogoUpload, which send the logo straight to file storage.")
+ createNewWorkspaceLogoUpload(workspaceId: String!, filename: String!, size: Float!): FileUploadTarget!
+ completeNewWorkspaceLogoUpload(workspaceId: String!, fileId: String!): FileWithSignedUrl!
generateTransientToken: TransientToken!
getAuthTokensFromLoginToken(loginToken: String!, origin: String!): AuthTokens!
getAuthTokensFromSSOExchangeToken(ssoExchangeToken: String!): AuthTokens!
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.ts b/packages/twenty-client-sdk/src/metadata/generated/schema.ts
index 90d89d127ef..79d50db3fbb 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/schema.ts
+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.ts
@@ -3279,11 +3279,11 @@ export interface MinimalMetadata {
export interface Query {
navigationMenuItems: NavigationMenuItem[]
navigationMenuItem?: NavigationMenuItem
- applicationSdkClientChecksums?: SdkClientChecksums
- isApplicationStopped: Scalars['Boolean']
enterprisePortalSession?: Scalars['String']
enterpriseCheckoutSession?: Scalars['String']
enterpriseSubscriptionStatus?: EnterpriseSubscriptionStatusDTO
+ applicationSdkClientChecksums?: SdkClientChecksums
+ isApplicationStopped: Scalars['Boolean']
usageLimits: UsageLimit[]
usageQuotasWithConsumption: UsageQuotaWithConsumption[]
usageQuotaDefinitions: UsageQuotaDefinitions
@@ -3428,8 +3428,12 @@ export interface Mutation {
refreshEnterpriseValidityToken: Scalars['Boolean']
releaseEnterpriseServerBinding: EnterpriseLicenseInfoDTO
setEnterpriseKey: EnterpriseLicenseInfoDTO
+ /** @deprecated Use createFileUpload with the CorePicture folder and completeWorkspaceLogoUpload, which send the logo straight to file storage. */
uploadWorkspaceLogo: FileWithSignedUrl
+ /** @deprecated Use createFileUpload with the CorePicture folder and completeWorkspaceMemberProfilePictureUpload, which send the picture straight to file storage. */
uploadWorkspaceMemberProfilePicture: FileWithSignedUrl
+ completeWorkspaceLogoUpload: FileWithSignedUrl
+ completeWorkspaceMemberProfilePictureUpload: FileWithSignedUrl
uploadFilesFieldFileByUniversalIdentifier: FileWithSignedUrl
createUsageLimit: UsageLimit
updateUsageLimit: UsageLimit
@@ -3635,7 +3639,10 @@ export interface Mutation {
signUp: AvailableWorkspacesAndAccessTokens
signUpInWorkspace: SignUp
signUpInNewWorkspace: SignUp
+ /** @deprecated Use createNewWorkspaceLogoUpload and completeNewWorkspaceLogoUpload, which send the logo straight to file storage. */
uploadNewWorkspaceLogo: FileWithSignedUrl
+ createNewWorkspaceLogoUpload: FileUploadTarget
+ completeNewWorkspaceLogoUpload: FileWithSignedUrl
generateTransientToken: TransientToken
getAuthTokensFromLoginToken: AuthTokens
getAuthTokensFromSSOExchangeToken: AuthTokens
@@ -7111,11 +7118,11 @@ export interface MinimalMetadataGenqlSelection{
export interface QueryGenqlSelection{
navigationMenuItems?: NavigationMenuItemGenqlSelection
navigationMenuItem?: (NavigationMenuItemGenqlSelection & { __args: {id: Scalars['UUID']} })
- applicationSdkClientChecksums?: (SdkClientChecksumsGenqlSelection & { __args: {applicationId: Scalars['UUID']} })
- isApplicationStopped?: { __args: {applicationUniversalIdentifier: Scalars['String']} }
enterprisePortalSession?: { __args: {returnUrlPath?: (Scalars['String'] | null)} } | boolean | number
enterpriseCheckoutSession?: { __args: {billingInterval?: (Scalars['String'] | null)} } | boolean | number
enterpriseSubscriptionStatus?: EnterpriseSubscriptionStatusDTOGenqlSelection
+ applicationSdkClientChecksums?: (SdkClientChecksumsGenqlSelection & { __args: {applicationId: Scalars['UUID']} })
+ isApplicationStopped?: { __args: {applicationUniversalIdentifier: Scalars['String']} }
usageLimits?: UsageLimitGenqlSelection
usageQuotasWithConsumption?: UsageQuotaWithConsumptionGenqlSelection
usageQuotaDefinitions?: UsageQuotaDefinitionsGenqlSelection
@@ -7309,8 +7316,12 @@ export interface MutationGenqlSelection{
refreshEnterpriseValidityToken?: boolean | number
releaseEnterpriseServerBinding?: EnterpriseLicenseInfoDTOGenqlSelection
setEnterpriseKey?: (EnterpriseLicenseInfoDTOGenqlSelection & { __args: {enterpriseKey: Scalars['String']} })
+ /** @deprecated Use createFileUpload with the CorePicture folder and completeWorkspaceLogoUpload, which send the logo straight to file storage. */
uploadWorkspaceLogo?: (FileWithSignedUrlGenqlSelection & { __args: {file: Scalars['Upload']} })
+ /** @deprecated Use createFileUpload with the CorePicture folder and completeWorkspaceMemberProfilePictureUpload, which send the picture straight to file storage. */
uploadWorkspaceMemberProfilePicture?: (FileWithSignedUrlGenqlSelection & { __args: {file: Scalars['Upload']} })
+ completeWorkspaceLogoUpload?: (FileWithSignedUrlGenqlSelection & { __args: {fileId: Scalars['String']} })
+ completeWorkspaceMemberProfilePictureUpload?: (FileWithSignedUrlGenqlSelection & { __args: {fileId: Scalars['String']} })
uploadFilesFieldFileByUniversalIdentifier?: (FileWithSignedUrlGenqlSelection & { __args: {file: Scalars['Upload'], fieldMetadataUniversalIdentifier: Scalars['String']} })
createUsageLimit?: (UsageLimitGenqlSelection & { __args: {input: CreateUsageLimitInput} })
updateUsageLimit?: (UsageLimitGenqlSelection & { __args: {input: UpdateUsageLimitInput} })
@@ -7516,7 +7527,10 @@ export interface MutationGenqlSelection{
signUp?: (AvailableWorkspacesAndAccessTokensGenqlSelection & { __args: {email: Scalars['String'], password: Scalars['String'], captchaToken?: (Scalars['String'] | null), locale?: (Scalars['String'] | null), verifyEmailRedirectPath?: (Scalars['String'] | null)} })
signUpInWorkspace?: (SignUpGenqlSelection & { __args: {email: Scalars['String'], password: Scalars['String'], workspaceId?: (Scalars['UUID'] | null), workspaceInviteHash?: (Scalars['String'] | null), workspacePersonalInviteToken?: (Scalars['String'] | null), captchaToken?: (Scalars['String'] | null), locale?: (Scalars['String'] | null), verifyEmailRedirectPath?: (Scalars['String'] | null)} })
signUpInNewWorkspace?: (SignUpGenqlSelection & { __args?: {input?: (SignUpInNewWorkspaceInput | null)} })
+ /** @deprecated Use createNewWorkspaceLogoUpload and completeNewWorkspaceLogoUpload, which send the logo straight to file storage. */
uploadNewWorkspaceLogo?: (FileWithSignedUrlGenqlSelection & { __args: {workspaceId: Scalars['String'], file: Scalars['Upload']} })
+ createNewWorkspaceLogoUpload?: (FileUploadTargetGenqlSelection & { __args: {workspaceId: Scalars['String'], filename: Scalars['String'], size: Scalars['Float']} })
+ completeNewWorkspaceLogoUpload?: (FileWithSignedUrlGenqlSelection & { __args: {workspaceId: Scalars['String'], fileId: Scalars['String']} })
generateTransientToken?: TransientTokenGenqlSelection
getAuthTokensFromLoginToken?: (AuthTokensGenqlSelection & { __args: {loginToken: Scalars['String'], origin: Scalars['String']} })
getAuthTokensFromSSOExchangeToken?: (AuthTokensGenqlSelection & { __args: {ssoExchangeToken: Scalars['String']} })
diff --git a/packages/twenty-client-sdk/src/metadata/generated/types.ts b/packages/twenty-client-sdk/src/metadata/generated/types.ts
index bade3b01483..75254e91235 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/types.ts
+++ b/packages/twenty-client-sdk/src/metadata/generated/types.ts
@@ -7325,24 +7325,6 @@ export default {
]
}
],
- "applicationSdkClientChecksums": [
- 96,
- {
- "applicationId": [
- 3,
- "UUID!"
- ]
- }
- ],
- "isApplicationStopped": [
- 8,
- {
- "applicationUniversalIdentifier": [
- 1,
- "String!"
- ]
- }
- ],
"enterprisePortalSession": [
1,
{
@@ -7362,6 +7344,24 @@ export default {
"enterpriseSubscriptionStatus": [
152
],
+ "applicationSdkClientChecksums": [
+ 96,
+ {
+ "applicationId": [
+ 3,
+ "UUID!"
+ ]
+ }
+ ],
+ "isApplicationStopped": [
+ 8,
+ {
+ "applicationUniversalIdentifier": [
+ 1,
+ "String!"
+ ]
+ }
+ ],
"usageLimits": [
160
],
@@ -8680,6 +8680,24 @@ export default {
]
}
],
+ "completeWorkspaceLogoUpload": [
+ 161,
+ {
+ "fileId": [
+ 1,
+ "String!"
+ ]
+ }
+ ],
+ "completeWorkspaceMemberProfilePictureUpload": [
+ 161,
+ {
+ "fileId": [
+ 1,
+ "String!"
+ ]
+ }
+ ],
"uploadFilesFieldFileByUniversalIdentifier": [
161,
{
@@ -10674,6 +10692,36 @@ export default {
]
}
],
+ "createNewWorkspaceLogoUpload": [
+ 162,
+ {
+ "workspaceId": [
+ 1,
+ "String!"
+ ],
+ "filename": [
+ 1,
+ "String!"
+ ],
+ "size": [
+ 15,
+ "Float!"
+ ]
+ }
+ ],
+ "completeNewWorkspaceLogoUpload": [
+ 161,
+ {
+ "workspaceId": [
+ 1,
+ "String!"
+ ],
+ "fileId": [
+ 1,
+ "String!"
+ ]
+ }
+ ],
"generateTransientToken": [
291
],
diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts
index cd313183efd..e16b63b72fb 100644
--- a/packages/twenty-front/src/generated-metadata/graphql.ts
+++ b/packages/twenty-front/src/generated-metadata/graphql.ts
@@ -3042,6 +3042,9 @@ export type Mutation = {
completeApplicationFileUploads: CompleteApplicationFileUploadsResult;
completeBookCallOnboardingStep: OnboardingStepSuccess;
completeFileUpload: FileWithSignedUrl;
+ completeNewWorkspaceLogoUpload: FileWithSignedUrl;
+ completeWorkspaceLogoUpload: FileWithSignedUrl;
+ completeWorkspaceMemberProfilePictureUpload: FileWithSignedUrl;
createApiKey: ApiKey;
createAppMessageChannel: MessageChannel;
createApplicationFileUploads: CreateApplicationFileUploadsResult;
@@ -3063,6 +3066,7 @@ export type Mutation = {
createManyViewGroups: Array<ViewGroup>;
createMessageSuppression: MessageSuppression;
createNavigationMenuItem: NavigationMenuItem;
+ createNewWorkspaceLogoUpload: FileUploadTarget;
createOIDCIdentityProvider: SetupSso;
createObjectEvent: Analytics;
createOneAgent: Agent;
@@ -3272,8 +3276,11 @@ export type Mutation = {
uploadAppTarball: ApplicationRegistration;
uploadApplicationFile: File;
uploadFilesFieldFileByUniversalIdentifier: FileWithSignedUrl;
+ /** @deprecated Use createNewWorkspaceLogoUpload and completeNewWorkspaceLogoUpload, which send the logo straight to file storage. */
uploadNewWorkspaceLogo: FileWithSignedUrl;
+ /** @deprecated Use createFileUpload with the CorePicture folder and completeWorkspaceLogoUpload, which send the logo straight to file storage. */
uploadWorkspaceLogo: FileWithSignedUrl;
+ /** @deprecated Use createFileUpload with the CorePicture folder and completeWorkspaceMemberProfilePictureUpload, which send the picture straight to file storage. */
uploadWorkspaceMemberProfilePicture: FileWithSignedUrl;
upsertFieldPermissions: Array<FieldPermission>;
upsertFieldsWidget: View;
@@ -3385,6 +3392,22 @@ export type MutationCompleteFileUploadArgs = {
};
+export type MutationCompleteNewWorkspaceLogoUploadArgs = {
+ fileId: Scalars['String']['input'];
+ workspaceId: Scalars['String']['input'];
+};
+
+
+export type MutationCompleteWorkspaceLogoUploadArgs = {
+ fileId: Scalars['String']['input'];
+};
+
+
+export type MutationCompleteWorkspaceMemberProfilePictureUploadArgs = {
+ fileId: Scalars['String']['input'];
+};
+
+
export type MutationCreateApiKeyArgs = {
input: CreateApiKeyInput;
};
@@ -3486,6 +3509,13 @@ export type MutationCreateNavigationMenuItemArgs = {
};
+export type MutationCreateNewWorkspaceLogoUploadArgs = {
+ filename: Scalars['String']['input'];
+ size: Scalars['Float']['input'];
+ workspaceId: Scalars['String']['input'];
+};
+
+
export type MutationCreateOidcIdentityProviderArgs = {
input: SetupOidcSsoInput;
};
@@ -8062,6 +8092,23 @@ export type AuthorizeAppMutationVariables = Exact<{
export type AuthorizeAppMutation = { __typename?: 'Mutation', authorizeApp: { __typename?: 'AuthorizeApp', redirectUrl: string } };
+export type CompleteNewWorkspaceLogoUploadMutationVariables = Exact<{
+ workspaceId: Scalars['String']['input'];
+ fileId: Scalars['String']['input'];
+}>;
+
+
+export type CompleteNewWorkspaceLogoUploadMutation = { __typename?: 'Mutation', completeNewWorkspaceLogoUpload: { __typename?: 'FileWithSignedUrl', id: string, path: string, size: number, createdAt: string, url: string } };
+
+export type CreateNewWorkspaceLogoUploadMutationVariables = Exact<{
+ workspaceId: Scalars['String']['input'];
+ filename: Scalars['String']['input'];
+ size: Scalars['Float']['input'];
+}>;
+
+
+export type CreateNewWorkspaceLogoUploadMutation = { __typename?: 'Mutation', createNewWorkspaceLogoUpload: { __typename?: 'FileUploadTarget', fileId: string, uploadUrl: string, contentType: string, expiresAt: string } };
+
export type EmailPasswordResetLinkMutationVariables = Exact<{
email: Scalars['String']['input'];
workspaceId?: InputMaybe<Scalars['UUID']['input']>;
@@ -8235,14 +8282,6 @@ export type UpdatePasswordViaResetTokenMutationVariables = Exact<{
export type UpdatePasswordViaResetTokenMutation = { __typename?: 'Mutation', updatePasswordViaResetToken: { __typename?: 'InvalidatePassword', success: boolean } };
-export type UploadNewWorkspaceLogoMutationVariables = Exact<{
- workspaceId: Scalars['String']['input'];
- file: Scalars['Upload']['input'];
-}>;
-
-
-export type UploadNewWorkspaceLogoMutation = { __typename?: 'Mutation', uploadNewWorkspaceLogo: { __typename?: 'FileWithSignedUrl', url: string } };
-
export type VerifyEmailAndGetLoginTokenMutationVariables = Exact<{
emailVerificationToken: Scalars['String']['input'];
email: Scalars['String']['input'];
@@ -9708,12 +9747,12 @@ export type UpdateLabPublicFeatureFlagMutationVariables = Exact<{
export type UpdateLabPublicFeatureFlagMutation = { __typename?: 'Mutation', updateLabPublicFeatureFlag: { __typename?: 'FeatureFlag', key: FeatureFlagKey, value: boolean } };
-export type UploadWorkspaceMemberProfilePictureMutationVariables = Exact<{
- file: Scalars['Upload']['input'];
+export type CompleteWorkspaceMemberProfilePictureUploadMutationVariables = Exact<{
+ fileId: Scalars['String']['input'];
}>;
-export type UploadWorkspaceMemberProfilePictureMutation = { __typename?: 'Mutation', uploadWorkspaceMemberProfilePicture: { __typename?: 'FileWithSignedUrl', id: string, url: string } };
+export type CompleteWorkspaceMemberProfilePictureUploadMutation = { __typename?: 'Mutation', completeWorkspaceMemberProfilePictureUpload: { __typename?: 'FileWithSignedUrl', id: string, path: string, size: number, createdAt: string, url: string } };
export type RevokeAllOtherUserSessionsMutationVariables = Exact<{ [key: string]: never; }>;
@@ -10190,6 +10229,13 @@ export type ActivateWorkspaceMutationVariables = Exact<{
export type ActivateWorkspaceMutation = { __typename?: 'Mutation', activateWorkspace: { __typename?: 'Workspace', id: string } };
+export type CompleteWorkspaceLogoUploadMutationVariables = Exact<{
+ fileId: Scalars['String']['input'];
+}>;
+
+
+export type CompleteWorkspaceLogoUploadMutation = { __typename?: 'Mutation', completeWorkspaceLogoUpload: { __typename?: 'FileWithSignedUrl', id: string, path: string, size: number, createdAt: string, url: string } };
+
export type DeleteCurrentWorkspaceMutationVariables = Exact<{ [key: string]: never; }>;
@@ -10209,13 +10255,6 @@ export type UpdateWorkspaceAllowedIframeOriginsMutationVariables = Exact<{
export type UpdateWorkspaceAllowedIframeOriginsMutation = { __typename?: 'Mutation', updateWorkspaceAllowedIframeOrigins: { __typename?: 'Workspace', id: string, allowedIframeOrigins?: Array<string> | null } };
-export type UploadWorkspaceLogoMutationVariables = Exact<{
- file: Scalars['Upload']['input'];
-}>;
-
-
-export type UploadWorkspaceLogoMutation = { __typename?: 'Mutation', uploadWorkspaceLogo: { __typename?: 'FileWithSignedUrl', url: string } };
-
export type CheckCustomDomainValidRecordsMutationVariables = Exact<{ [key: string]: never; }>;
@@ -10356,6 +10395,8 @@ export const FindOneApplicationNameDocument = {"kind":"Document","definitions":[
export const FindOneApplicationSummaryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindOneApplicationSummary"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findOneApplication"},"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"}}]}}]}}]} as unknown as DocumentNode<FindOneApplicationSummaryQuery, FindOneApplicationSummaryQueryVariables>;
export const IsApplicationStoppedDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"IsApplicationStopped"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationUniversalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"isApplicationStopped"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationUniversalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationUniversalIdentifier"}}}]}]}}]} as unknown as DocumentNode<IsApplicationStoppedQuery, IsApplicationStoppedQueryVariables>;
export const AuthorizeAppDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"authorizeApp"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"clientId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"codeChallenge"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"redirectUrl"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"state"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"issuer"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"authorizeApp"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"clientId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"clientId"}}},{"kind":"Argument","name":{"kind":"Name","value":"codeChallenge"},"value":{"kind":"Variable","name":{"kind":"Name","value":"codeChallenge"}}},{"kind":"Argument","name":{"kind":"Name","value":"redirectUrl"},"value":{"kind":"Variable","name":{"kind":"Name","value":"redirectUrl"}}},{"kind":"Argument","name":{"kind":"Name","value":"state"},"value":{"kind":"Variable","name":{"kind":"Name","value":"state"}}},{"kind":"Argument","name":{"kind":"Name","value":"issuer"},"value":{"kind":"Variable","name":{"kind":"Name","value":"issuer"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"redirectUrl"}}]}}]}}]} as unknown as DocumentNode<AuthorizeAppMutation, AuthorizeAppMutationVariables>;
+export const CompleteNewWorkspaceLogoUploadDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CompleteNewWorkspaceLogoUpload"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fileId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"completeNewWorkspaceLogoUpload"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"fileId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fileId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"path"}},{"kind":"Field","name":{"kind":"Name","value":"size"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]} as unknown as DocumentNode<CompleteNewWorkspaceLogoUploadMutation, CompleteNewWorkspaceLogoUploadMutationVariables>;
+export const CreateNewWorkspaceLogoUploadDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateNewWorkspaceLogoUpload"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filename"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"size"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Float"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createNewWorkspaceLogoUpload"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"filename"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filename"}}},{"kind":"Argument","name":{"kind":"Name","value":"size"},"value":{"kind":"Variable","name":{"kind":"Name","value":"size"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"fileId"}},{"kind":"Field","name":{"kind":"Name","value":"uploadUrl"}},{"kind":"Field","name":{"kind":"Name","value":"contentType"}},{"kind":"Field","name":{"kind":"Name","value":"expiresAt"}}]}}]}}]} as unknown as DocumentNode<CreateNewWorkspaceLogoUploadMutation, CreateNewWorkspaceLogoUploadMutationVariables>;
export const EmailPasswordResetLinkDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"EmailPasswordResetLink"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"captchaToken"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"emailPasswordResetLink"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"workspaceId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"captchaToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"captchaToken"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"success"}}]}}]}}]} as unknown as DocumentNode<EmailPasswordResetLinkMutation, EmailPasswordResetLinkMutationVariables>;
export const GenerateApiKeyTokenDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"GenerateApiKeyToken"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"apiKeyId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"expiresAt"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"generateApiKeyToken"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"apiKeyId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"apiKeyId"}}},{"kind":"Argument","name":{"kind":"Name","value":"expiresAt"},"value":{"kind":"Variable","name":{"kind":"Name","value":"expiresAt"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"token"}}]}}]}}]} as unknown as DocumentNode<GenerateApiKeyTokenMutation, GenerateApiKeyTokenMutationVariables>;
export const GeneratePlaygroundTokenDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"GeneratePlaygroundToken"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"generatePlaygroundToken"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"token"}},{"kind":"Field","name":{"kind":"Name","value":"expiresAt"}}]}}]}}]} as unknown as DocumentNode<GeneratePlaygroundTokenMutation, GeneratePlaygroundTokenMutationVariables>;
@@ -10378,7 +10419,6 @@ export const SignUpInNewWorkspaceDocument = {"kind":"Document","definitions":[{"
export const SignUpInWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"SignUpInWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"password"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceInviteHash"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspacePersonalInviteToken"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}},"defaultValue":{"kind":"NullValue"}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"captchaToken"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"locale"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"verifyEmailRedirectPath"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"signUpInWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"password"},"value":{"kind":"Variable","name":{"kind":"Name","value":"password"}}},{"kind":"Argument","name":{"kind":"Name","value":"workspaceInviteHash"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceInviteHash"}}},{"kind":"Argument","name":{"kind":"Name","value":"workspacePersonalInviteToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspacePersonalInviteToken"}}},{"kind":"Argument","name":{"kind":"Name","value":"captchaToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"captchaToken"}}},{"kind":"Argument","name":{"kind":"Name","value":"workspaceId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"locale"},"value":{"kind":"Variable","name":{"kind":"Name","value":"locale"}}},{"kind":"Argument","name":{"kind":"Name","value":"verifyEmailRedirectPath"},"value":{"kind":"Variable","name":{"kind":"Name","value":"verifyEmailRedirectPath"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"loginToken"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"AuthTokenFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceUrls"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"subdomainUrl"}},{"kind":"Field","name":{"kind":"Name","value":"customUrl"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AuthTokenFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AuthToken"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"token"}},{"kind":"Field","name":{"kind":"Name","value":"expiresAt"}}]}}]} as unknown as DocumentNode<SignUpInWorkspaceMutation, SignUpInWorkspaceMutationVariables>;
export const StopImpersonationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"StopImpersonation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"stopImpersonation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"canRestoreImpersonatorSession"}}]}}]}}]} as unknown as DocumentNode<StopImpersonationMutation, StopImpersonationMutationVariables>;
export const UpdatePasswordViaResetTokenDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdatePasswordViaResetToken"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"token"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"newPassword"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updatePasswordViaResetToken"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"passwordResetToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"token"}}},{"kind":"Argument","name":{"kind":"Name","value":"newPassword"},"value":{"kind":"Variable","name":{"kind":"Name","value":"newPassword"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"success"}}]}}]}}]} as unknown as DocumentNode<UpdatePasswordViaResetTokenMutation, UpdatePasswordViaResetTokenMutationVariables>;
-export const UploadNewWorkspaceLogoDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UploadNewWorkspaceLogo"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"file"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Upload"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"uploadNewWorkspaceLogo"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"file"},"value":{"kind":"Variable","name":{"kind":"Name","value":"file"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]} as unknown as DocumentNode<UploadNewWorkspaceLogoMutation, UploadNewWorkspaceLogoMutationVariables>;
export const VerifyEmailAndGetLoginTokenDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"VerifyEmailAndGetLoginToken"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emailVerificationToken"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"captchaToken"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"origin"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"verifyEmailAndGetLoginToken"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"emailVerificationToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emailVerificationToken"}}},{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"captchaToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"captchaToken"}}},{"kind":"Argument","name":{"kind":"Name","value":"origin"},"value":{"kind":"Variable","name":{"kind":"Name","value":"origin"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"loginToken"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"AuthTokenFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"workspaceUrls"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"WorkspaceUrlsFragment"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AuthTokenFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AuthToken"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"token"}},{"kind":"Field","name":{"kind":"Name","value":"expiresAt"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"WorkspaceUrlsFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"WorkspaceUrls"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"subdomainUrl"}},{"kind":"Field","name":{"kind":"Name","value":"customUrl"}}]}}]} as unknown as DocumentNode<VerifyEmailAndGetLoginTokenMutation, VerifyEmailAndGetLoginTokenMutationVariables>;
export const VerifyEmailAndGetWorkspaceAgnosticTokenDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"VerifyEmailAndGetWorkspaceAgnosticToken"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emailVerificationToken"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"captchaToken"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"verifyEmailAndGetWorkspaceAgnosticToken"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"emailVerificationToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emailVerificationToken"}}},{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"captchaToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"captchaToken"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"availableWorkspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"AvailableWorkspacesFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"tokens"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"AuthTokenPairFragment"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AvailableWorkspaceFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AvailableWorkspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"loginToken"}},{"kind":"Field","name":{"kind":"Name","value":"inviteHash"}},{"kind":"Field","name":{"kind":"Name","value":"personalInviteToken"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceUrls"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"subdomainUrl"}},{"kind":"Field","name":{"kind":"Name","value":"customUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"logo"}},{"kind":"Field","name":{"kind":"Name","value":"sso"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"issuer"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"status"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AuthTokenFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AuthToken"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"token"}},{"kind":"Field","name":{"kind":"Name","value":"expiresAt"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AvailableWorkspacesFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AvailableWorkspaces"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"availableWorkspacesForSignIn"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"AvailableWorkspaceFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"availableWorkspacesForSignUp"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"AvailableWorkspaceFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"AuthTokenPairFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AuthTokenPair"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accessOrWorkspaceAgnosticToken"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"AuthTokenFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"refreshToken"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"AuthTokenFragment"}}]}}]}}]} as unknown as DocumentNode<VerifyEmailAndGetWorkspaceAgnosticTokenMutation, VerifyEmailAndGetWorkspaceAgnosticTokenMutationVariables>;
export const CheckUserExistsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"CheckUserExists"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"captchaToken"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"checkUserExists"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"captchaToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"captchaToken"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"exists"}},{"kind":"Field","name":{"kind":"Name","value":"availableWorkspacesCount"}},{"kind":"Field","name":{"kind":"Name","value":"isEmailVerified"}}]}}]}}]} as unknown as DocumentNode<CheckUserExistsQuery, CheckUserExistsQueryVariables>;
@@ -10538,7 +10578,7 @@ export const EnterpriseSubscriptionStatusDocument = {"kind":"Document","definiti
export const EventLogsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"EventLogs"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"EventLogQueryInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"eventLogs"},"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":"records"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"event"}},{"kind":"Field","name":{"kind":"Name","value":"timestamp"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"properties"}},{"kind":"Field","name":{"kind":"Name","value":"recordId"}},{"kind":"Field","name":{"kind":"Name","value":"objectMetadataId"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"endCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}}]}}]}}]}}]} as unknown as DocumentNode<EventLogsQuery, EventLogsQueryVariables>;
export const EventLogsLiveDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"subscription","name":{"kind":"Name","value":"EventLogsLive"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"table"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"EventLogTable"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"eventLogsLive"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"table"},"value":{"kind":"Variable","name":{"kind":"Name","value":"table"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"event"}},{"kind":"Field","name":{"kind":"Name","value":"timestamp"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"properties"}},{"kind":"Field","name":{"kind":"Name","value":"recordId"}},{"kind":"Field","name":{"kind":"Name","value":"objectMetadataId"}}]}}]}}]} as unknown as DocumentNode<EventLogsLiveSubscription, EventLogsLiveSubscriptionVariables>;
export const UpdateLabPublicFeatureFlagDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateLabPublicFeatureFlag"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateLabPublicFeatureFlagInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateLabPublicFeatureFlag"},"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":"key"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]} as unknown as DocumentNode<UpdateLabPublicFeatureFlagMutation, UpdateLabPublicFeatureFlagMutationVariables>;
-export const UploadWorkspaceMemberProfilePictureDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UploadWorkspaceMemberProfilePicture"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"file"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Upload"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"uploadWorkspaceMemberProfilePicture"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"file"},"value":{"kind":"Variable","name":{"kind":"Name","value":"file"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]} as unknown as DocumentNode<UploadWorkspaceMemberProfilePictureMutation, UploadWorkspaceMemberProfilePictureMutationVariables>;
+export const CompleteWorkspaceMemberProfilePictureUploadDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CompleteWorkspaceMemberProfilePictureUpload"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fileId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"completeWorkspaceMemberProfilePictureUpload"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"fileId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fileId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"path"}},{"kind":"Field","name":{"kind":"Name","value":"size"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]} as unknown as DocumentNode<CompleteWorkspaceMemberProfilePictureUploadMutation, CompleteWorkspaceMemberProfilePictureUploadMutationVariables>;
export const RevokeAllOtherUserSessionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"RevokeAllOtherUserSessions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"revokeAllOtherUserSessions"}}]}}]} as unknown as DocumentNode<RevokeAllOtherUserSessionsMutation, RevokeAllOtherUserSessionsMutationVariables>;
export const RevokeUserSessionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"RevokeUserSession"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"userSessionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"revokeUserSession"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"userSessionId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"userSessionId"}}}]}]}}]} as unknown as DocumentNode<RevokeUserSessionMutation, RevokeUserSessionMutationVariables>;
export const CurrentUserSessionsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"CurrentUserSessions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentUserSessions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}},{"kind":"Field","name":{"kind":"Name","value":"authProvider"}},{"kind":"Field","name":{"kind":"Name","value":"isImpersonating"}},{"kind":"Field","name":{"kind":"Name","value":"userAgent"}},{"kind":"Field","name":{"kind":"Name","value":"ipAddress"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"lastActiveAt"}},{"kind":"Field","name":{"kind":"Name","value":"expiresAt"}},{"kind":"Field","name":{"kind":"Name","value":"isCurrent"}}]}}]}}]} as unknown as DocumentNode<CurrentUserSessionsQuery, CurrentUserSessionsQueryVariables>;
@@ -10601,10 +10641,10 @@ export const ResendWorkspaceInvitationDocument = {"kind":"Document","definitions
export const SendInvitationsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"SendInvitations"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emails"}},"type":{"kind":"NonNullType","type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"roleId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sendInvitations"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"emails"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emails"}}},{"kind":"Argument","name":{"kind":"Name","value":"roleId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"roleId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"success"}},{"kind":"Field","name":{"kind":"Name","value":"errors"}},{"kind":"Field","name":{"kind":"Name","value":"result"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"WorkspaceInvitation"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"roleId"}},{"kind":"Field","name":{"kind":"Name","value":"expiresAt"}}]}}]}}]}}]}}]} as unknown as DocumentNode<SendInvitationsMutation, SendInvitationsMutationVariables>;
export const GetWorkspaceInvitationsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaceInvitations"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findWorkspaceInvitations"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"roleId"}},{"kind":"Field","name":{"kind":"Name","value":"expiresAt"}}]}}]}}]} as unknown as DocumentNode<GetWorkspaceInvitationsQuery, GetWorkspaceInvitationsQueryVariables>;
export const ActivateWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ActivateWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ActivateWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"activateWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"data"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode<ActivateWorkspaceMutation, ActivateWorkspaceMutationVariables>;
+export const CompleteWorkspaceLogoUploadDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CompleteWorkspaceLogoUpload"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"fileId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"completeWorkspaceLogoUpload"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"fileId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"fileId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"path"}},{"kind":"Field","name":{"kind":"Name","value":"size"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]} as unknown as DocumentNode<CompleteWorkspaceLogoUploadMutation, CompleteWorkspaceLogoUploadMutationVariables>;
export const DeleteCurrentWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteCurrentWorkspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteCurrentWorkspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode<DeleteCurrentWorkspaceMutation, DeleteCurrentWorkspaceMutationVariables>;
export const UpdateWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"data"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"customDomain"}},{"kind":"Field","name":{"kind":"Name","value":"subdomain"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"logo"}},{"kind":"Field","name":{"kind":"Name","value":"allowImpersonation"}},{"kind":"Field","name":{"kind":"Name","value":"isPublicInviteLinkEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceDiscoverability"}},{"kind":"Field","name":{"kind":"Name","value":"isGoogleAuthEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"isMicrosoftAuthEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"isPasswordAuthEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"isTwoFactorAuthenticationEnforced"}},{"kind":"Field","name":{"kind":"Name","value":"isInternalMessagesImportEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"defaultRole"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"RoleFragment"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"RoleFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Role"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"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":"isEditable"}},{"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":"canBeAssignedToUsers"}},{"kind":"Field","name":{"kind":"Name","value":"canBeAssignedToAgents"}},{"kind":"Field","name":{"kind":"Name","value":"canBeAssignedToApiKeys"}}]}}]} as unknown as DocumentNode<UpdateWorkspaceMutation, UpdateWorkspaceMutationVariables>;
export const UpdateWorkspaceAllowedIframeOriginsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateWorkspaceAllowedIframeOrigins"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateWorkspaceAllowedIframeOriginsInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateWorkspaceAllowedIframeOrigins"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"data"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"allowedIframeOrigins"}}]}}]}}]} as unknown as DocumentNode<UpdateWorkspaceAllowedIframeOriginsMutation, UpdateWorkspaceAllowedIframeOriginsMutationVariables>;
-export const UploadWorkspaceLogoDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UploadWorkspaceLogo"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"file"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Upload"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"uploadWorkspaceLogo"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"file"},"value":{"kind":"Variable","name":{"kind":"Name","value":"file"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]} as unknown as DocumentNode<UploadWorkspaceLogoMutation, UploadWorkspaceLogoMutationVariables>;
export const CheckCustomDomainValidRecordsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CheckCustomDomainValidRecords"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"checkCustomDomainValidRecords"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"domain"}},{"kind":"Field","name":{"kind":"Name","value":"isCustomDomainEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"records"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"value"}},{"kind":"Field","name":{"kind":"Name","value":"validationType"}},{"kind":"Field","name":{"kind":"Name","value":"status"}}]}}]}}]}}]} as unknown as DocumentNode<CheckCustomDomainValidRecordsMutation, CheckCustomDomainValidRecordsMutationVariables>;
export const GetAiSystemPromptPreviewDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetAiSystemPromptPreview"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"getAiSystemPromptPreview"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sections"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"estimatedTokenCount"}}]}},{"kind":"Field","name":{"kind":"Name","value":"estimatedTokenCount"}}]}}]}}]} as unknown as DocumentNode<GetAiSystemPromptPreviewQuery, GetAiSystemPromptPreviewQueryVariables>;
export const GetPublicWorkspaceDataByIdDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetPublicWorkspaceDataById"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"getPublicWorkspaceDataById"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"logo"}}]}}]}}]} as unknown as DocumentNode<GetPublicWorkspaceDataByIdQuery, GetPublicWorkspaceDataByIdQueryVariables>;
diff --git a/packages/twenty-front/src/modules/auth/graphql/mutations/completeNewWorkspaceLogoUpload.ts b/packages/twenty-front/src/modules/auth/graphql/mutations/completeNewWorkspaceLogoUpload.ts
new file mode 100644
index 00000000000..e1bffd9e126
--- /dev/null
+++ b/packages/twenty-front/src/modules/auth/graphql/mutations/completeNewWorkspaceLogoUpload.ts
@@ -0,0 +1,16 @@
+import { gql } from '@apollo/client';
+
+export const COMPLETE_NEW_WORKSPACE_LOGO_UPLOAD = gql`
+ mutation CompleteNewWorkspaceLogoUpload(
+ $workspaceId: String!
+ $fileId: String!
+ ) {
+ completeNewWorkspaceLogoUpload(workspaceId: $workspaceId, fileId: $fileId) {
+ id
+ path
+ size
+ createdAt
+ url
+ }
+ }
+`;
diff --git a/packages/twenty-front/src/modules/auth/graphql/mutations/createNewWorkspaceLogoUpload.ts b/packages/twenty-front/src/modules/auth/graphql/mutations/createNewWorkspaceLogoUpload.ts
new file mode 100644
index 00000000000..ace4db79a1e
--- /dev/null
+++ b/packages/twenty-front/src/modules/auth/graphql/mutations/createNewWorkspaceLogoUpload.ts
@@ -0,0 +1,20 @@
+import { gql } from '@apollo/client';
+
+export const CREATE_NEW_WORKSPACE_LOGO_UPLOAD = gql`
+ mutation CreateNewWorkspaceLogoUpload(
+ $workspaceId: String!
+ $filename: String!
+ $size: Float!
+ ) {
+ createNewWorkspaceLogoUpload(
+ workspaceId: $workspaceId
+ filename: $filename
+ size: $size
+ ) {
+ fileId
+ uploadUrl
+ contentType
+ expiresAt
+ }
+ }
+`;
diff --git a/packages/twenty-front/src/modules/auth/graphql/mutations/uploadNewWorkspaceLogo.ts b/packages/twenty-front/src/modules/auth/graphql/mutations/uploadNewWorkspaceLogo.ts
deleted file mode 100644
index ee73ed9fd34..00000000000
--- a/packages/twenty-front/src/modules/auth/graphql/mutations/uploadNewWorkspaceLogo.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { gql } from '@apollo/client';
-
-export const UPLOAD_NEW_WORKSPACE_LOGO = gql`
- mutation UploadNewWorkspaceLogo($workspaceId: String!, $file: Upload!) {
- uploadNewWorkspaceLogo(workspaceId: $workspaceId, file: $file) {
- url
- }
- }
-`;
diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useSignUpInNewWorkspace.ts b/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useSignUpInNewWorkspace.ts
index 228d15fda63..7ac9ca6f710 100644
--- a/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useSignUpInNewWorkspace.ts
+++ b/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useSignUpInNewWorkspace.ts
@@ -1,4 +1,5 @@
import { useAuth } from '@/auth/hooks/useAuth';
+import { useUploadNewWorkspaceLogo } from '@/auth/sign-in-up/hooks/useUploadNewWorkspaceLogo';
import { isMultiWorkspaceEnabledState } from '@/client-config/states/isMultiWorkspaceEnabledState';
import { useRedirectToWorkspaceDomain } from '@/domain-manager/hooks/useRedirectToWorkspaceDomain';
import { getToastOptionsFromError } from '@/error-handler/utils/getToastOptionsFromError';
@@ -9,10 +10,7 @@ import { useLingui } from '@lingui/react/macro';
import { AppPath } from 'twenty-shared/types';
import { assertIsDefinedOrThrow, isDefined } from 'twenty-shared/utils';
import { useToast } from 'twenty-ui/components';
-import {
- SignUpInNewWorkspaceDocument,
- UploadNewWorkspaceLogoDocument,
-} from '~/generated-metadata/graphql';
+import { SignUpInNewWorkspaceDocument } from '~/generated-metadata/graphql';
import { getWorkspaceUrl } from '~/utils/getWorkspaceUrl';
export const useSignUpInNewWorkspace = () => {
@@ -27,9 +25,7 @@ export const useSignUpInNewWorkspace = () => {
const [signUpInNewWorkspaceMutation] = useMutation(
SignUpInNewWorkspaceDocument,
);
- const [uploadNewWorkspaceLogoMutation] = useMutation(
- UploadNewWorkspaceLogoDocument,
- );
+ const { uploadNewWorkspaceLogo } = useUploadNewWorkspaceLogo();
const createWorkspace = async ({
displayName,
@@ -50,9 +46,7 @@ export const useSignUpInNewWorkspace = () => {
if (isDefined(logo)) {
try {
- await uploadNewWorkspaceLogoMutation({
- variables: { workspaceId, file: logo },
- });
+ await uploadNewWorkspaceLogo({ workspaceId, file: logo });
} catch (logoUploadError) {
if (CombinedGraphQLErrors.is(logoUploadError)) {
enqueueToast(getToastOptionsFromError({ error: logoUploadError }));
diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useUploadNewWorkspaceLogo.ts b/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useUploadNewWorkspaceLogo.ts
new file mode 100644
index 00000000000..fabdc259248
--- /dev/null
+++ b/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useUploadNewWorkspaceLogo.ts
@@ -0,0 +1,52 @@
+import { putFileToUploadTarget } from '@/file/utils/putFileToUploadTarget';
+import { t } from '@lingui/core/macro';
+import { useMutation } from '@apollo/client/react';
+import { isDefined } from 'twenty-shared/utils';
+import {
+ CompleteNewWorkspaceLogoUploadDocument,
+ CreateNewWorkspaceLogoUploadDocument,
+ type FileWithSignedUrl,
+} from '~/generated-metadata/graphql';
+
+export const useUploadNewWorkspaceLogo = () => {
+ const [createNewWorkspaceLogoUpload] = useMutation(
+ CreateNewWorkspaceLogoUploadDocument,
+ );
+ const [completeNewWorkspaceLogoUpload] = useMutation(
+ CompleteNewWorkspaceLogoUploadDocument,
+ );
+
+ const uploadNewWorkspaceLogo = async ({
+ workspaceId,
+ file,
+ }: {
+ workspaceId: string;
+ file: File;
+ }): Promise<FileWithSignedUrl> => {
+ const createResult = await createNewWorkspaceLogoUpload({
+ variables: { workspaceId, filename: file.name, size: file.size },
+ });
+
+ const uploadTarget = createResult?.data?.createNewWorkspaceLogoUpload;
+
+ if (!isDefined(uploadTarget)) {
+ throw new Error(t`Failed to initiate logo upload`);
+ }
+
+ await putFileToUploadTarget({ file, uploadTarget });
+
+ const completeResult = await completeNewWorkspaceLogoUpload({
+ variables: { workspaceId, fileId: uploadTarget.fileId },
+ });
+
+ const uploadedLogo = completeResult?.data?.completeNewWorkspaceLogoUpload;
+
+ if (!isDefined(uploadedLogo)) {
+ throw new Error(t`Failed to finalize logo upload`);
+ }
+
+ return uploadedLogo;
+ };
+
+ return { uploadNewWorkspaceLogo };
+};
diff --git a/packages/twenty-front/src/modules/file/hooks/useDirectFileUpload.ts b/packages/twenty-front/src/modules/file/hooks/useDirectFileUpload.ts
index 0a7d056a7bd..8a6973bfedc 100644
--- a/packages/twenty-front/src/modules/file/hooks/useDirectFileUpload.ts
+++ b/packages/twenty-front/src/modules/file/hooks/useDirectFileUpload.ts
@@ -1,4 +1,6 @@
+import { putFileToUploadTarget } from '@/file/utils/putFileToUploadTarget';
import { useApolloClient, useMutation } from '@apollo/client/react';
+import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
import {
CompleteFileUploadDocument,
@@ -22,10 +24,10 @@ export const useDirectFileUpload = () => {
client: apolloClient,
});
- const uploadFile = async (
+ const createFileUploadAndPutFile = async (
file: File,
{ fileFolder, fieldMetadataId, signal }: DirectFileUploadOptions,
- ): Promise<FileWithSignedUrl> => {
+ ): Promise<{ fileId: string }> => {
const createResult = await createFileUpload({
variables: {
filename: file.name,
@@ -38,33 +40,33 @@ export const useDirectFileUpload = () => {
const uploadTarget = createResult?.data?.createFileUpload;
if (!isDefined(uploadTarget)) {
- throw new Error('Failed to initiate file upload');
+ throw new Error(t`Failed to initiate file upload`);
}
- const putResponse = await fetch(uploadTarget.uploadUrl, {
- method: 'PUT',
- headers: { 'Content-Type': uploadTarget.contentType },
- body: file,
- credentials: 'omit',
- signal,
- });
+ await putFileToUploadTarget({ file, uploadTarget, signal });
- if (!putResponse.ok) {
- throw new Error(`File upload failed with status ${putResponse.status}`);
- }
+ return { fileId: uploadTarget.fileId };
+ };
+
+ const uploadFile = async (
+ file: File,
+ options: DirectFileUploadOptions,
+ ): Promise<FileWithSignedUrl> => {
+ const { fileId } = await createFileUploadAndPutFile(file, options);
const completeResult = await completeFileUpload({
- variables: { fileId: uploadTarget.fileId },
+ variables: { fileId },
+ context: { fetchOptions: { signal: options.signal } },
});
const uploadedFile = completeResult?.data?.completeFileUpload;
if (!isDefined(uploadedFile)) {
- throw new Error('Failed to finalize file upload');
+ throw new Error(t`Failed to finalize file upload`);
}
return uploadedFile;
};
- return { uploadFile };
+ return { uploadFile, createFileUploadAndPutFile };
};
diff --git a/packages/twenty-front/src/modules/file/utils/putFileToUploadTarget.ts b/packages/twenty-front/src/modules/file/utils/putFileToUploadTarget.ts
new file mode 100644
index 00000000000..388fefa88e4
--- /dev/null
+++ b/packages/twenty-front/src/modules/file/utils/putFileToUploadTarget.ts
@@ -0,0 +1,26 @@
+import { t } from '@lingui/core/macro';
+import { type FileUploadTarget } from '~/generated-metadata/graphql';
+
+type PutFileToUploadTargetArgs = {
+ file: File;
+ uploadTarget: Pick<FileUploadTarget, 'uploadUrl' | 'contentType'>;
+ signal?: AbortSignal;
+};
+
+export const putFileToUploadTarget = async ({
+ file,
+ uploadTarget,
+ signal,
+}: PutFileToUploadTargetArgs): Promise<void> => {
+ const putResponse = await fetch(uploadTarget.uploadUrl, {
+ method: 'PUT',
+ headers: { 'Content-Type': uploadTarget.contentType },
+ body: file,
+ credentials: 'omit',
+ signal,
+ });
+
+ if (!putResponse.ok) {
+ throw new Error(t`File upload failed (${putResponse.status}).`);
+ }
+};
diff --git a/packages/twenty-front/src/modules/onboarding/components/OnboardingProfilePictureUploader.tsx b/packages/twenty-front/src/modules/onboarding/components/OnboardingProfilePictureUploader.tsx
index 0d2a6df04fc..43facb086fd 100644
--- a/packages/twenty-front/src/modules/onboarding/components/OnboardingProfilePictureUploader.tsx
+++ b/packages/twenty-front/src/modules/onboarding/components/OnboardingProfilePictureUploader.tsx
@@ -1,8 +1,8 @@
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
+import { useUploadWorkspaceMemberProfilePicture } from '@/settings/members/hooks/useUploadWorkspaceMemberProfilePicture';
import { useUpdateWorkspaceMemberSettings } from '@/settings/profile/hooks/useUpdateWorkspaceMemberSettings';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
-import { useMutation } from '@apollo/client/react';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { isNonEmptyString } from '@sniptt/guards';
@@ -13,7 +13,6 @@ import { useToast } from 'twenty-ui/components';
import { IconUserCircle } from 'twenty-ui/icon';
import { themeCssVariables, useTheme } from 'twenty-ui/theme-constants';
import { REACT_APP_SERVER_BASE_URL } from '~/config';
-import { UploadWorkspaceMemberProfilePictureDocument } from '~/generated-metadata/graphql';
const StyledUploader = styled.button`
align-items: center;
@@ -58,19 +57,13 @@ export const OnboardingProfilePictureUploader = ({
currentWorkspaceMemberState,
);
const { updateWorkspaceMemberSettings } = useUpdateWorkspaceMemberSettings();
- const [uploadPicture] = useMutation(
- UploadWorkspaceMemberProfilePictureDocument,
- );
+ const { uploadWorkspaceMemberProfilePicture } =
+ useUploadWorkspaceMemberProfilePicture();
const hiddenFileInputRef = useRef<HTMLInputElement>(null);
const handleUpload = async (file: File) => {
try {
- const { data } = await uploadPicture({ variables: { file } });
-
- const uploadedFile = data?.uploadWorkspaceMemberProfilePicture;
- if (!isDefined(uploadedFile)) {
- throw new Error('Avatar upload failed');
- }
+ const uploadedFile = await uploadWorkspaceMemberProfilePicture(file);
const newAvatarUrl = `${REACT_APP_SERVER_BASE_URL}/file/${FileFolder.CorePicture}/${uploadedFile.id}`;
diff --git a/packages/twenty-front/src/modules/settings/members/graphql/mutations/completeWorkspaceMemberProfilePictureUpload.ts b/packages/twenty-front/src/modules/settings/members/graphql/mutations/completeWorkspaceMemberProfilePictureUpload.ts
new file mode 100644
index 00000000000..8d9787ee7e1
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/members/graphql/mutations/completeWorkspaceMemberProfilePictureUpload.ts
@@ -0,0 +1,13 @@
+import { gql } from '@apollo/client';
+
+export const COMPLETE_WORKSPACE_MEMBER_PROFILE_PICTURE_UPLOAD = gql`
+ mutation CompleteWorkspaceMemberProfilePictureUpload($fileId: String!) {
+ completeWorkspaceMemberProfilePictureUpload(fileId: $fileId) {
+ id
+ path
+ size
+ createdAt
+ url
+ }
+ }
+`;
diff --git a/packages/twenty-front/src/modules/settings/members/graphql/mutations/uploadWorkspaceMemberProfilePicture.ts b/packages/twenty-front/src/modules/settings/members/graphql/mutations/uploadWorkspaceMemberProfilePicture.ts
deleted file mode 100644
index 5958e8c38c4..00000000000
--- a/packages/twenty-front/src/modules/settings/members/graphql/mutations/uploadWorkspaceMemberProfilePicture.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { gql } from '@apollo/client';
-
-export const UPLOAD_WORKSPACE_MEMBER_PROFILE_PICTURE = gql`
- mutation UploadWorkspaceMemberProfilePicture($file: Upload!) {
- uploadWorkspaceMemberProfilePicture(file: $file) {
- id
- url
- }
- }
-`;
diff --git a/packages/twenty-front/src/modules/settings/members/hooks/useUploadWorkspaceMemberProfilePicture.ts b/packages/twenty-front/src/modules/settings/members/hooks/useUploadWorkspaceMemberProfilePicture.ts
new file mode 100644
index 00000000000..2a0d6da657e
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/members/hooks/useUploadWorkspaceMemberProfilePicture.ts
@@ -0,0 +1,46 @@
+import { useDirectFileUpload } from '@/file/hooks/useDirectFileUpload';
+import { t } from '@lingui/core/macro';
+import { useMutation } from '@apollo/client/react';
+import { isDefined } from 'twenty-shared/utils';
+import {
+ CompleteWorkspaceMemberProfilePictureUploadDocument,
+ FileFolder,
+ type FileWithSignedUrl,
+} from '~/generated-metadata/graphql';
+
+type UploadWorkspaceMemberProfilePictureOptions = {
+ signal?: AbortSignal;
+};
+
+export const useUploadWorkspaceMemberProfilePicture = () => {
+ const { createFileUploadAndPutFile } = useDirectFileUpload();
+ const [completeWorkspaceMemberProfilePictureUpload] = useMutation(
+ CompleteWorkspaceMemberProfilePictureUploadDocument,
+ );
+
+ const uploadWorkspaceMemberProfilePicture = async (
+ file: File,
+ { signal }: UploadWorkspaceMemberProfilePictureOptions = {},
+ ): Promise<FileWithSignedUrl> => {
+ const { fileId } = await createFileUploadAndPutFile(file, {
+ fileFolder: FileFolder.CorePicture,
+ signal,
+ });
+
+ const completeResult = await completeWorkspaceMemberProfilePictureUpload({
+ variables: { fileId },
+ context: { fetchOptions: { signal } },
+ });
+
+ const uploadedPicture =
+ completeResult?.data?.completeWorkspaceMemberProfilePictureUpload;
+
+ if (!isDefined(uploadedPicture)) {
+ throw new Error(t`Failed to finalize file upload`);
+ }
+
+ return uploadedPicture;
+ };
+
+ return { uploadWorkspaceMemberProfilePicture };
+};
diff --git a/packages/twenty-front/src/modules/settings/workspace-member/components/WorkspaceMemberPictureUploader.tsx b/packages/twenty-front/src/modules/settings/workspace-member/components/WorkspaceMemberPictureUploader.tsx
index 9d949917693..a317e8fb991 100644
--- a/packages/twenty-front/src/modules/settings/workspace-member/components/WorkspaceMemberPictureUploader.tsx
+++ b/packages/twenty-front/src/modules/settings/workspace-member/components/WorkspaceMemberPictureUploader.tsx
@@ -2,17 +2,16 @@ import { t } from '@lingui/core/macro';
import { useState } from 'react';
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
+import { useUploadWorkspaceMemberProfilePicture } from '@/settings/members/hooks/useUploadWorkspaceMemberProfilePicture';
import { useCanEditProfileField } from '@/settings/profile/hooks/useCanEditProfileField';
import { useUpdateWorkspaceMemberSettings } from '@/settings/profile/hooks/useUpdateWorkspaceMemberSettings';
import { ImageInput } from '@/ui/input/components/ImageInput';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
-import { useMutation } from '@apollo/client/react';
import { FileFolder } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import { useToast } from 'twenty-ui/components';
import { REACT_APP_SERVER_BASE_URL } from '~/config';
-import { UploadWorkspaceMemberProfilePictureDocument } from '~/generated-metadata/graphql';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
type WorkspaceMemberPictureUploaderProps = {
@@ -39,9 +38,8 @@ export const WorkspaceMemberPictureUploader = ({
currentWorkspaceMemberState,
);
- const [uploadPicture] = useMutation(
- UploadWorkspaceMemberProfilePictureDocument,
- );
+ const { uploadWorkspaceMemberProfilePicture } =
+ useUploadWorkspaceMemberProfilePicture();
const { updateWorkspaceMemberSettings } = useUpdateWorkspaceMemberSettings();
@@ -63,20 +61,10 @@ export const WorkspaceMemberPictureUploader = ({
let newAvatarUrl: string | null = null;
try {
- const { data } = await uploadPicture({
- variables: { file },
- context: {
- fetchOptions: {
- signal: controller.signal,
- },
- },
+ const uploadedFile = await uploadWorkspaceMemberProfilePicture(file, {
+ signal: controller.signal,
});
- const uploadedFile = data?.uploadWorkspaceMemberProfilePicture;
- if (!isDefined(uploadedFile)) {
- throw new Error('Avatar upload failed');
- }
-
newAvatarUrl = `${REACT_APP_SERVER_BASE_URL}/file/${FileFolder.CorePicture}/${uploadedFile.id}`;
await updateWorkspaceMemberSettings({
workspaceMemberId,
diff --git a/packages/twenty-front/src/modules/settings/workspace/components/WorkspaceLogoUploader.tsx b/packages/twenty-front/src/modules/settings/workspace/components/WorkspaceLogoUploader.tsx
index dcdcf64c83f..3fb1e133284 100644
--- a/packages/twenty-front/src/modules/settings/workspace/components/WorkspaceLogoUploader.tsx
+++ b/packages/twenty-front/src/modules/settings/workspace/components/WorkspaceLogoUploader.tsx
@@ -1,15 +1,13 @@
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
import { ImageInput } from '@/ui/input/components/ImageInput';
+import { useUploadWorkspaceLogo } from '@/workspace/hooks/useUploadWorkspaceLogo';
import { useMutation } from '@apollo/client/react';
-import {
- UpdateWorkspaceDocument,
- UploadWorkspaceLogoDocument,
-} from '~/generated-metadata/graphql';
+import { UpdateWorkspaceDocument } from '~/generated-metadata/graphql';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
export const WorkspaceLogoUploader = () => {
- const [uploadLogo] = useMutation(UploadWorkspaceLogoDocument);
+ const { uploadWorkspaceLogo } = useUploadWorkspaceLogo();
const [updateWorkspace] = useMutation(UpdateWorkspaceDocument);
const [currentWorkspace, setCurrentWorkspace] = useAtomState(
currentWorkspaceState,
@@ -23,16 +21,11 @@ export const WorkspaceLogoUploader = () => {
throw new Error('Workspace id not found');
}
- await uploadLogo({
- variables: {
- file,
- },
- onCompleted: (data) => {
- setCurrentWorkspace({
- ...currentWorkspace,
- logo: data.uploadWorkspaceLogo.url,
- });
- },
+ const uploadedLogo = await uploadWorkspaceLogo(file);
+
+ setCurrentWorkspace({
+ ...currentWorkspace,
+ logo: uploadedLogo.url,
});
};
diff --git a/packages/twenty-front/src/modules/workspace/graphql/mutations/completeWorkspaceLogoUpload.ts b/packages/twenty-front/src/modules/workspace/graphql/mutations/completeWorkspaceLogoUpload.ts
new file mode 100644
index 00000000000..47946580834
--- /dev/null
+++ b/packages/twenty-front/src/modules/workspace/graphql/mutations/completeWorkspaceLogoUpload.ts
@@ -0,0 +1,13 @@
+import { gql } from '@apollo/client';
+
+export const COMPLETE_WORKSPACE_LOGO_UPLOAD = gql`
+ mutation CompleteWorkspaceLogoUpload($fileId: String!) {
+ completeWorkspaceLogoUpload(fileId: $fileId) {
+ id
+ path
+ size
+ createdAt
+ url
+ }
+ }
+`;
diff --git a/packages/twenty-front/src/modules/workspace/graphql/mutations/uploadWorkspaceLogo.ts b/packages/twenty-front/src/modules/workspace/graphql/mutations/uploadWorkspaceLogo.ts
deleted file mode 100644
index 3b80ff9a21e..00000000000
--- a/packages/twenty-front/src/modules/workspace/graphql/mutations/uploadWorkspaceLogo.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { gql } from '@apollo/client';
-
-export const UPLOAD_WORKSPACE_LOGO = gql`
- mutation UploadWorkspaceLogo($file: Upload!) {
- uploadWorkspaceLogo(file: $file) {
- url
- }
- }
-`;
diff --git a/packages/twenty-front/src/modules/workspace/hooks/useUploadWorkspaceLogo.ts b/packages/twenty-front/src/modules/workspace/hooks/useUploadWorkspaceLogo.ts
new file mode 100644
index 00000000000..190fa9c633e
--- /dev/null
+++ b/packages/twenty-front/src/modules/workspace/hooks/useUploadWorkspaceLogo.ts
@@ -0,0 +1,38 @@
+import { useDirectFileUpload } from '@/file/hooks/useDirectFileUpload';
+import { t } from '@lingui/core/macro';
+import { useMutation } from '@apollo/client/react';
+import { isDefined } from 'twenty-shared/utils';
+import {
+ CompleteWorkspaceLogoUploadDocument,
+ FileFolder,
+ type FileWithSignedUrl,
+} from '~/generated-metadata/graphql';
+
+export const useUploadWorkspaceLogo = () => {
+ const { createFileUploadAndPutFile } = useDirectFileUpload();
+ const [completeWorkspaceLogoUpload] = useMutation(
+ CompleteWorkspaceLogoUploadDocument,
+ );
+
+ const uploadWorkspaceLogo = async (
+ file: File,
+ ): Promise<FileWithSignedUrl> => {
+ const { fileId } = await createFileUploadAndPutFile(file, {
+ fileFolder: FileFolder.CorePicture,
+ });
+
+ const completeResult = await completeWorkspaceLogoUpload({
+ variables: { fileId },
+ });
+
+ const uploadedLogo = completeResult?.data?.completeWorkspaceLogoUpload;
+
+ if (!isDefined(uploadedLogo)) {
+ throw new Error(t`Failed to finalize logo upload`);
+ }
+
+ return uploadedLogo;
+ };
+
+ return { uploadWorkspaceLogo };
+};
diff --git a/packages/twenty-server/src/engine/constants/settings/index.ts b/packages/twenty-server/src/engine/constants/settings/index.ts
index 7fa1bf067b6..57ee071b0a1 100644
--- a/packages/twenty-server/src/engine/constants/settings/index.ts
+++ b/packages/twenty-server/src/engine/constants/settings/index.ts
@@ -7,6 +7,7 @@ export const settings: Settings = {
// without transiting the server memory, so they get a much higher cap
// than multipart uploads.
maxDirectUploadFileSize: '1GB',
+ maxCorePictureFileSize: '10MB',
},
minLengthOfStringForDuplicateCheck: 3,
maxVisibleViewFields: 30,
diff --git a/packages/twenty-server/src/engine/constants/settings/interfaces/settings.interface.ts b/packages/twenty-server/src/engine/constants/settings/interfaces/settings.interface.ts
index d346e60718d..18b123b5505 100644
--- a/packages/twenty-server/src/engine/constants/settings/interfaces/settings.interface.ts
+++ b/packages/twenty-server/src/engine/constants/settings/interfaces/settings.interface.ts
@@ -2,6 +2,7 @@ export interface Settings {
storage: {
maxFileSize: `${number}MB`;
maxDirectUploadFileSize: `${number}MB` | `${number}GB`;
+ maxCorePictureFileSize: `${number}MB`;
};
minLengthOfStringForDuplicateCheck: number;
maxVisibleViewFields: number;
diff --git a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.spec.ts b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.spec.ts
index 4f472ca0a3a..7a612f78cfb 100644
--- a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.spec.ts
@@ -25,6 +25,7 @@ import { WorkspaceDomainsService } from 'src/engine/core-modules/domain/workspac
import { EmailVerificationService } from 'src/engine/core-modules/email-verification/services/email-verification.service';
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
import { FileCorePictureService } from 'src/engine/core-modules/file/file-core-picture/services/file-core-picture.service';
+import { FileUploadService } from 'src/engine/core-modules/file/file-upload/services/file-upload.service';
import { UserSessionCookieService } from 'src/engine/core-modules/user-session/services/user-session-cookie.service';
import { UserSessionService } from 'src/engine/core-modules/user-session/services/user-session.service';
import { SsoService } from 'src/engine/core-modules/sso/services/sso.service';
@@ -132,6 +133,10 @@ describe('AuthResolver', () => {
provide: FileCorePictureService,
useValue: {},
},
+ {
+ provide: FileUploadService,
+ useValue: {},
+ },
{
provide: UserSessionService,
useValue: {
diff --git a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts
index 5961cbc4b0e..2e2ba01d7af 100644
--- a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts
+++ b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts
@@ -8,7 +8,10 @@ import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
import omit from 'lodash.omit';
import { PermissionFlagType } from 'twenty-shared/constants';
import { SOURCE_LOCALE } from 'twenty-shared/translations';
-import { TwoFactorAuthenticationStrategy } from 'twenty-shared/types';
+import {
+ FileFolder,
+ TwoFactorAuthenticationStrategy,
+} from 'twenty-shared/types';
import { assertIsDefinedOrThrow, isDefined } from 'twenty-shared/utils';
import { Repository } from 'typeorm';
@@ -67,7 +70,10 @@ import { EmailVerificationExceptionFilter } from 'src/engine/core-modules/email-
import { EmailVerificationTrigger } from 'src/engine/core-modules/email-verification/email-verification.constants';
import { EmailVerificationService } from 'src/engine/core-modules/email-verification/services/email-verification.service';
import { FileWithSignedUrlDTO } from 'src/engine/core-modules/file/dtos/file-with-sign-url.dto';
+import { FileUploadTargetDTO } from 'src/engine/core-modules/file/file-upload/dtos/file-upload-target.dto';
+import { FileUploadGraphqlApiExceptionFilter } from 'src/engine/core-modules/file/file-upload/filters/file-upload-graphql-api-exception.filter';
import { FileCorePictureService } from 'src/engine/core-modules/file/file-core-picture/services/file-core-picture.service';
+import { FileUploadService } from 'src/engine/core-modules/file/file-upload/services/file-upload.service';
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 { I18nContext } from 'src/engine/core-modules/i18n/types/i18n-context.type';
@@ -129,6 +135,7 @@ const PASSWORD_RESET_EMAIL_RATE_LIMIT_WINDOW_MS = 15 * 60 * 1000;
EmailVerificationExceptionFilter,
TwoFactorAuthenticationExceptionFilter,
WorkspaceGraphqlApiExceptionFilter,
+ FileUploadGraphqlApiExceptionFilter,
ThrottlerGraphqlApiExceptionFilter,
PreventNestToAutoLogGraphqlErrorsFilter,
)
@@ -163,6 +170,7 @@ export class AuthResolver {
private readonly impersonationAuthorizationService: ImpersonationAuthorizationService,
private readonly subdomainManagerService: SubdomainManagerService,
private readonly fileCorePictureService: FileCorePictureService,
+ private readonly fileUploadService: FileUploadService,
private readonly userSessionService: UserSessionService,
private readonly userSessionCookieService: UserSessionCookieService,
) {}
@@ -641,7 +649,10 @@ export class AuthResolver {
};
}
- @Mutation(() => FileWithSignedUrlDTO)
+ @Mutation(() => FileWithSignedUrlDTO, {
+ deprecationReason:
+ 'Use createNewWorkspaceLogoUpload and completeNewWorkspaceLogoUpload, which send the logo straight to file storage.',
+ })
@UseGuards(UserAuthGuard, NoPermissionGuard)
@AllowSuspendedWorkspace()
async uploadNewWorkspaceLogo(
@@ -670,6 +681,56 @@ export class AuthResolver {
});
}
+ @Mutation(() => FileUploadTargetDTO)
+ @UseGuards(UserAuthGuard, NoPermissionGuard)
+ @AllowSuspendedWorkspace()
+ async createNewWorkspaceLogoUpload(
+ @AuthUser() currentUser: AuthContextUser,
+ @Args('workspaceId') workspaceId: string,
+ @Args({ name: 'filename', type: () => String })
+ filename: string,
+ @Args({ name: 'size', type: () => Number })
+ size: number,
+ ): Promise<FileUploadTargetDTO> {
+ const workspace =
+ await this.fileCorePictureService.getPendingWorkspaceForLogoUploadOrThrow(
+ {
+ userId: currentUser.id,
+ workspaceId,
+ },
+ );
+
+ return this.fileUploadService.createFileUpload({
+ workspaceId: workspace.id,
+ filename,
+ size,
+ fileFolder: FileFolder.CorePicture,
+ });
+ }
+
+ @Mutation(() => FileWithSignedUrlDTO)
+ @UseGuards(UserAuthGuard, NoPermissionGuard)
+ @AllowSuspendedWorkspace()
+ async completeNewWorkspaceLogoUpload(
+ @AuthUser() currentUser: AuthContextUser,
+ @Args('workspaceId') workspaceId: string,
+ @Args({ name: 'fileId', type: () => String })
+ fileId: string,
+ ): Promise<FileWithSignedUrlDTO> {
+ const workspace =
+ await this.fileCorePictureService.getPendingWorkspaceForLogoUploadOrThrow(
+ {
+ userId: currentUser.id,
+ workspaceId,
+ },
+ );
+
+ return this.fileCorePictureService.completeWorkspaceLogoUpload({
+ workspaceId: workspace.id,
+ fileId,
+ });
+ }
+
@Mutation(() => TransientTokenDTO)
@UseGuards(UserAuthGuard, RequireUserSessionGuard, NoPermissionGuard)
async generateTransientToken(
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-core-picture/file-core-picture.module.ts b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/file-core-picture.module.ts
index af0994e7772..5c6bd1e23af 100644
--- a/packages/twenty-server/src/engine/core-modules/file/file-core-picture/file-core-picture.module.ts
+++ b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/file-core-picture.module.ts
@@ -1,10 +1,12 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
+import { CoreEntityCacheModule } from 'src/engine/core-entity-cache/core-entity-cache.module';
import { FileStorageModule } from 'src/engine/core-modules/file-storage/file-storage.module';
import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity';
import { FileCorePictureResolver } from 'src/engine/core-modules/file/file-core-picture/resolvers/file-core-picture.resolver';
import { FileCorePictureService } from 'src/engine/core-modules/file/file-core-picture/services/file-core-picture.service';
+import { FileUploadModule } from 'src/engine/core-modules/file/file-upload/file-upload.module';
import { FileUrlModule } from 'src/engine/core-modules/file/file-url/file-url.module';
import { JwtModule } from 'src/engine/core-modules/jwt/jwt.module';
import { SecureHttpClientModule } from 'src/engine/core-modules/secure-http-client/secure-http-client.module';
@@ -21,8 +23,10 @@ import { provideWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspac
UserWorkspaceEntity,
]),
PermissionsModule,
+ CoreEntityCacheModule,
FileStorageModule,
FileUrlModule,
+ FileUploadModule,
SecureHttpClientModule,
],
providers: [
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-core-picture/resolvers/file-core-picture.resolver.ts b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/resolvers/file-core-picture.resolver.ts
index 649fc51d7ab..4756db1d12b 100644
--- a/packages/twenty-server/src/engine/core-modules/file/file-core-picture/resolvers/file-core-picture.resolver.ts
+++ b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/resolvers/file-core-picture.resolver.ts
@@ -9,10 +9,13 @@ import type { FileUpload } from 'graphql-upload/processRequest.mjs';
import { MetadataResolver } from 'src/engine/api/graphql/graphql-config/decorators/metadata-resolver.decorator';
import { settings } from 'src/engine/constants/settings';
+import { AuthGraphqlApiExceptionFilter } from 'src/engine/core-modules/auth/filters/auth-graphql-api-exception.filter';
import { FileWithSignedUrlDTO } from 'src/engine/core-modules/file/dtos/file-with-sign-url.dto';
import { FileCorePictureService } from 'src/engine/core-modules/file/file-core-picture/services/file-core-picture.service';
+import { FileUploadGraphqlApiExceptionFilter } from 'src/engine/core-modules/file/file-upload/filters/file-upload-graphql-api-exception.filter';
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 { UsageLimitGraphqlApiExceptionFilter } from 'src/engine/core-modules/usage-limit/filters/usage-limit-graphql-api-exception.filter';
import { UploadProfilePicturePermissionGuard } from 'src/engine/core-modules/user-workspace/guards/upload-profile-picture-permission.guard';
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';
@@ -20,14 +23,13 @@ import { SettingsPermissionGuard } from 'src/engine/guards/settings-permission.g
import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard';
import { PermissionsGraphqlApiExceptionFilter } from 'src/engine/metadata-modules/permissions/utils/permissions-graphql-api-exception.filter';
import { streamToBuffer } from 'src/utils/stream-to-buffer';
-import { AuthGraphqlApiExceptionFilter } from 'src/engine/core-modules/auth/filters/auth-graphql-api-exception.filter';
-import { UsageLimitGraphqlApiExceptionFilter } from 'src/engine/core-modules/usage-limit/filters/usage-limit-graphql-api-exception.filter';
@UseGuards(WorkspaceAuthGuard)
@UsePipes(ResolverValidationPipe)
@UseFilters(
UsageLimitGraphqlApiExceptionFilter,
PermissionsGraphqlApiExceptionFilter,
+ FileUploadGraphqlApiExceptionFilter,
PreventNestToAutoLogGraphqlErrorsFilter,
AuthGraphqlApiExceptionFilter,
)
@@ -37,7 +39,10 @@ export class FileCorePictureResolver {
private readonly fileCorePictureService: FileCorePictureService,
) {}
- @Mutation(() => FileWithSignedUrlDTO)
+ @Mutation(() => FileWithSignedUrlDTO, {
+ deprecationReason:
+ 'Use createFileUpload with the CorePicture folder and completeWorkspaceLogoUpload, which send the logo straight to file storage.',
+ })
@UseGuards(
WorkspaceAuthGuard,
SettingsPermissionGuard(PermissionFlagType.WORKSPACE),
@@ -59,7 +64,10 @@ export class FileCorePictureResolver {
});
}
- @Mutation(() => FileWithSignedUrlDTO)
+ @Mutation(() => FileWithSignedUrlDTO, {
+ deprecationReason:
+ 'Use createFileUpload with the CorePicture folder and completeWorkspaceMemberProfilePictureUpload, which send the picture straight to file storage.',
+ })
@UseGuards(WorkspaceAuthGuard, UploadProfilePicturePermissionGuard)
async uploadWorkspaceMemberProfilePicture(
@AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
@@ -79,4 +87,35 @@ export class FileCorePictureResolver {
},
);
}
+
+ @Mutation(() => FileWithSignedUrlDTO)
+ @UseGuards(
+ WorkspaceAuthGuard,
+ SettingsPermissionGuard(PermissionFlagType.WORKSPACE),
+ )
+ async completeWorkspaceLogoUpload(
+ @AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
+ @Args({ name: 'fileId', type: () => String })
+ fileId: string,
+ ): Promise<FileWithSignedUrlDTO> {
+ return this.fileCorePictureService.completeWorkspaceLogoUpload({
+ workspaceId,
+ fileId,
+ });
+ }
+
+ @Mutation(() => FileWithSignedUrlDTO)
+ @UseGuards(WorkspaceAuthGuard, UploadProfilePicturePermissionGuard)
+ async completeWorkspaceMemberProfilePictureUpload(
+ @AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
+ @Args({ name: 'fileId', type: () => String })
+ fileId: string,
+ ): Promise<FileWithSignedUrlDTO> {
+ return this.fileCorePictureService.completeWorkspaceMemberProfilePictureUpload(
+ {
+ workspaceId,
+ fileId,
+ },
+ );
+ }
}
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-core-picture/services/__tests__/file-core-picture.service.complete-workspace-logo-upload.spec.ts b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/services/__tests__/file-core-picture.service.complete-workspace-logo-upload.spec.ts
new file mode 100644
index 00000000000..ff8d0a61b18
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/services/__tests__/file-core-picture.service.complete-workspace-logo-upload.spec.ts
@@ -0,0 +1,107 @@
+import { FileCorePictureService } from 'src/engine/core-modules/file/file-core-picture/services/file-core-picture.service';
+import { FileUploadExceptionCode } from 'src/engine/core-modules/file/file-upload/file-upload.exception';
+
+describe('FileCorePictureService.completeWorkspaceLogoUpload', () => {
+ const workspaceId = '20202020-0000-4000-8000-000000000001';
+ const previousLogoFileId = '20202020-0000-4000-8000-000000000002';
+ const concurrentLogoFileId = '20202020-0000-4000-8000-000000000003';
+ const logoFileId = '20202020-0000-4000-8000-000000000004';
+
+ const buildService = ({
+ logoFileIdUnderLock,
+ isTemporaryFileUnderLock,
+ }: {
+ logoFileIdUnderLock: string;
+ isTemporaryFileUnderLock: boolean;
+ }) => {
+ const manager = {
+ findOneOrFail: jest.fn().mockResolvedValue({
+ id: workspaceId,
+ logoFileId: logoFileIdUnderLock,
+ }),
+ update: jest.fn(),
+ };
+ const transactionalFileRepository = {
+ findOne: jest.fn().mockResolvedValue({
+ id: logoFileId,
+ settings: {
+ isTemporaryFile: isTemporaryFileUnderLock,
+ toDelete: false,
+ },
+ }),
+ update: jest.fn(),
+ };
+ const fileStorageService = { deleteFile: jest.fn() };
+
+ const service = new FileCorePictureService(
+ fileStorageService as never,
+ {
+ findOneOrFail: jest.fn().mockResolvedValue({
+ id: workspaceId,
+ logoFileId: previousLogoFileId,
+ }),
+ manager: {
+ transaction: jest.fn(
+ (run: (entityManager: typeof manager) => unknown) => run(manager),
+ ),
+ },
+ } as never,
+ {} as never,
+ {
+ findOne: jest.fn().mockResolvedValue({
+ id: logoFileId,
+ path: `core-picture/${logoFileId}.png`,
+ settings: { isTemporaryFile: true, toDelete: false },
+ }),
+ withManager: jest.fn().mockReturnValue(transactionalFileRepository),
+ } as never,
+ {} as never,
+ {} as never,
+ {
+ completeFileUpload: jest.fn().mockResolvedValue({ id: logoFileId }),
+ } as never,
+ { invalidate: jest.fn() } as never,
+ );
+
+ return {
+ service,
+ manager,
+ transactionalFileRepository,
+ fileStorageService,
+ };
+ };
+
+ it('should refuse a file bound and replaced while its completion waited for the workspace lock', async () => {
+ const {
+ service,
+ manager,
+ transactionalFileRepository,
+ fileStorageService,
+ } = buildService({
+ logoFileIdUnderLock: concurrentLogoFileId,
+ isTemporaryFileUnderLock: false,
+ });
+
+ await expect(
+ service.completeWorkspaceLogoUpload({ workspaceId, fileId: logoFileId }),
+ ).rejects.toMatchObject({ code: FileUploadExceptionCode.BAD_REQUEST });
+
+ expect(manager.update).not.toHaveBeenCalled();
+ expect(transactionalFileRepository.update).not.toHaveBeenCalled();
+ expect(fileStorageService.deleteFile).not.toHaveBeenCalled();
+ });
+
+ it('should leave the logo as is when a concurrent completion of the same file bound it first', async () => {
+ const { service, manager, fileStorageService } = buildService({
+ logoFileIdUnderLock: logoFileId,
+ isTemporaryFileUnderLock: false,
+ });
+
+ await expect(
+ service.completeWorkspaceLogoUpload({ workspaceId, fileId: logoFileId }),
+ ).resolves.toMatchObject({ id: logoFileId });
+
+ expect(manager.update).not.toHaveBeenCalled();
+ expect(fileStorageService.deleteFile).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-core-picture/services/__tests__/file-core-picture.service.complete-workspace-member-profile-picture-upload.spec.ts b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/services/__tests__/file-core-picture.service.complete-workspace-member-profile-picture-upload.spec.ts
new file mode 100644
index 00000000000..80e4a960912
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/services/__tests__/file-core-picture.service.complete-workspace-member-profile-picture-upload.spec.ts
@@ -0,0 +1,87 @@
+import { FileCorePictureService } from 'src/engine/core-modules/file/file-core-picture/services/file-core-picture.service';
+import { FileUploadExceptionCode } from 'src/engine/core-modules/file/file-upload/file-upload.exception';
+
+describe('FileCorePictureService.completeWorkspaceMemberProfilePictureUpload', () => {
+ const workspaceId = '20202020-0000-4000-8000-000000000001';
+ const pictureFileId = '20202020-0000-4000-8000-000000000002';
+
+ const buildService = ({
+ isTemporaryFileUnderLock,
+ }: {
+ isTemporaryFileUnderLock: boolean;
+ }) => {
+ const manager = {};
+ const transactionalFileRepository = {
+ findOne: jest.fn().mockResolvedValue({
+ id: pictureFileId,
+ settings: {
+ isTemporaryFile: isTemporaryFileUnderLock,
+ toDelete: false,
+ },
+ }),
+ update: jest.fn(),
+ };
+
+ const service = new FileCorePictureService(
+ {} as never,
+ {
+ manager: {
+ transaction: jest.fn(
+ (run: (entityManager: typeof manager) => unknown) => run(manager),
+ ),
+ },
+ } as never,
+ {} as never,
+ {
+ findOne: jest.fn().mockResolvedValue({
+ id: pictureFileId,
+ path: `core-picture/${pictureFileId}.png`,
+ settings: { isTemporaryFile: true, toDelete: false },
+ }),
+ withManager: jest.fn().mockReturnValue(transactionalFileRepository),
+ } as never,
+ {} as never,
+ {} as never,
+ {
+ completeFileUpload: jest.fn().mockResolvedValue({ id: pictureFileId }),
+ } as never,
+ {} as never,
+ );
+
+ return { service, transactionalFileRepository };
+ };
+
+ it('should mark the completed picture permanent', async () => {
+ const { service, transactionalFileRepository } = buildService({
+ isTemporaryFileUnderLock: true,
+ });
+
+ await expect(
+ service.completeWorkspaceMemberProfilePictureUpload({
+ workspaceId,
+ fileId: pictureFileId,
+ }),
+ ).resolves.toMatchObject({ id: pictureFileId });
+
+ expect(transactionalFileRepository.update).toHaveBeenCalledWith(
+ workspaceId,
+ { id: pictureFileId },
+ { settings: { isTemporaryFile: false, toDelete: false } },
+ );
+ });
+
+ it('should refuse a picture claimed as the workspace logo while its completion ran', async () => {
+ const { service, transactionalFileRepository } = buildService({
+ isTemporaryFileUnderLock: false,
+ });
+
+ await expect(
+ service.completeWorkspaceMemberProfilePictureUpload({
+ workspaceId,
+ fileId: pictureFileId,
+ }),
+ ).rejects.toMatchObject({ code: FileUploadExceptionCode.BAD_REQUEST });
+
+ expect(transactionalFileRepository.update).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-core-picture/services/file-core-picture.service.ts b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/services/file-core-picture.service.ts
index e4911aed377..55a5840b494 100644
--- a/packages/twenty-server/src/engine/core-modules/file/file-core-picture/services/file-core-picture.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/services/file-core-picture.service.ts
@@ -3,11 +3,17 @@ import { InjectRepository } from '@nestjs/typeorm';
import { buffer as streamToBuffer } from 'node:stream/consumers';
+import { msg } from '@lingui/core/macro';
import { isNonEmptyString } from '@sniptt/guards';
import { FileFolder } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
-import { Like, type QueryRunner, Repository } from 'typeorm';
+import {
+ type EntityManager,
+ Like,
+ type QueryRunner,
+ Repository,
+} from 'typeorm';
import { v4 } from 'uuid';
import {
@@ -18,9 +24,15 @@ import {
AuthException,
AuthExceptionCode,
} from 'src/engine/core-modules/auth/auth.exception';
+import { CoreEntityCacheService } from 'src/engine/core-entity-cache/services/core-entity-cache.service';
import { FileStorageService } from 'src/engine/core-modules/file-storage/services/file-storage.service';
import { FileWithSignedUrlDTO } from 'src/engine/core-modules/file/dtos/file-with-sign-url.dto';
import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity';
+import {
+ FileUploadException,
+ FileUploadExceptionCode,
+} from 'src/engine/core-modules/file/file-upload/file-upload.exception';
+import { FileUploadService } from 'src/engine/core-modules/file/file-upload/services/file-upload.service';
import { FileUrlService } from 'src/engine/core-modules/file/file-url/file-url.service';
import { extractFileInfoOrThrow } from 'src/engine/core-modules/file/utils/extract-file-info-or-throw.utils';
import { removeFileFolderFromFileEntityPath } from 'src/engine/core-modules/file/utils/remove-file-folder-from-file-entity-path.utils';
@@ -45,6 +57,8 @@ export class FileCorePictureService {
private readonly fileRepository: WorkspaceScopedRepository<FileEntity>,
private readonly fileUrlService: FileUrlService,
private readonly secureHttpClientService: SecureHttpClientService,
+ private readonly fileUploadService: FileUploadService,
+ private readonly coreEntityCacheService: CoreEntityCacheService,
) {}
private async findCustomApplicationUniversalIdentifier(
@@ -72,12 +86,14 @@ export class FileCorePictureService {
workspaceId,
applicationUniversalIdentifier,
queryRunner,
+ isTemporaryFile = false,
}: {
file: Buffer;
filename: string;
workspaceId: string;
applicationUniversalIdentifier?: string;
queryRunner?: QueryRunner;
+ isTemporaryFile?: boolean;
}): Promise<FileEntity> {
const { ext } = await extractFileInfoOrThrow({ file, filename });
@@ -96,7 +112,7 @@ export class FileCorePictureService {
workspaceId,
fileId,
settings: {
- isTemporaryFile: false,
+ isTemporaryFile,
toDelete: false,
},
queryRunner,
@@ -105,6 +121,198 @@ export class FileCorePictureService {
return savedFile;
}
+ private async toFileWithSignedUrl({
+ file,
+ workspaceId,
+ }: {
+ file: FileEntity;
+ workspaceId: string;
+ }): Promise<FileWithSignedUrlDTO> {
+ return {
+ ...file,
+ url: await this.fileUrlService.signFileByIdUrl({
+ fileId: file.id,
+ fileFolder: FileFolder.CorePicture,
+ workspaceId,
+ }),
+ };
+ }
+
+ private async findCorePictureFileOrThrow({
+ workspaceId,
+ fileId,
+ }: {
+ workspaceId: string;
+ fileId: string;
+ }): Promise<FileEntity> {
+ const file = await this.fileRepository.findOne(workspaceId, {
+ where: {
+ id: fileId,
+ path: Like(`${FileFolder.CorePicture}/%`),
+ },
+ });
+
+ if (!isDefined(file)) {
+ throw new FileUploadException(
+ `File not found: ${fileId}`,
+ FileUploadExceptionCode.FILE_NOT_FOUND,
+ { userFriendlyMessage: msg`File not found.` },
+ );
+ }
+
+ return file;
+ }
+
+ private async findCurrentLogoFileId(
+ workspaceId: string,
+ ): Promise<string | null> {
+ const workspace = await this.workspaceRepository.findOneOrFail({
+ where: { id: workspaceId },
+ select: ['id', 'logoFileId'],
+ });
+
+ return workspace.logoFileId;
+ }
+
+ private async claimTemporaryFile({
+ manager,
+ workspaceId,
+ fileId,
+ }: {
+ manager: EntityManager;
+ workspaceId: string;
+ fileId: string;
+ }): Promise<void> {
+ const transactionalFileRepository =
+ this.fileRepository.withManager(manager);
+
+ const file = await transactionalFileRepository.findOne(workspaceId, {
+ where: { id: fileId },
+ lock: { mode: 'pessimistic_write' },
+ });
+
+ if (!isDefined(file)) {
+ throw new FileUploadException(
+ `File not found: ${fileId}`,
+ FileUploadExceptionCode.FILE_NOT_FOUND,
+ { userFriendlyMessage: msg`File not found.` },
+ );
+ }
+
+ if (file.settings?.isTemporaryFile !== true) {
+ throw new FileUploadException(
+ `File ${fileId} was already finalized`,
+ FileUploadExceptionCode.BAD_REQUEST,
+ {
+ userFriendlyMessage: msg`This file upload has already been finalized.`,
+ },
+ );
+ }
+
+ await transactionalFileRepository.update(
+ workspaceId,
+ { id: fileId },
+ { settings: { isTemporaryFile: false, toDelete: false } },
+ );
+ }
+
+ private async claimFileAsWorkspaceLogo({
+ workspaceId,
+ fileId,
+ }: {
+ workspaceId: string;
+ fileId: string;
+ }): Promise<string | null> {
+ return this.workspaceRepository.manager.transaction(async (manager) => {
+ const workspace = await manager.findOneOrFail(WorkspaceEntity, {
+ where: { id: workspaceId },
+ select: ['id', 'logoFileId'],
+ lock: { mode: 'pessimistic_write' },
+ });
+
+ if (workspace.logoFileId === fileId) {
+ return null;
+ }
+
+ await this.claimTemporaryFile({ manager, workspaceId, fileId });
+
+ await manager.update(WorkspaceEntity, workspaceId, {
+ logoFileId: fileId,
+ });
+
+ return workspace.logoFileId;
+ });
+ }
+
+ private async bindWorkspaceLogo({
+ workspaceId,
+ fileId,
+ }: {
+ workspaceId: string;
+ fileId: string;
+ }): Promise<void> {
+ const replacedLogoFileId = await this.claimFileAsWorkspaceLogo({
+ workspaceId,
+ fileId,
+ });
+
+ await this.coreEntityCacheService.invalidate(
+ 'workspaceEntity',
+ workspaceId,
+ );
+
+ if (isDefined(replacedLogoFileId)) {
+ await this.deleteCorePicture({ fileId: replacedLogoFileId, workspaceId });
+ }
+ }
+
+ async completeWorkspaceLogoUpload({
+ workspaceId,
+ fileId,
+ }: {
+ workspaceId: string;
+ fileId: string;
+ }): Promise<FileWithSignedUrlDTO> {
+ const file = await this.findCorePictureFileOrThrow({ workspaceId, fileId });
+ const currentLogoFileId = await this.findCurrentLogoFileId(workspaceId);
+
+ if (currentLogoFileId === file.id) {
+ return this.toFileWithSignedUrl({ file, workspaceId });
+ }
+
+ const completedFile = await this.fileUploadService.completeFileUpload({
+ workspaceId,
+ fileId,
+ dedicatedFileFolder: FileFolder.CorePicture,
+ });
+
+ await this.bindWorkspaceLogo({ workspaceId, fileId });
+
+ return completedFile;
+ }
+
+ async completeWorkspaceMemberProfilePictureUpload({
+ workspaceId,
+ fileId,
+ }: {
+ workspaceId: string;
+ fileId: string;
+ }): Promise<FileWithSignedUrlDTO> {
+ await this.findCorePictureFileOrThrow({ workspaceId, fileId });
+
+ const completedFile = await this.fileUploadService.completeFileUpload({
+ workspaceId,
+ fileId,
+ dedicatedFileFolder: FileFolder.CorePicture,
+ });
+
+ await this.workspaceRepository.manager.transaction((manager) =>
+ this.claimTemporaryFile({ manager, workspaceId, fileId }),
+ );
+
+ return completedFile;
+ }
+
async uploadWorkspacePicture({
file,
filename,
@@ -118,29 +326,18 @@ export class FileCorePictureService {
file,
filename,
workspaceId: workspace.id,
+ isTemporaryFile: true,
});
- await this.workspaceRepository.update(workspace.id, {
- logoFileId: savedFile.id,
+ await this.bindWorkspaceLogo({
+ workspaceId: workspace.id,
+ fileId: savedFile.id,
});
- if (isDefined(workspace.logoFileId)) {
- await this.deleteCorePicture({
- fileId: workspace.logoFileId,
- workspaceId: workspace.id,
- });
- }
-
- const url = await this.fileUrlService.signFileByIdUrl({
- fileId: savedFile.id,
- fileFolder: FileFolder.CorePicture,
+ return this.toFileWithSignedUrl({
+ file: savedFile,
workspaceId: workspace.id,
});
-
- return {
- ...savedFile,
- url,
- };
}
async getPendingWorkspaceForLogoUploadOrThrow({
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-upload/constants/core-picture-upload-permission-flags.constant.ts b/packages/twenty-server/src/engine/core-modules/file/file-upload/constants/core-picture-upload-permission-flags.constant.ts
new file mode 100644
index 00000000000..bc3fc99709a
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/file/file-upload/constants/core-picture-upload-permission-flags.constant.ts
@@ -0,0 +1,8 @@
+import { PermissionFlagType } from 'twenty-shared/constants';
+
+export const CORE_PICTURE_UPLOAD_PERMISSION_FLAGS = [
+ PermissionFlagType.UPLOAD_FILE,
+ PermissionFlagType.WORKSPACE,
+ PermissionFlagType.WORKSPACE_MEMBERS,
+ PermissionFlagType.PROFILE_INFORMATION,
+] as const;
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-upload/file-upload.module.ts b/packages/twenty-server/src/engine/core-modules/file/file-upload/file-upload.module.ts
index 514709ec610..14659d9c621 100644
--- a/packages/twenty-server/src/engine/core-modules/file/file-upload/file-upload.module.ts
+++ b/packages/twenty-server/src/engine/core-modules/file/file-upload/file-upload.module.ts
@@ -2,7 +2,6 @@ import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
-import { ApplicationModule } from 'src/engine/core-modules/application/application.module';
import { FileStorageModule } from 'src/engine/core-modules/file-storage/file-storage.module';
import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity';
import { FileUploadController } from 'src/engine/core-modules/file/file-upload/controllers/file-upload.controller';
@@ -16,6 +15,7 @@ import { FileUploadTargetService } from 'src/engine/core-modules/file/file-uploa
import { PendingFileCleanupService } from 'src/engine/core-modules/file/file-upload/services/pending-file-cleanup.service';
import { FileUrlModule } from 'src/engine/core-modules/file/file-url/file-url.module';
import { JwtModule } from 'src/engine/core-modules/jwt/jwt.module';
+import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { PermissionsModule } from 'src/engine/metadata-modules/permissions/permissions.module';
import { provideWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspace-scoped-repository/provide-workspace-scoped-repository';
@@ -27,11 +27,11 @@ import { provideWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspac
FileEntity,
ApplicationEntity,
FieldMetadataEntity,
+ WorkspaceEntity,
]),
PermissionsModule,
FileStorageModule,
FileUrlModule,
- ApplicationModule,
],
providers: [
FileUploadService,
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-upload/guards/create-file-upload-permission.guard.ts b/packages/twenty-server/src/engine/core-modules/file/file-upload/guards/create-file-upload-permission.guard.ts
new file mode 100644
index 00000000000..66d0ebbaf76
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/file/file-upload/guards/create-file-upload-permission.guard.ts
@@ -0,0 +1,67 @@
+import {
+ Injectable,
+ type CanActivate,
+ type ExecutionContext,
+} from '@nestjs/common';
+import { GqlExecutionContext } from '@nestjs/graphql';
+
+import { msg } from '@lingui/core/macro';
+import { PermissionFlagType } from 'twenty-shared/constants';
+import { FileFolder } from 'twenty-shared/types';
+import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
+
+import { CORE_PICTURE_UPLOAD_PERMISSION_FLAGS } from 'src/engine/core-modules/file/file-upload/constants/core-picture-upload-permission-flags.constant';
+import {
+ PermissionsException,
+ PermissionsExceptionCode,
+ PermissionsExceptionMessage,
+} from 'src/engine/metadata-modules/permissions/permissions.exception';
+import { PermissionsService } from 'src/engine/metadata-modules/permissions/permissions.service';
+
+@Injectable()
+export class CreateFileUploadPermissionGuard implements CanActivate {
+ constructor(private readonly permissionsService: PermissionsService) {}
+
+ async canActivate(context: ExecutionContext): Promise<boolean> {
+ const gqlContext = GqlExecutionContext.create(context);
+ const request = gqlContext.getContext().req;
+ const { fileFolder } = gqlContext.getArgs<{ fileFolder: FileFolder }>();
+
+ if (
+ [
+ WorkspaceActivationStatus.PENDING_CREATION,
+ WorkspaceActivationStatus.ONGOING_CREATION,
+ ].includes(request.workspace.activationStatus)
+ ) {
+ return true;
+ }
+
+ const acceptedPermissionFlags =
+ fileFolder === FileFolder.CorePicture
+ ? CORE_PICTURE_UPLOAD_PERMISSION_FLAGS
+ : [PermissionFlagType.UPLOAD_FILE];
+
+ for (const permissionFlag of acceptedPermissionFlags) {
+ const hasPermission =
+ await this.permissionsService.userHasWorkspaceSettingPermission({
+ userWorkspaceId: request.userWorkspaceId,
+ workspaceId: request.workspace.id,
+ setting: permissionFlag,
+ apiKeyId: request.apiKey?.id,
+ applicationId: request.application?.id,
+ });
+
+ if (hasPermission) {
+ return true;
+ }
+ }
+
+ throw new PermissionsException(
+ PermissionsExceptionMessage.PERMISSION_DENIED,
+ PermissionsExceptionCode.PERMISSION_DENIED,
+ {
+ userFriendlyMessage: msg`You do not have permission to access this feature. Please contact your workspace administrator for access.`,
+ },
+ );
+ }
+}
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-upload/resolvers/file-upload.resolver.ts b/packages/twenty-server/src/engine/core-modules/file/file-upload/resolvers/file-upload.resolver.ts
index a52584024b5..77a0d48d4fb 100644
--- a/packages/twenty-server/src/engine/core-modules/file/file-upload/resolvers/file-upload.resolver.ts
+++ b/packages/twenty-server/src/engine/core-modules/file/file-upload/resolvers/file-upload.resolver.ts
@@ -8,6 +8,7 @@ import { MetadataResolver } from 'src/engine/api/graphql/graphql-config/decorato
import { FileWithSignedUrlDTO } from 'src/engine/core-modules/file/dtos/file-with-sign-url.dto';
import { FileUploadTargetDTO } from 'src/engine/core-modules/file/file-upload/dtos/file-upload-target.dto';
import { FileUploadGraphqlApiExceptionFilter } from 'src/engine/core-modules/file/file-upload/filters/file-upload-graphql-api-exception.filter';
+import { CreateFileUploadPermissionGuard } from 'src/engine/core-modules/file/file-upload/guards/create-file-upload-permission.guard';
import { FileUploadService } from 'src/engine/core-modules/file/file-upload/services/file-upload.service';
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,7 +32,7 @@ export class FileUploadResolver {
constructor(private readonly fileUploadService: FileUploadService) {}
@Mutation(() => FileUploadTargetDTO)
- @UseGuards(SettingsPermissionGuard(PermissionFlagType.UPLOAD_FILE))
+ @UseGuards(CreateFileUploadPermissionGuard)
async createFileUpload(
@AuthWorkspace()
{ id: workspaceId }: WorkspaceEntity,
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-upload/services/file-upload.service.ts b/packages/twenty-server/src/engine/core-modules/file/file-upload/services/file-upload.service.ts
index fef86b51ec5..105227b9b0a 100644
--- a/packages/twenty-server/src/engine/core-modules/file/file-upload/services/file-upload.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/file/file-upload/services/file-upload.service.ts
@@ -12,7 +12,10 @@ import { Repository } from 'typeorm';
import { v4 } from 'uuid';
import { ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
-import { ApplicationService } from 'src/engine/core-modules/application/application.service';
+import {
+ ApplicationException,
+ ApplicationExceptionCode,
+} from 'src/engine/core-modules/application/application.exception';
import { FileStorageService } from 'src/engine/core-modules/file-storage/services/file-storage.service';
import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity';
import { COMPLETE_FILE_UPLOAD_DEADLINE_MS } from 'src/engine/core-modules/file/file-upload/constants/complete-file-upload-deadline.constant';
@@ -32,6 +35,7 @@ import { FILE_STATUS } from 'src/engine/core-modules/file/types/file-status.type
import { buildFileInfo } from 'src/engine/core-modules/file/utils/build-file-info.utils';
import { buildPendingUploadResourcePath } from 'src/engine/core-modules/file/file-upload/utils/build-pending-upload-resource-path.util';
import { removeFileFolderFromFileEntityPath } from 'src/engine/core-modules/file/utils/remove-file-folder-from-file-entity-path.utils';
+import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
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';
@@ -44,6 +48,7 @@ export const DIRECT_UPLOAD_FILE_FOLDERS = [
FileFolder.AgentChat,
FileFolder.EmailImage,
FileFolder.AppTarball,
+ FileFolder.CorePicture,
] as const;
// A tarball leaves quarantine through completeAppTarballUpload only, behind
@@ -51,6 +56,7 @@ export const DIRECT_UPLOAD_FILE_FOLDERS = [
// allowed to upload files, must not persist bytes in that folder.
export const DEDICATED_COMPLETION_FILE_FOLDERS = [
FileFolder.AppTarball,
+ FileFolder.CorePicture,
] as const;
@Injectable()
@@ -62,9 +68,10 @@ export class FileUploadService {
private readonly fileUrlService: FileUrlService,
private readonly fileUploadTargetService: FileUploadTargetService,
private readonly fileUploadCompletionService: FileUploadCompletionService,
- private readonly applicationService: ApplicationService,
@InjectRepository(ApplicationEntity)
private readonly applicationRepository: Repository<ApplicationEntity>,
+ @InjectRepository(WorkspaceEntity)
+ private readonly workspaceRepository: Repository<WorkspaceEntity>,
@InjectRepository(FieldMetadataEntity)
private readonly fieldMetadataRepository: Repository<FieldMetadataEntity>,
@InjectWorkspaceScopedRepository(FileEntity)
@@ -100,7 +107,7 @@ export class FileUploadService {
);
}
- assertValidDirectUploadSize(size);
+ assertValidDirectUploadSize({ size, fileFolder });
const { ext } = buildFileInfo(filename);
@@ -244,9 +251,11 @@ export class FileUploadService {
async completeFileUpload({
workspaceId,
fileId,
+ dedicatedFileFolder,
}: {
workspaceId: string;
fileId: string;
+ dedicatedFileFolder?: FileFolder;
}): Promise<CompletedFileUpload> {
const file = await this.findFileOrThrow({ workspaceId, fileId });
const [fileFolder] = file.path.split('/');
@@ -266,6 +275,7 @@ export class FileUploadService {
}
if (
+ fileFolder !== dedicatedFileFolder &&
DEDICATED_COMPLETION_FILE_FOLDERS.includes(
fileFolder as (typeof DEDICATED_COMPLETION_FILE_FOLDERS)[number],
)
@@ -389,16 +399,35 @@ export class FileUploadService {
};
}
- const { workspaceCustomFlatApplication } =
- await this.applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow(
- {
- workspaceId,
- },
+ const workspace = await this.workspaceRepository.findOne({
+ select: ['id', 'workspaceCustomApplicationId'],
+ where: { id: workspaceId },
+ withDeleted: true,
+ });
+
+ if (!isDefined(workspace)) {
+ throw new ApplicationException(
+ `Could not find workspace ${workspaceId}`,
+ ApplicationExceptionCode.APPLICATION_NOT_FOUND,
);
+ }
+
+ const workspaceCustomApplication = await this.applicationRepository.findOne(
+ {
+ where: { id: workspace.workspaceCustomApplicationId, workspaceId },
+ },
+ );
+
+ if (!isDefined(workspaceCustomApplication)) {
+ throw new ApplicationException(
+ `Could not find workspace custom application ${workspace.workspaceCustomApplicationId}`,
+ ApplicationExceptionCode.APPLICATION_NOT_FOUND,
+ );
+ }
return {
applicationUniversalIdentifier:
- workspaceCustomFlatApplication.universalIdentifier,
+ workspaceCustomApplication.universalIdentifier,
resourcePath: name,
};
}
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-upload/utils/assert-valid-direct-upload-size.util.ts b/packages/twenty-server/src/engine/core-modules/file/file-upload/utils/assert-valid-direct-upload-size.util.ts
index f10d6edd907..7a28c7b4cf6 100644
--- a/packages/twenty-server/src/engine/core-modules/file/file-upload/utils/assert-valid-direct-upload-size.util.ts
+++ b/packages/twenty-server/src/engine/core-modules/file/file-upload/utils/assert-valid-direct-upload-size.util.ts
@@ -1,5 +1,6 @@
import { msg } from '@lingui/core/macro';
import bytes from 'bytes';
+import { FileFolder } from 'twenty-shared/types';
import { settings } from 'src/engine/constants/settings';
import {
@@ -7,8 +8,19 @@ import {
FileUploadExceptionCode,
} from 'src/engine/core-modules/file/file-upload/file-upload.exception';
-export const assertValidDirectUploadSize = (size: number): void => {
- const maxFileSize = bytes(settings.storage.maxDirectUploadFileSize) ?? 0;
+export const assertValidDirectUploadSize = ({
+ size,
+ fileFolder,
+}: {
+ size: number;
+ fileFolder: FileFolder;
+}): void => {
+ const maxFileSize =
+ bytes(
+ fileFolder === FileFolder.CorePicture
+ ? settings.storage.maxCorePictureFileSize
+ : settings.storage.maxDirectUploadFileSize,
+ ) ?? 0;
if (!Number.isInteger(size) || size <= 0 || size > maxFileSize) {
throw new FileUploadException(
diff --git a/packages/twenty-server/src/engine/core-modules/file/interfaces/file-folder.interface.ts b/packages/twenty-server/src/engine/core-modules/file/interfaces/file-folder.interface.ts
index 9dea1214c24..7d49225da4e 100644
--- a/packages/twenty-server/src/engine/core-modules/file/interfaces/file-folder.interface.ts
+++ b/packages/twenty-server/src/engine/core-modules/file/interfaces/file-folder.interface.ts
@@ -1,6 +1,9 @@
import { registerEnumType } from '@nestjs/graphql';
-import { EMAIL_IMAGE_MIME_TYPES } from 'twenty-shared/constants';
+import {
+ CORE_PICTURE_MIME_TYPES,
+ EMAIL_IMAGE_MIME_TYPES,
+} from 'twenty-shared/constants';
import { FileFolder } from 'twenty-shared/types';
registerEnumType(FileFolder, {
@@ -33,7 +36,7 @@ export const fileFolderConfigs: Record<FileFolder, FileFolderConfig> = {
[FileFolder.CorePicture]: {
ignoreExpirationToken: true,
cacheControl: IMMUTABLE_FILE_CACHE_CONTROL,
- allowedMimeTypes: ANY_MIME_TYPE,
+ allowedMimeTypes: CORE_PICTURE_MIME_TYPES,
},
[FileFolder.AgentChat]: {
ignoreExpirationToken: false,
diff --git a/packages/twenty-server/test/integration/graphql/suites/auth/sign-up/successful-new-workspace-logo-direct-upload.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/auth/sign-up/successful-new-workspace-logo-direct-upload.integration-spec.ts
new file mode 100644
index 00000000000..ef9a1ef6b9d
--- /dev/null
+++ b/packages/twenty-server/test/integration/graphql/suites/auth/sign-up/successful-new-workspace-logo-direct-upload.integration-spec.ts
@@ -0,0 +1,218 @@
+import { randomUUID } from 'crypto';
+
+import bytes from 'bytes';
+import gql from 'graphql-tag';
+import { signUpInNewWorkspace } from 'test/integration/graphql/utils/sign-up-in-new-workspace.util';
+import { signUp } from 'test/integration/graphql/utils/sign-up.util';
+import { putFileToUploadTarget } from 'test/integration/graphql/utils/upload-file-with-direct-upload.util';
+import { ONE_BY_ONE_TRANSPARENT_PNG } from 'test/integration/metadata/suites/file/utils/seed-workspace-logo.util';
+import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
+
+import { settings } from 'src/engine/constants/settings';
+import { FILE_STATUS } from 'src/engine/core-modules/file/types/file-status.types';
+import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
+
+const createNewWorkspaceLogoUploadMutation = gql`
+ mutation CreateNewWorkspaceLogoUpload(
+ $workspaceId: String!
+ $filename: String!
+ $size: Float!
+ ) {
+ createNewWorkspaceLogoUpload(
+ workspaceId: $workspaceId
+ filename: $filename
+ size: $size
+ ) {
+ fileId
+ uploadUrl
+ contentType
+ expiresAt
+ }
+ }
+`;
+
+const completeNewWorkspaceLogoUploadMutation = gql`
+ mutation CompleteNewWorkspaceLogoUpload(
+ $workspaceId: String!
+ $fileId: String!
+ ) {
+ completeNewWorkspaceLogoUpload(workspaceId: $workspaceId, fileId: $fileId) {
+ id
+ path
+ size
+ createdAt
+ url
+ }
+ }
+`;
+
+describe('New workspace logo direct upload', () => {
+ const email = `test-${randomUUID()}@example.com`;
+ let userAccessToken: string;
+ let newWorkspaceId: string;
+ let uploadedLogoFileId: string | undefined;
+
+ beforeAll(async () => {
+ jest.useRealTimers();
+
+ const { data: signUpData } = await signUp({
+ input: { email, password: 'Test123!@#' },
+ expectToFail: false,
+ });
+
+ userAccessToken =
+ signUpData.signUp.tokens.accessOrWorkspaceAgnosticToken.token;
+
+ await globalThis.testDataSource.query(
+ 'UPDATE core."user" SET "isEmailVerified" = true WHERE email = $1',
+ [email],
+ );
+
+ const { data: signUpInNewWorkspaceData } = await signUpInNewWorkspace({
+ accessToken: userAccessToken,
+ expectToFail: false,
+ });
+
+ newWorkspaceId = signUpInNewWorkspaceData.signUpInNewWorkspace.workspace.id;
+ }, 60000);
+
+ afterAll(async () => {
+ if (uploadedLogoFileId !== undefined) {
+ await globalThis.testDataSource.query(
+ `DELETE FROM core."file" WHERE id = $1`,
+ [uploadedLogoFileId],
+ );
+ }
+
+ await globalThis.testDataSource.query(
+ `DELETE FROM core."workspace" WHERE id = $1`,
+ [newWorkspaceId],
+ );
+ await globalThis.testDataSource.query(
+ `DELETE FROM core."user" WHERE email = $1`,
+ [email],
+ );
+
+ jest.useFakeTimers();
+ }, 60000);
+
+ it('should let the creator upload a logo for the workspace being created', async () => {
+ const createResponse = await makeMetadataAPIRequest(
+ {
+ query: createNewWorkspaceLogoUploadMutation,
+ variables: {
+ workspaceId: newWorkspaceId,
+ filename: 'logo.png',
+ size: ONE_BY_ONE_TRANSPARENT_PNG.length,
+ },
+ },
+ userAccessToken,
+ );
+
+ expect(createResponse.body.errors).toBeUndefined();
+
+ const uploadTarget = createResponse.body.data.createNewWorkspaceLogoUpload;
+
+ uploadedLogoFileId = uploadTarget.fileId;
+
+ const putResponse = await putFileToUploadTarget({
+ uploadTarget,
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ });
+
+ expect(putResponse.status).toBe(204);
+
+ const completeResponse = await makeMetadataAPIRequest(
+ {
+ query: completeNewWorkspaceLogoUploadMutation,
+ variables: { workspaceId: newWorkspaceId, fileId: uploadTarget.fileId },
+ },
+ userAccessToken,
+ );
+
+ expect(completeResponse.body.errors).toBeUndefined();
+ expect(completeResponse.body.data.completeNewWorkspaceLogoUpload).toEqual({
+ id: uploadTarget.fileId,
+ path: expect.stringMatching(/^core-picture\/[0-9a-f-]{36}\.png$/),
+ size: ONE_BY_ONE_TRANSPARENT_PNG.length,
+ createdAt: expect.any(String),
+ url: expect.stringContaining(uploadTarget.fileId),
+ });
+
+ const [file] = await globalThis.testDataSource.query(
+ `SELECT "status", "mimeType", "workspaceId" FROM core."file" WHERE id = $1`,
+ [uploadTarget.fileId],
+ );
+
+ expect(file).toEqual({
+ status: FILE_STATUS.UPLOADED,
+ mimeType: 'image/png',
+ workspaceId: newWorkspaceId,
+ });
+
+ const [workspace] = await globalThis.testDataSource.query(
+ `SELECT "logoFileId" FROM core."workspace" WHERE id = $1`,
+ [newWorkspaceId],
+ );
+
+ expect(workspace.logoFileId).toBe(uploadTarget.fileId);
+ }, 30000);
+
+ it('should refuse a logo larger than the core picture size limit', async () => {
+ const response = await makeMetadataAPIRequest(
+ {
+ query: createNewWorkspaceLogoUploadMutation,
+ variables: {
+ workspaceId: newWorkspaceId,
+ filename: 'logo.png',
+ size: (bytes(settings.storage.maxCorePictureFileSize) ?? 0) + 1,
+ },
+ },
+ userAccessToken,
+ );
+
+ expect(response.body.data).toBeNull();
+ expect(response.body.errors[0].extensions.code).toBe('BAD_USER_INPUT');
+ expect(response.body.errors[0].extensions.subCode).toBe('FILE_TOO_LARGE');
+ }, 30000);
+
+ it('should refuse a user who is not a member of the workspace being created', async () => {
+ const response = await makeMetadataAPIRequest(
+ {
+ query: createNewWorkspaceLogoUploadMutation,
+ variables: {
+ workspaceId: newWorkspaceId,
+ filename: 'logo.png',
+ size: ONE_BY_ONE_TRANSPARENT_PNG.length,
+ },
+ },
+ APPLE_JANE_ADMIN_ACCESS_TOKEN,
+ );
+
+ expect(response.body.data).toBeNull();
+ expect(response.body.errors[0].extensions.code).toBe('FORBIDDEN');
+ expect(response.body.errors[0].message).toBe(
+ 'Cannot set a logo for this workspace',
+ );
+ }, 30000);
+
+ it('should refuse a workspace that is not pending creation', async () => {
+ const response = await makeMetadataAPIRequest(
+ {
+ query: createNewWorkspaceLogoUploadMutation,
+ variables: {
+ workspaceId: SEED_APPLE_WORKSPACE_ID,
+ filename: 'logo.png',
+ size: ONE_BY_ONE_TRANSPARENT_PNG.length,
+ },
+ },
+ APPLE_JANE_ADMIN_ACCESS_TOKEN,
+ );
+
+ expect(response.body.data).toBeNull();
+ expect(response.body.errors[0].extensions.code).toBe('FORBIDDEN');
+ expect(response.body.errors[0].message).toBe(
+ 'Cannot set a logo for this workspace',
+ );
+ }, 30000);
+});
diff --git a/packages/twenty-server/test/integration/graphql/suites/file-upload/direct-file-upload.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/file-upload/direct-file-upload.integration-spec.ts
index 2d718753529..0b6a7f06ee5 100644
--- a/packages/twenty-server/test/integration/graphql/suites/file-upload/direct-file-upload.integration-spec.ts
+++ b/packages/twenty-server/test/integration/graphql/suites/file-upload/direct-file-upload.integration-spec.ts
@@ -311,9 +311,9 @@ describe('direct file upload (createFileUpload / completeFileUpload)', () => {
it('should reject file folders without direct upload support', async () => {
const createResponse = await createFileUpload({
- filename: 'picture.png',
+ filename: 'export.csv',
size: 10,
- fileFolder: 'CorePicture',
+ fileFolder: 'RecordExport',
});
expect(createResponse.body.errors).toBeDefined();
diff --git a/packages/twenty-server/test/integration/graphql/suites/settings-permissions/security.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/settings-permissions/security.integration-spec.ts
index deaf9c4a6dd..c88fdc83349 100644
--- a/packages/twenty-server/test/integration/graphql/suites/settings-permissions/security.integration-spec.ts
+++ b/packages/twenty-server/test/integration/graphql/suites/settings-permissions/security.integration-spec.ts
@@ -1,6 +1,10 @@
import { gql } from 'graphql-tag';
import request from 'supertest';
import { MAX_ALLOWED_IFRAME_ORIGINS } from 'twenty-shared/constants';
+import {
+ completeWorkspaceLogoUploadMutation,
+ uploadWorkspaceLogoWithDirectUpload,
+} from 'test/integration/graphql/utils/upload-core-picture-with-direct-upload.util';
import { makeMetadataAPIRequestWithFileUpload } from 'test/integration/metadata/suites/utils/make-metadata-api-request-with-file-upload.util';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
@@ -724,5 +728,65 @@ describe('Security permissions', () => {
);
});
});
+
+ describe('logo direct upload', () => {
+ beforeAll(() => {
+ jest.useRealTimers();
+ });
+
+ afterAll(() => {
+ jest.useFakeTimers();
+ });
+
+ it('should update workspace logo when user has workspace settings permission', async () => {
+ const testImageBuffer = Buffer.from(
+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==',
+ 'base64',
+ );
+
+ const uploadedLogo = await uploadWorkspaceLogoWithDirectUpload({
+ filename: 'test-logo.png',
+ content: testImageBuffer,
+ token: APPLE_JANE_ADMIN_ACCESS_TOKEN,
+ });
+
+ expect(uploadedLogo.id).toBeDefined();
+ expect(uploadedLogo.url).toBeDefined();
+
+ const getWorkspaceQuery = gql`
+ query GetWorkspace {
+ currentWorkspace {
+ logo
+ }
+ }
+ `;
+
+ const workspaceResponse = await makeMetadataAPIRequest({
+ query: getWorkspaceQuery,
+ });
+
+ expect(workspaceResponse.body.data.currentWorkspace.logo).toBeDefined();
+ });
+
+ it('should throw a permission error when user does not have permission (member role)', async () => {
+ const response = await makeMetadataAPIRequest(
+ {
+ query: completeWorkspaceLogoUploadMutation,
+ variables: { fileId: '20202020-0000-4000-8000-000000000000' },
+ },
+ APPLE_JONY_MEMBER_ACCESS_TOKEN,
+ );
+
+ expect(response.status).toBe(200);
+ expect(response.body.data).toBeNull();
+ expect(response.body.errors).toBeDefined();
+ expect(response.body.errors[0].message).toBe(
+ PermissionsExceptionMessage.PERMISSION_DENIED,
+ );
+ expect(response.body.errors[0].extensions.code).toBe(
+ ErrorCode.FORBIDDEN,
+ );
+ });
+ });
});
});
diff --git a/packages/twenty-server/test/integration/graphql/suites/settings-permissions/workspace.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/settings-permissions/workspace.integration-spec.ts
index cd2010fb1c7..c1f8c6f3ba5 100644
--- a/packages/twenty-server/test/integration/graphql/suites/settings-permissions/workspace.integration-spec.ts
+++ b/packages/twenty-server/test/integration/graphql/suites/settings-permissions/workspace.integration-spec.ts
@@ -1,5 +1,9 @@
import gql from 'graphql-tag';
import request from 'supertest';
+import {
+ completeWorkspaceLogoUploadMutation,
+ uploadWorkspaceLogoWithDirectUpload,
+} from 'test/integration/graphql/utils/upload-core-picture-with-direct-upload.util';
import { makeMetadataAPIRequestWithFileUpload } from 'test/integration/metadata/suites/utils/make-metadata-api-request-with-file-upload.util';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { FeatureFlagKey } from 'twenty-shared/types';
@@ -436,6 +440,66 @@ describe('workspace permissions', () => {
);
});
});
+
+ describe('logo direct upload', () => {
+ beforeAll(() => {
+ jest.useRealTimers();
+ });
+
+ afterAll(() => {
+ jest.useFakeTimers();
+ });
+
+ it('should update workspace logo when user has workspace settings permission', async () => {
+ const testImageBuffer = Buffer.from(
+ 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==',
+ 'base64',
+ );
+
+ const uploadedLogo = await uploadWorkspaceLogoWithDirectUpload({
+ filename: 'test-logo.png',
+ content: testImageBuffer,
+ token: APPLE_JANE_ADMIN_ACCESS_TOKEN,
+ });
+
+ expect(uploadedLogo.id).toBeDefined();
+ expect(uploadedLogo.url).toBeDefined();
+
+ const getWorkspaceQuery = gql`
+ query GetWorkspace {
+ currentWorkspace {
+ logo
+ }
+ }
+ `;
+
+ const workspaceResponse = await makeMetadataAPIRequest({
+ query: getWorkspaceQuery,
+ });
+
+ expect(workspaceResponse.body.data.currentWorkspace.logo).toBeDefined();
+ });
+
+ it('should throw a permission error when user does not have permission (member role)', async () => {
+ const response = await makeMetadataAPIRequest(
+ {
+ query: completeWorkspaceLogoUploadMutation,
+ variables: { fileId: '20202020-0000-4000-8000-000000000000' },
+ },
+ APPLE_JONY_MEMBER_ACCESS_TOKEN,
+ );
+
+ expect(response.status).toBe(200);
+ expect(response.body.data).toBeNull();
+ expect(response.body.errors).toBeDefined();
+ expect(response.body.errors[0].message).toBe(
+ PermissionsExceptionMessage.PERMISSION_DENIED,
+ );
+ expect(response.body.errors[0].extensions.code).toBe(
+ ErrorCode.FORBIDDEN,
+ );
+ });
+ });
});
describe('billing', () => {
diff --git a/packages/twenty-server/test/integration/graphql/utils/upload-core-picture-with-direct-upload.util.ts b/packages/twenty-server/test/integration/graphql/utils/upload-core-picture-with-direct-upload.util.ts
new file mode 100644
index 00000000000..f253f800b70
--- /dev/null
+++ b/packages/twenty-server/test/integration/graphql/utils/upload-core-picture-with-direct-upload.util.ts
@@ -0,0 +1,119 @@
+import gql from 'graphql-tag';
+import {
+ createFileUploadAndPutFile,
+ createFileUploadMutation,
+ type DirectUploadTarget,
+} from 'test/integration/graphql/utils/upload-file-with-direct-upload.util';
+import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
+
+export const completeWorkspaceLogoUploadMutation = gql`
+ mutation CompleteWorkspaceLogoUpload($fileId: String!) {
+ completeWorkspaceLogoUpload(fileId: $fileId) {
+ id
+ path
+ size
+ createdAt
+ url
+ }
+ }
+`;
+
+export const completeWorkspaceMemberProfilePictureUploadMutation = gql`
+ mutation CompleteWorkspaceMemberProfilePictureUpload($fileId: String!) {
+ completeWorkspaceMemberProfilePictureUpload(fileId: $fileId) {
+ id
+ path
+ size
+ createdAt
+ url
+ }
+ }
+`;
+
+export type UploadedCorePicture = {
+ id: string;
+ path: string;
+ size: number;
+ createdAt: string;
+ url: string;
+};
+
+export const createCorePictureUpload = async ({
+ filename,
+ size,
+ token,
+}: {
+ filename: string;
+ size: number;
+ token?: string;
+}): Promise<DirectUploadTarget> => {
+ const response = await makeMetadataAPIRequest(
+ {
+ query: createFileUploadMutation,
+ variables: { filename, size, fileFolder: 'CorePicture' },
+ },
+ token,
+ );
+
+ expect(response.body.errors).toBeUndefined();
+
+ return response.body.data.createFileUpload;
+};
+
+export const uploadWorkspaceLogoWithDirectUpload = async ({
+ filename,
+ content,
+ token,
+}: {
+ filename: string;
+ content: Buffer;
+ token?: string;
+}): Promise<UploadedCorePicture> => {
+ const { fileId } = await createFileUploadAndPutFile({
+ filename,
+ content,
+ fileFolder: 'CorePicture',
+ token,
+ });
+
+ const completeResponse = await makeMetadataAPIRequest(
+ {
+ query: completeWorkspaceLogoUploadMutation,
+ variables: { fileId },
+ },
+ token,
+ );
+
+ expect(completeResponse.body.errors).toBeUndefined();
+
+ return completeResponse.body.data.completeWorkspaceLogoUpload;
+};
+
+export const uploadWorkspaceMemberProfilePictureWithDirectUpload = async ({
+ filename,
+ content,
+ token,
+}: {
+ filename: string;
+ content: Buffer;
+ token?: string;
+}): Promise<UploadedCorePicture> => {
+ const { fileId } = await createFileUploadAndPutFile({
+ filename,
+ content,
+ fileFolder: 'CorePicture',
+ token,
+ });
+
+ const completeResponse = await makeMetadataAPIRequest(
+ {
+ query: completeWorkspaceMemberProfilePictureUploadMutation,
+ variables: { fileId },
+ },
+ token,
+ );
+
+ expect(completeResponse.body.errors).toBeUndefined();
+
+ return completeResponse.body.data.completeWorkspaceMemberProfilePictureUpload;
+};
diff --git a/packages/twenty-server/test/integration/graphql/utils/upload-file-with-direct-upload.util.ts b/packages/twenty-server/test/integration/graphql/utils/upload-file-with-direct-upload.util.ts
index 9f0a044b193..ef7b8e70e43 100644
--- a/packages/twenty-server/test/integration/graphql/utils/upload-file-with-direct-upload.util.ts
+++ b/packages/twenty-server/test/integration/graphql/utils/upload-file-with-direct-upload.util.ts
@@ -3,7 +3,7 @@ import request from 'supertest';
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
import { FileFolder } from 'twenty-shared/types';
-const createFileUploadMutation = gql`
+export const createFileUploadMutation = gql`
mutation CreateFileUpload(
$filename: String!
$size: Float!
@@ -23,7 +23,7 @@ const createFileUploadMutation = gql`
}
`;
-const completeFileUploadMutation = gql`
+export const completeFileUploadMutation = gql`
mutation CompleteFileUpload($fileId: String!) {
completeFileUpload(fileId: $fileId) {
id
@@ -35,11 +35,18 @@ const completeFileUploadMutation = gql`
}
`;
+export type DirectUploadTarget = {
+ fileId: string;
+ uploadUrl: string;
+ contentType: string;
+};
+
type UploadFileWithDirectUploadArgs = {
filename: string;
content: Buffer;
fileFolder: keyof typeof FileFolder;
fieldMetadataId?: string;
+ token?: string;
};
type DirectUploadedFile = {
@@ -50,42 +57,65 @@ type DirectUploadedFile = {
url: string;
};
-export const uploadFileWithDirectUpload = async ({
+export const putFileToUploadTarget = async ({
+ uploadTarget,
+ content,
+}: {
+ uploadTarget: DirectUploadTarget;
+ content: Buffer;
+}) => {
+ const { pathname, search } = new URL(uploadTarget.uploadUrl);
+
+ return request(global.app.getHttpServer())
+ .put(`${pathname}${search}`)
+ .set('Content-Type', uploadTarget.contentType)
+ .send(content);
+};
+
+export const createFileUploadAndPutFile = async ({
filename,
content,
fileFolder,
fieldMetadataId,
-}: UploadFileWithDirectUploadArgs): Promise<DirectUploadedFile> => {
- const createResponse = await makeMetadataAPIRequest({
- query: createFileUploadMutation,
- variables: {
- filename,
- size: content.length,
- fileFolder,
- fieldMetadataId,
+ token,
+}: UploadFileWithDirectUploadArgs): Promise<DirectUploadTarget> => {
+ const createResponse = await makeMetadataAPIRequest(
+ {
+ query: createFileUploadMutation,
+ variables: {
+ filename,
+ size: content.length,
+ fileFolder,
+ fieldMetadataId,
+ },
},
- });
+ token,
+ );
expect(createResponse.body.errors).toBeUndefined();
- const { fileId, uploadUrl, contentType } =
+ const uploadTarget: DirectUploadTarget =
createResponse.body.data.createFileUpload;
- // Integration tests run on the local storage driver, so the upload url
- // targets the server's streaming endpoint: replay it against the test app.
- const { pathname, search } = new URL(uploadUrl);
-
- const putResponse = await request(global.app.getHttpServer())
- .put(`${pathname}${search}`)
- .set('Content-Type', contentType)
- .send(content);
+ const putResponse = await putFileToUploadTarget({ uploadTarget, content });
expect(putResponse.status).toBe(204);
- const completeResponse = await makeMetadataAPIRequest({
- query: completeFileUploadMutation,
- variables: { fileId },
- });
+ return uploadTarget;
+};
+
+export const uploadFileWithDirectUpload = async (
+ args: UploadFileWithDirectUploadArgs,
+): Promise<DirectUploadedFile> => {
+ const { fileId } = await createFileUploadAndPutFile(args);
+
+ const completeResponse = await makeMetadataAPIRequest(
+ {
+ query: completeFileUploadMutation,
+ variables: { fileId },
+ },
+ args.token,
+ );
expect(completeResponse.body.errors).toBeUndefined();
diff --git a/packages/twenty-server/test/integration/graphql/utils/upload-workspace-logo-mutation.util.ts b/packages/twenty-server/test/integration/graphql/utils/upload-workspace-logo-mutation.util.ts
deleted file mode 100644
index 1a8af27ce0b..00000000000
--- a/packages/twenty-server/test/integration/graphql/utils/upload-workspace-logo-mutation.util.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import gql from 'graphql-tag';
-
-export const uploadWorkspaceLogoMutation = gql`
- mutation UploadWorkspaceLogo($file: Upload!) {
- uploadWorkspaceLogo(file: $file) {
- id
- url
- }
- }
-`;
diff --git a/packages/twenty-server/test/integration/metadata/suites/file/__snapshots__/failing-core-picture-direct-upload.integration-spec.ts.snap b/packages/twenty-server/test/integration/metadata/suites/file/__snapshots__/failing-core-picture-direct-upload.integration-spec.ts.snap
new file mode 100644
index 00000000000..6b2c2436d62
--- /dev/null
+++ b/packages/twenty-server/test/integration/metadata/suites/file/__snapshots__/failing-core-picture-direct-upload.integration-spec.ts.snap
@@ -0,0 +1,85 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Core picture direct upload should fail should refuse a logo whose content is not an image 1`] = `
+{
+ "extensions": {
+ "code": "BAD_USER_INPUT",
+ "subCode": "BAD_REQUEST",
+ "userFriendlyMessage": "This file format is not supported.",
+ },
+ "message": "MIME type application/pdf is not allowed in file folder core-picture",
+ "name": "UserInputError",
+}
+`;
+
+exports[`Core picture direct upload should fail should refuse the generic completion for a core picture 1`] = `
+{
+ "extensions": {
+ "code": "BAD_USER_INPUT",
+ "subCode": "BAD_REQUEST",
+ "userFriendlyMessage": "This file must be completed with its dedicated mutation.",
+ },
+ "message": "File <fileId> in folder core-picture is completed by its dedicated mutation",
+ "name": "UserInputError",
+}
+`;
+
+exports[`Core picture direct upload should fail should refuse to bind a completed profile picture as the workspace logo 1`] = `
+{
+ "extensions": {
+ "code": "BAD_USER_INPUT",
+ "subCode": "BAD_REQUEST",
+ "userFriendlyMessage": "This file upload has already been finalized.",
+ },
+ "message": "File <fileId> is not awaiting an upload confirmation",
+ "name": "UserInputError",
+}
+`;
+
+exports[`Core picture direct upload should fail should refuse to bind a file reserved outside the core picture folder 1`] = `
+{
+ "extensions": {
+ "code": "NOT_FOUND",
+ "subCode": "FILE_NOT_FOUND",
+ "userFriendlyMessage": "File not found.",
+ },
+ "message": "File not found: <fileId>",
+ "name": "NotFoundError",
+}
+`;
+
+exports[`Core picture direct upload should fail should refuse to bind a logo whose bytes were never uploaded 1`] = `
+{
+ "extensions": {
+ "code": "BAD_USER_INPUT",
+ "subCode": "FILE_NOT_UPLOADED",
+ "userFriendlyMessage": "The file has not been uploaded yet. Please upload it before confirming.",
+ },
+ "message": "File "core-picture/<fileId>.png" has not been uploaded to storage yet.",
+ "name": "UserInputError",
+}
+`;
+
+exports[`Core picture direct upload should fail should refuse to complete an unknown file 1`] = `
+{
+ "extensions": {
+ "code": "NOT_FOUND",
+ "subCode": "FILE_NOT_FOUND",
+ "userFriendlyMessage": "File not found.",
+ },
+ "message": "File not found: <fileId>",
+ "name": "NotFoundError",
+}
+`;
+
+exports[`Core picture direct upload should fail should refuse to reserve a picture larger than the core picture size limit 1`] = `
+{
+ "extensions": {
+ "code": "BAD_USER_INPUT",
+ "subCode": "FILE_TOO_LARGE",
+ "userFriendlyMessage": "The file is empty or exceeds the maximum allowed size.",
+ },
+ "message": "Invalid file size 10485761 (max 10485760 bytes)",
+ "name": "UserInputError",
+}
+`;
diff --git a/packages/twenty-server/test/integration/metadata/suites/file/core-picture-direct-upload-permissions.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/file/core-picture-direct-upload-permissions.integration-spec.ts
new file mode 100644
index 00000000000..8a376d3f701
--- /dev/null
+++ b/packages/twenty-server/test/integration/metadata/suites/file/core-picture-direct-upload-permissions.integration-spec.ts
@@ -0,0 +1,210 @@
+import { type ASTNode } from 'graphql';
+import {
+ completeWorkspaceLogoUploadMutation,
+ completeWorkspaceMemberProfilePictureUploadMutation,
+} from 'test/integration/graphql/utils/upload-core-picture-with-direct-upload.util';
+import {
+ completeFileUploadMutation,
+ createFileUploadAndPutFile,
+ createFileUploadMutation,
+} from 'test/integration/graphql/utils/upload-file-with-direct-upload.util';
+import { ONE_BY_ONE_TRANSPARENT_PNG } from 'test/integration/metadata/suites/file/utils/seed-workspace-logo.util';
+import { upsertPermissionFlags } from 'test/integration/metadata/suites/role-permission-flag/utils/upsert-permission-flags.util';
+import { createOneRole } from 'test/integration/metadata/suites/role/utils/create-one-role.util';
+import { deleteOneRole } from 'test/integration/metadata/suites/role/utils/delete-one-role.util';
+import { findOneRoleByLabel } from 'test/integration/metadata/suites/role/utils/find-one-role-by-label.util';
+import { updateWorkspaceMemberRole } from 'test/integration/metadata/suites/role/utils/update-workspace-member-role.util';
+import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
+import { PermissionFlagType } from 'twenty-shared/constants';
+
+import { ErrorCode } from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
+import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
+import { WORKSPACE_MEMBER_DATA_SEED_IDS } from 'src/engine/workspace-manager/dev-seeder/data/constants/workspace-member-data-seeds.constant';
+
+const createRoleWithPermissionFlags = async (
+ label: string,
+ permissionFlagKeys: PermissionFlagType[],
+): Promise<string> => {
+ const { data } = await createOneRole({
+ expectToFail: false,
+ input: {
+ label,
+ canUpdateAllSettings: false,
+ canAccessAllTools: false,
+ canReadAllObjectRecords: true,
+ canUpdateAllObjectRecords: false,
+ canSoftDeleteAllObjectRecords: false,
+ canDestroyAllObjectRecords: false,
+ },
+ });
+
+ const roleId = data.createOneRole.id;
+
+ if (permissionFlagKeys.length > 0) {
+ await upsertPermissionFlags({
+ expectToFail: false,
+ input: { roleId, permissionFlagKeys },
+ });
+ }
+
+ return roleId;
+};
+
+const assignRoleToJony = async (roleId: string) => {
+ await updateWorkspaceMemberRole({
+ expectToFail: false,
+ input: {
+ workspaceMemberId: WORKSPACE_MEMBER_DATA_SEED_IDS.JONY,
+ roleId,
+ },
+ });
+};
+
+const reserveAsJony = async (fileFolder: string) =>
+ makeMetadataAPIRequest(
+ {
+ query: createFileUploadMutation,
+ variables: {
+ filename: 'picture.png',
+ size: ONE_BY_ONE_TRANSPARENT_PNG.length,
+ fileFolder,
+ },
+ },
+ APPLE_JONY_MEMBER_ACCESS_TOKEN,
+ );
+
+const completeAsJony = async (query: ASTNode, fileId: string) =>
+ makeMetadataAPIRequest(
+ { query, variables: { fileId } },
+ APPLE_JONY_MEMBER_ACCESS_TOKEN,
+ );
+
+const expectForbidden = (response: {
+ body: { data: unknown; errors?: { extensions: { code: string } }[] };
+}) => {
+ expect(response.body.data).toBeNull();
+ expect(response.body.errors?.[0].extensions.code).toBe(ErrorCode.FORBIDDEN);
+};
+
+describe('Core picture direct upload permissions', () => {
+ let memberRoleId: string;
+ let workspaceSettingsRoleId: string;
+ let profileInformationRoleId: string;
+ let noUploadRoleId: string;
+ const uploadedFileIds: string[] = [];
+
+ beforeAll(async () => {
+ jest.useRealTimers();
+
+ memberRoleId = (await findOneRoleByLabel({ label: 'Member' })).id;
+ workspaceSettingsRoleId = await createRoleWithPermissionFlags(
+ 'Core picture test workspace settings',
+ [PermissionFlagType.WORKSPACE],
+ );
+ profileInformationRoleId = await createRoleWithPermissionFlags(
+ 'Core picture test profile information',
+ [PermissionFlagType.PROFILE_INFORMATION],
+ );
+ noUploadRoleId = await createRoleWithPermissionFlags(
+ 'Core picture test no upload',
+ [],
+ );
+ }, 60000);
+
+ afterAll(async () => {
+ await assignRoleToJony(memberRoleId);
+
+ for (const roleId of [
+ workspaceSettingsRoleId,
+ profileInformationRoleId,
+ noUploadRoleId,
+ ]) {
+ await deleteOneRole({
+ expectToFail: false,
+ input: { idToDelete: roleId },
+ });
+ }
+
+ await globalThis.testDataSource.query(
+ `UPDATE core."workspace" SET "logoFileId" = NULL WHERE id = $1 AND "logoFileId" = ANY($2)`,
+ [SEED_APPLE_WORKSPACE_ID, uploadedFileIds],
+ );
+ await globalThis.testDataSource.query(
+ `DELETE FROM core."file" WHERE id = ANY($1)`,
+ [uploadedFileIds],
+ );
+
+ jest.useFakeTimers();
+ }, 60000);
+
+ describe('with the workspace settings permission and no upload permission', () => {
+ beforeAll(async () => {
+ await assignRoleToJony(workspaceSettingsRoleId);
+ });
+
+ it('should reserve, upload and bind a workspace logo', async () => {
+ const { fileId } = await createFileUploadAndPutFile({
+ filename: 'logo.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ fileFolder: 'CorePicture',
+ token: APPLE_JONY_MEMBER_ACCESS_TOKEN,
+ });
+
+ uploadedFileIds.push(fileId);
+
+ const completeResponse = await completeAsJony(
+ completeWorkspaceLogoUploadMutation,
+ fileId,
+ );
+
+ expect(completeResponse.body.errors).toBeUndefined();
+ expect(completeResponse.body.data.completeWorkspaceLogoUpload.id).toBe(
+ fileId,
+ );
+ }, 30000);
+
+ it('should refuse to reserve a file outside the core picture folder', async () => {
+ expectForbidden(await reserveAsJony('Workflow'));
+ }, 30000);
+ });
+
+ describe('with the profile information permission and no upload permission', () => {
+ beforeAll(async () => {
+ await assignRoleToJony(profileInformationRoleId);
+ });
+
+ it('should reserve, upload and complete a profile picture', async () => {
+ const { fileId } = await createFileUploadAndPutFile({
+ filename: 'avatar.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ fileFolder: 'CorePicture',
+ token: APPLE_JONY_MEMBER_ACCESS_TOKEN,
+ });
+
+ uploadedFileIds.push(fileId);
+
+ expectForbidden(await completeAsJony(completeFileUploadMutation, fileId));
+
+ const completeResponse = await completeAsJony(
+ completeWorkspaceMemberProfilePictureUploadMutation,
+ fileId,
+ );
+
+ expect(completeResponse.body.errors).toBeUndefined();
+ expect(
+ completeResponse.body.data.completeWorkspaceMemberProfilePictureUpload
+ .id,
+ ).toBe(fileId);
+ }, 30000);
+ });
+
+ describe('without any upload, workspace or profile permission', () => {
+ beforeAll(async () => {
+ await assignRoleToJony(noUploadRoleId);
+ });
+
+ it('should refuse to reserve a core picture', async () => {
+ expectForbidden(await reserveAsJony('CorePicture'));
+ }, 30000);
+ });
+});
diff --git a/packages/twenty-server/test/integration/metadata/suites/file/failing-core-picture-direct-upload.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/file/failing-core-picture-direct-upload.integration-spec.ts
new file mode 100644
index 00000000000..88714976efc
--- /dev/null
+++ b/packages/twenty-server/test/integration/metadata/suites/file/failing-core-picture-direct-upload.integration-spec.ts
@@ -0,0 +1,233 @@
+import bytes from 'bytes';
+import { expectOneNotInternalServerErrorSnapshot } from 'test/integration/graphql/utils/expect-one-not-internal-server-error-snapshot.util';
+import {
+ completeWorkspaceLogoUploadMutation,
+ createCorePictureUpload,
+ uploadWorkspaceMemberProfilePictureWithDirectUpload,
+} from 'test/integration/graphql/utils/upload-core-picture-with-direct-upload.util';
+import {
+ completeFileUploadMutation,
+ createFileUploadMutation,
+ putFileToUploadTarget,
+} from 'test/integration/graphql/utils/upload-file-with-direct-upload.util';
+import { ONE_BY_ONE_TRANSPARENT_PNG } from 'test/integration/metadata/suites/file/utils/seed-workspace-logo.util';
+import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
+import { v4 as uuidv4 } from 'uuid';
+
+import { settings } from 'src/engine/constants/settings';
+import { FILE_STATUS } from 'src/engine/core-modules/file/types/file-status.types';
+import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
+
+const MINIMAL_PDF = Buffer.from(
+ '%PDF-1.4\n1 0 obj<<>>endobj\ntrailer<<>>\n%%EOF',
+);
+
+const completeWorkspaceLogoUpload = async (fileId: string) => {
+ const response = await makeMetadataAPIRequest({
+ query: completeWorkspaceLogoUploadMutation,
+ variables: { fileId },
+ });
+
+ return response.body;
+};
+
+const findFileStatus = async (fileId: string): Promise<string> => {
+ const [row] = await globalThis.testDataSource.query(
+ `SELECT "status" FROM core."file" WHERE id = $1`,
+ [fileId],
+ );
+
+ return row.status;
+};
+
+const findWorkspaceLogoFileId = async (): Promise<string | null> => {
+ const [workspace] = await globalThis.testDataSource.query(
+ `SELECT "logoFileId" FROM core."workspace" WHERE id = $1`,
+ [SEED_APPLE_WORKSPACE_ID],
+ );
+
+ return workspace.logoFileId;
+};
+
+describe('Core picture direct upload should fail', () => {
+ const reservedFileIds: string[] = [];
+
+ beforeAll(() => {
+ jest.useRealTimers();
+ });
+
+ afterAll(async () => {
+ await globalThis.testDataSource.query(
+ `DELETE FROM core."file" WHERE id = ANY($1)`,
+ [reservedFileIds],
+ );
+
+ jest.useFakeTimers();
+ });
+
+ it('should refuse to bind a logo whose bytes were never uploaded', async () => {
+ const uploadTarget = await createCorePictureUpload({
+ filename: 'logo.png',
+ size: ONE_BY_ONE_TRANSPARENT_PNG.length,
+ });
+
+ reservedFileIds.push(uploadTarget.fileId);
+
+ const { data, errors } = await completeWorkspaceLogoUpload(
+ uploadTarget.fileId,
+ );
+
+ expect(data).toBeNull();
+ expectOneNotInternalServerErrorSnapshot({
+ errors,
+ normalizeMessage: (message) =>
+ message.replace(uploadTarget.fileId, '<fileId>'),
+ });
+ expect(await findFileStatus(uploadTarget.fileId)).toBe(FILE_STATUS.PENDING);
+ expect(await findWorkspaceLogoFileId()).not.toBe(uploadTarget.fileId);
+ }, 30000);
+
+ it('should refuse a logo whose content is not an image', async () => {
+ const uploadTarget = await createCorePictureUpload({
+ filename: 'logo.pdf',
+ size: MINIMAL_PDF.length,
+ });
+
+ reservedFileIds.push(uploadTarget.fileId);
+
+ const putResponse = await putFileToUploadTarget({
+ uploadTarget,
+ content: MINIMAL_PDF,
+ });
+
+ expect(putResponse.status).toBe(204);
+
+ const { data, errors } = await completeWorkspaceLogoUpload(
+ uploadTarget.fileId,
+ );
+
+ expect(data).toBeNull();
+ expectOneNotInternalServerErrorSnapshot({ errors });
+ expect(await findFileStatus(uploadTarget.fileId)).toBe(FILE_STATUS.PENDING);
+ expect(await findWorkspaceLogoFileId()).not.toBe(uploadTarget.fileId);
+ }, 30000);
+
+ it('should refuse to bind a file reserved outside the core picture folder', async () => {
+ const createResponse = await makeMetadataAPIRequest({
+ query: createFileUploadMutation,
+ variables: {
+ filename: 'logo.png',
+ size: ONE_BY_ONE_TRANSPARENT_PNG.length,
+ fileFolder: 'Workflow',
+ },
+ });
+
+ expect(createResponse.body.errors).toBeUndefined();
+
+ const uploadTarget = createResponse.body.data.createFileUpload;
+
+ reservedFileIds.push(uploadTarget.fileId);
+
+ const putResponse = await putFileToUploadTarget({
+ uploadTarget,
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ });
+
+ expect(putResponse.status).toBe(204);
+
+ const { data, errors } = await completeWorkspaceLogoUpload(
+ uploadTarget.fileId,
+ );
+
+ expect(data).toBeNull();
+ expectOneNotInternalServerErrorSnapshot({
+ errors,
+ normalizeMessage: (message) =>
+ message.replace(uploadTarget.fileId, '<fileId>'),
+ });
+ expect(await findFileStatus(uploadTarget.fileId)).toBe(FILE_STATUS.PENDING);
+ expect(await findWorkspaceLogoFileId()).not.toBe(uploadTarget.fileId);
+ }, 30000);
+
+ it('should refuse the generic completion for a core picture', async () => {
+ const uploadTarget = await createCorePictureUpload({
+ filename: 'logo.png',
+ size: ONE_BY_ONE_TRANSPARENT_PNG.length,
+ });
+
+ reservedFileIds.push(uploadTarget.fileId);
+
+ const putResponse = await putFileToUploadTarget({
+ uploadTarget,
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ });
+
+ expect(putResponse.status).toBe(204);
+
+ const completeResponse = await makeMetadataAPIRequest({
+ query: completeFileUploadMutation,
+ variables: { fileId: uploadTarget.fileId },
+ });
+
+ expect(completeResponse.body.data).toBeNull();
+ expectOneNotInternalServerErrorSnapshot({
+ errors: completeResponse.body.errors,
+ normalizeMessage: (message) =>
+ message.replace(uploadTarget.fileId, '<fileId>'),
+ });
+ expect(await findFileStatus(uploadTarget.fileId)).toBe(FILE_STATUS.PENDING);
+ }, 30000);
+
+ it('should refuse to bind a completed profile picture as the workspace logo', async () => {
+ const logoFileIdBefore = await findWorkspaceLogoFileId();
+ const profilePicture =
+ await uploadWorkspaceMemberProfilePictureWithDirectUpload({
+ filename: 'avatar.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ token: APPLE_JONY_MEMBER_ACCESS_TOKEN,
+ });
+
+ reservedFileIds.push(profilePicture.id);
+
+ const { data, errors } = await completeWorkspaceLogoUpload(
+ profilePicture.id,
+ );
+
+ expect(data).toBeNull();
+ expectOneNotInternalServerErrorSnapshot({
+ errors,
+ normalizeMessage: (message) =>
+ message.replace(profilePicture.id, '<fileId>'),
+ });
+ expect(await findWorkspaceLogoFileId()).toBe(logoFileIdBefore);
+ expect(await findFileStatus(profilePicture.id)).toBe(FILE_STATUS.UPLOADED);
+ }, 30000);
+
+ it('should refuse to reserve a picture larger than the core picture size limit', async () => {
+ const createResponse = await makeMetadataAPIRequest({
+ query: createFileUploadMutation,
+ variables: {
+ filename: 'logo.png',
+ size: (bytes(settings.storage.maxCorePictureFileSize) ?? 0) + 1,
+ fileFolder: 'CorePicture',
+ },
+ });
+
+ expect(createResponse.body.data).toBeNull();
+ expectOneNotInternalServerErrorSnapshot({
+ errors: createResponse.body.errors,
+ });
+ }, 30000);
+
+ it('should refuse to complete an unknown file', async () => {
+ const unknownFileId = uuidv4();
+
+ const { data, errors } = await completeWorkspaceLogoUpload(unknownFileId);
+
+ expect(data).toBeNull();
+ expectOneNotInternalServerErrorSnapshot({
+ errors,
+ normalizeMessage: (message) => message.replace(unknownFileId, '<fileId>'),
+ });
+ }, 30000);
+});
diff --git a/packages/twenty-server/test/integration/metadata/suites/file/successful-core-picture-direct-upload.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/file/successful-core-picture-direct-upload.integration-spec.ts
new file mode 100644
index 00000000000..41eeaad9163
--- /dev/null
+++ b/packages/twenty-server/test/integration/metadata/suites/file/successful-core-picture-direct-upload.integration-spec.ts
@@ -0,0 +1,208 @@
+import gql from 'graphql-tag';
+import {
+ completeWorkspaceLogoUploadMutation,
+ uploadWorkspaceLogoWithDirectUpload,
+ uploadWorkspaceMemberProfilePictureWithDirectUpload,
+} from 'test/integration/graphql/utils/upload-core-picture-with-direct-upload.util';
+import { createFileUploadAndPutFile } from 'test/integration/graphql/utils/upload-file-with-direct-upload.util';
+import { ONE_BY_ONE_TRANSPARENT_PNG } from 'test/integration/metadata/suites/file/utils/seed-workspace-logo.util';
+import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
+
+import { FILE_STATUS } from 'src/engine/core-modules/file/types/file-status.types';
+import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
+
+const CORE_PICTURE_PATH_PATTERN = /^core-picture\/[0-9a-f-]{36}\.png$/;
+
+const findFileRow = async (
+ fileId: string,
+): Promise<{ status: string; mimeType: string } | undefined> => {
+ const [row] = await globalThis.testDataSource.query(
+ `SELECT "status", "mimeType" FROM core."file" WHERE id = $1`,
+ [fileId],
+ );
+
+ return row;
+};
+
+const findWorkspaceLogoFileId = async (): Promise<string | null> => {
+ const [workspace] = await globalThis.testDataSource.query(
+ `SELECT "logoFileId" FROM core."workspace" WHERE id = $1`,
+ [SEED_APPLE_WORKSPACE_ID],
+ );
+
+ return workspace.logoFileId;
+};
+
+describe('Core picture direct upload should succeed', () => {
+ const uploadedFileIds: string[] = [];
+
+ beforeAll(() => {
+ jest.useRealTimers();
+ });
+
+ afterAll(async () => {
+ await globalThis.testDataSource.query(
+ `UPDATE core."workspace" SET "logoFileId" = NULL WHERE id = $1`,
+ [SEED_APPLE_WORKSPACE_ID],
+ );
+ await globalThis.testDataSource.query(
+ `DELETE FROM core."file" WHERE id = ANY($1)`,
+ [uploadedFileIds],
+ );
+
+ jest.useFakeTimers();
+ });
+
+ it('should upload a workspace logo and bind it to the workspace', async () => {
+ const uploadedLogo = await uploadWorkspaceLogoWithDirectUpload({
+ filename: 'logo.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ });
+
+ uploadedFileIds.push(uploadedLogo.id);
+
+ expect(uploadedLogo).toEqual({
+ id: expect.any(String),
+ path: expect.stringMatching(CORE_PICTURE_PATH_PATTERN),
+ size: ONE_BY_ONE_TRANSPARENT_PNG.length,
+ createdAt: expect.any(String),
+ url: expect.stringContaining(uploadedLogo.id),
+ });
+
+ expect(await findFileRow(uploadedLogo.id)).toEqual({
+ status: FILE_STATUS.UPLOADED,
+ mimeType: 'image/png',
+ });
+ expect(await findWorkspaceLogoFileId()).toBe(uploadedLogo.id);
+
+ const workspaceResponse = await makeMetadataAPIRequest({
+ query: gql`
+ query GetWorkspaceLogo {
+ currentWorkspace {
+ logo
+ }
+ }
+ `,
+ });
+
+ expect(workspaceResponse.body.errors).toBeUndefined();
+ expect(workspaceResponse.body.data.currentWorkspace.logo).toContain(
+ uploadedLogo.id,
+ );
+ }, 30000);
+
+ it('should delete the previous logo when a new one replaces it', async () => {
+ const previousLogo = await uploadWorkspaceLogoWithDirectUpload({
+ filename: 'previous-logo.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ });
+ const newLogo = await uploadWorkspaceLogoWithDirectUpload({
+ filename: 'new-logo.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ });
+
+ uploadedFileIds.push(previousLogo.id, newLogo.id);
+
+ expect(await findWorkspaceLogoFileId()).toBe(newLogo.id);
+ expect(await findFileRow(previousLogo.id)).toBeUndefined();
+ expect(await findFileRow(newLogo.id)).toEqual({
+ status: FILE_STATUS.UPLOADED,
+ mimeType: 'image/png',
+ });
+ }, 30000);
+
+ it('should keep one logo and delete the other when two uploads complete concurrently', async () => {
+ const previousLogo = await uploadWorkspaceLogoWithDirectUpload({
+ filename: 'previous-logo.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ });
+ const firstUpload = await createFileUploadAndPutFile({
+ filename: 'first-logo.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ fileFolder: 'CorePicture',
+ });
+ const secondUpload = await createFileUploadAndPutFile({
+ filename: 'second-logo.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ fileFolder: 'CorePicture',
+ });
+
+ uploadedFileIds.push(
+ previousLogo.id,
+ firstUpload.fileId,
+ secondUpload.fileId,
+ );
+
+ const completeResponses = await Promise.all(
+ [firstUpload.fileId, secondUpload.fileId].map((fileId) =>
+ makeMetadataAPIRequest({
+ query: completeWorkspaceLogoUploadMutation,
+ variables: { fileId },
+ }),
+ ),
+ );
+
+ for (const completeResponse of completeResponses) {
+ expect(completeResponse.body.errors).toBeUndefined();
+ }
+
+ const boundLogoFileId = await findWorkspaceLogoFileId();
+ const replacedLogoFileId =
+ boundLogoFileId === firstUpload.fileId
+ ? secondUpload.fileId
+ : firstUpload.fileId;
+
+ expect([firstUpload.fileId, secondUpload.fileId]).toContain(
+ boundLogoFileId,
+ );
+ expect(await findFileRow(replacedLogoFileId)).toBeUndefined();
+ expect(await findFileRow(previousLogo.id)).toBeUndefined();
+ }, 30000);
+
+ it('should return the bound logo again when its completion is retried', async () => {
+ const uploadedLogo = await uploadWorkspaceLogoWithDirectUpload({
+ filename: 'logo.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ });
+
+ uploadedFileIds.push(uploadedLogo.id);
+
+ const retriedResponse = await makeMetadataAPIRequest({
+ query: completeWorkspaceLogoUploadMutation,
+ variables: { fileId: uploadedLogo.id },
+ });
+
+ expect(retriedResponse.body.errors).toBeUndefined();
+ expect(retriedResponse.body.data.completeWorkspaceLogoUpload).toEqual({
+ ...uploadedLogo,
+ url: expect.stringContaining(uploadedLogo.id),
+ });
+ expect(await findWorkspaceLogoFileId()).toBe(uploadedLogo.id);
+ }, 30000);
+
+ it('should upload a workspace member profile picture without touching the workspace logo', async () => {
+ const logoFileIdBefore = await findWorkspaceLogoFileId();
+
+ const uploadedPicture =
+ await uploadWorkspaceMemberProfilePictureWithDirectUpload({
+ filename: 'avatar.png',
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ token: APPLE_JONY_MEMBER_ACCESS_TOKEN,
+ });
+
+ uploadedFileIds.push(uploadedPicture.id);
+
+ expect(uploadedPicture).toEqual({
+ id: expect.any(String),
+ path: expect.stringMatching(CORE_PICTURE_PATH_PATTERN),
+ size: ONE_BY_ONE_TRANSPARENT_PNG.length,
+ createdAt: expect.any(String),
+ url: expect.stringContaining(uploadedPicture.id),
+ });
+ expect(await findFileRow(uploadedPicture.id)).toEqual({
+ status: FILE_STATUS.UPLOADED,
+ mimeType: 'image/png',
+ });
+ expect(await findWorkspaceLogoFileId()).toBe(logoFileIdBefore);
+ }, 30000);
+});
diff --git a/packages/twenty-server/test/integration/metadata/suites/file/utils/seed-workspace-logo.util.ts b/packages/twenty-server/test/integration/metadata/suites/file/utils/seed-workspace-logo.util.ts
index 312136f4377..e4da5b3d088 100644
--- a/packages/twenty-server/test/integration/metadata/suites/file/utils/seed-workspace-logo.util.ts
+++ b/packages/twenty-server/test/integration/metadata/suites/file/utils/seed-workspace-logo.util.ts
@@ -1,5 +1,4 @@
-import { uploadWorkspaceLogoMutation } from 'test/integration/graphql/utils/upload-workspace-logo-mutation.util';
-import { makeMetadataAPIRequestWithFileUpload } from 'test/integration/metadata/suites/utils/make-metadata-api-request-with-file-upload.util';
+import { uploadWorkspaceLogoWithDirectUpload } from 'test/integration/graphql/utils/upload-core-picture-with-direct-upload.util';
import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
@@ -19,27 +18,11 @@ type SeededWorkspaceLogo = {
};
export const seedWorkspaceLogo = async (): Promise<SeededWorkspaceLogo> => {
- const response = await makeMetadataAPIRequestWithFileUpload(
- {
- query: uploadWorkspaceLogoMutation,
- variables: { file: null },
- },
- {
- field: 'file',
- buffer: ONE_BY_ONE_TRANSPARENT_PNG,
+ const { id: fileId, url: signedUrl } =
+ await uploadWorkspaceLogoWithDirectUpload({
filename: 'logo.png',
- contentType: 'image/png',
- },
- );
-
- if (response.body.errors !== undefined) {
- throw new Error(
- `uploadWorkspaceLogo failed: ${JSON.stringify(response.body.errors)}`,
- );
- }
-
- const { id: fileId, url: signedUrl } = response.body.data
- .uploadWorkspaceLogo as { id: string; url: string };
+ content: ONE_BY_ONE_TRANSPARENT_PNG,
+ });
const workspaceId = SEED_APPLE_WORKSPACE_ID;
diff --git a/packages/twenty-shared/src/constants/CorePictureMimeTypes.ts b/packages/twenty-shared/src/constants/CorePictureMimeTypes.ts
new file mode 100644
index 00000000000..2087b64733e
--- /dev/null
+++ b/packages/twenty-shared/src/constants/CorePictureMimeTypes.ts
@@ -0,0 +1,7 @@
+export const CORE_PICTURE_MIME_TYPES = [
+ 'image/gif',
+ 'image/jpeg',
+ 'image/png',
+ 'image/svg+xml',
+ 'image/webp',
+] as const;
diff --git a/packages/twenty-shared/src/constants/index.ts b/packages/twenty-shared/src/constants/index.ts
index 03edc139593..60461c4c65f 100644
--- a/packages/twenty-shared/src/constants/index.ts
+++ b/packages/twenty-shared/src/constants/index.ts
@@ -16,6 +16,7 @@ export { CLIENT_CONFIG_BOOTSTRAP_ELEMENT_ID } from './ClientConfigBootstrapEleme
export { COMMAND_MENU_CONFIRMATION_MODAL_RESULT_BROWSER_EVENT_NAME } from './CommandMenuConfirmationModalResultBrowserEventName';
export { COMPOSITE_FIELD_SUB_FIELD_LABELS } from './CompositeFieldSubFieldLabels';
export { COMPOSITE_FIELD_TYPE_SUB_FIELDS_NAMES } from './CompositeFieldTypeSubFieldsNames';
+export { CORE_PICTURE_MIME_TYPES } from './CorePictureMimeTypes';
export { CSV_DANGEROUS_CHARACTERS } from './CsvDangerousCharacters';
export { CSV_INJECTION_PREVENTION_ZWJ } from './CsvInjectionPreventionZwj';
export { CurrencyCode } from './CurrencyCode';