@@ -125,6 +125,58 @@ export class Messages {
125125 return response ;
126126 }
127127
128+ public async createMessageWithMultiFiles (
129+ files : File [ ] ,
130+ input : MessageWithFileInputInterface ,
131+ token ?: string // Optional token parameter
132+ ) : Promise < any > {
133+ if ( ! this . options || ! this . axiosClient )
134+ throw new Error ( 'FileSystem module not initialized' ) ;
135+
136+ const formData = new FormData ( ) ;
137+
138+ formData . append (
139+ 'operations' ,
140+ JSON . stringify ( {
141+ query : CREATE_MESSAGE_WITH_FILE_MUTATION ,
142+ variables : {
143+ input : {
144+ ...input ,
145+ files : null ,
146+ } ,
147+ } ,
148+ } )
149+ ) ;
150+
151+ // Build the map object for multiple files
152+ const map : Record < string , string [ ] > = { } ;
153+ files . forEach ( ( _ , index ) => {
154+ map [ index . toString ( ) ] = [ `variables.input.files.${ index } ` ] ;
155+ } ) ;
156+
157+ formData . append ( 'map' , JSON . stringify ( map ) ) ;
158+
159+ // Append each file to the formData
160+ files . forEach ( ( file , index ) => {
161+ formData . append ( index . toString ( ) , file , file . name ) ;
162+ } ) ;
163+
164+ // Create headers object
165+ const headers : Record < string , string > = {
166+ 'Content-Type' : 'multipart/form-data' ,
167+ } ;
168+
169+ // Add Authorization header if token is provided
170+ if ( token ) {
171+ headers [ 'Authorization' ] = `Bearer ${ token } ` ;
172+ }
173+
174+ // Make the request with our headers
175+ const response = await this . axiosClient . post ( '' , formData , { headers } ) ;
176+
177+ return response ;
178+ }
179+
128180 public async updateMessage (
129181 id : string ,
130182 input : MessageUpdateInputInterface
@@ -412,7 +464,7 @@ export class Messages {
412464 } ;
413465 } = { }
414466 ) : Promise < AllLikedMessagesByUser > {
415- const { where, orderBy, first, page , childrenOptions = { } } = options ;
467+ const { where, orderBy, first, page, childrenOptions = { } } = options ;
416468
417469 const { alias = 'children' , first : childrenFirst } = childrenOptions ;
418470
0 commit comments