22 * API calls for creating, updating, deleting a corpus, and fetching the list of corpora.
33 */
44
5+ import type { CorpusMetadata , MutableCorpusMetadata , UUID } from "@/types/corpora"
56// --- libraries ---
67import axios from "axios"
78// --- types ---
8- import type { AxiosResponse } from "axios"
9- import type {
10- UUID ,
11- CorpusMetadata ,
12- MutableCorpusMetadata ,
13- } from "@/types/corpora"
9+ import type { AxiosResponse } from "axios"
1410
1511type CorporaResponse = AxiosResponse < CorpusMetadata [ ] >
1612type CorpusResponse = AxiosResponse < CorpusMetadata >
1713
1814// --- data ---
19- const corporaPath = ` /corpora`
20- const datasetCorporaPath = ` /datasets_corpora`
15+ const corporaPath = " /corpora"
16+ const datasetCorporaPath = " /datasets_corpora"
2117
2218// --- computed ---
2319const corpusPath = ( uuid : UUID ) => `${ corporaPath } /${ uuid } `
@@ -28,40 +24,40 @@ const corpusPath = (uuid: UUID) => `${corporaPath}/${uuid}`
2824 * public (datasets), shared (collaborator/viewer), and owned.
2925 */
3026export function getCorpora ( ) : Promise < CorporaResponse > {
31- return axios . get ( corporaPath )
27+ return axios . get ( corporaPath )
3228}
3329
3430/**
3531 * Fetch a single corpus by UUID.
3632 * @param uuid UUID of corpus.
3733 */
3834export function getCorpus ( uuid : UUID ) : Promise < CorpusResponse > {
39- return axios . get ( corpusPath ( uuid ) )
35+ return axios . get ( corpusPath ( uuid ) )
4036}
4137
4238/**
4339 * Fetch all datasets. Note that all datasets are public. Cheaper than getCorpora().
4440 */
4541export function getDatasetCorpora ( ) : Promise < CorporaResponse > {
46- return axios . get ( datasetCorporaPath )
42+ return axios . get ( datasetCorporaPath )
4743}
4844
4945/**
5046 * Create a new corpus with the given metadata.
5147 * @param corpus Metadata of new corpus.
5248 */
5349export function postCorpus (
54- corpus : MutableCorpusMetadata ,
50+ corpus : MutableCorpusMetadata ,
5551) : Promise < AxiosResponse < UUID > > {
56- return axios . post ( corporaPath , corpus )
52+ return axios . post ( corporaPath , corpus )
5753}
5854
5955/**
6056 * Delete a corpus by UUID.
6157 * @param uuid UUID of corpus to delete.
6258 */
6359export function deleteCorpus ( uuid : UUID ) {
64- return axios . delete ( corpusPath ( uuid ) )
60+ return axios . delete ( corpusPath ( uuid ) )
6561}
6662
6763/**
@@ -70,5 +66,5 @@ export function deleteCorpus(uuid: UUID) {
7066 * @param metadata New metadata.
7167 */
7268export function patchCorpus ( uuid : UUID , metadata : MutableCorpusMetadata ) {
73- return axios . patch ( corpusPath ( uuid ) , metadata )
69+ return axios . patch ( corpusPath ( uuid ) , metadata )
7470}
0 commit comments