MCPcopy Create free account
hub / github.com/SecureAI-Tools/SecureAI-Tools / createDocument

Function createDocument

apps/web/lib/fe/document-utils.ts:41–62  ·  view source on GitHub ↗
(
  documentCollectionId: Id<DocumentCollectionCreateRequest>,
  selectedDocument: SelectedDocument,
  indexingMode: IndexingMode,
)

Source from the content-addressed store, hash-verified

39};
40
41export 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
64const uploadDocument = async (
65 documentCollectionId: Id<DocumentCollectionCreateRequest>,

Callers 2

createDocumentsFunction · 0.90
createDocumentsFunction · 0.90

Calls 3

postDocumentApiPathFunction · 0.90
uploadDocumentFunction · 0.85
toStringMethod · 0.80

Tested by

no test coverage detected