Skip to content
Snippets Groups Projects
Commit 463fbb99 authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Update TypeScript definitions for elements

parent 10629561
No related branches found
No related tags found
1 merge request!1653Update TypeScript definitions for elements
import axios from 'axios'
import { PageNumberPaginationParameters, unique } from '.'
import { ElementSlim, PageNumberPagination, UUID } from '@/types'
import { ElementTiny, PageNumberPagination, UUID } from '@/types'
import { Entity, EntityLight, EntityLink, EntityType, TranscriptionEntity } from '@/types/entity'
// Retrieve an entity
......@@ -18,7 +18,7 @@ export const listCorpusEntities = unique(async (id: UUID, params: CorpusEntities
export const listElementLinks = unique(async (id: UUID): Promise<PageNumberPagination<EntityLink>> => (await axios.get(`/element/${id}/links/`)).data)
// List all elements linked to an entity
export const listEntityElements = unique(async (id: UUID, params: PageNumberPaginationParameters = {}): Promise<PageNumberPagination<ElementSlim>> => (await axios.get(`/entity/${id}/elements/`, { params })).data)
export const listEntityElements = unique(async (id: UUID, params: PageNumberPaginationParameters = {}): Promise<PageNumberPagination<ElementTiny>> => (await axios.get(`/entity/${id}/elements/`, { params })).data)
interface TranscriptionEntityListParameters extends PageNumberPaginationParameters {
entity_worker_run?: UUID | false
......
import axios from 'axios'
import { PageNumberPagination, ElementSlim, Image, UUID } from '@/types'
import { PageNumberPagination, ElementTiny, Image, UUID } from '@/types'
import { PageNumberPaginationParameters, unique } from '.'
/**
......@@ -29,6 +29,6 @@ export interface ImageElementsParameters extends PageNumberPaginationParameters
* List all elements on an image.
*/
export const listImageElements = unique(
async ({ id, ...params }: ImageElementsParameters): Promise<PageNumberPagination<ElementSlim>> =>
async ({ id, ...params }: ImageElementsParameters): Promise<PageNumberPagination<ElementTiny>> =>
(await axios.get(`/image/${id}/elements/`, { params })).data
)
import { ElementSlim, PageNumberPagination, UUID } from '@/types'
import { ElementTiny, PageNumberPagination, UUID } from '@/types'
import { defineStore } from 'pinia'
import { useNotificationStore } from './notification'
import { CorpusEntitiesListParameters, PageNumberPaginationParameters, listCorpusEntities, listElementLinks, listEntityElements, listTranscriptionEntities, retrieveEntity } from '@/api'
......@@ -25,7 +25,7 @@ interface State {
/**
* A page of elements related to an entity
*/
elements: PageNumberPagination<ElementSlim> | null,
elements: PageNumberPagination<ElementTiny> | null,
/**
* Entities per transcription, with pagination status
* { [transcription ID]: { count, results, loaded } }
......
import { defineStore } from 'pinia'
import { listImageElements, ImageElementsParameters } from '@/api'
import { errorParser } from '@/helpers'
import { ElementSlim, PageNumberPagination, UUID } from '@/types'
import { ElementTiny, PageNumberPagination, UUID } from '@/types'
import { useNotificationStore } from '.'
export interface ImageElements extends PageNumberPagination<ElementSlim> {
export interface ImageElements extends PageNumberPagination<ElementTiny> {
imageId: UUID
}
......@@ -27,7 +27,7 @@ export const useImageStore = defineStore('image', {
notificationStore.notify({ type: 'error', text: errorParser(err) })
}
},
setElements (imageId: UUID, data: PageNumberPagination<ElementSlim>) {
setElements (imageId: UUID, data: PageNumberPagination<ElementTiny>) {
this.elements = {
...data,
imageId
......
......@@ -147,23 +147,21 @@ export interface ElementTiny extends Required<Pick<ElementBase, 'id' | 'type' |
corpus: CorpusLight
}
export interface ElementSlim extends ElementTiny {
export interface Element extends ElementTiny {
created: string
creator: string | null
rights: Right[]
metadata_count: number
classifications: Classification[]
worker_version: UUID | null
worker_run: WorkerRunSummary | null
confidence: number | null
/**
* URL of the element's thumbnail, on which a PUT request can be made to upload a new thumbnail.
* The URL will only be available if the element's type is a folder type and the user is admin or internal.
* The URL will only be available if the element's type is a folder type
* and the user is a corpus admin, or a corpus contributor and the element's creator.
*/
thumbnail_put_url?: string | null
}
export interface Element extends ElementSlim {
created: string,
creator: string | null,
rights: Right[],
metadata_count: number,
classifications: Classification[],
worker_version: UUID | null,
worker_run: WorkerRunSummary | null,
confidence: number | null
thumbnail_put_url: string | null
}
export interface ElementList extends Required<Pick<ElementBase, 'id' | 'type' | 'name' | 'corpus' | 'thumbnail_url' | 'zone' | 'rotation_angle' | 'mirrored' | 'created' | 'classes' | 'metadata' | 'has_children'>> {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment