( documentCollectionId: Id<DocumentCollectionCreateRequest>, selectedDocument: SelectedDocument, indexingMode: IndexingMode, )
| 39 | }; |
| 40 | |
| 41 | export const createDocument = async ( |
| 42 | documentCollectionId: Id<DocumentCollectionCreateRequest>, |
| 43 | selectedDocument: SelectedDocument, |
| 44 | indexingMode: IndexingMode, |
| 45 | ): Promise<DocumentResponse> => { |
| 46 | if (selectedDocument.dataSource === DataSource.UPLOAD) { |
| 47 | return await uploadDocument(documentCollectionId, selectedDocument.file!, indexingMode); |
| 48 | } |
| 49 | |
| 50 | // Create doc |
| 51 | return ( |
| 52 | await post<DocumentCreateRequest, DocumentResponse>( |
| 53 | postDocumentApiPath(documentCollectionId), |
| 54 | { |
| 55 | name: selectedDocument.name, |
| 56 | externalId: selectedDocument.externalId!, |
| 57 | dataSourceConnectionId: selectedDocument.dataSourceConnectionId!.toString(), |
| 58 | indexingMode: indexingMode, |
| 59 | }, |
| 60 | ) |
| 61 | ).response; |
| 62 | } |
| 63 | |
| 64 | const uploadDocument = async ( |
| 65 | documentCollectionId: Id<DocumentCollectionCreateRequest>, |
no test coverage detected