Skip to content

The open alternative to Salesforce, designed for AI.

feat(apps): upload application files through batched direct upload (#23526)

martmull82337f0269b1
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
index c63af4dd777..89b80f584b8 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
@@ -2569,6 +2569,60 @@ type ApplicationAuthorization {
createdAt: DateTime!
}
+type File {
+ id: UUID!
+ path: String!
+ size: Float!
+ createdAt: DateTime!
+}
+
+type ApplicationFileCompletionError {
+ fileId: UUID!
+ message: String!
+}
+
+type CompleteApplicationFileUploadsResult {
+ files: [File!]!
+ errors: [ApplicationFileCompletionError!]!
+}
+
+type ApplicationFileUploadTarget {
+ fileId: UUID!
+ fileFolder: FileFolder!
+ filePath: String!
+ uploadUrl: String!
+ contentType: String!
+ expiresAt: DateTime!
+}
+
+enum FileFolder {
+ CorePicture
+ AgentChat
+ BuiltLogicFunction
+ BuiltFrontComponent
+ PublicAsset
+ Source
+ FilesField
+ Dependencies
+ Workflow
+ EmailAttachment
+ EmailImage
+ AppTarball
+ GeneratedSdkClient
+ Dpa
+}
+
+type ApplicationFileUploadError {
+ fileFolder: FileFolder!
+ filePath: String!
+ message: String!
+}
+
+type CreateApplicationFileUploadsResult {
+ targets: [ApplicationFileUploadTarget!]!
+ errors: [ApplicationFileUploadError!]!
+}
+
type DevelopmentApplication {
id: String!
universalIdentifier: String!
@@ -2579,13 +2633,6 @@ type WorkspaceMigration {
actions: JSON!
}
-type File {
- id: UUID!
- path: String!
- size: Float!
- createdAt: DateTime!
-}
-
type PublicDomain {
id: UUID!
domain: String!
@@ -3781,6 +3828,8 @@ type Mutation {
createDevelopmentApplication(universalIdentifier: String!, name: String!): DevelopmentApplication!
syncApplication(manifest: JSON!, dryRun: Boolean): WorkspaceMigration!
uploadApplicationFile(file: Upload!, applicationUniversalIdentifier: String!, fileFolder: FileFolder!, filePath: String!): File!
+ createApplicationFileUploads(applicationUniversalIdentifier: String!, files: [ApplicationFileUploadRequestInput!]!): CreateApplicationFileUploadsResult!
+ completeApplicationFileUploads(applicationUniversalIdentifier: String!, fileIds: [UUID!]!): CompleteApplicationFileUploadsResult!
revokeApplicationAuthorization(applicationAuthorizationId: UUID!): Boolean!
generateApplicationToken(applicationId: UUID!): ApplicationTokenPair!
renewApplicationToken(applicationRefreshToken: String!): ApplicationTokenPair!
@@ -3831,23 +3880,6 @@ input UpdateNavigationMenuItemInput {
pageLayoutId: UUID
}
-enum FileFolder {
- CorePicture
- AgentChat
- BuiltLogicFunction
- BuiltFrontComponent
- PublicAsset
- Source
- FilesField
- Dependencies
- Workflow
- EmailAttachment
- EmailImage
- AppTarball
- GeneratedSdkClient
- Dpa
-}
-
"""The `Upload` scalar type represents a file upload."""
scalar Upload
@@ -5048,6 +5080,12 @@ input UpdateLabPublicFeatureFlagInput {
value: Boolean!
}
+input ApplicationFileUploadRequestInput {
+ fileFolder: FileFolder!
+ filePath: String!
+ size: Int!
+}
+
type Subscription {
onEventSubscription(eventStreamId: String!): EventSubscription
logicFunctionLogs(input: LogicFunctionLogsInput!): LogicFunctionLogs!
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.ts b/packages/twenty-client-sdk/src/metadata/generated/schema.ts
index ff5003f2e73..41fce50b3bd 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/schema.ts
+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.ts
@@ -2246,6 +2246,51 @@ export interface ApplicationAuthorization {
__typename: 'ApplicationAuthorization'
}
+export interface File {
+ id: Scalars['UUID']
+ path: Scalars['String']
+ size: Scalars['Float']
+ createdAt: Scalars['DateTime']
+ __typename: 'File'
+}
+
+export interface ApplicationFileCompletionError {
+ fileId: Scalars['UUID']
+ message: Scalars['String']
+ __typename: 'ApplicationFileCompletionError'
+}
+
+export interface CompleteApplicationFileUploadsResult {
+ files: File[]
+ errors: ApplicationFileCompletionError[]
+ __typename: 'CompleteApplicationFileUploadsResult'
+}
+
+export interface ApplicationFileUploadTarget {
+ fileId: Scalars['UUID']
+ fileFolder: FileFolder
+ filePath: Scalars['String']
+ uploadUrl: Scalars['String']
+ contentType: Scalars['String']
+ expiresAt: Scalars['DateTime']
+ __typename: 'ApplicationFileUploadTarget'
+}
+
+export type FileFolder = 'CorePicture' | 'AgentChat' | 'BuiltLogicFunction' | 'BuiltFrontComponent' | 'PublicAsset' | 'Source' | 'FilesField' | 'Dependencies' | 'Workflow' | 'EmailAttachment' | 'EmailImage' | 'AppTarball' | 'GeneratedSdkClient' | 'Dpa'
+
+export interface ApplicationFileUploadError {
+ fileFolder: FileFolder
+ filePath: Scalars['String']
+ message: Scalars['String']
+ __typename: 'ApplicationFileUploadError'
+}
+
+export interface CreateApplicationFileUploadsResult {
+ targets: ApplicationFileUploadTarget[]
+ errors: ApplicationFileUploadError[]
+ __typename: 'CreateApplicationFileUploadsResult'
+}
+
export interface DevelopmentApplication {
id: Scalars['String']
universalIdentifier: Scalars['String']
@@ -2258,14 +2303,6 @@ export interface WorkspaceMigration {
__typename: 'WorkspaceMigration'
}
-export interface File {
- id: Scalars['UUID']
- path: Scalars['String']
- size: Scalars['Float']
- createdAt: Scalars['DateTime']
- __typename: 'File'
-}
-
export interface PublicDomain {
id: Scalars['UUID']
domain: Scalars['String']
@@ -3281,14 +3318,14 @@ export interface Mutation {
createDevelopmentApplication: DevelopmentApplication
syncApplication: WorkspaceMigration
uploadApplicationFile: File
+ createApplicationFileUploads: CreateApplicationFileUploadsResult
+ completeApplicationFileUploads: CompleteApplicationFileUploadsResult
revokeApplicationAuthorization: Scalars['Boolean']
generateApplicationToken: ApplicationTokenPair
renewApplicationToken: ApplicationTokenPair
__typename: 'Mutation'
}
-export type FileFolder = 'CorePicture' | 'AgentChat' | 'BuiltLogicFunction' | 'BuiltFrontComponent' | 'PublicAsset' | 'Source' | 'FilesField' | 'Dependencies' | 'Workflow' | 'EmailAttachment' | 'EmailImage' | 'AppTarball' | 'GeneratedSdkClient' | 'Dpa'
-
export type RunAgentMessageRole = 'user' | 'assistant'
export type AnalyticsType = 'PAGEVIEW' | 'TRACK'
@@ -5656,25 +5693,65 @@ export interface ApplicationAuthorizationGenqlSelection{
__scalar?: boolean | number
}
-export interface DevelopmentApplicationGenqlSelection{
+export interface FileGenqlSelection{
id?: boolean | number
- universalIdentifier?: boolean | number
+ path?: boolean | number
+ size?: boolean | number
+ createdAt?: boolean | number
__typename?: boolean | number
__scalar?: boolean | number
}
-export interface WorkspaceMigrationGenqlSelection{
- applicationUniversalIdentifier?: boolean | number
- actions?: boolean | number
+export interface ApplicationFileCompletionErrorGenqlSelection{
+ fileId?: boolean | number
+ message?: boolean | number
__typename?: boolean | number
__scalar?: boolean | number
}
-export interface FileGenqlSelection{
+export interface CompleteApplicationFileUploadsResultGenqlSelection{
+ files?: FileGenqlSelection
+ errors?: ApplicationFileCompletionErrorGenqlSelection
+ __typename?: boolean | number
+ __scalar?: boolean | number
+}
+
+export interface ApplicationFileUploadTargetGenqlSelection{
+ fileId?: boolean | number
+ fileFolder?: boolean | number
+ filePath?: boolean | number
+ uploadUrl?: boolean | number
+ contentType?: boolean | number
+ expiresAt?: boolean | number
+ __typename?: boolean | number
+ __scalar?: boolean | number
+}
+
+export interface ApplicationFileUploadErrorGenqlSelection{
+ fileFolder?: boolean | number
+ filePath?: boolean | number
+ message?: boolean | number
+ __typename?: boolean | number
+ __scalar?: boolean | number
+}
+
+export interface CreateApplicationFileUploadsResultGenqlSelection{
+ targets?: ApplicationFileUploadTargetGenqlSelection
+ errors?: ApplicationFileUploadErrorGenqlSelection
+ __typename?: boolean | number
+ __scalar?: boolean | number
+}
+
+export interface DevelopmentApplicationGenqlSelection{
id?: boolean | number
- path?: boolean | number
- size?: boolean | number
- createdAt?: boolean | number
+ universalIdentifier?: boolean | number
+ __typename?: boolean | number
+ __scalar?: boolean | number
+}
+
+export interface WorkspaceMigrationGenqlSelection{
+ applicationUniversalIdentifier?: boolean | number
+ actions?: boolean | number
__typename?: boolean | number
__scalar?: boolean | number
}
@@ -6757,6 +6834,8 @@ export interface MutationGenqlSelection{
createDevelopmentApplication?: (DevelopmentApplicationGenqlSelection & { __args: {universalIdentifier: Scalars['String'], name: Scalars['String']} })
syncApplication?: (WorkspaceMigrationGenqlSelection & { __args: {manifest: Scalars['JSON'], dryRun?: (Scalars['Boolean'] | null)} })
uploadApplicationFile?: (FileGenqlSelection & { __args: {file: Scalars['Upload'], applicationUniversalIdentifier: Scalars['String'], fileFolder: FileFolder, filePath: Scalars['String']} })
+ createApplicationFileUploads?: (CreateApplicationFileUploadsResultGenqlSelection & { __args: {applicationUniversalIdentifier: Scalars['String'], files: ApplicationFileUploadRequestInput[]} })
+ completeApplicationFileUploads?: (CompleteApplicationFileUploadsResultGenqlSelection & { __args: {applicationUniversalIdentifier: Scalars['String'], fileIds: Scalars['UUID'][]} })
revokeApplicationAuthorization?: { __args: {applicationAuthorizationId: Scalars['UUID']} }
generateApplicationToken?: (ApplicationTokenPairGenqlSelection & { __args: {applicationId: Scalars['UUID']} })
renewApplicationToken?: (ApplicationTokenPairGenqlSelection & { __args: {applicationRefreshToken: Scalars['String']} })
@@ -7172,6 +7251,8 @@ export interface ConnectionParametersInput {host: Scalars['String'],port: Scalar
export interface UpdateLabPublicFeatureFlagInput {publicFeatureFlag: Scalars['String'],value: Scalars['Boolean']}
+export interface ApplicationFileUploadRequestInput {fileFolder: FileFolder,filePath: Scalars['String'],size: Scalars['Int']}
+
export interface SubscriptionGenqlSelection{
onEventSubscription?: (EventSubscriptionGenqlSelection & { __args: {eventStreamId: Scalars['String']} })
logicFunctionLogs?: (LogicFunctionLogsGenqlSelection & { __args: {input: LogicFunctionLogsInput} })
@@ -8832,6 +8913,54 @@ export interface LogicFunctionLogsInput {applicationId?: (Scalars['UUID'] | null
+ const File_possibleTypes: string[] = ['File']
+ export const isFile = (obj?: { __typename?: any } | null): obj is File => {
+ if (!obj?.__typename) throw new Error('__typename is missing in "isFile"')
+ return File_possibleTypes.includes(obj.__typename)
+ }
+
+
+
+ const ApplicationFileCompletionError_possibleTypes: string[] = ['ApplicationFileCompletionError']
+ export const isApplicationFileCompletionError = (obj?: { __typename?: any } | null): obj is ApplicationFileCompletionError => {
+ if (!obj?.__typename) throw new Error('__typename is missing in "isApplicationFileCompletionError"')
+ return ApplicationFileCompletionError_possibleTypes.includes(obj.__typename)
+ }
+
+
+
+ const CompleteApplicationFileUploadsResult_possibleTypes: string[] = ['CompleteApplicationFileUploadsResult']
+ export const isCompleteApplicationFileUploadsResult = (obj?: { __typename?: any } | null): obj is CompleteApplicationFileUploadsResult => {
+ if (!obj?.__typename) throw new Error('__typename is missing in "isCompleteApplicationFileUploadsResult"')
+ return CompleteApplicationFileUploadsResult_possibleTypes.includes(obj.__typename)
+ }
+
+
+
+ const ApplicationFileUploadTarget_possibleTypes: string[] = ['ApplicationFileUploadTarget']
+ export const isApplicationFileUploadTarget = (obj?: { __typename?: any } | null): obj is ApplicationFileUploadTarget => {
+ if (!obj?.__typename) throw new Error('__typename is missing in "isApplicationFileUploadTarget"')
+ return ApplicationFileUploadTarget_possibleTypes.includes(obj.__typename)
+ }
+
+
+
+ const ApplicationFileUploadError_possibleTypes: string[] = ['ApplicationFileUploadError']
+ export const isApplicationFileUploadError = (obj?: { __typename?: any } | null): obj is ApplicationFileUploadError => {
+ if (!obj?.__typename) throw new Error('__typename is missing in "isApplicationFileUploadError"')
+ return ApplicationFileUploadError_possibleTypes.includes(obj.__typename)
+ }
+
+
+
+ const CreateApplicationFileUploadsResult_possibleTypes: string[] = ['CreateApplicationFileUploadsResult']
+ export const isCreateApplicationFileUploadsResult = (obj?: { __typename?: any } | null): obj is CreateApplicationFileUploadsResult => {
+ if (!obj?.__typename) throw new Error('__typename is missing in "isCreateApplicationFileUploadsResult"')
+ return CreateApplicationFileUploadsResult_possibleTypes.includes(obj.__typename)
+ }
+
+
+
const DevelopmentApplication_possibleTypes: string[] = ['DevelopmentApplication']
export const isDevelopmentApplication = (obj?: { __typename?: any } | null): obj is DevelopmentApplication => {
if (!obj?.__typename) throw new Error('__typename is missing in "isDevelopmentApplication"')
@@ -8848,14 +8977,6 @@ export interface LogicFunctionLogsInput {applicationId?: (Scalars['UUID'] | null
- const File_possibleTypes: string[] = ['File']
- export const isFile = (obj?: { __typename?: any } | null): obj is File => {
- if (!obj?.__typename) throw new Error('__typename is missing in "isFile"')
- return File_possibleTypes.includes(obj.__typename)
- }
-
-
-
const PublicDomain_possibleTypes: string[] = ['PublicDomain']
export const isPublicDomain = (obj?: { __typename?: any } | null): obj is PublicDomain => {
if (!obj?.__typename) throw new Error('__typename is missing in "isPublicDomain"')
@@ -9960,6 +10081,23 @@ export const enumEmailConnectionSecurity = {
SSL_TLS: 'SSL_TLS' as const
}
+export const enumFileFolder = {
+ CorePicture: 'CorePicture' as const,
+ AgentChat: 'AgentChat' as const,
+ BuiltLogicFunction: 'BuiltLogicFunction' as const,
+ BuiltFrontComponent: 'BuiltFrontComponent' as const,
+ PublicAsset: 'PublicAsset' as const,
+ Source: 'Source' as const,
+ FilesField: 'FilesField' as const,
+ Dependencies: 'Dependencies' as const,
+ Workflow: 'Workflow' as const,
+ EmailAttachment: 'EmailAttachment' as const,
+ EmailImage: 'EmailImage' as const,
+ AppTarball: 'AppTarball' as const,
+ GeneratedSdkClient: 'GeneratedSdkClient' as const,
+ Dpa: 'Dpa' as const
+}
+
export const enumEmailingDomainStatus = {
PENDING: 'PENDING' as const,
VERIFIED: 'VERIFIED' as const,
@@ -10138,23 +10276,6 @@ export const enumUsageOperationType = {
EMAIL_SEND: 'EMAIL_SEND' as const
}
-export const enumFileFolder = {
- CorePicture: 'CorePicture' as const,
- AgentChat: 'AgentChat' as const,
- BuiltLogicFunction: 'BuiltLogicFunction' as const,
- BuiltFrontComponent: 'BuiltFrontComponent' as const,
- PublicAsset: 'PublicAsset' as const,
- Source: 'Source' as const,
- FilesField: 'FilesField' as const,
- Dependencies: 'Dependencies' as const,
- Workflow: 'Workflow' as const,
- EmailAttachment: 'EmailAttachment' as const,
- EmailImage: 'EmailImage' as const,
- AppTarball: 'AppTarball' as const,
- GeneratedSdkClient: 'GeneratedSdkClient' as const,
- Dpa: 'Dpa' as const
-}
-
export const enumRunAgentMessageRole = {
user: 'user' as const,
assistant: 'assistant' as const
diff --git a/packages/twenty-client-sdk/src/metadata/generated/types.ts b/packages/twenty-client-sdk/src/metadata/generated/types.ts
index 3c028e46952..13c2c1cd897 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/types.ts
+++ b/packages/twenty-client-sdk/src/metadata/generated/types.ts
@@ -67,32 +67,32 @@ export default {
233,
242,
248,
- 284,
- 286,
- 287,
- 288,
- 289,
+ 282,
290,
- 291,
292,
- 299,
- 300,
- 303,
- 340,
- 347,
- 349,
- 350,
- 351,
- 352,
- 354,
+ 293,
+ 294,
+ 295,
+ 296,
+ 297,
+ 298,
+ 305,
+ 306,
+ 309,
+ 346,
+ 353,
+ 355,
356,
- 361,
- 375,
- 382,
- 389,
- 390,
- 503,
- 527
+ 357,
+ 358,
+ 360,
+ 362,
+ 367,
+ 381,
+ 388,
+ 395,
+ 508,
+ 532
],
"types": {
"BillingProductDTO": {
@@ -5089,45 +5089,116 @@ export default {
1
]
},
- "DevelopmentApplication": {
+ "File": {
"id": [
- 1
+ 3
],
- "universalIdentifier": [
+ "path": [
1
],
+ "size": [
+ 15
+ ],
+ "createdAt": [
+ 4
+ ],
"__typename": [
1
]
},
- "WorkspaceMigration": {
- "applicationUniversalIdentifier": [
+ "ApplicationFileCompletionError": {
+ "fileId": [
+ 3
+ ],
+ "message": [
1
],
- "actions": [
- 9
+ "__typename": [
+ 1
+ ]
+ },
+ "CompleteApplicationFileUploadsResult": {
+ "files": [
+ 278
+ ],
+ "errors": [
+ 279
],
"__typename": [
1
]
},
- "File": {
- "id": [
+ "ApplicationFileUploadTarget": {
+ "fileId": [
3
],
- "path": [
+ "fileFolder": [
+ 282
+ ],
+ "filePath": [
1
],
- "size": [
- 15
+ "uploadUrl": [
+ 1
],
- "createdAt": [
+ "contentType": [
+ 1
+ ],
+ "expiresAt": [
4
],
"__typename": [
1
]
},
+ "FileFolder": {},
+ "ApplicationFileUploadError": {
+ "fileFolder": [
+ 282
+ ],
+ "filePath": [
+ 1
+ ],
+ "message": [
+ 1
+ ],
+ "__typename": [
+ 1
+ ]
+ },
+ "CreateApplicationFileUploadsResult": {
+ "targets": [
+ 281
+ ],
+ "errors": [
+ 283
+ ],
+ "__typename": [
+ 1
+ ]
+ },
+ "DevelopmentApplication": {
+ "id": [
+ 1
+ ],
+ "universalIdentifier": [
+ 1
+ ],
+ "__typename": [
+ 1
+ ]
+ },
+ "WorkspaceMigration": {
+ "applicationUniversalIdentifier": [
+ 1
+ ],
+ "actions": [
+ 9
+ ],
+ "__typename": [
+ 1
+ ]
+ },
"PublicDomain": {
"id": [
3
@@ -5182,10 +5253,10 @@ export default {
1
],
"status": [
- 284
+ 290
],
"verificationRecords": [
- 282
+ 288
],
"verifiedAt": [
4
@@ -5200,7 +5271,7 @@ export default {
3
],
"visibility": [
- 286
+ 292
],
"handle": [
1
@@ -5209,16 +5280,16 @@ export default {
1
],
"type": [
- 287
+ 293
],
"isContactAutoCreationEnabled": [
8
],
"contactAutoCreationPolicy": [
- 288
+ 294
],
"messageFolderImportPolicy": [
- 289
+ 295
],
"excludeNonProfessionalEmails": [
8
@@ -5227,7 +5298,7 @@ export default {
8
],
"pendingGroupEmailsAction": [
- 290
+ 296
],
"isSyncEnabled": [
8
@@ -5236,10 +5307,10 @@ export default {
4
],
"syncStatus": [
- 291
+ 297
],
"syncStage": [
- 292
+ 298
],
"syncStageStartedAt": [
4
@@ -5275,7 +5346,7 @@ export default {
"MessageChannelSyncStage": {},
"CreateEmailGroupChannelOutput": {
"messageChannel": [
- 285
+ 291
],
"forwardingAddress": [
1
@@ -5337,7 +5408,7 @@ export default {
26
],
"skipped": [
- 296
+ 302
],
"__typename": [
1
@@ -5354,10 +5425,10 @@ export default {
1
],
"reason": [
- 299
+ 305
],
"source": [
- 300
+ 306
],
"unsubscribeTopicId": [
3
@@ -5370,7 +5441,7 @@ export default {
"MessageSuppressionSource": {},
"MessageSuppressionList": {
"records": [
- 298
+ 304
],
"totalCount": [
26
@@ -5396,7 +5467,7 @@ export default {
1
],
"visibility": [
- 303
+ 309
],
"__typename": [
1
@@ -5442,7 +5513,7 @@ export default {
1
],
"location": [
- 305
+ 311
],
"__typename": [
1
@@ -5470,13 +5541,13 @@ export default {
1
],
"IMAP": [
- 307
+ 313
],
"SMTP": [
- 307
+ 313
],
"CALDAV": [
- 307
+ 313
],
"__typename": [
1
@@ -5496,7 +5567,7 @@ export default {
3
],
"connectionParameters": [
- 308
+ 314
],
"__typename": [
1
@@ -5718,7 +5789,7 @@ export default {
1
],
"series": [
- 317
+ 323
],
"xAxisLabel": [
1
@@ -5767,7 +5838,7 @@ export default {
1
],
"data": [
- 319
+ 325
],
"__typename": [
1
@@ -5775,7 +5846,7 @@ export default {
},
"LineChartData": {
"series": [
- 320
+ 326
],
"xAxisLabel": [
1
@@ -5812,7 +5883,7 @@ export default {
},
"PieChartData": {
"data": [
- 322
+ 328
],
"showLegend": [
8
@@ -5917,13 +5988,13 @@ export default {
},
"EventLogQueryResult": {
"records": [
- 327
+ 333
],
"totalCount": [
26
],
"pageInfo": [
- 328
+ 334
],
"__typename": [
1
@@ -5987,7 +6058,7 @@ export default {
1
],
"parts": [
- 313
+ 319
],
"processedAt": [
4
@@ -6056,7 +6127,7 @@ export default {
},
"AiSystemPromptPreview": {
"sections": [
- 333
+ 339
],
"estimatedTokenCount": [
26
@@ -6084,7 +6155,7 @@ export default {
26
],
"error": [
- 335
+ 341
],
"__typename": [
1
@@ -6117,10 +6188,10 @@ export default {
},
"StartWorkspaceSetupChatResult": {
"outcome": [
- 340
+ 346
],
"thread": [
- 332
+ 338
],
"__typename": [
1
@@ -6158,10 +6229,10 @@ export default {
3
],
"evaluations": [
- 341
+ 347
],
"messages": [
- 331
+ 337
],
"createdAt": [
4
@@ -6217,7 +6288,7 @@ export default {
9
],
"scope": [
- 347
+ 353
],
"__typename": [
1
@@ -6232,19 +6303,19 @@ export default {
1
],
"syncStatus": [
- 349
+ 355
],
"syncStage": [
- 350
+ 356
],
"visibility": [
- 351
+ 357
],
"isContactAutoCreationEnabled": [
8
],
"contactAutoCreationPolicy": [
- 352
+ 358
],
"isSyncEnabled": [
8
@@ -6295,7 +6366,7 @@ export default {
1
],
"pendingSyncAction": [
- 354
+ 360
],
"messageChannelId": [
3
@@ -6337,7 +6408,7 @@ export default {
1
],
"provenance": [
- 356
+ 362
],
"__typename": [
1
@@ -6363,7 +6434,7 @@ export default {
3
],
"through": [
- 357
+ 363
],
"__typename": [
1
@@ -6383,7 +6454,7 @@ export default {
1
],
"emit": [
- 358
+ 364
],
"action": [
1
@@ -6418,7 +6489,7 @@ export default {
},
"CollectionHash": {
"collectionName": [
- 361
+ 367
],
"hash": [
1
@@ -6482,13 +6553,13 @@ export default {
},
"MinimalMetadata": {
"objectMetadataItems": [
- 362
+ 368
],
"views": [
- 363
+ 369
],
"collectionHashes": [
- 360
+ 366
],
"__typename": [
1
@@ -6662,7 +6733,7 @@ export default {
2,
{
"input": [
- 366,
+ 372,
"GetApiKeyInput!"
]
}
@@ -6768,7 +6839,7 @@ export default {
10,
{
"input": [
- 367,
+ 373,
"AgentIdInput!"
]
}
@@ -6781,7 +6852,7 @@ export default {
"CursorPaging!"
],
"filter": [
- 368,
+ 374,
"ObjectFilter!"
]
}
@@ -6811,7 +6882,7 @@ export default {
21,
{
"input": [
- 369,
+ 375,
"LogicFunctionIdInput!"
]
}
@@ -6823,7 +6894,7 @@ export default {
9,
{
"input": [
- 369,
+ 375,
"LogicFunctionIdInput!"
]
}
@@ -6832,7 +6903,7 @@ export default {
1,
{
"input": [
- 369,
+ 375,
"LogicFunctionIdInput!"
]
}
@@ -7051,28 +7122,28 @@ export default {
46
],
"previewMessageCampaignAudience": [
- 294,
+ 300,
{
"input": [
- 370,
+ 376,
"PreviewMessageCampaignAudienceInput!"
]
}
],
"messageSuppressions": [
- 301,
+ 307,
{
"input": [
- 371,
+ 377,
"FindMessageSuppressionsInput!"
]
}
],
"unsubscribeTopics": [
- 302
+ 308
],
"myMessageChannels": [
- 285,
+ 291,
{
"connectedAccountId": [
3
@@ -7080,13 +7151,13 @@ export default {
}
],
"getEmailingDomains": [
- 283
+ 289
],
"myConnectedAccounts": [
250
],
"getToolIndex": [
- 312
+ 318
],
"getToolInputSchema": [
9,
@@ -7098,10 +7169,10 @@ export default {
}
],
"webhooks": [
- 311
+ 317
],
"webhook": [
- 311,
+ 317,
{
"id": [
3,
@@ -7110,7 +7181,7 @@ export default {
}
],
"myMessageFolders": [
- 353,
+ 359,
{
"messageChannelId": [
3
@@ -7118,7 +7189,7 @@ export default {
}
],
"myCalendarChannels": [
- 348,
+ 354,
{
"connectedAccountId": [
3
@@ -7126,17 +7197,17 @@ export default {
}
],
"minimalMetadata": [
- 364
+ 370
],
"appKeyValue": [
- 346,
+ 352,
{
"key": [
1,
"String!"
],
"scope": [
- 347
+ 353
]
}
],
@@ -7144,7 +7215,7 @@ export default {
204,
{
"filter": [
- 372
+ 378
]
}
],
@@ -7158,13 +7229,13 @@ export default {
}
],
"findWorkspaceAiStats": [
- 343
+ 349
],
"chatThreads": [
- 332
+ 338
],
"chatThread": [
- 332,
+ 338,
{
"id": [
3,
@@ -7173,7 +7244,7 @@ export default {
}
],
"chatMessages": [
- 331,
+ 337,
{
"threadId": [
3,
@@ -7182,7 +7253,7 @@ export default {
}
],
"chatStreamCatchupChunks": [
- 336,
+ 342,
{
"threadId": [
3,
@@ -7191,13 +7262,13 @@ export default {
}
],
"getAiSystemPromptPreview": [
- 334
+ 340
],
"skills": [
- 330
+ 336
],
"skill": [
- 330,
+ 336,
{
"id": [
3,
@@ -7206,7 +7277,7 @@ export default {
}
],
"agentTurns": [
- 342,
+ 348,
{
"agentId": [
3,
@@ -7215,13 +7286,13 @@ export default {
}
],
"timelineActivityTypes": [
- 359
+ 365
],
"metadataTranslations": [
- 355,
+ 361,
{
"input": [
- 373,
+ 379,
"MetadataTranslationsInput!"
]
}
@@ -7284,43 +7355,43 @@ export default {
210
],
"eventLogs": [
- 329,
+ 335,
{
"input": [
- 374,
+ 380,
"EventLogQueryInput!"
]
}
],
"pieChartData": [
- 323,
+ 329,
{
"input": [
- 378,
+ 384,
"PieChartDataInput!"
]
}
],
"lineChartData": [
- 321,
+ 327,
{
"input": [
- 379,
+ 385,
"LineChartDataInput!"
]
}
],
"barChartData": [
- 318,
+ 324,
{
"input": [
- 380,
+ 386,
"BarChartDataInput!"
]
}
],
"getConnectedImapSmtpCaldavAccount": [
- 309,
+ 315,
{
"id": [
3,
@@ -7329,7 +7400,7 @@ export default {
}
],
"getAutoCompleteAddress": [
- 304,
+ 310,
{
"address": [
1,
@@ -7348,7 +7419,7 @@ export default {
}
],
"getAddressDetails": [
- 306,
+ 312,
{
"placeId": [
1,
@@ -7364,12 +7435,12 @@ export default {
276,
{
"input": [
- 381
+ 387
]
}
],
"findManyPublicDomains": [
- 281
+ 287
],
"currentUserApplicationAuthorizations": [
277
@@ -7396,10 +7467,10 @@ export default {
},
"ObjectFilter": {
"and": [
- 368
+ 374
],
"or": [
- 368
+ 374
],
"id": [
29
@@ -7453,7 +7524,7 @@ export default {
},
"FindMessageSuppressionsInput": {
"reason": [
- 299
+ 305
],
"searchTerm": [
1
@@ -7501,10 +7572,10 @@ export default {
},
"EventLogQueryInput": {
"table": [
- 375
+ 381
],
"filters": [
- 376
+ 382
],
"first": [
26
@@ -7525,7 +7596,7 @@ export default {
1
],
"dateRange": [
- 377
+ 383
],
"recordId": [
1
@@ -7592,7 +7663,7 @@ export default {
1
],
"operationTypes": [
- 382
+ 388
],
"__typename": [
1
@@ -7604,7 +7675,7 @@ export default {
8,
{
"input": [
- 384,
+ 390,
"AddQuerySubscriptionInput!"
]
}
@@ -7613,7 +7684,7 @@ export default {
8,
{
"input": [
- 385,
+ 391,
"RemoveQueryFromEventStreamInput!"
]
}
@@ -7622,7 +7693,7 @@ export default {
150,
{
"inputs": [
- 386,
+ 392,
"[CreateNavigationMenuItemInput!]!"
]
}
@@ -7631,7 +7702,7 @@ export default {
150,
{
"input": [
- 386,
+ 392,
"CreateNavigationMenuItemInput!"
]
}
@@ -7640,7 +7711,7 @@ export default {
150,
{
"inputs": [
- 387,
+ 393,
"[UpdateOneNavigationMenuItemInput!]!"
]
}
@@ -7649,7 +7720,7 @@ export default {
150,
{
"input": [
- 387,
+ 393,
"UpdateOneNavigationMenuItemInput!"
]
}
@@ -7684,7 +7755,7 @@ export default {
"Float!"
],
"fileFolder": [
- 389,
+ 282,
"FileFolder!"
],
"fieldMetadataId": [
@@ -7723,7 +7794,7 @@ export default {
147,
{
"file": [
- 390,
+ 395,
"Upload!"
]
}
@@ -7732,7 +7803,7 @@ export default {
147,
{
"file": [
- 390,
+ 395,
"Upload!"
]
}
@@ -7741,7 +7812,7 @@ export default {
147,
{
"file": [
- 390,
+ 395,
"Upload!"
]
}
@@ -7750,7 +7821,7 @@ export default {
147,
{
"file": [
- 390,
+ 395,
"Upload!"
]
}
@@ -7759,7 +7830,7 @@ export default {
147,
{
"file": [
- 390,
+ 395,
"Upload!"
]
}
@@ -7768,7 +7839,7 @@ export default {
147,
{
"file": [
- 390,
+ 395,
"Upload!"
],
"fieldMetadataId": [
@@ -7781,7 +7852,7 @@ export default {
147,
{
"file": [
- 390,
+ 395,
"Upload!"
],
"fieldMetadataUniversalIdentifier": [
@@ -7794,7 +7865,7 @@ export default {
53,
{
"input": [
- 391,
+ 396,
"CreateViewFilterGroupInput!"
]
}
@@ -7807,7 +7878,7 @@ export default {
"String!"
],
"input": [
- 392,
+ 397,
"UpdateViewFilterGroupInput!"
]
}
@@ -7834,7 +7905,7 @@ export default {
55,
{
"input": [
- 393,
+ 398,
"CreateViewFilterInput!"
]
}
@@ -7843,7 +7914,7 @@ export default {
55,
{
"input": [
- 394,
+ 399,
"UpdateViewFilterInput!"
]
}
@@ -7852,7 +7923,7 @@ export default {
55,
{
"input": [
- 396,
+ 401,
"DeleteViewFilterInput!"
]
}
@@ -7861,7 +7932,7 @@ export default {
55,
{
"input": [
- 397,
+ 402,
"DestroyViewFilterInput!"
]
}
@@ -7870,7 +7941,7 @@ export default {
61,
{
"input": [
- 398,
+ 403,
"CreateViewInput!"
]
}
@@ -7883,7 +7954,7 @@ export default {
"String!"
],
"input": [
- 399,
+ 404,
"UpdateViewInput!"
]
}
@@ -7910,7 +7981,7 @@ export default {
61,
{
"input": [
- 400,
+ 405,
"UpsertViewWidgetInput!"
]
}
@@ -7919,7 +7990,7 @@ export default {
58,
{
"input": [
- 406,
+ 411,
"CreateViewSortInput!"
]
}
@@ -7928,7 +7999,7 @@ export default {
58,
{
"input": [
- 407,
+ 412,
"UpdateViewSortInput!"
]
}
@@ -7937,7 +8008,7 @@ export default {
8,
{
"input": [
- 409,
+ 414,
"DeleteViewSortInput!"
]
}
@@ -7946,7 +8017,7 @@ export default {
8,
{
"input": [
- 410,
+ 415,
"DestroyViewSortInput!"
]
}
@@ -7955,7 +8026,7 @@ export default {
51,
{
"input": [
- 411,
+ 416,
"UpdateViewFieldInput!"
]
}
@@ -7964,7 +8035,7 @@ export default {
51,
{
"input": [
- 413,
+ 418,
"CreateViewFieldInput!"
]
}
@@ -7973,7 +8044,7 @@ export default {
51,
{
"inputs": [
- 413,
+ 418,
"[CreateViewFieldInput!]!"
]
}
@@ -7982,7 +8053,7 @@ export default {
51,
{
"input": [
- 414,
+ 419,
"DeleteViewFieldInput!"
]
}
@@ -7991,7 +8062,7 @@ export default {
51,
{
"input": [
- 415,
+ 420,
"DestroyViewFieldInput!"
]
}
@@ -8000,7 +8071,7 @@ export default {
60,
{
"input": [
- 416,
+ 421,
"UpdateViewFieldGroupInput!"
]
}
@@ -8009,7 +8080,7 @@ export default {
60,
{
"input": [
- 418,
+ 423,
"CreateViewFieldGroupInput!"
]
}
@@ -8018,7 +8089,7 @@ export default {
60,
{
"inputs": [
- 418,
+ 423,
"[CreateViewFieldGroupInput!]!"
]
}
@@ -8027,7 +8098,7 @@ export default {
60,
{
"input": [
- 419,
+ 424,
"DeleteViewFieldGroupInput!"
]
}
@@ -8036,7 +8107,7 @@ export default {
60,
{
"input": [
- 420,
+ 425,
"DestroyViewFieldGroupInput!"
]
}
@@ -8045,7 +8116,7 @@ export default {
61,
{
"input": [
- 421,
+ 426,
"UpsertFieldsWidgetInput!"
]
}
@@ -8054,7 +8125,7 @@ export default {
2,
{
"input": [
- 424,
+ 429,
"CreateApiKeyInput!"
]
}
@@ -8063,7 +8134,7 @@ export default {
2,
{
"input": [
- 425,
+ 430,
"UpdateApiKeyInput!"
]
}
@@ -8072,7 +8143,7 @@ export default {
2,
{
"input": [
- 426,
+ 431,
"RevokeApiKeyInput!"
]
}
@@ -8265,7 +8336,7 @@ export default {
146,
{
"input": [
- 427,
+ 432,
"CreateApprovedAccessDomainInput!"
]
}
@@ -8274,7 +8345,7 @@ export default {
8,
{
"input": [
- 428,
+ 433,
"DeleteApprovedAccessDomainInput!"
]
}
@@ -8283,7 +8354,7 @@ export default {
146,
{
"input": [
- 429,
+ 434,
"ValidateApprovedAccessDomainInput!"
]
}
@@ -8292,7 +8363,7 @@ export default {
120,
{
"input": [
- 430,
+ 435,
"CreatePageLayoutTabInput!"
]
}
@@ -8305,7 +8376,7 @@ export default {
"String!"
],
"input": [
- 431,
+ 436,
"UpdatePageLayoutTabInput!"
]
}
@@ -8323,7 +8394,7 @@ export default {
121,
{
"input": [
- 432,
+ 437,
"CreatePageLayoutInput!"
]
}
@@ -8336,7 +8407,7 @@ export default {
"String!"
],
"input": [
- 433,
+ 438,
"UpdatePageLayoutInput!"
]
}
@@ -8358,7 +8429,7 @@ export default {
"String!"
],
"input": [
- 434,
+ 439,
"UpdatePageLayoutWithTabsInput!"
]
}
@@ -8394,7 +8465,7 @@ export default {
78,
{
"input": [
- 438,
+ 443,
"CreatePageLayoutWidgetInput!"
]
}
@@ -8407,7 +8478,7 @@ export default {
"String!"
],
"input": [
- 439,
+ 444,
"UpdatePageLayoutWidgetInput!"
]
}
@@ -8425,7 +8496,7 @@ export default {
10,
{
"input": [
- 440,
+ 445,
"CreateAgentInput!"
]
}
@@ -8434,7 +8505,7 @@ export default {
10,
{
"input": [
- 441,
+ 446,
"UpdateAgentInput!"
]
}
@@ -8443,7 +8514,7 @@ export default {
10,
{
"input": [
- 367,
+ 373,
"AgentIdInput!"
]
}
@@ -8452,7 +8523,7 @@ export default {
23,
{
"input": [
- 442,
+ 447,
"CreateOneObjectInput!"
]
}
@@ -8461,7 +8532,7 @@ export default {
23,
{
"input": [
- 444,
+ 449,
"DeleteOneObjectInput!"
]
}
@@ -8470,7 +8541,7 @@ export default {
23,
{
"input": [
- 445,
+ 450,
"UpdateOneObjectInput!"
]
}
@@ -8479,7 +8550,7 @@ export default {
232,
{
"input": [
- 448,
+ 453,
"CreateOneIndexInput!"
]
}
@@ -8488,7 +8559,7 @@ export default {
232,
{
"input": [
- 451,
+ 456,
"DeleteOneIndexInput!"
]
}
@@ -8497,7 +8568,7 @@ export default {
21,
{
"input": [
- 369,
+ 375,
"LogicFunctionIdInput!"
]
}
@@ -8506,7 +8577,7 @@ export default {
21,
{
"input": [
- 452,
+ 457,
"CreateLogicFunctionFromSourceInput!"
]
}
@@ -8515,7 +8586,7 @@ export default {
142,
{
"input": [
- 453,
+ 458,
"ExecuteOneLogicFunctionInput!"
]
}
@@ -8524,7 +8595,7 @@ export default {
8,
{
"input": [
- 454,
+ 459,
"UpdateLogicFunctionFromSourceInput!"
]
}
@@ -8533,7 +8604,7 @@ export default {
14,
{
"input": [
- 456,
+ 461,
"CreateCommandMenuItemInput!"
]
}
@@ -8542,7 +8613,7 @@ export default {
14,
{
"input": [
- 457,
+ 462,
"UpdateCommandMenuItemInput!"
]
}
@@ -8569,7 +8640,7 @@ export default {
13,
{
"input": [
- 458,
+ 463,
"CreateFrontComponentInput!"
]
}
@@ -8578,7 +8649,7 @@ export default {
13,
{
"input": [
- 459,
+ 464,
"UpdateFrontComponentInput!"
]
}
@@ -8596,7 +8667,7 @@ export default {
67,
{
"data": [
- 461,
+ 466,
"ActivateWorkspaceInput!"
]
}
@@ -8605,7 +8676,7 @@ export default {
67,
{
"data": [
- 462,
+ 467,
"UpdateWorkspaceInput!"
]
}
@@ -8636,7 +8707,7 @@ export default {
201,
{
"input": [
- 463,
+ 468,
"CreateApplicationRegistrationInput!"
]
}
@@ -8645,7 +8716,7 @@ export default {
73,
{
"input": [
- 464,
+ 469,
"UpdateApplicationRegistrationInput!"
]
}
@@ -8672,7 +8743,7 @@ export default {
174,
{
"input": [
- 466,
+ 471,
"CreateApplicationRegistrationVariableInput!"
]
}
@@ -8681,7 +8752,7 @@ export default {
174,
{
"input": [
- 467,
+ 472,
"UpdateApplicationRegistrationVariableInput!"
]
}
@@ -8699,7 +8770,7 @@ export default {
73,
{
"file": [
- 390,
+ 395,
"Upload!"
],
"universalIdentifier": [
@@ -8761,7 +8832,7 @@ export default {
"UUID!"
],
"input": [
- 469,
+ 474,
"UpdateApplicationInput!"
]
}
@@ -8782,7 +8853,7 @@ export default {
224,
{
"input": [
- 470,
+ 475,
"CreateOneFieldMetadataInput!"
]
}
@@ -8791,7 +8862,7 @@ export default {
224,
{
"input": [
- 472,
+ 477,
"UpdateOneFieldMetadataInput!"
]
}
@@ -8800,7 +8871,7 @@ export default {
224,
{
"input": [
- 474,
+ 479,
"DeleteOneFieldInput!"
]
}
@@ -8809,7 +8880,7 @@ export default {
57,
{
"input": [
- 475,
+ 480,
"CreateViewGroupInput!"
]
}
@@ -8818,7 +8889,7 @@ export default {
57,
{
"inputs": [
- 475,
+ 480,
"[CreateViewGroupInput!]!"
]
}
@@ -8827,7 +8898,7 @@ export default {
57,
{
"input": [
- 476,
+ 481,
"UpdateViewGroupInput!"
]
}
@@ -8836,7 +8907,7 @@ export default {
57,
{
"inputs": [
- 476,
+ 481,
"[UpdateViewGroupInput!]!"
]
}
@@ -8845,7 +8916,7 @@ export default {
57,
{
"input": [
- 478,
+ 483,
"DeleteViewGroupInput!"
]
}
@@ -8854,7 +8925,7 @@ export default {
57,
{
"input": [
- 479,
+ 484,
"DestroyViewGroupInput!"
]
}
@@ -8876,7 +8947,7 @@ export default {
46,
{
"createRoleInput": [
- 480,
+ 485,
"CreateRoleInput!"
]
}
@@ -8885,7 +8956,7 @@ export default {
46,
{
"updateRoleInput": [
- 481,
+ 486,
"UpdateRoleInput!"
]
}
@@ -8903,7 +8974,7 @@ export default {
43,
{
"upsertObjectPermissionsInput": [
- 483,
+ 488,
"UpsertObjectPermissionsInput!"
]
}
@@ -8912,7 +8983,7 @@ export default {
44,
{
"upsertPermissionFlagsInput": [
- 485,
+ 490,
"UpsertPermissionFlagsInput!"
]
}
@@ -8921,7 +8992,7 @@ export default {
38,
{
"upsertFieldPermissionsInput": [
- 486,
+ 491,
"UpsertFieldPermissionsInput!"
]
}
@@ -8930,7 +9001,7 @@ export default {
245,
{
"input": [
- 488,
+ 493,
"UpsertRowLevelPermissionPredicatesInput!"
]
}
@@ -8958,46 +9029,46 @@ export default {
}
],
"sendEmailViaEmailingDomain": [
- 295,
+ 301,
{
"input": [
- 491,
+ 496,
"SendEmailViaDomainInput!"
]
}
],
"sendMessageCampaign": [
- 297,
+ 303,
{
"input": [
- 492,
+ 497,
"SendMessageCampaignInput!"
]
}
],
"sendMessageCampaignTest": [
- 295,
+ 301,
{
"input": [
- 493,
+ 498,
"SendMessageCampaignTestInput!"
]
}
],
"createUnsubscribeTopic": [
- 302,
+ 308,
{
"input": [
- 494,
+ 499,
"CreateUnsubscribeTopicInput!"
]
}
],
"updateUnsubscribeTopic": [
- 302,
+ 308,
{
"input": [
- 495,
+ 500,
"UpdateUnsubscribeTopicInput!"
]
}
@@ -9012,34 +9083,34 @@ export default {
}
],
"updateMessageChannel": [
- 285,
+ 291,
{
"input": [
- 496,
+ 501,
"UpdateMessageChannelInput!"
]
}
],
"createEmailGroupChannel": [
- 293,
+ 299,
{
"input": [
- 498,
+ 503,
"CreateEmailGroupChannelInput!"
]
}
],
"updateEmailGroupChannel": [
- 285,
+ 291,
{
"input": [
- 499,
+ 504,
"UpdateEmailGroupChannelInput!"
]
}
],
"deleteEmailGroupChannel": [
- 285,
+ 291,
{
"id": [
3,
@@ -9048,10 +9119,10 @@ export default {
}
],
"createEmailingDomain": [
- 283,
+ 289,
{
"input": [
- 500,
+ 505,
"CreateEmailingDomainInput!"
]
}
@@ -9066,7 +9137,7 @@ export default {
}
],
"verifyEmailingDomain": [
- 283,
+ 289,
{
"id": [
1,
@@ -9084,34 +9155,34 @@ export default {
}
],
"runAgent": [
- 314,
+ 320,
{
"input": [
- 501,
+ 506,
"RunAgentInput!"
]
}
],
"createWebhook": [
- 311,
+ 317,
{
"input": [
- 504,
+ 509,
"CreateWebhookInput!"
]
}
],
"updateWebhook": [
- 311,
+ 317,
{
"input": [
- 505,
+ 510,
"UpdateWebhookInput!"
]
}
],
"deleteWebhook": [
- 311,
+ 317,
{
"id": [
3,
@@ -9120,37 +9191,37 @@ export default {
}
],
"updateMessageFolder": [
- 353,
+ 359,
{
"input": [
- 507,
+ 512,
"UpdateMessageFolderInput!"
]
}
],
"updateMessageFolders": [
- 353,
+ 359,
{
"input": [
- 509,
+ 514,
"UpdateMessageFoldersInput!"
]
}
],
"updateCalendarChannel": [
- 348,
+ 354,
{
"input": [
- 510,
+ 515,
"UpdateCalendarChannelInput!"
]
}
],
"setAppKeyValue": [
- 346,
+ 352,
{
"input": [
- 512,
+ 517,
"SetAppKeyValueInput!"
]
}
@@ -9163,33 +9234,33 @@ export default {
"String!"
],
"scope": [
- 347
+ 353
]
}
],
"enqueueJob": [
- 344,
+ 350,
{
"input": [
- 513,
+ 518,
"EnqueueJobInput!"
]
}
],
"enqueueJobs": [
- 345,
+ 351,
{
"input": [
- 514,
+ 519,
"EnqueueJobsInput!"
]
}
],
"createChatThread": [
- 332
+ 338
],
"sendChatMessage": [
- 337,
+ 343,
{
"threadId": [
3,
@@ -9210,13 +9281,13 @@ export default {
1
],
"fileAttachments": [
- 515,
+ 520,
"[FileAttachmentInput!]"
]
}
],
"retryChatMessage": [
- 337,
+ 343,
{
"threadId": [
3,
@@ -9228,7 +9299,7 @@ export default {
}
],
"answerAgentChatQuestion": [
- 337,
+ 343,
{
"threadId": [
3,
@@ -9239,14 +9310,14 @@ export default {
"UUID!"
],
"answers": [
- 516,
+ 521,
"[AgentChatQuestionAnswerInput!]!"
],
"modelId": [
1
],
"fileAttachments": [
- 515,
+ 520,
"[FileAttachmentInput!]"
]
}
@@ -9261,7 +9332,7 @@ export default {
}
],
"renameChatThread": [
- 332,
+ 338,
{
"id": [
3,
@@ -9274,7 +9345,7 @@ export default {
}
],
"archiveChatThread": [
- 332,
+ 338,
{
"id": [
3,
@@ -9283,7 +9354,7 @@ export default {
}
],
"unarchiveChatThread": [
- 332,
+ 338,
{
"id": [
3,
@@ -9310,7 +9381,7 @@ export default {
}
],
"startWorkspaceSetupChat": [
- 339,
+ 345,
{
"companyContext": [
9
@@ -9321,25 +9392,25 @@ export default {
}
],
"createSkill": [
- 330,
+ 336,
{
"input": [
- 517,
+ 522,
"CreateSkillInput!"
]
}
],
"updateSkill": [
- 330,
+ 336,
{
"input": [
- 518,
+ 523,
"UpdateSkillInput!"
]
}
],
"deleteSkill": [
- 330,
+ 336,
{
"id": [
3,
@@ -9348,7 +9419,7 @@ export default {
}
],
"activateSkill": [
- 330,
+ 336,
{
"id": [
3,
@@ -9357,7 +9428,7 @@ export default {
}
],
"deactivateSkill": [
- 330,
+ 336,
{
"id": [
3,
@@ -9366,7 +9437,7 @@ export default {
}
],
"evaluateAgentTurn": [
- 341,
+ 347,
{
"turnId": [
3,
@@ -9375,7 +9446,7 @@ export default {
}
],
"runEvaluationInput": [
- 342,
+ 348,
{
"agentId": [
3,
@@ -9388,16 +9459,16 @@ export default {
}
],
"updateTimelineActivityType": [
- 359,
+ 365,
{
"input": [
- 519,
+ 524,
"UpdateTimelineActivityTypeInput!"
]
}
],
"resetTimelineActivityType": [
- 359,
+ 365,
{
"id": [
3,
@@ -9409,7 +9480,7 @@ export default {
258,
{
"input": [
- 520,
+ 525,
"GetAuthorizationUrlForSSOInput!"
]
}
@@ -9575,7 +9646,7 @@ export default {
261,
{
"input": [
- 521
+ 526
]
}
],
@@ -9587,7 +9658,7 @@ export default {
"String!"
],
"file": [
- 390,
+ 395,
"Upload!"
]
}
@@ -9750,7 +9821,7 @@ export default {
8,
{
"input": [
- 522,
+ 527,
"UpdateWorkspaceMemberSettingsInput!"
]
}
@@ -9784,7 +9855,7 @@ export default {
211,
{
"input": [
- 523,
+ 528,
"SetupOIDCSsoInput!"
]
}
@@ -9793,7 +9864,7 @@ export default {
211,
{
"input": [
- 524,
+ 529,
"SetupSAMLSsoInput!"
]
}
@@ -9802,7 +9873,7 @@ export default {
207,
{
"input": [
- 525,
+ 530,
"DeleteSsoInput!"
]
}
@@ -9811,13 +9882,13 @@ export default {
208,
{
"input": [
- 526,
+ 531,
"EditSsoInput!"
]
}
],
"createObjectEvent": [
- 326,
+ 332,
{
"event": [
1,
@@ -9837,10 +9908,10 @@ export default {
}
],
"trackAnalytics": [
- 326,
+ 332,
{
"type": [
- 527,
+ 532,
"AnalyticsType!"
],
"name": [
@@ -9855,7 +9926,7 @@ export default {
}
],
"duplicateDashboard": [
- 324,
+ 330,
{
"id": [
3,
@@ -9880,25 +9951,25 @@ export default {
273
],
"createCalendarEvent": [
- 316,
+ 322,
{
"input": [
- 528,
+ 533,
"CreateCalendarEventInput!"
]
}
],
"sendEmail": [
- 325,
+ 331,
{
"input": [
- 529,
+ 534,
"SendEmailInput!"
]
}
],
"startChannelSync": [
- 315,
+ 321,
{
"connectedAccountId": [
3,
@@ -9907,14 +9978,14 @@ export default {
}
],
"saveImapSmtpCaldavAccount": [
- 310,
+ 316,
{
"handle": [
1,
"String!"
],
"connectionParameters": [
- 531,
+ 536,
"EmailAccountConnectionParameters!"
],
"id": [
@@ -9926,13 +9997,13 @@ export default {
171,
{
"input": [
- 533,
+ 538,
"UpdateLabPublicFeatureFlagInput!"
]
}
],
"createPublicDomain": [
- 281,
+ 287,
{
"domain": [
1,
@@ -9963,7 +10034,7 @@ export default {
}
],
"createDevelopmentApplication": [
- 278,
+ 285,
{
"universalIdentifier": [
1,
@@ -9976,7 +10047,7 @@ export default {
}
],
"syncApplication": [
- 279,
+ 286,
{
"manifest": [
9,
@@ -9988,10 +10059,10 @@ export default {
}
],
"uploadApplicationFile": [
- 280,
+ 278,
{
"file": [
- 390,
+ 395,
"Upload!"
],
"applicationUniversalIdentifier": [
@@ -9999,7 +10070,7 @@ export default {
"String!"
],
"fileFolder": [
- 389,
+ 282,
"FileFolder!"
],
"filePath": [
@@ -10008,6 +10079,32 @@ export default {
]
}
],
+ "createApplicationFileUploads": [
+ 284,
+ {
+ "applicationUniversalIdentifier": [
+ 1,
+ "String!"
+ ],
+ "files": [
+ 539,
+ "[ApplicationFileUploadRequestInput!]!"
+ ]
+ }
+ ],
+ "completeApplicationFileUploads": [
+ 280,
+ {
+ "applicationUniversalIdentifier": [
+ 1,
+ "String!"
+ ],
+ "fileIds": [
+ 3,
+ "[UUID!]!"
+ ]
+ }
+ ],
"revokeApplicationAuthorization": [
8,
{
@@ -10113,7 +10210,7 @@ export default {
3
],
"update": [
- 388
+ 394
],
"__typename": [
1
@@ -10145,7 +10242,6 @@ export default {
1
]
},
- "FileFolder": {},
"Upload": {},
"CreateViewFilterGroupInput": {
"id": [
@@ -10224,7 +10320,7 @@ export default {
3
],
"update": [
- 395
+ 400
],
"__typename": [
1
@@ -10395,19 +10491,19 @@ export default {
3
],
"view": [
- 401
+ 406
],
"viewFields": [
- 402
+ 407
],
"viewFilters": [
- 403
+ 408
],
"viewFilterGroups": [
- 404
+ 409
],
"viewSorts": [
- 405
+ 410
],
"__typename": [
1
@@ -10556,7 +10652,7 @@ export default {
3
],
"update": [
- 408
+ 413
],
"__typename": [
1
@@ -10594,7 +10690,7 @@ export default {
3
],
"update": [
- 412
+ 417
],
"__typename": [
1
@@ -10670,7 +10766,7 @@ export default {
3
],
"update": [
- 417
+ 422
],
"__typename": [
1
@@ -10734,10 +10830,10 @@ export default {
3
],
"groups": [
- 422
+ 427
],
"fields": [
- 423
+ 428
],
"__typename": [
1
@@ -10757,7 +10853,7 @@ export default {
8
],
"fields": [
- 423
+ 428
],
"__typename": [
1
@@ -10925,7 +11021,7 @@ export default {
3
],
"tabs": [
- 435
+ 440
],
"__typename": [
1
@@ -10948,7 +11044,7 @@ export default {
82
],
"widgets": [
- 436
+ 441
],
"__typename": [
1
@@ -10971,7 +11067,7 @@ export default {
3
],
"gridPosition": [
- 437
+ 442
],
"position": [
9
@@ -11020,7 +11116,7 @@ export default {
3
],
"gridPosition": [
- 437
+ 442
],
"position": [
9
@@ -11046,7 +11142,7 @@ export default {
3
],
"gridPosition": [
- 437
+ 442
],
"position": [
9
@@ -11139,7 +11235,7 @@ export default {
},
"CreateOneObjectInput": {
"object": [
- 443
+ 448
],
"__typename": [
1
@@ -11199,7 +11295,7 @@ export default {
},
"UpdateOneObjectInput": {
"update": [
- 446
+ 451
],
"id": [
3
@@ -11252,7 +11348,7 @@ export default {
24
],
"translations": [
- 447
+ 452
],
"__typename": [
1
@@ -11274,7 +11370,7 @@ export default {
},
"CreateOneIndexInput": {
"index": [
- 449
+ 454
],
"__typename": [
1
@@ -11285,7 +11381,7 @@ export default {
3
],
"fields": [
- 450
+ 455
],
"indexType": [
233
@@ -11370,7 +11466,7 @@ export default {
3
],
"update": [
- 455
+ 460
],
"__typename": [
1
@@ -11530,7 +11626,7 @@ export default {
3
],
"update": [
- 460
+ 465
],
"__typename": [
1
@@ -11657,7 +11753,7 @@ export default {
1
],
"update": [
- 465
+ 470
],
"__typename": [
1
@@ -11711,7 +11807,7 @@ export default {
1
],
"update": [
- 468
+ 473
],
"__typename": [
1
@@ -11741,7 +11837,7 @@ export default {
},
"CreateOneFieldMetadataInput": {
"field": [
- 471
+ 476
],
"__typename": [
1
@@ -11814,7 +11910,7 @@ export default {
3
],
"update": [
- 473
+ 478
],
"__typename": [
1
@@ -11873,7 +11969,7 @@ export default {
9
],
"translations": [
- 447
+ 452
],
"__typename": [
1
@@ -11912,7 +12008,7 @@ export default {
3
],
"update": [
- 477
+ 482
],
"__typename": [
1
@@ -11997,7 +12093,7 @@ export default {
},
"UpdateRoleInput": {
"update": [
- 482
+ 487
],
"id": [
3
@@ -12052,7 +12148,7 @@ export default {
3
],
"objectPermissions": [
- 484
+ 489
],
"__typename": [
1
@@ -12094,7 +12190,7 @@ export default {
3
],
"fieldPermissions": [
- 487
+ 492
],
"__typename": [
1
@@ -12125,10 +12221,10 @@ export default {
3
],
"predicates": [
- 489
+ 494
],
"predicateGroups": [
- 490
+ 495
],
"__typename": [
1
@@ -12254,7 +12350,7 @@ export default {
1
],
"visibility": [
- 303
+ 309
],
"__typename": [
1
@@ -12271,7 +12367,7 @@ export default {
1
],
"visibility": [
- 303
+ 309
],
"__typename": [
1
@@ -12282,7 +12378,7 @@ export default {
3
],
"update": [
- 497
+ 502
],
"__typename": [
1
@@ -12290,16 +12386,16 @@ export default {
},
"UpdateMessageChannelInputUpdates": {
"visibility": [
- 286
+ 292
],
"isContactAutoCreationEnabled": [
8
],
"contactAutoCreationPolicy": [
- 288
+ 294
],
"messageFolderImportPolicy": [
- 289
+ 295
],
"isSyncEnabled": [
8
@@ -12355,7 +12451,7 @@ export default {
3
],
"messages": [
- 502
+ 507
],
"__typename": [
1
@@ -12363,7 +12459,7 @@ export default {
},
"RunAgentMessageInput": {
"role": [
- 503
+ 508
],
"content": [
1
@@ -12398,7 +12494,7 @@ export default {
3
],
"update": [
- 506
+ 511
],
"__typename": [
1
@@ -12426,7 +12522,7 @@ export default {
3
],
"update": [
- 508
+ 513
],
"__typename": [
1
@@ -12445,7 +12541,7 @@ export default {
3
],
"update": [
- 508
+ 513
],
"__typename": [
1
@@ -12456,7 +12552,7 @@ export default {
3
],
"update": [
- 511
+ 516
],
"__typename": [
1
@@ -12464,13 +12560,13 @@ export default {
},
"UpdateCalendarChannelInputUpdates": {
"visibility": [
- 351
+ 357
],
"isContactAutoCreationEnabled": [
8
],
"contactAutoCreationPolicy": [
- 352
+ 358
],
"isSyncEnabled": [
8
@@ -12487,7 +12583,7 @@ export default {
9
],
"scope": [
- 347
+ 353
],
"__typename": [
1
@@ -12615,7 +12711,7 @@ export default {
8
],
"translations": [
- 447
+ 452
],
"__typename": [
1
@@ -12781,7 +12877,7 @@ export default {
1
],
"files": [
- 530
+ 535
],
"__typename": [
1
@@ -12803,13 +12899,13 @@ export default {
1
],
"IMAP": [
- 532
+ 537
],
"SMTP": [
- 532
+ 537
],
"CALDAV": [
- 532
+ 537
],
"__typename": [
1
@@ -12846,6 +12942,20 @@ export default {
1
]
},
+ "ApplicationFileUploadRequestInput": {
+ "fileFolder": [
+ 282
+ ],
+ "filePath": [
+ 1
+ ],
+ "size": [
+ 26
+ ],
+ "__typename": [
+ 1
+ ]
+ },
"Subscription": {
"onEventSubscription": [
158,
@@ -12860,13 +12970,13 @@ export default {
246,
{
"input": [
- 535,
+ 541,
"LogicFunctionLogsInput!"
]
}
],
"onAgentChatEvent": [
- 338,
+ 344,
{
"threadId": [
3,
@@ -12875,10 +12985,10 @@ export default {
}
],
"eventLogsLive": [
- 327,
+ 333,
{
"table": [
- 375,
+ 381,
"EventLogTable!"
]
}
diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts
index 13abbd28cc4..96647de2563 100644
--- a/packages/twenty-front/src/generated-metadata/graphql.ts
+++ b/packages/twenty-front/src/generated-metadata/graphql.ts
@@ -351,6 +351,35 @@ export type ApplicationConnectionProviderOAuthConfig = {
scopes: Array<Scalars['String']['output']>;
};
+export type ApplicationFileCompletionError = {
+ __typename?: 'ApplicationFileCompletionError';
+ fileId: Scalars['UUID']['output'];
+ message: Scalars['String']['output'];
+};
+
+export type ApplicationFileUploadError = {
+ __typename?: 'ApplicationFileUploadError';
+ fileFolder: FileFolder;
+ filePath: Scalars['String']['output'];
+ message: Scalars['String']['output'];
+};
+
+export type ApplicationFileUploadRequestInput = {
+ fileFolder: FileFolder;
+ filePath: Scalars['String']['input'];
+ size: Scalars['Int']['input'];
+};
+
+export type ApplicationFileUploadTarget = {
+ __typename?: 'ApplicationFileUploadTarget';
+ contentType: Scalars['String']['output'];
+ expiresAt: Scalars['DateTime']['output'];
+ fileFolder: FileFolder;
+ fileId: Scalars['UUID']['output'];
+ filePath: Scalars['String']['output'];
+ uploadUrl: Scalars['String']['output'];
+};
+
export type ApplicationRegistration = {
__typename?: 'ApplicationRegistration';
createdAt: Scalars['DateTime']['output'];
@@ -1033,6 +1062,12 @@ export enum CommandMenuItemAvailabilityType {
export type CommandMenuItemPayload = ObjectMetadataCommandMenuItemPayload | PathCommandMenuItemPayload;
+export type CompleteApplicationFileUploadsResult = {
+ __typename?: 'CompleteApplicationFileUploadsResult';
+ errors: Array<ApplicationFileCompletionError>;
+ files: Array<File>;
+};
+
export type ConnectedAccountPublicDto = {
__typename?: 'ConnectedAccountPublicDTO';
applicationId?: Maybe<Scalars['UUID']['output']>;
@@ -1091,6 +1126,12 @@ export type CreateApiKeyInput = {
roleId: Scalars['UUID']['input'];
};
+export type CreateApplicationFileUploadsResult = {
+ __typename?: 'CreateApplicationFileUploadsResult';
+ errors: Array<ApplicationFileUploadError>;
+ targets: Array<ApplicationFileUploadTarget>;
+};
+
export type CreateApplicationRegistration = {
__typename?: 'CreateApplicationRegistration';
applicationRegistration: ApplicationRegistration;
@@ -2662,9 +2703,11 @@ export type Mutation = {
checkPublicDomainValidRecords?: Maybe<DomainValidRecords>;
checkoutSession: BillingSession;
claimApplicationRegistrationOwnership: ApplicationRegistration;
+ completeApplicationFileUploads: CompleteApplicationFileUploadsResult;
completeBookCallOnboardingStep: OnboardingStepSuccess;
completeFileUpload: FileWithSignedUrl;
createApiKey: ApiKey;
+ createApplicationFileUploads: CreateApplicationFileUploadsResult;
createApplicationRegistration: CreateApplicationRegistration;
createApplicationRegistrationVariable: ApplicationRegistrationVariable;
createApprovedAccessDomain: ApprovedAccessDomain;
@@ -2964,6 +3007,12 @@ export type MutationClaimApplicationRegistrationOwnershipArgs = {
};
+export type MutationCompleteApplicationFileUploadsArgs = {
+ applicationUniversalIdentifier: Scalars['String']['input'];
+ fileIds: Array<Scalars['UUID']['input']>;
+};
+
+
export type MutationCompleteBookCallOnboardingStepArgs = {
hasBookedCall?: Scalars['Boolean']['input'];
isAutoSkipped?: Scalars['Boolean']['input'];
@@ -2980,6 +3029,12 @@ export type MutationCreateApiKeyArgs = {
};
+export type MutationCreateApplicationFileUploadsArgs = {
+ applicationUniversalIdentifier: Scalars['String']['input'];
+ files: Array<ApplicationFileUploadRequestInput>;
+};
+
+
export type MutationCreateApplicationRegistrationArgs = {
input: CreateApplicationRegistrationInput;
};
diff --git a/packages/twenty-sdk/src/cli/__tests__/integration/utils/setup-app-dev-mocks.ts b/packages/twenty-sdk/src/cli/__tests__/integration/utils/setup-app-dev-mocks.ts
index 31aa92ceb2a..8521c022782 100644
--- a/packages/twenty-sdk/src/cli/__tests__/integration/utils/setup-app-dev-mocks.ts
+++ b/packages/twenty-sdk/src/cli/__tests__/integration/utils/setup-app-dev-mocks.ts
@@ -29,7 +29,6 @@ export const mockApiService = {
data: { id: 'mock-app-id', universalIdentifier: 'mock-uid' },
}),
syncApplication: vi.fn().mockResolvedValue({ success: true, data: true }),
- uploadFile: vi.fn().mockResolvedValue({ success: true, data: true }),
getSchema: vi
.fn()
.mockResolvedValue({ success: true, data: 'mock-core-schema' }),
@@ -47,14 +46,13 @@ vi.mock('@/cli/utilities/api/api-service', () => ({
mockApiService.createApplicationRegistration;
createDevelopmentApplication = mockApiService.createDevelopmentApplication;
syncApplication = mockApiService.syncApplication;
- uploadFile = mockApiService.uploadFile;
getSchema = mockApiService.getSchema;
},
}));
vi.mock('@/cli/utilities/file/file-uploader', () => ({
FileUploader: class {
- uploadFile = vi.fn().mockResolvedValue({ success: true, data: true });
+ uploadFiles = vi.fn().mockResolvedValue([]);
},
}));
diff --git a/packages/twenty-sdk/src/cli/operations/dev-once.ts b/packages/twenty-sdk/src/cli/operations/dev-once.ts
index f668416c24e..9b48aa1212f 100644
--- a/packages/twenty-sdk/src/cli/operations/dev-once.ts
+++ b/packages/twenty-sdk/src/cli/operations/dev-once.ts
@@ -311,35 +311,24 @@ const innerAppDevOnce = async (
applicationUniversalIdentifier: manifest.application.universalIdentifier,
});
- const uploadErrors: string[] = [];
-
- const uploadPromises = Array.from(buildResult.builtFileInfos.values()).map(
- async (builtFileInfo) => {
- if (verbose) {
- onProgress?.(`Uploading ${builtFileInfo.builtPath}`);
- }
-
- const result = await fileUploader.uploadFile({
- builtPath: builtFileInfo.builtPath,
- fileFolder: builtFileInfo.fileFolder,
- });
-
- if (!result.success) {
- uploadErrors.push(
- `Failed to upload ${builtFileInfo.builtPath}: ${serializeError(result.error)}`,
- );
- }
- },
+ const uploadFailures = await fileUploader.uploadFiles(
+ Array.from(buildResult.builtFileInfos.values()).map((builtFileInfo) => ({
+ builtPath: builtFileInfo.builtPath,
+ fileFolder: builtFileInfo.fileFolder,
+ })),
);
- await Promise.all(uploadPromises);
-
- if (uploadErrors.length > 0) {
+ if (uploadFailures.length > 0) {
return {
success: false,
error: {
code: APP_ERROR_CODES.SYNC_FAILED,
- message: uploadErrors.join('\n'),
+ message: uploadFailures
+ .map(
+ (failure) =>
+ `Failed to upload ${failure.builtPath}: ${failure.error}`,
+ )
+ .join('\n'),
},
};
}
diff --git a/packages/twenty-sdk/src/cli/utilities/api/api-service.ts b/packages/twenty-sdk/src/cli/utilities/api/api-service.ts
index 63c5861cebb..62bc8199945 100644
--- a/packages/twenty-sdk/src/cli/utilities/api/api-service.ts
+++ b/packages/twenty-sdk/src/cli/utilities/api/api-service.ts
@@ -144,4 +144,16 @@ export class ApiService {
uploadFile(...args: Parameters<FileApi['uploadFile']>) {
return this.fileApi.uploadFile(...args);
}
+
+ createApplicationFileUploads(
+ ...args: Parameters<FileApi['createApplicationFileUploads']>
+ ) {
+ return this.fileApi.createApplicationFileUploads(...args);
+ }
+
+ completeApplicationFileUploads(
+ ...args: Parameters<FileApi['completeApplicationFileUploads']>
+ ) {
+ return this.fileApi.completeApplicationFileUploads(...args);
+ }
}
diff --git a/packages/twenty-sdk/src/cli/utilities/api/file-api.ts b/packages/twenty-sdk/src/cli/utilities/api/file-api.ts
index ecd70939080..b937afa8346 100644
--- a/packages/twenty-sdk/src/cli/utilities/api/file-api.ts
+++ b/packages/twenty-sdk/src/cli/utilities/api/file-api.ts
@@ -50,6 +50,41 @@ const getMimeType = (filename: string): string => {
return MIME_TYPES[ext] || 'application/octet-stream';
};
+export type ApplicationFileUploadRequest = {
+ fileFolder: FileFolder;
+ filePath: string;
+ size: number;
+};
+
+export type ApplicationFileUploadTarget = {
+ fileId: string;
+ filePath: string;
+ uploadUrl: string;
+ contentType: string;
+ expiresAt: string;
+};
+
+export type ApplicationFileUploadError = {
+ fileFolder: string;
+ filePath: string;
+ message: string;
+};
+
+export type CreateApplicationFileUploadsResult = {
+ targets: ApplicationFileUploadTarget[];
+ errors: ApplicationFileUploadError[];
+};
+
+export type ApplicationFileCompletionError = {
+ fileId: string;
+ message: string;
+};
+
+export type CompleteApplicationFileUploadsResult = {
+ files: { id: string; path: string }[];
+ errors: ApplicationFileCompletionError[];
+};
+
export class FileApi {
constructor(private readonly client: AxiosInstance) {}
@@ -280,4 +315,124 @@ export class FileApi {
};
}
}
+
+ async createApplicationFileUploads({
+ applicationUniversalIdentifier,
+ files,
+ }: {
+ applicationUniversalIdentifier: string;
+ files: ApplicationFileUploadRequest[];
+ }): Promise<ApiResponse<CreateApplicationFileUploadsResult>> {
+ const mutation = `
+ mutation CreateApplicationFileUploads($applicationUniversalIdentifier: String!, $files: [ApplicationFileUploadRequestInput!]!) {
+ createApplicationFileUploads(applicationUniversalIdentifier: $applicationUniversalIdentifier, files: $files) {
+ targets {
+ fileId
+ filePath
+ uploadUrl
+ contentType
+ expiresAt
+ }
+ errors {
+ fileFolder
+ filePath
+ message
+ }
+ }
+ }
+ `;
+
+ return this.runMetadataMutation<CreateApplicationFileUploadsResult>({
+ mutation,
+ variables: {
+ applicationUniversalIdentifier,
+ files: files.map(({ fileFolder, filePath, size }) => ({
+ fileFolder: pascalCase(fileFolder),
+ filePath,
+ size,
+ })),
+ },
+ resultKey: 'createApplicationFileUploads',
+ defaultErrorMessage: 'Failed to create application file uploads',
+ });
+ }
+
+ async completeApplicationFileUploads({
+ applicationUniversalIdentifier,
+ fileIds,
+ }: {
+ applicationUniversalIdentifier: string;
+ fileIds: string[];
+ }): Promise<ApiResponse<CompleteApplicationFileUploadsResult>> {
+ const mutation = `
+ mutation CompleteApplicationFileUploads($applicationUniversalIdentifier: String!, $fileIds: [UUID!]!) {
+ completeApplicationFileUploads(applicationUniversalIdentifier: $applicationUniversalIdentifier, fileIds: $fileIds) {
+ files {
+ id
+ path
+ }
+ errors {
+ fileId
+ message
+ }
+ }
+ }
+ `;
+
+ return this.runMetadataMutation<CompleteApplicationFileUploadsResult>({
+ mutation,
+ variables: { applicationUniversalIdentifier, fileIds },
+ resultKey: 'completeApplicationFileUploads',
+ defaultErrorMessage: 'Failed to complete application file uploads',
+ });
+ }
+
+ private async runMetadataMutation<TData>({
+ mutation,
+ variables,
+ resultKey,
+ defaultErrorMessage,
+ }: {
+ mutation: string;
+ variables: Record<string, unknown>;
+ resultKey: string;
+ defaultErrorMessage: string;
+ }): Promise<ApiResponse<TData>> {
+ try {
+ const response: AxiosResponse = await this.client.post(
+ '/metadata',
+ { query: mutation, variables },
+ {
+ headers: {
+ 'Content-Type': 'application/json',
+ Accept: '*/*',
+ },
+ },
+ );
+
+ if (response.data.errors) {
+ return {
+ success: false,
+ error: response.data.errors[0]?.message || defaultErrorMessage,
+ };
+ }
+
+ return {
+ success: true,
+ data: response.data.data[resultKey],
+ };
+ } catch (error) {
+ if (axios.isAxiosError(error) && error.response) {
+ return {
+ success: false,
+ error: error.response.data?.errors?.[0]?.message || error.message,
+ };
+ }
+
+ return {
+ success: false,
+ error,
+ };
+ }
+ }
}
diff --git a/packages/twenty-sdk/src/cli/utilities/dev/orchestrator/steps/upload-files-orchestrator-step.ts b/packages/twenty-sdk/src/cli/utilities/dev/orchestrator/steps/upload-files-orchestrator-step.ts
index 8cac9c20f72..721be8f6f54 100644
--- a/packages/twenty-sdk/src/cli/utilities/dev/orchestrator/steps/upload-files-orchestrator-step.ts
+++ b/packages/twenty-sdk/src/cli/utilities/dev/orchestrator/steps/upload-files-orchestrator-step.ts
@@ -12,6 +12,12 @@ export type UploadFilesOrchestratorStepOutput = {
activeUploads: Set<Promise<void>>;
};
+type QueuedUpload = {
+ builtPath: string;
+ sourcePath: string;
+ fileFolder: FileFolder;
+};
+
export class UploadFilesOrchestratorStep {
private state: OrchestratorState;
private notify: () => void;
@@ -59,63 +65,7 @@ export class UploadFilesOrchestratorStep {
sourcePath: string,
fileFolder: FileFolder,
): void {
- const step = this.state.steps.uploadFiles;
-
- if (!step.output.fileUploader) {
- return;
- }
-
- step.status = 'in_progress';
- this.totalQueued++;
-
- if (this.verbose) {
- this.state.addEvent({
- message: `Uploading ${builtPath}`,
- status: 'info',
- });
- }
- this.state.updateEntityStatus(sourcePath, 'uploading');
- this.notify();
-
- const uploadPromise = step.output.fileUploader
- .uploadFile({ builtPath, fileFolder })
- .then((result) => {
- if (result.success) {
- this.uploadedCount++;
-
- if (this.verbose) {
- this.state.addEvent({
- message: `Successfully uploaded ${builtPath}`,
- status: 'success',
- });
- }
- this.state.updateEntityStatus(sourcePath, 'success');
- } else {
- this.failedCount++;
- this.state.addEvent({
- message: `Failed to upload ${builtPath}: ${result.error}`,
- status: 'error',
- });
- }
- })
- .catch((error) => {
- this.failedCount++;
- this.state.addEvent({
- message: `Upload failed for ${builtPath}: ${error}`,
- status: 'error',
- });
- })
- .finally(() => {
- step.output.activeUploads.delete(uploadPromise);
-
- if (step.output.activeUploads.size === 0) {
- this.logUploadSummary();
- step.status = 'done';
- this.notify();
- }
- });
-
- step.output.activeUploads.add(uploadPromise);
+ this.queueUploads([{ builtPath, sourcePath, fileFolder }]);
}
async waitForUploads(): Promise<void> {
@@ -158,11 +108,86 @@ export class UploadFilesOrchestratorStep {
}
private uploadPendingFiles(): void {
- for (const [
- builtPath,
- { fileFolder, sourcePath },
- ] of this.state.steps.uploadFiles.output.builtFileInfos.entries()) {
- this.uploadFile(builtPath, sourcePath, fileFolder);
+ this.queueUploads(
+ Array.from(
+ this.state.steps.uploadFiles.output.builtFileInfos.entries(),
+ ).map(([builtPath, { fileFolder, sourcePath }]) => ({
+ builtPath,
+ sourcePath,
+ fileFolder,
+ })),
+ );
+ }
+
+ private queueUploads(files: QueuedUpload[]): void {
+ const step = this.state.steps.uploadFiles;
+ const fileUploader = step.output.fileUploader;
+
+ if (!isDefined(fileUploader) || files.length === 0) {
+ return;
}
+
+ step.status = 'in_progress';
+ this.totalQueued += files.length;
+
+ if (this.verbose) {
+ this.state.addEvent({
+ message: `Uploading ${files.map(({ builtPath }) => builtPath).join(', ')}`,
+ status: 'info',
+ });
+ }
+
+ for (const { sourcePath } of files) {
+ this.state.updateEntityStatus(sourcePath, 'uploading');
+ }
+ this.notify();
+
+ const uploadPromise = fileUploader
+ .uploadFiles(
+ files.map(({ builtPath, fileFolder }) => ({ builtPath, fileFolder })),
+ )
+ .then((failures) => {
+ for (const failure of failures) {
+ this.failedCount++;
+ this.state.addEvent({
+ message: `Failed to upload ${failure.builtPath}: ${failure.error}`,
+ status: 'error',
+ });
+ }
+
+ for (const { builtPath, sourcePath } of files) {
+ if (failures.some((failure) => failure.builtPath === builtPath)) {
+ continue;
+ }
+
+ this.uploadedCount++;
+
+ if (this.verbose) {
+ this.state.addEvent({
+ message: `Successfully uploaded ${builtPath}`,
+ status: 'success',
+ });
+ }
+ this.state.updateEntityStatus(sourcePath, 'success');
+ }
+ })
+ .catch((error) => {
+ this.failedCount += files.length;
+ this.state.addEvent({
+ message: `Upload failed: ${error}`,
+ status: 'error',
+ });
+ })
+ .finally(() => {
+ step.output.activeUploads.delete(uploadPromise);
+
+ if (step.output.activeUploads.size === 0) {
+ this.logUploadSummary();
+ step.status = 'done';
+ this.notify();
+ }
+ });
+
+ step.output.activeUploads.add(uploadPromise);
}
}
diff --git a/packages/twenty-sdk/src/cli/utilities/file/__tests__/file-uploader.spec.ts b/packages/twenty-sdk/src/cli/utilities/file/__tests__/file-uploader.spec.ts
new file mode 100644
index 00000000000..5d4e88f4e41
--- /dev/null
+++ b/packages/twenty-sdk/src/cli/utilities/file/__tests__/file-uploader.spec.ts
@@ -0,0 +1,265 @@
+import { mkdir, mkdtemp, writeFile } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+
+import { OUTPUT_DIR } from 'twenty-shared/application';
+import { FileFolder } from 'twenty-shared/types';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+const mockCreateApplicationFileUploads = vi.fn();
+const mockCompleteApplicationFileUploads = vi.fn();
+const mockUploadFile = vi.fn();
+const mockPutFileToUploadUrl = vi.fn();
+
+vi.mock('@/cli/utilities/api/api-service', () => ({
+ ApiService: class {
+ createApplicationFileUploads = mockCreateApplicationFileUploads;
+ completeApplicationFileUploads = mockCompleteApplicationFileUploads;
+ uploadFile = mockUploadFile;
+ },
+}));
+
+vi.mock('@/cli/utilities/file/put-file-to-upload-url', () => ({
+ putFileToUploadUrl: (...args: unknown[]) => mockPutFileToUploadUrl(...args),
+}));
+
+const { FileUploader } = await import('@/cli/utilities/file/file-uploader');
+
+const buildUploadTargets = (builtPaths: string[]) =>
+ builtPaths.map((builtPath, index) => ({
+ fileId: `file-id-${index}`,
+ filePath: builtPath,
+ uploadUrl: `https://storage.tld/${index}`,
+ contentType: 'application/octet-stream',
+ expiresAt: '2026-01-01T00:00:00.000Z',
+ }));
+
+describe('FileUploader.uploadFiles', () => {
+ let appPath: string;
+
+ const builtFiles = ['handler.mjs', 'component.js'];
+
+ const filesToUpload = builtFiles.map((name) => ({
+ builtPath: join(OUTPUT_DIR, name),
+ fileFolder: FileFolder.BuiltLogicFunction,
+ }));
+
+ const buildUploader = () =>
+ new FileUploader({
+ appPath,
+ applicationUniversalIdentifier: 'application-uid',
+ });
+
+ beforeEach(async () => {
+ vi.clearAllMocks();
+
+ appPath = await mkdtemp(join(tmpdir(), 'twenty-file-uploader-'));
+ await mkdir(join(appPath, OUTPUT_DIR), { recursive: true });
+
+ for (const name of builtFiles) {
+ await writeFile(join(appPath, OUTPUT_DIR, name), `content of ${name}`);
+ }
+
+ mockCreateApplicationFileUploads.mockResolvedValue({
+ success: true,
+ data: { targets: buildUploadTargets(builtFiles), errors: [] },
+ });
+ mockCompleteApplicationFileUploads.mockResolvedValue({
+ success: true,
+ data: { files: [], errors: [] },
+ });
+ mockUploadFile.mockResolvedValue({ success: true, data: true });
+ mockPutFileToUploadUrl.mockResolvedValue(undefined);
+ });
+
+ it('should reserve, upload and confirm a batch in two api calls', async () => {
+ const failures = await buildUploader().uploadFiles(filesToUpload);
+
+ expect(failures).toEqual([]);
+ expect(mockCreateApplicationFileUploads).toHaveBeenCalledTimes(1);
+ expect(mockCompleteApplicationFileUploads).toHaveBeenCalledTimes(1);
+ expect(mockPutFileToUploadUrl).toHaveBeenCalledTimes(2);
+ });
+
+ it('should declare paths relative to the output directory with their real size', async () => {
+ await buildUploader().uploadFiles(filesToUpload);
+
+ expect(mockCreateApplicationFileUploads).toHaveBeenCalledWith({
+ applicationUniversalIdentifier: 'application-uid',
+ files: [
+ {
+ fileFolder: FileFolder.BuiltLogicFunction,
+ filePath: 'handler.mjs',
+ size: 'content of handler.mjs'.length,
+ },
+ {
+ fileFolder: FileFolder.BuiltLogicFunction,
+ filePath: 'component.js',
+ size: 'content of component.js'.length,
+ },
+ ],
+ });
+ });
+
+ it('should report the failing file and confirm the rest when one upload fails', async () => {
+ mockPutFileToUploadUrl.mockRejectedValueOnce(new Error('storage refused'));
+
+ const failures = await buildUploader().uploadFiles(filesToUpload);
+
+ expect(failures).toEqual([
+ {
+ builtPath: join(OUTPUT_DIR, 'handler.mjs'),
+ error: expect.stringContaining('storage refused'),
+ },
+ ]);
+ expect(mockCompleteApplicationFileUploads).toHaveBeenCalledWith({
+ applicationUniversalIdentifier: 'application-uid',
+ fileIds: ['file-id-1'],
+ });
+ });
+
+ it('should fail the whole batch when no upload url could be reserved', async () => {
+ mockCreateApplicationFileUploads.mockResolvedValue({
+ success: false,
+ error: 'Limit reached',
+ });
+
+ const failures = await buildUploader().uploadFiles(filesToUpload);
+
+ expect(failures).toHaveLength(2);
+ expect(failures[0].error).toContain('Limit reached');
+ expect(mockPutFileToUploadUrl).not.toHaveBeenCalled();
+ expect(mockCompleteApplicationFileUploads).not.toHaveBeenCalled();
+ });
+
+ it('should fall back to multipart uploads when the server does not support direct uploads', async () => {
+ mockCreateApplicationFileUploads.mockResolvedValue({
+ success: false,
+ error:
+ 'Cannot query field "createApplicationFileUploads" on type "Mutation".',
+ });
+
+ const failures = await buildUploader().uploadFiles(filesToUpload);
+
+ expect(failures).toEqual([]);
+ expect(mockUploadFile).toHaveBeenCalledTimes(2);
+ expect(mockUploadFile).toHaveBeenCalledWith({
+ applicationUniversalIdentifier: 'application-uid',
+ builtHandlerPath: 'handler.mjs',
+ fileFolder: FileFolder.BuiltLogicFunction,
+ filePath: join(appPath, OUTPUT_DIR, 'handler.mjs'),
+ });
+ expect(mockPutFileToUploadUrl).not.toHaveBeenCalled();
+ expect(mockCompleteApplicationFileUploads).not.toHaveBeenCalled();
+ });
+
+ it('should report multipart upload failures after falling back for an older server', async () => {
+ mockCreateApplicationFileUploads.mockResolvedValue({
+ success: false,
+ error:
+ 'Cannot query field "createApplicationFileUploads" on type "Mutation".',
+ });
+ mockUploadFile.mockResolvedValueOnce({
+ success: false,
+ error: 'legacy upload failed',
+ });
+
+ const failures = await buildUploader().uploadFiles(filesToUpload);
+
+ expect(failures).toEqual([
+ {
+ builtPath: join(OUTPUT_DIR, 'handler.mjs'),
+ error: 'legacy upload failed',
+ },
+ ]);
+ });
+
+ it('should fall back when an older server rejects the direct upload input type', async () => {
+ mockCreateApplicationFileUploads.mockResolvedValue({
+ success: false,
+ error: 'Unknown type "ApplicationFileUploadRequestInput".',
+ });
+
+ const failures = await buildUploader().uploadFiles(filesToUpload);
+
+ expect(failures).toEqual([]);
+ expect(mockUploadFile).toHaveBeenCalledTimes(2);
+ expect(mockPutFileToUploadUrl).not.toHaveBeenCalled();
+ expect(mockCompleteApplicationFileUploads).not.toHaveBeenCalled();
+ });
+
+ it('should fail every uploaded file when the batch cannot be confirmed', async () => {
+ mockCompleteApplicationFileUploads.mockResolvedValue({
+ success: false,
+ error: 'confirmation failed',
+ });
+
+ const failures = await buildUploader().uploadFiles(filesToUpload);
+
+ expect(failures).toHaveLength(2);
+ expect(
+ failures.every((failure) =>
+ failure.error.includes('confirmation failed'),
+ ),
+ ).toBe(true);
+ });
+
+ it('should map per-file reservation errors back to their built path (fail-slow)', async () => {
+ mockCreateApplicationFileUploads.mockResolvedValue({
+ success: true,
+ data: {
+ targets: buildUploadTargets(['component.js']).map((target) => ({
+ ...target,
+ filePath: 'component.js',
+ })),
+ errors: [
+ {
+ fileFolder: 'BuiltLogicFunction',
+ filePath: 'handler.mjs',
+ message: 'reservation refused',
+ },
+ ],
+ },
+ });
+
+ const failures = await buildUploader().uploadFiles(filesToUpload);
+
+ expect(failures).toEqual([
+ {
+ builtPath: join(OUTPUT_DIR, 'handler.mjs'),
+ error: 'reservation refused',
+ },
+ ]);
+ expect(mockPutFileToUploadUrl).toHaveBeenCalledTimes(1);
+ expect(mockCompleteApplicationFileUploads).toHaveBeenCalledWith({
+ applicationUniversalIdentifier: 'application-uid',
+ fileIds: ['file-id-0'],
+ });
+ });
+
+ it('should map per-file completion errors back to their built path (fail-slow)', async () => {
+ mockCompleteApplicationFileUploads.mockResolvedValue({
+ success: true,
+ data: {
+ files: [{ id: 'file-id-0', path: 'built-logic-function/handler.mjs' }],
+ errors: [{ fileId: 'file-id-1', message: 'size mismatch' }],
+ },
+ });
+
+ const failures = await buildUploader().uploadFiles(filesToUpload);
+
+ expect(failures).toEqual([
+ {
+ builtPath: join(OUTPUT_DIR, 'component.js'),
+ error: 'size mismatch',
+ },
+ ]);
+ });
+
+ it('should not call the api at all when there is nothing to upload', async () => {
+ const failures = await buildUploader().uploadFiles([]);
+
+ expect(failures).toEqual([]);
+ expect(mockCreateApplicationFileUploads).not.toHaveBeenCalled();
+ });
+});
diff --git a/packages/twenty-sdk/src/cli/utilities/file/file-uploader.ts b/packages/twenty-sdk/src/cli/utilities/file/file-uploader.ts
index f909cf74f08..0d9ec2b8036 100644
--- a/packages/twenty-sdk/src/cli/utilities/file/file-uploader.ts
+++ b/packages/twenty-sdk/src/cli/utilities/file/file-uploader.ts
@@ -1,7 +1,39 @@
import { ApiService } from '@/cli/utilities/api/api-service';
+import { type ApplicationFileUploadRequest } from '@/cli/utilities/api/file-api';
+import { serializeError } from '@/cli/utilities/error/serialize-error';
+import { putFileToUploadUrl } from '@/cli/utilities/file/put-file-to-upload-url';
+import * as fs from 'fs';
import path, { relative } from 'path';
+import {
+ APPLICATION_FILE_UPLOAD_BATCH_SIZE,
+ OUTPUT_DIR,
+} from 'twenty-shared/application';
import { type FileFolder } from 'twenty-shared/types';
-import { OUTPUT_DIR } from 'twenty-shared/application';
+
+export type FileToUpload = {
+ builtPath: string;
+ fileFolder: FileFolder;
+};
+
+export type FileUploadFailure = {
+ builtPath: string;
+ error: string;
+};
+
+const DIRECT_UPLOAD_CONCURRENCY = 10;
+
+const isMissingDirectUploadMutationError = (error: unknown): boolean => {
+ const message = serializeError(error);
+
+ return (
+ (message.includes('createApplicationFileUploads') ||
+ message.includes('ApplicationFileUploadRequestInput') ||
+ message.includes('CreateApplicationFileUploads')) &&
+ (message.includes('Cannot query field') ||
+ message.includes('Unknown type') ||
+ message.includes('Unknown field'))
+ );
+};
export class FileUploader {
private apiService = new ApiService();
@@ -17,20 +49,173 @@ export class FileUploader {
this.appPath = options.appPath;
}
- async uploadFile({
- builtPath,
- fileFolder,
- }: {
- builtPath: string;
- fileFolder: FileFolder;
- }) {
- const builtHandlerPath = relative(OUTPUT_DIR, builtPath);
+ async uploadFiles(files: FileToUpload[]): Promise<FileUploadFailure[]> {
+ const failures: FileUploadFailure[] = [];
+
+ for (
+ let index = 0;
+ index < files.length;
+ index += APPLICATION_FILE_UPLOAD_BATCH_SIZE
+ ) {
+ const batch = files.slice(
+ index,
+ index + APPLICATION_FILE_UPLOAD_BATCH_SIZE,
+ );
+
+ failures.push(...(await this.uploadBatch(batch)));
+ }
+
+ return failures;
+ }
+
+ private async uploadBatch(
+ batch: FileToUpload[],
+ ): Promise<FileUploadFailure[]> {
+ const builtPathByRelativePath = new Map<string, string>(
+ batch.map(({ builtPath }) => [
+ relative(OUTPUT_DIR, builtPath),
+ builtPath,
+ ]),
+ );
- return await this.apiService.uploadFile({
- filePath: path.join(this.appPath, builtPath),
- builtHandlerPath,
- fileFolder,
+ const uploadRequests: ApplicationFileUploadRequest[] = batch.map(
+ ({ builtPath, fileFolder }) => ({
+ fileFolder,
+ filePath: relative(OUTPUT_DIR, builtPath),
+ size: fs.statSync(path.join(this.appPath, builtPath)).size,
+ }),
+ );
+
+ const createResult = await this.apiService.createApplicationFileUploads({
applicationUniversalIdentifier: this.applicationUniversalIdentifier,
+ files: uploadRequests,
});
+
+ if (!createResult.success) {
+ if (
+ isMissingDirectUploadMutationError(
+ createResult.error ?? createResult.message,
+ )
+ ) {
+ return this.uploadBatchWithMultipartMutation(batch);
+ }
+
+ return this.failWholeBatch(batch, serializeError(createResult.error));
+ }
+
+ const { targets, errors: createErrors } = createResult.data;
+
+ const failures: FileUploadFailure[] = createErrors.map((error) => ({
+ builtPath: builtPathByRelativePath.get(error.filePath) ?? error.filePath,
+ error: error.message,
+ }));
+
+ const builtPathByFileId = new Map<string, string>();
+ const uploadedFileIds: string[] = [];
+
+ await this.runWithConcurrency(targets, async (target) => {
+ const builtPath = builtPathByRelativePath.get(target.filePath);
+
+ if (builtPath === undefined) {
+ return;
+ }
+
+ builtPathByFileId.set(target.fileId, builtPath);
+
+ try {
+ await putFileToUploadUrl({
+ absolutePath: path.join(this.appPath, builtPath),
+ uploadUrl: target.uploadUrl,
+ contentType: target.contentType,
+ });
+
+ uploadedFileIds.push(target.fileId);
+ } catch (error) {
+ failures.push({ builtPath, error: serializeError(error) });
+ }
+ });
+
+ if (uploadedFileIds.length === 0) {
+ return failures;
+ }
+
+ const completeResult = await this.apiService.completeApplicationFileUploads(
+ {
+ applicationUniversalIdentifier: this.applicationUniversalIdentifier,
+ fileIds: uploadedFileIds,
+ },
+ );
+
+ if (!completeResult.success) {
+ return [
+ ...failures,
+ ...uploadedFileIds.map((fileId) => ({
+ builtPath: builtPathByFileId.get(fileId) ?? fileId,
+ error: serializeError(completeResult.error),
+ })),
+ ];
+ }
+
+ for (const error of completeResult.data.errors) {
+ failures.push({
+ builtPath: builtPathByFileId.get(error.fileId) ?? error.fileId,
+ error: error.message,
+ });
+ }
+
+ return failures;
+ }
+
+ private async uploadBatchWithMultipartMutation(
+ batch: FileToUpload[],
+ ): Promise<FileUploadFailure[]> {
+ const failures: FileUploadFailure[] = [];
+
+ await this.runWithConcurrency(batch, async ({ builtPath, fileFolder }) => {
+ const result = await this.apiService.uploadFile({
+ filePath: path.join(this.appPath, builtPath),
+ builtHandlerPath: relative(OUTPUT_DIR, builtPath),
+ fileFolder,
+ applicationUniversalIdentifier: this.applicationUniversalIdentifier,
+ });
+
+ if (!result.success) {
+ failures.push({
+ builtPath,
+ error: serializeError(result.error ?? result.message),
+ });
+ }
+ });
+
+ return failures;
+ }
+
+ private failWholeBatch(
+ batch: FileToUpload[],
+ error: string,
+ ): FileUploadFailure[] {
+ return batch.map(({ builtPath }) => ({ builtPath, error }));
+ }
+
+ private async runWithConcurrency<TItem>(
+ items: TItem[],
+ handle: (item: TItem, index: number) => Promise<void>,
+ ): Promise<void> {
+ let nextIndex = 0;
+
+ const worker = async () => {
+ while (nextIndex < items.length) {
+ const index = nextIndex++;
+
+ await handle(items[index], index);
+ }
+ };
+
+ await Promise.all(
+ Array.from(
+ { length: Math.min(DIRECT_UPLOAD_CONCURRENCY, items.length) },
+ worker,
+ ),
+ );
}
}
diff --git a/packages/twenty-sdk/src/cli/utilities/file/put-file-to-upload-url.ts b/packages/twenty-sdk/src/cli/utilities/file/put-file-to-upload-url.ts
new file mode 100644
index 00000000000..2721dfc5f73
--- /dev/null
+++ b/packages/twenty-sdk/src/cli/utilities/file/put-file-to-upload-url.ts
@@ -0,0 +1,23 @@
+import axios from 'axios';
+import * as fs from 'fs';
+
+export const putFileToUploadUrl = async ({
+ absolutePath,
+ uploadUrl,
+ contentType,
+}: {
+ absolutePath: string;
+ uploadUrl: string;
+ contentType: string;
+}): Promise<void> => {
+ const buffer = await fs.promises.readFile(absolutePath);
+
+ await axios.put(uploadUrl, buffer, {
+ headers: {
+ 'Content-Type': contentType,
+ 'Content-Length': buffer.length,
+ },
+ maxBodyLength: Infinity,
+ maxContentLength: Infinity,
+ });
+};
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/__tests__/application-file-upload.service.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/__tests__/application-file-upload.service.spec.ts
new file mode 100644
index 00000000000..e7690f1b2c5
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/__tests__/application-file-upload.service.spec.ts
@@ -0,0 +1,334 @@
+import { Test, type TestingModule } from '@nestjs/testing';
+
+import { FileFolder } from 'twenty-shared/types';
+
+import { ApplicationFileUploadService } from 'src/engine/core-modules/application/application-development/application-file-upload.service';
+import { ApplicationException } from 'src/engine/core-modules/application/application.exception';
+import { ApplicationService } from 'src/engine/core-modules/application/application.service';
+import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity';
+import { FileUploadCompletionService } from 'src/engine/core-modules/file/file-upload/services/file-upload-completion.service';
+import { FileUploadTargetService } from 'src/engine/core-modules/file/file-upload/services/file-upload-target.service';
+import { getWorkspaceScopedRepositoryToken } from 'src/engine/twenty-orm/workspace-scoped-repository/get-workspace-scoped-repository-token.util';
+
+const WORKSPACE_ID = 'workspace-id';
+const APPLICATION_UNIVERSAL_IDENTIFIER = 'application-uid';
+
+describe('ApplicationFileUploadService', () => {
+ let service: ApplicationFileUploadService;
+
+ const applicationService = {
+ findByUniversalIdentifier: jest.fn().mockResolvedValue({
+ id: 'application-id',
+ universalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ }),
+ };
+
+ const fileUploadTargetService = {
+ createUploadTargetsBatch: jest.fn(),
+ };
+
+ const fileUploadCompletionService = {
+ completeUploadsBatch: jest.fn(),
+ };
+
+ const fileRepository = {
+ find: jest.fn(),
+ };
+
+ beforeEach(async () => {
+ jest.clearAllMocks();
+
+ fileUploadTargetService.createUploadTargetsBatch.mockImplementation(
+ (requests: { resourcePath: string }[]) =>
+ Promise.resolve(
+ requests.map((request, index) => ({
+ success: true,
+ value: {
+ fileId: `file-id-${index}`,
+ uploadUrl: `https://storage.tld/${request.resourcePath}`,
+ contentType: 'application/octet-stream',
+ expiresAt: new Date('2026-01-01T00:00:00.000Z'),
+ },
+ })),
+ ),
+ );
+
+ const module: TestingModule = await Test.createTestingModule({
+ providers: [
+ ApplicationFileUploadService,
+ { provide: ApplicationService, useValue: applicationService },
+ { provide: FileUploadTargetService, useValue: fileUploadTargetService },
+ {
+ provide: FileUploadCompletionService,
+ useValue: fileUploadCompletionService,
+ },
+ {
+ provide: getWorkspaceScopedRepositoryToken(FileEntity),
+ useValue: fileRepository,
+ },
+ ],
+ }).compile();
+
+ service = module.get<ApplicationFileUploadService>(
+ ApplicationFileUploadService,
+ );
+ });
+
+ describe('createApplicationFileUploads', () => {
+ it('should return one upload target per valid file, delegating to the batch primitive', async () => {
+ const result = await service.createApplicationFileUploads({
+ workspaceId: WORKSPACE_ID,
+ applicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ files: [
+ {
+ fileFolder: FileFolder.BuiltLogicFunction,
+ filePath: 'handler.mjs',
+ size: 12,
+ },
+ {
+ fileFolder: FileFolder.PublicAsset,
+ filePath: 'logo.png',
+ size: 34,
+ },
+ ],
+ });
+
+ expect(result.errors).toEqual([]);
+ expect(result.targets).toHaveLength(2);
+ expect(result.targets[0].filePath).toBe('handler.mjs');
+ expect(result.targets[0].fileFolder).toBe(FileFolder.BuiltLogicFunction);
+ expect(result.targets[0].uploadUrl).toContain('https://storage.tld/');
+ expect(result.targets[1].filePath).toBe('logo.png');
+ expect(
+ fileUploadTargetService.createUploadTargetsBatch,
+ ).toHaveBeenCalledTimes(1);
+ });
+
+ it('should reserve pending files as octet-stream through the batch primitive', async () => {
+ await service.createApplicationFileUploads({
+ workspaceId: WORKSPACE_ID,
+ applicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ files: [
+ {
+ fileFolder: FileFolder.Source,
+ filePath: 'src/index.ts',
+ size: 12,
+ },
+ ],
+ });
+
+ expect(
+ fileUploadTargetService.createUploadTargetsBatch,
+ ).toHaveBeenCalledWith([
+ expect.objectContaining({
+ workspaceId: WORKSPACE_ID,
+ applicationId: 'application-id',
+ fileFolder: FileFolder.Source,
+ resourcePath: 'src/index.ts',
+ size: 12,
+ }),
+ ]);
+ });
+
+ it('should collect a per-file error and skip the batch for a disallowed file folder', async () => {
+ const result = await service.createApplicationFileUploads({
+ workspaceId: WORKSPACE_ID,
+ applicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ files: [
+ {
+ fileFolder: FileFolder.FilesField,
+ filePath: 'document.pdf',
+ size: 12,
+ },
+ ],
+ });
+
+ expect(result.targets).toEqual([]);
+ expect(result.errors).toEqual([
+ {
+ fileFolder: FileFolder.FilesField,
+ filePath: 'document.pdf',
+ message: expect.stringContaining('Invalid fileFolder'),
+ },
+ ]);
+ expect(
+ fileUploadTargetService.createUploadTargetsBatch,
+ ).toHaveBeenCalledWith([]);
+ });
+
+ it('should fail slow: a path escaping the folder becomes a per-file error while valid files still upload', async () => {
+ const result = await service.createApplicationFileUploads({
+ workspaceId: WORKSPACE_ID,
+ applicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ files: [
+ {
+ fileFolder: FileFolder.Source,
+ filePath: 'src/index.ts',
+ size: 12,
+ },
+ {
+ fileFolder: FileFolder.Source,
+ filePath: '../../../etc/passwd',
+ size: 12,
+ },
+ ],
+ });
+
+ expect(result.targets).toHaveLength(1);
+ expect(result.targets[0].filePath).toBe('src/index.ts');
+ expect(result.errors).toHaveLength(1);
+ expect(result.errors[0].filePath).toBe('../../../etc/passwd');
+ expect(
+ fileUploadTargetService.createUploadTargetsBatch,
+ ).toHaveBeenCalledWith([
+ expect.objectContaining({ resourcePath: 'src/index.ts' }),
+ ]);
+ });
+
+ it('should collect a per-file error for a file larger than the direct upload limit', async () => {
+ const result = await service.createApplicationFileUploads({
+ workspaceId: WORKSPACE_ID,
+ applicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ files: [
+ {
+ fileFolder: FileFolder.Source,
+ filePath: 'src/index.ts',
+ size: 2 * 1024 * 1024 * 1024,
+ },
+ ],
+ });
+
+ expect(result.targets).toEqual([]);
+ expect(result.errors[0].message).toContain('above the');
+ });
+
+ it('should surface a batch-primitive failure as a per-file error', async () => {
+ fileUploadTargetService.createUploadTargetsBatch.mockResolvedValueOnce([
+ { success: false, error: 'storage exploded' },
+ ]);
+
+ const result = await service.createApplicationFileUploads({
+ workspaceId: WORKSPACE_ID,
+ applicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ files: [
+ {
+ fileFolder: FileFolder.Source,
+ filePath: 'src/index.ts',
+ size: 12,
+ },
+ ],
+ });
+
+ expect(result.targets).toEqual([]);
+ expect(result.errors).toEqual([
+ {
+ fileFolder: FileFolder.Source,
+ filePath: 'src/index.ts',
+ message: 'storage exploded',
+ },
+ ]);
+ });
+
+ it('should throw when the application does not exist in the workspace', async () => {
+ applicationService.findByUniversalIdentifier.mockResolvedValueOnce(null);
+
+ await expect(
+ service.createApplicationFileUploads({
+ workspaceId: WORKSPACE_ID,
+ applicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ files: [
+ {
+ fileFolder: FileFolder.Source,
+ filePath: 'src/index.ts',
+ size: 12,
+ },
+ ],
+ }),
+ ).rejects.toThrow(ApplicationException);
+ });
+ });
+
+ describe('completeApplicationFileUploads', () => {
+ const file = {
+ id: 'file-id',
+ path: `${FileFolder.BuiltLogicFunction}/handler.mjs`,
+ size: 12,
+ createdAt: new Date('2026-01-01T00:00:00.000Z'),
+ };
+
+ it('should return the completed files delegated to the batch primitive', async () => {
+ fileRepository.find.mockResolvedValueOnce([file]);
+ fileUploadCompletionService.completeUploadsBatch.mockResolvedValueOnce([
+ {
+ success: true,
+ value: {
+ id: 'file-id',
+ path: file.path,
+ size: 12,
+ createdAt: file.createdAt,
+ },
+ },
+ ]);
+
+ const result = await service.completeApplicationFileUploads({
+ workspaceId: WORKSPACE_ID,
+ applicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ fileIds: ['file-id'],
+ });
+
+ expect(result.errors).toEqual([]);
+ expect(result.files).toEqual([
+ {
+ id: 'file-id',
+ path: file.path,
+ size: 12,
+ createdAt: file.createdAt,
+ },
+ ]);
+ expect(
+ fileUploadCompletionService.completeUploadsBatch,
+ ).toHaveBeenCalledWith([
+ expect.objectContaining({ workspaceId: WORKSPACE_ID, file }),
+ ]);
+ });
+
+ it('should surface a batch-primitive completion failure as a per-file error', async () => {
+ fileRepository.find.mockResolvedValueOnce([file]);
+ fileUploadCompletionService.completeUploadsBatch.mockResolvedValueOnce([
+ { success: false, error: 'size mismatch' },
+ ]);
+
+ const result = await service.completeApplicationFileUploads({
+ workspaceId: WORKSPACE_ID,
+ applicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ fileIds: ['file-id'],
+ });
+
+ expect(result.files).toEqual([]);
+ expect(result.errors).toEqual([
+ { fileId: 'file-id', message: 'size mismatch' },
+ ]);
+ });
+
+ it('should report file ids that do not belong to the application as errors', async () => {
+ fileRepository.find.mockResolvedValueOnce([]);
+ fileUploadCompletionService.completeUploadsBatch.mockResolvedValueOnce(
+ [],
+ );
+
+ const result = await service.completeApplicationFileUploads({
+ workspaceId: WORKSPACE_ID,
+ applicationUniversalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,
+ fileIds: ['file-id-from-another-application'],
+ });
+
+ expect(result.files).toEqual([]);
+ expect(result.errors).toEqual([
+ {
+ fileId: 'file-id-from-another-application',
+ message: expect.stringContaining('No pending upload found'),
+ },
+ ]);
+ });
+ });
+});
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.module.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.module.ts
index 0f6d078207a..85f847c55f7 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.module.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.module.ts
@@ -1,4 +1,5 @@
import { Module } from '@nestjs/common';
+import { TypeOrmModule } from '@nestjs/typeorm';
import { ApplicationRegistrationModule } from 'src/engine/core-modules/application/application-registration/application-registration.module';
import { ApplicationManifestModule } from 'src/engine/core-modules/application/application-manifest/application-manifest.module';
@@ -6,11 +7,15 @@ import { ApplicationModule } from 'src/engine/core-modules/application/applicati
import { ApplicationPackageModule } from 'src/engine/core-modules/application/application-package/application-package.module';
import { ApplicationDevelopmentResolver } from 'src/engine/core-modules/application/application-development/application-development.resolver';
import { ApplicationDevelopmentService } from 'src/engine/core-modules/application/application-development/application-development.service';
+import { ApplicationFileUploadService } from 'src/engine/core-modules/application/application-development/application-file-upload.service';
import { CacheLockModule } from 'src/engine/core-modules/cache-lock/cache-lock.module';
import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-flag.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 { FileUploadModule } from 'src/engine/core-modules/file/file-upload/file-upload.module';
import { ThrottlerModule } from 'src/engine/core-modules/throttler/throttler.module';
import { PermissionsModule } from 'src/engine/metadata-modules/permissions/permissions.module';
+import { provideWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspace-scoped-repository/provide-workspace-scoped-repository';
import { WorkspaceMigrationGraphqlApiExceptionInterceptor } from 'src/engine/workspace-manager/workspace-migration/interceptors/workspace-migration-graphql-api-exception.interceptor';
@Module({
@@ -22,13 +27,17 @@ import { WorkspaceMigrationGraphqlApiExceptionInterceptor } from 'src/engine/wor
CacheLockModule,
FeatureFlagModule,
FileStorageModule,
+ FileUploadModule,
PermissionsModule,
ThrottlerModule,
+ TypeOrmModule.forFeature([FileEntity]),
],
providers: [
ApplicationDevelopmentResolver,
ApplicationDevelopmentService,
+ ApplicationFileUploadService,
WorkspaceMigrationGraphqlApiExceptionInterceptor,
+ provideWorkspaceScopedRepository(FileEntity),
],
})
export class ApplicationDevelopmentModule {}
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.resolver.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.resolver.ts
index be5c41bf266..76f7d044339 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.resolver.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.resolver.ts
@@ -13,7 +13,12 @@ import type { FileUpload } from 'graphql-upload/processRequest.mjs';
import { MetadataResolver } from 'src/engine/api/graphql/graphql-config/decorators/metadata-resolver.decorator';
import { ApplicationDevelopmentService } from 'src/engine/core-modules/application/application-development/application-development.service';
+import { ApplicationFileUploadService } from 'src/engine/core-modules/application/application-development/application-file-upload.service';
import { ApplicationInput } from 'src/engine/core-modules/application/application-development/dtos/application.input';
+import { CompleteApplicationFileUploadsResultDTO } from 'src/engine/core-modules/application/application-development/dtos/complete-application-file-uploads-result.dto';
+import { CompleteApplicationFileUploadsInput } from 'src/engine/core-modules/application/application-development/dtos/complete-application-file-uploads.input';
+import { CreateApplicationFileUploadsResultDTO } from 'src/engine/core-modules/application/application-development/dtos/create-application-file-uploads-result.dto';
+import { CreateApplicationFileUploadsInput } from 'src/engine/core-modules/application/application-development/dtos/create-application-file-uploads.input';
import { CreateDevelopmentApplicationInput } from 'src/engine/core-modules/application/application-development/dtos/create-development-application.input';
import { DevelopmentApplicationDTO } from 'src/engine/core-modules/application/application-development/dtos/development-application.dto';
import { UploadApplicationFileInput } from 'src/engine/core-modules/application/application-development/dtos/upload-application-file.input';
@@ -39,6 +44,7 @@ import { streamToBuffer } from 'src/utils/stream-to-buffer';
export class ApplicationDevelopmentResolver {
constructor(
private readonly applicationDevelopmentService: ApplicationDevelopmentService,
+ private readonly applicationFileUploadService: ApplicationFileUploadService,
) {}
@Mutation(() => DevelopmentApplicationDTO)
@@ -86,4 +92,36 @@ export class ApplicationDevelopmentResolver {
getFileBuffer: () => streamToBuffer(createReadStream()),
});
}
+
+ @Mutation(() => CreateApplicationFileUploadsResultDTO)
+ @UseGuards(SettingsPermissionGuard(PermissionFlagType.UPLOAD_FILE))
+ async createApplicationFileUploads(
+ @AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
+ @Args() {
+ applicationUniversalIdentifier,
+ files,
+ }: CreateApplicationFileUploadsInput,
+ ): Promise<CreateApplicationFileUploadsResultDTO> {
+ return this.applicationFileUploadService.createApplicationFileUploads({
+ workspaceId,
+ applicationUniversalIdentifier,
+ files,
+ });
+ }
+
+ @Mutation(() => CompleteApplicationFileUploadsResultDTO)
+ @UseGuards(SettingsPermissionGuard(PermissionFlagType.UPLOAD_FILE))
+ async completeApplicationFileUploads(
+ @AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
+ @Args() {
+ applicationUniversalIdentifier,
+ fileIds,
+ }: CompleteApplicationFileUploadsInput,
+ ): Promise<CompleteApplicationFileUploadsResultDTO> {
+ return this.applicationFileUploadService.completeApplicationFileUploads({
+ workspaceId,
+ applicationUniversalIdentifier,
+ fileIds,
+ });
+ }
}
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.service.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.service.ts
index 36ef2dac64d..e5a71f7909e 100644
--- a/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.service.ts
@@ -3,6 +3,11 @@ import { Injectable, Logger } from '@nestjs/common';
import { FileFolder } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
+import {
+ ALLOWED_APPLICATION_FILE_FOLDERS,
+ APP_DEV_RATE_LIMIT_MAX,
+ APP_DEV_RATE_LIMIT_WINDOW_MS,
+} from 'src/engine/core-modules/application/application-development/constants/application-development.constants';
import { type ApplicationInput } from 'src/engine/core-modules/application/application-development/dtos/application.input';
import { type DevelopmentApplicationDTO } from 'src/engine/core-modules/application/application-development/dtos/development-application.dto';
import { type WorkspaceMigrationDTO } from 'src/engine/core-modules/application/application-development/dtos/workspace-migration.dto';
@@ -19,25 +24,14 @@ import {
} from 'src/engine/core-modules/application/application.exception';
import { ApplicationService } from 'src/engine/core-modules/application/application.service';
import { CacheLockService } from 'src/engine/core-modules/cache-lock/cache-lock.service';
+import { ThrottlerService } from 'src/engine/core-modules/throttler/throttler.service';
import { FileStorageService } from 'src/engine/core-modules/file-storage/services/file-storage.service';
import { validateFilePath } from 'src/engine/core-modules/file-storage/utils/validate-file-path.util';
import { type FileDTO } from 'src/engine/core-modules/file/dtos/file.dto';
-import { ThrottlerService } from 'src/engine/core-modules/throttler/throttler.service';
import { streamToBuffer } from 'src/utils/stream-to-buffer';
-const APP_DEV_RATE_LIMIT_MAX = 30;
-const APP_DEV_RATE_LIMIT_WINDOW_MS = 30_000;
-
const APP_SYNC_LOCK_OPTIONS = { ttl: 60_000, ms: 500, maxRetries: 120 };
-const ALLOWED_APPLICATION_FILE_FOLDERS: FileFolder[] = [
- FileFolder.BuiltLogicFunction,
- FileFolder.BuiltFrontComponent,
- FileFolder.PublicAsset,
- FileFolder.Source,
- FileFolder.Dependencies,
-];
-
@Injectable()
export class ApplicationDevelopmentService {
private readonly logger = new Logger(ApplicationDevelopmentService.name);
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/application-file-upload.service.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/application-file-upload.service.ts
new file mode 100644
index 00000000000..96478f1d279
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/application-file-upload.service.ts
@@ -0,0 +1,217 @@
+import { Injectable } from '@nestjs/common';
+
+import bytes from 'bytes';
+import { isDefined } from 'twenty-shared/utils';
+import { In } from 'typeorm';
+
+import { ALLOWED_APPLICATION_FILE_FOLDERS } from 'src/engine/core-modules/application/application-development/constants/application-development.constants';
+import { CompleteApplicationFileUploadsResultDTO } from 'src/engine/core-modules/application/application-development/dtos/complete-application-file-uploads-result.dto';
+import { CreateApplicationFileUploadsResultDTO } from 'src/engine/core-modules/application/application-development/dtos/create-application-file-uploads-result.dto';
+import { type ApplicationFileUploadRequestInput } from 'src/engine/core-modules/application/application-development/dtos/create-application-file-uploads.input';
+import {
+ ApplicationException,
+ ApplicationExceptionCode,
+} from 'src/engine/core-modules/application/application.exception';
+import { ApplicationService } from 'src/engine/core-modules/application/application.service';
+import { settings } from 'src/engine/constants/settings';
+import { validateFilePath } from 'src/engine/core-modules/file-storage/utils/validate-file-path.util';
+import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity';
+import {
+ type BatchUploadTargetRequest,
+ FileUploadTargetService,
+} from 'src/engine/core-modules/file/file-upload/services/file-upload-target.service';
+import { FileUploadCompletionService } from 'src/engine/core-modules/file/file-upload/services/file-upload-completion.service';
+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';
+
+const APPLICATION_FILE_SETTINGS = {
+ isTemporaryFile: false,
+ toDelete: false,
+} as const;
+
+@Injectable()
+export class ApplicationFileUploadService {
+ constructor(
+ private readonly applicationService: ApplicationService,
+ private readonly fileUploadTargetService: FileUploadTargetService,
+ private readonly fileUploadCompletionService: FileUploadCompletionService,
+ @InjectWorkspaceScopedRepository(FileEntity)
+ private readonly fileRepository: WorkspaceScopedRepository<FileEntity>,
+ ) {}
+
+ async createApplicationFileUploads({
+ workspaceId,
+ applicationUniversalIdentifier,
+ files,
+ }: {
+ workspaceId: string;
+ applicationUniversalIdentifier: string;
+ files: ApplicationFileUploadRequestInput[];
+ }): Promise<CreateApplicationFileUploadsResultDTO> {
+ const application = await this.findApplicationOrThrow({
+ workspaceId,
+ applicationUniversalIdentifier,
+ });
+
+ const maxFileSize = bytes(settings.storage.maxDirectUploadFileSize) ?? 0;
+
+ const result: CreateApplicationFileUploadsResultDTO = {
+ targets: [],
+ errors: [],
+ };
+
+ const validFiles: ApplicationFileUploadRequestInput[] = [];
+
+ for (const file of files) {
+ const validationError = this.getFileValidationError(file, maxFileSize);
+
+ if (isDefined(validationError)) {
+ result.errors.push({
+ fileFolder: file.fileFolder,
+ filePath: file.filePath,
+ message: validationError,
+ });
+ continue;
+ }
+
+ validFiles.push(file);
+ }
+
+ const requests: BatchUploadTargetRequest[] = validFiles.map((file) => ({
+ workspaceId,
+ applicationUniversalIdentifier,
+ applicationId: application.id,
+ fileFolder: file.fileFolder,
+ resourcePath: file.filePath,
+ size: file.size,
+ settings: APPLICATION_FILE_SETTINGS,
+ }));
+
+ const batchResults =
+ await this.fileUploadTargetService.createUploadTargetsBatch(requests);
+
+ batchResults.forEach((batchResult, index) => {
+ const file = validFiles[index];
+
+ if (batchResult.success) {
+ result.targets.push({
+ ...batchResult.value,
+ fileFolder: file.fileFolder,
+ filePath: file.filePath,
+ });
+ } else {
+ result.errors.push({
+ fileFolder: file.fileFolder,
+ filePath: file.filePath,
+ message: batchResult.error,
+ });
+ }
+ });
+
+ return result;
+ }
+
+ async completeApplicationFileUploads({
+ workspaceId,
+ applicationUniversalIdentifier,
+ fileIds,
+ }: {
+ workspaceId: string;
+ applicationUniversalIdentifier: string;
+ fileIds: string[];
+ }): Promise<CompleteApplicationFileUploadsResultDTO> {
+ const application = await this.findApplicationOrThrow({
+ workspaceId,
+ applicationUniversalIdentifier,
+ });
+
+ const files = await this.fileRepository.find(workspaceId, {
+ where: { id: In(fileIds), applicationId: application.id },
+ });
+
+ const result: CompleteApplicationFileUploadsResultDTO = {
+ files: [],
+ errors: [],
+ };
+
+ const foundFileIds = new Set(files.map((file) => file.id));
+
+ for (const fileId of fileIds) {
+ if (!foundFileIds.has(fileId)) {
+ result.errors.push({
+ fileId,
+ message: 'No pending upload found for this file.',
+ });
+ }
+ }
+
+ const batchResults =
+ await this.fileUploadCompletionService.completeUploadsBatch(
+ files.map((file) => ({
+ workspaceId,
+ applicationUniversalIdentifier,
+ file,
+ })),
+ );
+
+ batchResults.forEach((batchResult, index) => {
+ const file = files[index];
+
+ if (batchResult.success) {
+ result.files.push(batchResult.value);
+ } else {
+ result.errors.push({ fileId: file.id, message: batchResult.error });
+ }
+ });
+
+ return result;
+ }
+
+ private getFileValidationError(
+ file: ApplicationFileUploadRequestInput,
+ maxFileSize: number,
+ ): string | undefined {
+ if (!ALLOWED_APPLICATION_FILE_FOLDERS.includes(file.fileFolder)) {
+ return `Invalid fileFolder for application file upload. Allowed values: ${ALLOWED_APPLICATION_FILE_FOLDERS.join(', ')}`;
+ }
+
+ const pathValidationResult = validateFilePath({
+ resourcePath: file.filePath,
+ fileFolder: file.fileFolder,
+ });
+
+ if (!pathValidationResult.isValid) {
+ return pathValidationResult.error;
+ }
+
+ if (file.size > maxFileSize) {
+ return `File "${file.filePath}" is ${file.size} bytes, above the ${maxFileSize} bytes limit.`;
+ }
+
+ return undefined;
+ }
+
+ private async findApplicationOrThrow({
+ workspaceId,
+ applicationUniversalIdentifier,
+ }: {
+ workspaceId: string;
+ applicationUniversalIdentifier: string;
+ }) {
+ const application = await this.applicationService.findByUniversalIdentifier(
+ {
+ universalIdentifier: applicationUniversalIdentifier,
+ workspaceId,
+ },
+ );
+
+ if (!isDefined(application)) {
+ throw new ApplicationException(
+ 'Application not found in workspace.',
+ ApplicationExceptionCode.APPLICATION_NOT_FOUND,
+ );
+ }
+
+ return application;
+ }
+}
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/constants/application-development.constants.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/constants/application-development.constants.ts
new file mode 100644
index 00000000000..43c5833a172
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/constants/application-development.constants.ts
@@ -0,0 +1,14 @@
+import { FileFolder } from 'twenty-shared/types';
+
+export const APP_DEV_RATE_LIMIT_MAX = 30;
+export const APP_DEV_RATE_LIMIT_WINDOW_MS = 30_000;
+
+export const MAX_APPLICATION_FILE_UPLOAD_BATCH_SIZE = 100;
+
+export const ALLOWED_APPLICATION_FILE_FOLDERS: FileFolder[] = [
+ FileFolder.BuiltLogicFunction,
+ FileFolder.BuiltFrontComponent,
+ FileFolder.PublicAsset,
+ FileFolder.Source,
+ FileFolder.Dependencies,
+];
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/application-file-upload-target.dto.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/application-file-upload-target.dto.ts
new file mode 100644
index 00000000000..c785498a296
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/application-file-upload-target.dto.ts
@@ -0,0 +1,26 @@
+import { Field, ObjectType } from '@nestjs/graphql';
+
+import { FileFolder } from 'twenty-shared/types';
+
+import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
+
+@ObjectType('ApplicationFileUploadTarget')
+export class ApplicationFileUploadTargetDTO {
+ @Field(() => UUIDScalarType)
+ fileId: string;
+
+ @Field(() => FileFolder)
+ fileFolder: FileFolder;
+
+ @Field()
+ filePath: string;
+
+ @Field()
+ uploadUrl: string;
+
+ @Field()
+ contentType: string;
+
+ @Field(() => Date, { nullable: false })
+ expiresAt: Date;
+}
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/complete-application-file-uploads-result.dto.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/complete-application-file-uploads-result.dto.ts
new file mode 100644
index 00000000000..54ad5535bbd
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/complete-application-file-uploads-result.dto.ts
@@ -0,0 +1,22 @@
+import { Field, ObjectType } from '@nestjs/graphql';
+
+import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
+import { FileDTO } from 'src/engine/core-modules/file/dtos/file.dto';
+
+@ObjectType('ApplicationFileCompletionError')
+export class ApplicationFileCompletionErrorDTO {
+ @Field(() => UUIDScalarType)
+ fileId: string;
+
+ @Field()
+ message: string;
+}
+
+@ObjectType('CompleteApplicationFileUploadsResult')
+export class CompleteApplicationFileUploadsResultDTO {
+ @Field(() => [FileDTO])
+ files: FileDTO[];
+
+ @Field(() => [ApplicationFileCompletionErrorDTO])
+ errors: ApplicationFileCompletionErrorDTO[];
+}
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/complete-application-file-uploads.input.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/complete-application-file-uploads.input.ts
new file mode 100644
index 00000000000..ebd7400aa82
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/complete-application-file-uploads.input.ts
@@ -0,0 +1,24 @@
+import { ArgsType, Field } from '@nestjs/graphql';
+
+import {
+ ArrayMaxSize,
+ ArrayNotEmpty,
+ IsArray,
+ IsNotEmpty,
+} from 'class-validator';
+
+import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
+import { MAX_APPLICATION_FILE_UPLOAD_BATCH_SIZE } from 'src/engine/core-modules/application/application-development/constants/application-development.constants';
+
+@ArgsType()
+export class CompleteApplicationFileUploadsInput {
+ @Field(() => String)
+ @IsNotEmpty()
+ applicationUniversalIdentifier: string;
+
+ @Field(() => [UUIDScalarType])
+ @IsArray()
+ @ArrayNotEmpty()
+ @ArrayMaxSize(MAX_APPLICATION_FILE_UPLOAD_BATCH_SIZE)
+ fileIds: string[];
+}
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/create-application-file-uploads-result.dto.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/create-application-file-uploads-result.dto.ts
new file mode 100644
index 00000000000..03e6d59d210
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/create-application-file-uploads-result.dto.ts
@@ -0,0 +1,26 @@
+import { Field, ObjectType } from '@nestjs/graphql';
+
+import { FileFolder } from 'twenty-shared/types';
+
+import { ApplicationFileUploadTargetDTO } from 'src/engine/core-modules/application/application-development/dtos/application-file-upload-target.dto';
+
+@ObjectType('ApplicationFileUploadError')
+export class ApplicationFileUploadErrorDTO {
+ @Field(() => FileFolder)
+ fileFolder: FileFolder;
+
+ @Field()
+ filePath: string;
+
+ @Field()
+ message: string;
+}
+
+@ObjectType('CreateApplicationFileUploadsResult')
+export class CreateApplicationFileUploadsResultDTO {
+ @Field(() => [ApplicationFileUploadTargetDTO])
+ targets: ApplicationFileUploadTargetDTO[];
+
+ @Field(() => [ApplicationFileUploadErrorDTO])
+ errors: ApplicationFileUploadErrorDTO[];
+}
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/create-application-file-uploads.input.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/create-application-file-uploads.input.ts
new file mode 100644
index 00000000000..d1b7e44ab8f
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/dtos/create-application-file-uploads.input.ts
@@ -0,0 +1,44 @@
+import { ArgsType, Field, InputType, Int } from '@nestjs/graphql';
+
+import { Type } from 'class-transformer';
+import {
+ ArrayMaxSize,
+ ArrayNotEmpty,
+ IsArray,
+ IsInt,
+ IsNotEmpty,
+ Min,
+ ValidateNested,
+} from 'class-validator';
+import { FileFolder } from 'twenty-shared/types';
+
+import { MAX_APPLICATION_FILE_UPLOAD_BATCH_SIZE } from 'src/engine/core-modules/application/application-development/constants/application-development.constants';
+
+@InputType()
+export class ApplicationFileUploadRequestInput {
+ @Field(() => FileFolder)
+ fileFolder: FileFolder;
+
+ @Field(() => String)
+ filePath: string;
+
+ @Field(() => Int)
+ @IsInt()
+ @Min(1)
+ size: number;
+}
+
+@ArgsType()
+export class CreateApplicationFileUploadsInput {
+ @Field(() => String)
+ @IsNotEmpty()
+ applicationUniversalIdentifier: string;
+
+ @Field(() => [ApplicationFileUploadRequestInput])
+ @IsArray()
+ @ArrayNotEmpty()
+ @ArrayMaxSize(MAX_APPLICATION_FILE_UPLOAD_BATCH_SIZE)
+ @ValidateNested({ each: true })
+ @Type(() => ApplicationFileUploadRequestInput)
+ files: ApplicationFileUploadRequestInput[];
+}
diff --git a/packages/twenty-server/src/engine/core-modules/file-storage/services/file-storage.service.ts b/packages/twenty-server/src/engine/core-modules/file-storage/services/file-storage.service.ts
index 893dc2b1f5d..22cda530872 100644
--- a/packages/twenty-server/src/engine/core-modules/file-storage/services/file-storage.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/file-storage/services/file-storage.service.ts
@@ -268,6 +268,7 @@ export class FileStorageService {
async createPendingFile({
fileFolder,
applicationUniversalIdentifier,
+ applicationId,
workspaceId,
resourcePath,
fileId,
@@ -275,15 +276,18 @@ export class FileStorageService {
mimeType,
settings,
}: ResourceIdentifier & {
+ applicationId?: string;
fileId: string;
size: number;
mimeType: string;
settings: FileSettings;
}): Promise<FileEntity> {
- const applicationId = await this.resolveApplicationIdOrThrow({
- applicationUniversalIdentifier,
- workspaceId,
- });
+ const resolvedApplicationId =
+ applicationId ??
+ (await this.resolveApplicationIdOrThrow({
+ applicationUniversalIdentifier,
+ workspaceId,
+ }));
const { filePath } = this.validateAndBuildFileStoragePathOrThrow({
workspaceId,
@@ -296,7 +300,7 @@ export class FileStorageService {
workspaceId,
{
path: filePath,
- applicationId,
+ applicationId: resolvedApplicationId,
id: fileId,
mimeType,
size,
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 29ffab2c1a0..514709ec610 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
@@ -10,7 +10,9 @@ import { PendingFileCleanupCronCommand } from 'src/engine/core-modules/file/file
import { PendingFileCleanupCronJob } from 'src/engine/core-modules/file/file-upload/crons/jobs/pending-file-cleanup.cron.job';
import { FileUploadTokenGuard } from 'src/engine/core-modules/file/file-upload/guards/file-upload-token.guard';
import { FileUploadResolver } from 'src/engine/core-modules/file/file-upload/resolvers/file-upload.resolver';
+import { FileUploadCompletionService } from 'src/engine/core-modules/file/file-upload/services/file-upload-completion.service';
import { FileUploadService } from 'src/engine/core-modules/file/file-upload/services/file-upload.service';
+import { FileUploadTargetService } from 'src/engine/core-modules/file/file-upload/services/file-upload-target.service';
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';
@@ -33,6 +35,8 @@ import { provideWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspac
],
providers: [
FileUploadService,
+ FileUploadTargetService,
+ FileUploadCompletionService,
FileUploadResolver,
FileUploadTokenGuard,
PendingFileCleanupService,
@@ -40,7 +44,12 @@ import { provideWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspac
PendingFileCleanupCronCommand,
provideWorkspaceScopedRepository(FileEntity),
],
- exports: [FileUploadService, PendingFileCleanupCronCommand],
+ exports: [
+ FileUploadService,
+ FileUploadTargetService,
+ FileUploadCompletionService,
+ PendingFileCleanupCronCommand,
+ ],
controllers: [FileUploadController],
})
export class FileUploadModule {}
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-upload/services/file-upload-completion.service.ts b/packages/twenty-server/src/engine/core-modules/file/file-upload/services/file-upload-completion.service.ts
new file mode 100644
index 00000000000..f2481315bf3
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/file/file-upload/services/file-upload-completion.service.ts
@@ -0,0 +1,226 @@
+import { Injectable } from '@nestjs/common';
+
+import { msg } from '@lingui/core/macro';
+import { Readable } from 'stream';
+import { FileFolder } from 'twenty-shared/types';
+import { isDefined } from 'twenty-shared/utils';
+
+import { FileStorageService } from 'src/engine/core-modules/file-storage/services/file-storage.service';
+import { FileDTO } from 'src/engine/core-modules/file/dtos/file.dto';
+import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity';
+import { FILE_CONTENT_SNIFF_BYTE_COUNT } from 'src/engine/core-modules/file/file-upload/constants/file-content-sniff.constant';
+import {
+ FileUploadException,
+ FileUploadExceptionCode,
+} from 'src/engine/core-modules/file/file-upload/file-upload.exception';
+import { type BatchFileResult } from 'src/engine/core-modules/file/file-upload/types/batch-file-result.type';
+import { toBatchErrorMessage } from 'src/engine/core-modules/file/file-upload/utils/to-batch-error-message.util';
+import { fileFolderConfigs } from 'src/engine/core-modules/file/interfaces/file-folder.interface';
+import { FILE_STATUS } from 'src/engine/core-modules/file/types/file-status.types';
+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';
+import { sanitizeFile } from 'src/engine/core-modules/file/utils/sanitize-file.utils';
+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';
+import { readReadablePrefix } from 'src/utils/read-readable-prefix';
+import { streamToBuffer } from 'src/utils/stream-to-buffer';
+
+export type BatchCompleteUploadRequest = {
+ workspaceId: string;
+ applicationUniversalIdentifier: string;
+ file: FileEntity;
+};
+
+export type FileUploadStorageLocation = {
+ fileFolder: FileFolder;
+ applicationUniversalIdentifier: string;
+ workspaceId: string;
+ resourcePath: string;
+};
+
+type CompletedUploadedFile = FileDTO & Pick<FileEntity, 'mimeType'>;
+
+@Injectable()
+export class FileUploadCompletionService {
+ constructor(
+ private readonly fileStorageService: FileStorageService,
+ @InjectWorkspaceScopedRepository(FileEntity)
+ private readonly fileRepository: WorkspaceScopedRepository<FileEntity>,
+ ) {}
+
+ async completeUploadsBatch(
+ requests: BatchCompleteUploadRequest[],
+ ): Promise<BatchFileResult<FileDTO>[]> {
+ return Promise.all(
+ requests.map(async (request) => {
+ try {
+ const value = await this.completeUploadedFile({
+ workspaceId: request.workspaceId,
+ file: request.file,
+ storageLocation: this.getApplicationFileStorageLocation(request),
+ });
+
+ return { success: true as const, value };
+ } catch (error) {
+ return { success: false as const, error: toBatchErrorMessage(error) };
+ }
+ }),
+ );
+ }
+
+ async completeUploadedFile({
+ workspaceId,
+ file,
+ storageLocation,
+ }: {
+ workspaceId: string;
+ file: FileEntity;
+ storageLocation: FileUploadStorageLocation;
+ }): Promise<CompletedUploadedFile> {
+ const metadata =
+ await this.fileStorageService.getFileMetadata(storageLocation);
+
+ if (!isDefined(metadata)) {
+ throw new FileUploadException(
+ `File "${file.path}" has not been uploaded to storage yet.`,
+ FileUploadExceptionCode.FILE_NOT_UPLOADED,
+ {
+ userFriendlyMessage: msg`The file has not been uploaded yet. Please upload it before confirming.`,
+ },
+ );
+ }
+
+ const declaredSize = Number(file.size);
+
+ if (metadata.size !== declaredSize) {
+ throw new FileUploadException(
+ `File "${file.path}" has ${metadata.size} bytes in storage but ${declaredSize} were declared.`,
+ FileUploadExceptionCode.FILE_SIZE_MISMATCH,
+ {
+ userFriendlyMessage: msg`The uploaded file does not match the declared size. Please retry the upload.`,
+ },
+ );
+ }
+
+ const mimeType = await this.detectUploadedMimeTypeOrThrow({
+ ...storageLocation,
+ filename: file.path,
+ });
+
+ this.assertMimeTypeAllowedForFolder(storageLocation.fileFolder, mimeType);
+
+ const size = await this.sanitizeUploadedFileIfNeeded({
+ storageLocation,
+ mimeType,
+ size: metadata.size,
+ });
+
+ await this.fileRepository.update(
+ workspaceId,
+ { id: file.id },
+ { status: FILE_STATUS.UPLOADED, mimeType, size },
+ );
+
+ return {
+ id: file.id,
+ path: file.path,
+ size,
+ createdAt: file.createdAt,
+ mimeType,
+ };
+ }
+
+ private getApplicationFileStorageLocation({
+ workspaceId,
+ applicationUniversalIdentifier,
+ file,
+ }: BatchCompleteUploadRequest): FileUploadStorageLocation {
+ const [fileFolder] = file.path.split('/');
+
+ return {
+ fileFolder: fileFolder as FileFolder,
+ applicationUniversalIdentifier,
+ workspaceId,
+ resourcePath: removeFileFolderFromFileEntityPath(file.path),
+ };
+ }
+
+ private async detectUploadedMimeTypeOrThrow({
+ fileFolder,
+ applicationUniversalIdentifier,
+ workspaceId,
+ resourcePath,
+ filename,
+ }: FileUploadStorageLocation & { filename: string }): Promise<string> {
+ const stream = await this.fileStorageService.readFile({
+ fileFolder,
+ applicationUniversalIdentifier,
+ workspaceId,
+ resourcePath,
+ });
+
+ const prefix = await readReadablePrefix(
+ stream,
+ FILE_CONTENT_SNIFF_BYTE_COUNT,
+ );
+
+ const { mimeType } = await extractFileInfoOrThrow({
+ file: prefix,
+ filename,
+ });
+
+ return mimeType;
+ }
+
+ private assertMimeTypeAllowedForFolder(
+ fileFolder: FileFolder,
+ mimeType: string,
+ ): void {
+ const { allowedMimeTypes } = fileFolderConfigs[fileFolder];
+
+ if (!allowedMimeTypes || allowedMimeTypes.includes(mimeType)) {
+ return;
+ }
+
+ throw new FileUploadException(
+ `MIME type ${mimeType} is not allowed in file folder ${fileFolder}`,
+ FileUploadExceptionCode.BAD_REQUEST,
+ {
+ userFriendlyMessage: msg`This file format is not supported.`,
+ },
+ );
+ }
+
+ private async sanitizeUploadedFileIfNeeded({
+ storageLocation,
+ mimeType,
+ size,
+ }: {
+ storageLocation: FileUploadStorageLocation;
+ mimeType: string;
+ size: number;
+ }): Promise<number> {
+ if (mimeType !== 'image/svg+xml') {
+ return size;
+ }
+
+ const stream = await this.fileStorageService.readFile(storageLocation);
+ const sanitizedFile = sanitizeFile({
+ file: await streamToBuffer(stream),
+ ext: 'svg',
+ mimeType,
+ });
+
+ const sanitizedBuffer = Buffer.isBuffer(sanitizedFile)
+ ? sanitizedFile
+ : Buffer.from(sanitizedFile);
+
+ await this.fileStorageService.writeFileStream({
+ ...storageLocation,
+ stream: Readable.from(sanitizedBuffer),
+ mimeType,
+ });
+
+ return sanitizedBuffer.length;
+ }
+}
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-upload/services/file-upload-target.service.ts b/packages/twenty-server/src/engine/core-modules/file/file-upload/services/file-upload-target.service.ts
new file mode 100644
index 00000000000..c098bbca815
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/file/file-upload/services/file-upload-target.service.ts
@@ -0,0 +1,137 @@
+import { Injectable } from '@nestjs/common';
+
+import { ApiPath, FileFolder } from 'twenty-shared/types';
+import { isDefined } from 'twenty-shared/utils';
+import { v4 } from 'uuid';
+
+import { FileStorageService } from 'src/engine/core-modules/file-storage/services/file-storage.service';
+import { FileUploadTargetDTO } from 'src/engine/core-modules/file/file-upload/dtos/file-upload-target.dto';
+import { type BatchFileResult } from 'src/engine/core-modules/file/file-upload/types/batch-file-result.type';
+import { toBatchErrorMessage } from 'src/engine/core-modules/file/file-upload/utils/to-batch-error-message.util';
+import { FileSettings } from 'src/engine/core-modules/file/types/file-settings.types';
+import { FileUploadTokenJwtPayload } from 'src/engine/core-modules/auth/types/file-upload-token-jwt-payload.type';
+import { JwtTokenTypeEnum } from 'src/engine/core-modules/auth/types/jwt-token-type.enum';
+import { JwtWrapperService } from 'src/engine/core-modules/jwt/services/jwt-wrapper.service';
+import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
+
+const DIRECT_UPLOAD_CONTENT_TYPE = 'application/octet-stream';
+
+export type BatchUploadTargetRequest = {
+ workspaceId: string;
+ applicationUniversalIdentifier: string;
+ applicationId?: string;
+ fileFolder: FileFolder;
+ resourcePath: string;
+ size: number;
+ settings: FileSettings;
+};
+
+@Injectable()
+export class FileUploadTargetService {
+ constructor(
+ private readonly fileStorageService: FileStorageService,
+ private readonly jwtWrapperService: JwtWrapperService,
+ private readonly twentyConfigService: TwentyConfigService,
+ ) {}
+
+ async buildUploadTarget({
+ workspaceId,
+ fileId,
+ fileFolder,
+ applicationUniversalIdentifier,
+ resourcePath,
+ contentType,
+ size,
+ }: {
+ workspaceId: string;
+ fileId: string;
+ fileFolder: FileFolder;
+ applicationUniversalIdentifier: string;
+ resourcePath: string;
+ contentType: string;
+ size: number;
+ }): Promise<FileUploadTargetDTO> {
+ const expiresInSeconds = this.twentyConfigService.get(
+ 'STORAGE_S3_PRESIGNED_URL_EXPIRES_IN',
+ );
+ const expiresAt = new Date(Date.now() + expiresInSeconds * 1000);
+
+ const presignedUploadUrl =
+ await this.fileStorageService.getPresignedUploadUrl({
+ fileFolder,
+ applicationUniversalIdentifier,
+ workspaceId,
+ resourcePath,
+ contentType,
+ contentLength: size,
+ expiresInSeconds,
+ });
+
+ if (isDefined(presignedUploadUrl)) {
+ return {
+ fileId,
+ uploadUrl: presignedUploadUrl,
+ contentType,
+ expiresAt,
+ };
+ }
+
+ const payload: FileUploadTokenJwtPayload = {
+ workspaceId,
+ fileId,
+ sub: workspaceId,
+ type: JwtTokenTypeEnum.FILE_UPLOAD,
+ };
+
+ const token = await this.jwtWrapperService.signAsyncOrThrow(payload, {
+ expiresIn: expiresInSeconds,
+ });
+
+ const serverUrl = this.twentyConfigService.get('SERVER_URL');
+
+ return {
+ fileId,
+ uploadUrl: `${serverUrl}/${ApiPath.FileUpload}/${fileId}?token=${token}`,
+ contentType: DIRECT_UPLOAD_CONTENT_TYPE,
+ expiresAt,
+ };
+ }
+
+ async createUploadTargetsBatch(
+ requests: BatchUploadTargetRequest[],
+ ): Promise<BatchFileResult<FileUploadTargetDTO>[]> {
+ return Promise.all(
+ requests.map(async (request) => {
+ try {
+ const pendingFile = await this.fileStorageService.createPendingFile({
+ fileFolder: request.fileFolder,
+ applicationUniversalIdentifier:
+ request.applicationUniversalIdentifier,
+ applicationId: request.applicationId,
+ workspaceId: request.workspaceId,
+ resourcePath: request.resourcePath,
+ fileId: v4(),
+ size: request.size,
+ mimeType: DIRECT_UPLOAD_CONTENT_TYPE,
+ settings: request.settings,
+ });
+
+ const value = await this.buildUploadTarget({
+ workspaceId: request.workspaceId,
+ fileId: pendingFile.id,
+ fileFolder: request.fileFolder,
+ applicationUniversalIdentifier:
+ request.applicationUniversalIdentifier,
+ resourcePath: request.resourcePath,
+ contentType: DIRECT_UPLOAD_CONTENT_TYPE,
+ size: request.size,
+ });
+
+ return { success: true as const, value };
+ } catch (error) {
+ return { success: false as const, error: toBatchErrorMessage(error) };
+ }
+ }),
+ );
+ }
+}
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 2d08f462c9f..5a7c585e9ed 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
@@ -1,13 +1,13 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
-import { type Readable, Transform } from 'stream';
+import { Readable, Transform } from 'stream';
import { pipeline } from 'stream/promises';
import { msg } from '@lingui/core/macro';
import { isNonEmptyString } from '@sniptt/guards';
import bytes from 'bytes';
-import { ApiPath, FileFolder } from 'twenty-shared/types';
+import { FileFolder } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import { Repository } from 'typeorm';
import { v4 } from 'uuid';
@@ -15,29 +15,23 @@ import { v4 } from 'uuid';
import { settings } from 'src/engine/constants/settings';
import { ApplicationEntity } from 'src/engine/core-modules/application/application.entity';
import { ApplicationService } from 'src/engine/core-modules/application/application.service';
-import { FileUploadTokenJwtPayload } from 'src/engine/core-modules/auth/types/file-upload-token-jwt-payload.type';
-import { JwtTokenTypeEnum } from 'src/engine/core-modules/auth/types/jwt-token-type.enum';
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 { FILE_CONTENT_SNIFF_BYTE_COUNT } from 'src/engine/core-modules/file/file-upload/constants/file-content-sniff.constant';
import { FileUploadTargetDTO } from 'src/engine/core-modules/file/file-upload/dtos/file-upload-target.dto';
import {
FileUploadException,
FileUploadExceptionCode,
} from 'src/engine/core-modules/file/file-upload/file-upload.exception';
+import { FileUploadCompletionService } from 'src/engine/core-modules/file/file-upload/services/file-upload-completion.service';
+import { FileUploadTargetService } from 'src/engine/core-modules/file/file-upload/services/file-upload-target.service';
import { FileUrlService } from 'src/engine/core-modules/file/file-url/file-url.service';
import { FILE_STATUS } from 'src/engine/core-modules/file/types/file-status.types';
import { buildFileInfo } from 'src/engine/core-modules/file/utils/build-file-info.utils';
-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';
-import { fileFolderConfigs } from 'src/engine/core-modules/file/interfaces/file-folder.interface';
-import { JwtWrapperService } from 'src/engine/core-modules/jwt/services/jwt-wrapper.service';
-import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
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';
-import { readReadablePrefix } from 'src/utils/read-readable-prefix';
export const DIRECT_UPLOAD_FILE_FOLDERS = [
FileFolder.FilesField,
@@ -52,8 +46,8 @@ export class FileUploadService {
constructor(
private readonly fileStorageService: FileStorageService,
private readonly fileUrlService: FileUrlService,
- private readonly jwtWrapperService: JwtWrapperService,
- private readonly twentyConfigService: TwentyConfigService,
+ private readonly fileUploadTargetService: FileUploadTargetService,
+ private readonly fileUploadCompletionService: FileUploadCompletionService,
private readonly applicationService: ApplicationService,
@InjectRepository(ApplicationEntity)
private readonly applicationRepository: Repository<ApplicationEntity>,
@@ -133,59 +127,17 @@ export class FileUploadService {
},
});
- const expiresInSeconds = this.twentyConfigService.get(
- 'STORAGE_S3_PRESIGNED_URL_EXPIRES_IN',
- );
- const expiresAt = new Date(Date.now() + expiresInSeconds * 1000);
-
- const presignedUploadUrl =
- await this.fileStorageService.getPresignedUploadUrl({
- fileFolder,
- applicationUniversalIdentifier,
- workspaceId,
- resourcePath,
- contentType: mimeType,
- contentLength: size,
- expiresInSeconds,
- });
-
- if (isDefined(presignedUploadUrl)) {
- return {
- fileId,
- uploadUrl: presignedUploadUrl,
- contentType: mimeType,
- expiresAt,
- };
- }
-
- // No presign support (local storage, or S3 without presign enabled):
- // fall back to the token-authenticated streaming endpoint on the server.
- const payload: FileUploadTokenJwtPayload = {
+ return this.fileUploadTargetService.buildUploadTarget({
workspaceId,
fileId,
- sub: workspaceId,
- type: JwtTokenTypeEnum.FILE_UPLOAD,
- };
-
- const token = await this.jwtWrapperService.signAsyncOrThrow(payload, {
- expiresIn: expiresInSeconds,
+ fileFolder,
+ applicationUniversalIdentifier,
+ resourcePath,
+ contentType: mimeType,
+ size,
});
-
- const serverUrl = this.twentyConfigService.get('SERVER_URL');
-
- return {
- fileId,
- uploadUrl: `${serverUrl}/${ApiPath.FileUpload}/${fileId}?token=${token}`,
- // octet-stream keeps the request body away from the server's json/text
- // body parsers; the real mime type is already on the file record.
- contentType: 'application/octet-stream',
- expiresAt,
- };
}
- // Streams the request body straight to the storage driver, bounded by the
- // size declared at createFileUpload time. Memory usage stays constant no
- // matter how large the file is.
async receiveFileStream({
workspaceId,
fileId,
@@ -248,8 +200,6 @@ export class FileUploadService {
}),
]);
} catch (error) {
- // The storage-side pipeline can lose the rejection race to the limiter:
- // surface the size violation over the resulting stream teardown error.
if (receivedBytes > declaredSize) {
throw new FileUploadException(
`Upload exceeds declared size of ${declaredSize} bytes`,
@@ -264,10 +214,6 @@ export class FileUploadService {
}
if (receivedBytes !== declaredSize) {
- // The short object stays in storage but the record stays PENDING, so it
- // can never be served or attached: the client retries against the same
- // upload url (overwriting it), and the pending-file cleanup cron
- // (follow-up PR) reaps whatever is abandoned.
throw new FileUploadException(
`Uploaded ${receivedBytes} bytes but ${declaredSize} were declared`,
FileUploadExceptionCode.FILE_SIZE_MISMATCH,
@@ -278,8 +224,6 @@ export class FileUploadService {
}
}
- // Verifies the bytes actually landed in storage with the declared size and
- // flips the file to UPLOADED. Idempotent: confirming twice is a no-op.
async completeFileUpload({
workspaceId,
fileId,
@@ -290,8 +234,6 @@ export class FileUploadService {
const file = await this.findFileOrThrow({ workspaceId, fileId });
const [fileFolder] = file.path.split('/');
- // Restrict to files created through createFileUpload so this mutation
- // cannot be used to mint signed download urls for arbitrary files.
if (
!DIRECT_UPLOAD_FILE_FOLDERS.includes(
fileFolder as (typeof DIRECT_UPLOAD_FILE_FOLDERS)[number],
@@ -307,9 +249,6 @@ export class FileUploadService {
}
if (file.status === FILE_STATUS.UPLOADED) {
- // Idempotent retry of a confirm that already succeeded. Only files not
- // yet attached to a record qualify: this cannot be used to mint signed
- // urls for files that went through the legacy flow and got attached.
if (!file.settings?.isTemporaryFile) {
throw new FileUploadException(
`File ${fileId} is not awaiting an upload confirmation`,
@@ -332,108 +271,25 @@ export class FileUploadService {
file,
});
- const metadata = await this.fileStorageService.getFileMetadata({
- fileFolder: fileFolder as FileFolder,
- applicationUniversalIdentifier: application.universalIdentifier,
- workspaceId,
- resourcePath,
- });
-
- if (!isDefined(metadata)) {
- throw new FileUploadException(
- `File ${fileId} has not been uploaded to storage yet`,
- FileUploadExceptionCode.FILE_NOT_UPLOADED,
- {
- userFriendlyMessage: msg`The file has not been uploaded yet. Please upload it before confirming.`,
- },
- );
- }
-
- if (metadata.size !== Number(file.size)) {
- throw new FileUploadException(
- `File ${fileId} has ${metadata.size} bytes in storage but ${file.size} were declared`,
- FileUploadExceptionCode.FILE_SIZE_MISMATCH,
- {
- userFriendlyMessage: msg`The uploaded file does not match the declared size. Please retry the upload.`,
+ const completedFile =
+ await this.fileUploadCompletionService.completeUploadedFile({
+ workspaceId,
+ file,
+ storageLocation: {
+ fileFolder: fileFolder as FileFolder,
+ applicationUniversalIdentifier: application.universalIdentifier,
+ workspaceId,
+ resourcePath,
},
- );
- }
-
- const mimeType = await this.detectUploadedMimeTypeOrThrow({
- fileFolder: fileFolder as FileFolder,
- applicationUniversalIdentifier: application.universalIdentifier,
- workspaceId,
- resourcePath,
- filename: file.path,
- });
-
- this.assertMimeTypeAllowedForFolder(fileFolder as FileFolder, mimeType);
-
- await this.fileRepository.update(
- workspaceId,
- { id: fileId },
- { status: FILE_STATUS.UPLOADED, mimeType },
- );
+ });
return this.toFileWithSignedUrl({
- file: { ...file, status: FILE_STATUS.UPLOADED, mimeType },
+ file: { ...file, ...completedFile, status: FILE_STATUS.UPLOADED },
fileFolder: fileFolder as FileFolder,
workspaceId,
});
}
- private async detectUploadedMimeTypeOrThrow({
- fileFolder,
- applicationUniversalIdentifier,
- workspaceId,
- resourcePath,
- filename,
- }: {
- fileFolder: FileFolder;
- applicationUniversalIdentifier: string;
- workspaceId: string;
- resourcePath: string;
- filename: string;
- }): Promise<string> {
- const stream = await this.fileStorageService.readFile({
- fileFolder,
- applicationUniversalIdentifier,
- workspaceId,
- resourcePath,
- });
-
- const prefix = await readReadablePrefix(
- stream,
- FILE_CONTENT_SNIFF_BYTE_COUNT,
- );
-
- const { mimeType } = await extractFileInfoOrThrow({
- file: prefix,
- filename,
- });
-
- return mimeType;
- }
-
- private assertMimeTypeAllowedForFolder(
- fileFolder: FileFolder,
- mimeType: string,
- ): void {
- const { allowedMimeTypes } = fileFolderConfigs[fileFolder];
-
- if (!allowedMimeTypes || allowedMimeTypes.includes(mimeType)) {
- return;
- }
-
- throw new FileUploadException(
- `MIME type ${mimeType} is not allowed in file folder ${fileFolder}`,
- FileUploadExceptionCode.BAD_REQUEST,
- {
- userFriendlyMessage: msg`This file format is not supported.`,
- },
- );
- }
-
private async resolveUploadLocation({
workspaceId,
fileFolder,
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-upload/types/batch-file-result.type.ts b/packages/twenty-server/src/engine/core-modules/file/file-upload/types/batch-file-result.type.ts
new file mode 100644
index 00000000000..55b6f0982b0
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/file/file-upload/types/batch-file-result.type.ts
@@ -0,0 +1,3 @@
+export type BatchFileResult<TValue> =
+ | { success: true; value: TValue }
+ | { success: false; error: string };
diff --git a/packages/twenty-server/src/engine/core-modules/file/file-upload/utils/to-batch-error-message.util.ts b/packages/twenty-server/src/engine/core-modules/file/file-upload/utils/to-batch-error-message.util.ts
new file mode 100644
index 00000000000..5c842d35093
--- /dev/null
+++ b/packages/twenty-server/src/engine/core-modules/file/file-upload/utils/to-batch-error-message.util.ts
@@ -0,0 +1,2 @@
+export const toBatchErrorMessage = (error: unknown): string =>
+ error instanceof Error ? error.message : String(error);
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/successful-direct-application-file-upload.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/successful-direct-application-file-upload.integration-spec.ts
new file mode 100644
index 00000000000..b059b325725
--- /dev/null
+++ b/packages/twenty-server/test/integration/metadata/suites/application/successful-direct-application-file-upload.integration-spec.ts
@@ -0,0 +1,230 @@
+import { readFileSync } from 'fs';
+import { join } from 'path';
+
+import request from 'supertest';
+import {
+ type ApplicationFileUploadTarget,
+ completeApplicationFileUploads,
+ createApplicationFileUploads,
+} from 'test/integration/metadata/suites/application/utils/create-application-file-uploads.util';
+import { cleanupApplicationAndAppRegistration } from 'test/integration/metadata/suites/application/utils/cleanup-application-and-app-registration.util';
+import { setupApplicationForSync } from 'test/integration/metadata/suites/application/utils/setup-application-for-sync.util';
+import { v4 as uuidv4 } from 'uuid';
+
+import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';
+
+const TEST_APP_UID = uuidv4();
+const TEST_WORKSPACE_ID = SEED_APPLE_WORKSPACE_ID;
+const STORAGE_LOCAL_PATH = join(process.cwd(), '.local-storage');
+
+const HANDLER_PATH = 'handler.mjs';
+const HANDLER_CONTENT = 'export const main = () => "hello";';
+
+const LOGO_PATH = 'assets/logo.svg';
+const LOGO_CONTENT =
+ '<svg xmlns="http://www.w3.org/2000/svg"><script>alert(1)</script><circle r="10" /></svg>';
+const EXPECTED_SANITIZED_LOGO_CONTENT =
+ '<svg xmlns="http://www.w3.org/2000/svg"><circle r="10"></circle></svg>';
+
+const putToUploadTarget = (
+ uploadTarget: ApplicationFileUploadTarget,
+ body: Buffer,
+) => {
+ const { pathname, search } = new URL(uploadTarget.uploadUrl);
+
+ return request(`http://localhost:${APP_PORT}`)
+ .put(`${pathname}${search}`)
+ .set('Content-Type', uploadTarget.contentType)
+ .send(body);
+};
+
+const readStoredFile = (fileFolder: string, filePath: string) =>
+ readFileSync(
+ join(
+ STORAGE_LOCAL_PATH,
+ TEST_WORKSPACE_ID,
+ TEST_APP_UID,
+ fileFolder,
+ filePath,
+ ),
+ 'utf-8',
+ );
+
+describe('Direct application file upload', () => {
+ beforeAll(async () => {
+ await setupApplicationForSync({
+ applicationUniversalIdentifier: TEST_APP_UID,
+ name: 'Test Direct Application File Upload App',
+ description: 'App for verifying batched direct application file uploads',
+ sourcePath: 'test-direct-application-file-upload',
+ });
+ }, 60000);
+
+ afterAll(async () => {
+ await cleanupApplicationAndAppRegistration({
+ applicationUniversalIdentifier: TEST_APP_UID,
+ });
+ });
+
+ it('should upload a whole batch of files without going through the server body', async () => {
+ jest.useRealTimers();
+
+ const handlerBuffer = Buffer.from(HANDLER_CONTENT, 'utf-8');
+ const logoBuffer = Buffer.from(LOGO_CONTENT, 'utf-8');
+
+ const { data: createData, errors: createErrors } =
+ await createApplicationFileUploads({
+ applicationUniversalIdentifier: TEST_APP_UID,
+ files: [
+ {
+ fileFolder: 'BuiltLogicFunction',
+ filePath: HANDLER_PATH,
+ size: handlerBuffer.length,
+ },
+ {
+ fileFolder: 'PublicAsset',
+ filePath: LOGO_PATH,
+ size: logoBuffer.length,
+ },
+ ],
+ });
+
+ expect(createErrors).toBeUndefined();
+
+ const { targets, errors: reservationErrors } =
+ createData!.createApplicationFileUploads;
+
+ expect(reservationErrors).toEqual([]);
+ expect(targets).toHaveLength(2);
+ expect(targets[0].filePath).toBe(HANDLER_PATH);
+ expect(targets[0].fileFolder).toBe('BuiltLogicFunction');
+ expect(targets[1].filePath).toBe(LOGO_PATH);
+
+ const [pendingRow] = await globalThis.testDataSource.query(
+ `SELECT status, "mimeType" FROM core."file" WHERE id = $1`,
+ [targets[0].fileId],
+ );
+
+ expect(pendingRow.status).toBe('PENDING');
+ expect(pendingRow.mimeType).toBe('application/octet-stream');
+
+ const handlerResponse = await putToUploadTarget(targets[0], handlerBuffer);
+ const logoResponse = await putToUploadTarget(targets[1], logoBuffer);
+
+ expect(handlerResponse.status).toBe(204);
+ expect(logoResponse.status).toBe(204);
+
+ const { data: completeData, errors: completeRequestErrors } =
+ await completeApplicationFileUploads({
+ applicationUniversalIdentifier: TEST_APP_UID,
+ fileIds: targets.map((target) => target.fileId),
+ });
+
+ jest.useFakeTimers();
+
+ expect(completeRequestErrors).toBeUndefined();
+
+ const { files: completedFiles, errors: completionErrors } =
+ completeData!.completeApplicationFileUploads;
+
+ expect(completionErrors).toEqual([]);
+ expect(completedFiles).toHaveLength(2);
+
+ const rows = await globalThis.testDataSource.query(
+ `SELECT id, status, "mimeType" FROM core."file" WHERE id = ANY($1)`,
+ [targets.map((target) => target.fileId)],
+ );
+
+ expect(rows).toHaveLength(2);
+ expect(
+ rows.every((row: { status: string }) => row.status === 'UPLOADED'),
+ ).toBe(true);
+
+ expect(readStoredFile('built-logic-function', HANDLER_PATH)).toBe(
+ HANDLER_CONTENT,
+ );
+
+ expect(readStoredFile('public-asset', LOGO_PATH)).toBe(
+ EXPECTED_SANITIZED_LOGO_CONTENT,
+ );
+
+ const logoRow = rows.find(
+ (row: { id: string }) => row.id === targets[1].fileId,
+ );
+
+ expect(logoRow.mimeType).toBe('image/svg+xml');
+ }, 60000);
+
+ it('should fail slow: reserve valid files and report a disallowed folder as a per-file error', async () => {
+ jest.useRealTimers();
+
+ const { data } = await createApplicationFileUploads({
+ applicationUniversalIdentifier: TEST_APP_UID,
+ files: [
+ { fileFolder: 'Source', filePath: 'src/valid.ts', size: 10 },
+ { fileFolder: 'FilesField', filePath: 'note.pdf', size: 10 },
+ ],
+ });
+
+ jest.useFakeTimers();
+
+ const { targets, errors } = data!.createApplicationFileUploads;
+
+ expect(targets).toHaveLength(1);
+ expect(targets[0].filePath).toBe('src/valid.ts');
+ expect(errors).toHaveLength(1);
+ expect(errors[0].filePath).toBe('note.pdf');
+ expect(errors[0].message).toContain('Invalid fileFolder');
+ }, 30000);
+
+ it('should fail slow: report a path escaping the application folder as a per-file error', async () => {
+ jest.useRealTimers();
+
+ const { data } = await createApplicationFileUploads({
+ applicationUniversalIdentifier: TEST_APP_UID,
+ files: [
+ {
+ fileFolder: 'Source',
+ filePath: '../../../etc/passwd.ts',
+ size: 10,
+ },
+ ],
+ });
+
+ jest.useFakeTimers();
+
+ const { targets, errors } = data!.createApplicationFileUploads;
+
+ expect(targets).toEqual([]);
+ expect(errors).toHaveLength(1);
+ expect(errors[0].filePath).toBe('../../../etc/passwd.ts');
+ }, 30000);
+
+ it('should fail slow: report a file whose bytes never reached storage as a per-file completion error', async () => {
+ jest.useRealTimers();
+
+ const { data: createData } = await createApplicationFileUploads({
+ applicationUniversalIdentifier: TEST_APP_UID,
+ files: [
+ { fileFolder: 'Source', filePath: 'never-uploaded.ts', size: 10 },
+ ],
+ });
+
+ const fileId =
+ createData!.createApplicationFileUploads.targets[0].fileId;
+
+ const { data: completeData } = await completeApplicationFileUploads({
+ applicationUniversalIdentifier: TEST_APP_UID,
+ fileIds: [fileId],
+ });
+
+ jest.useFakeTimers();
+
+ const { files, errors } = completeData!.completeApplicationFileUploads;
+
+ expect(files).toEqual([]);
+ expect(errors).toHaveLength(1);
+ expect(errors[0].fileId).toBe(fileId);
+ expect(errors[0].message).toContain('has not been uploaded to storage');
+ }, 30000);
+});
diff --git a/packages/twenty-server/test/integration/metadata/suites/application/utils/create-application-file-uploads.util.ts b/packages/twenty-server/test/integration/metadata/suites/application/utils/create-application-file-uploads.util.ts
new file mode 100644
index 00000000000..5148ebadf57
--- /dev/null
+++ b/packages/twenty-server/test/integration/metadata/suites/application/utils/create-application-file-uploads.util.ts
@@ -0,0 +1,111 @@
+import gql from 'graphql-tag';
+import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
+
+export type ApplicationFileUploadTarget = {
+ fileId: string;
+ fileFolder: string;
+ filePath: string;
+ uploadUrl: string;
+ contentType: string;
+ expiresAt: string;
+};
+
+export type ApplicationFileUploadError = {
+ fileFolder: string;
+ filePath: string;
+ message: string;
+};
+
+export type CreateApplicationFileUploadsResult = {
+ targets: ApplicationFileUploadTarget[];
+ errors: ApplicationFileUploadError[];
+};
+
+export type CompleteApplicationFileUploadsResult = {
+ files: { id: string; path: string; size: number }[];
+ errors: { fileId: string; message: string }[];
+};
+
+export const createApplicationFileUploads = async ({
+ applicationUniversalIdentifier,
+ files,
+}: {
+ applicationUniversalIdentifier: string;
+ files: { fileFolder: string; filePath: string; size: number }[];
+}) => {
+ const response = await makeMetadataAPIRequest({
+ query: gql`
+ mutation CreateApplicationFileUploads(
+ $applicationUniversalIdentifier: String!
+ $files: [ApplicationFileUploadRequestInput!]!
+ ) {
+ createApplicationFileUploads(
+ applicationUniversalIdentifier: $applicationUniversalIdentifier
+ files: $files
+ ) {
+ targets {
+ fileId
+ fileFolder
+ filePath
+ uploadUrl
+ contentType
+ expiresAt
+ }
+ errors {
+ fileFolder
+ filePath
+ message
+ }
+ }
+ }
+ `,
+ variables: { applicationUniversalIdentifier, files },
+ });
+
+ return {
+ data: response.body.data as {
+ createApplicationFileUploads: CreateApplicationFileUploadsResult;
+ } | null,
+ errors: response.body.errors as { message: string }[] | undefined,
+ };
+};
+
+export const completeApplicationFileUploads = async ({
+ applicationUniversalIdentifier,
+ fileIds,
+}: {
+ applicationUniversalIdentifier: string;
+ fileIds: string[];
+}) => {
+ const response = await makeMetadataAPIRequest({
+ query: gql`
+ mutation CompleteApplicationFileUploads(
+ $applicationUniversalIdentifier: String!
+ $fileIds: [UUID!]!
+ ) {
+ completeApplicationFileUploads(
+ applicationUniversalIdentifier: $applicationUniversalIdentifier
+ fileIds: $fileIds
+ ) {
+ files {
+ id
+ path
+ size
+ }
+ errors {
+ fileId
+ message
+ }
+ }
+ }
+ `,
+ variables: { applicationUniversalIdentifier, fileIds },
+ });
+
+ return {
+ data: response.body.data as {
+ completeApplicationFileUploads: CompleteApplicationFileUploadsResult;
+ } | null,
+ errors: response.body.errors as { message: string }[] | undefined,
+ };
+};
diff --git a/packages/twenty-shared/src/application/constants/ApplicationFileUploadBatchSize.ts b/packages/twenty-shared/src/application/constants/ApplicationFileUploadBatchSize.ts
new file mode 100644
index 00000000000..e1d87874488
--- /dev/null
+++ b/packages/twenty-shared/src/application/constants/ApplicationFileUploadBatchSize.ts
@@ -0,0 +1 @@
+export const APPLICATION_FILE_UPLOAD_BATCH_SIZE = 100;
diff --git a/packages/twenty-shared/src/application/index.ts b/packages/twenty-shared/src/application/index.ts
index cef3d833704..7a790ad1d55 100644
--- a/packages/twenty-shared/src/application/index.ts
+++ b/packages/twenty-shared/src/application/index.ts
@@ -31,6 +31,7 @@ export { APPLICATION_VARIABLE_FIELD_METADATA_TYPES } from './applicationVariable
export type { AssetManifest } from './assetManifestType';
export type { ConnectionProviderManifest } from './connectionProviderManifestType';
export type { ConnectionProviderType } from './connectionProviderType';
+export { APPLICATION_FILE_UPLOAD_BATCH_SIZE } from './constants/ApplicationFileUploadBatchSize';
export { ASSETS_DIR } from './constants/AssetDirectory';
export { DEFAULT_API_KEY_NAME } from './constants/DefaultApiKeyName';
export { DEFAULT_API_URL_NAME } from './constants/DefaultApiUrlName';