@@ -213,6 +213,7 @@ const upsertDocumentToDatasource: ProcessingFunction = async ({
213
213
// Use the file id as the document id to make it easy to track the document back to the file.
214
214
const sourceUrl = file . getPrivateUrl ( auth ) ;
215
215
const documentId = upsertArgs ?. document_id ?? file . sId ; // Use the file sId as a fallback to make it easy to track the table back to the file.
216
+ const { title : upsertTitle , ...restArgs } = upsertArgs ?? { } ;
216
217
const upsertDocumentRes = await upsertDocument ( {
217
218
document_id : documentId ,
218
219
source_url : sourceUrl ,
@@ -223,10 +224,10 @@ const upsertDocumentToDatasource: ProcessingFunction = async ({
223
224
dataSource,
224
225
auth,
225
226
mime_type : file . contentType ,
226
- title : file . fileName ,
227
+ title : upsertTitle ?? file . fileName ,
227
228
228
229
// Used to override defaults.
229
- ...( upsertArgs ?? { } ) ,
230
+ ...restArgs ,
230
231
} ) ;
231
232
232
233
if ( upsertDocumentRes . isErr ( ) ) {
@@ -253,6 +254,7 @@ const upsertTableToDatasource: ProcessingFunction = async ({
253
254
if ( upsertArgs && "tableId" in upsertArgs ) {
254
255
tableId = upsertArgs . tableId ?? tableId ;
255
256
}
257
+ const { title : upsertTitle , ...restArgs } = upsertArgs ?? { } ;
256
258
const upsertTableRes = await upsertTable ( {
257
259
tableId,
258
260
name : slugify ( file . fileName ) ,
@@ -265,11 +267,11 @@ const upsertTableToDatasource: ProcessingFunction = async ({
265
267
dataSource,
266
268
auth,
267
269
useAppForHeaderDetection : true ,
268
- title : file . fileName ,
270
+ title : upsertTitle ?? file . fileName ,
269
271
mimeType : file . contentType ,
270
272
271
273
// Used to override defaults, for manual file uploads where some fields are user-defined.
272
- ...( upsertArgs ?? { } ) ,
274
+ ...restArgs ,
273
275
} ) ;
274
276
275
277
if ( upsertTableRes . isErr ( ) ) {
0 commit comments