({
documentName,
memoryName,
account
}: {
documentName: string;
memoryName: string;
account: Account;
})
| 927 | } |
| 928 | |
| 929 | async function deleteDocument({ |
| 930 | documentName, |
| 931 | memoryName, |
| 932 | account |
| 933 | }: { |
| 934 | documentName: string; |
| 935 | memoryName: string; |
| 936 | account: Account; |
| 937 | }) { |
| 938 | const { deleteDocument } = getMemoryApiUrls({ |
| 939 | memoryName, |
| 940 | documentName |
| 941 | }); |
| 942 | |
| 943 | try { |
| 944 | const response = await fetch(deleteDocument, { |
| 945 | method: 'DELETE', |
| 946 | headers: { |
| 947 | 'Content-Type': 'application/json', |
| 948 | Authorization: `Bearer ${account.apiKey}` |
| 949 | } |
| 950 | }); |
| 951 | |
| 952 | if (!response.ok) { |
| 953 | const errorData = (await response.json()) as ErrorResponse; |
| 954 | throw new Error( |
| 955 | `HTTP error! status: ${response.status}, message: ${errorData.error?.message}` |
| 956 | ); |
| 957 | } |
| 958 | |
| 959 | return response; |
| 960 | } catch (error) { |
| 961 | dlog('Error in deleteDocument:', error); |
| 962 | throw error; |
| 963 | } |
| 964 | } |
| 965 | |
| 966 | async function uploadDocument(signedUrl: string, document: Blob) { |
| 967 | let mimeType = document.type; |
no test coverage detected