import { API } from '../../core/api' ; import defaults from './defaults' ; import { Node , FileIndex } from '../../models' ; extends API export default class Schemas extends API { returns async defaults ( ) { return defaults ; } returns async defaultByName ( name ) { const key = Object . keys ( defaults ) . find ( ( known ) => known === name ) ; if ( key ) { return defaults [ key ] ; } return ; } param schema returns async add ( schema ) { const response = await this . sendPost ( `/api/v0/mills/schema` , undefined , undefined , schema , { 'Content-Type' : 'application/json' } ) ; return response . json ( ) as Promise < FileIndex > ; } param thread returns async get ( thread ) { const response = await this . sendGet ( `/api/v0/threads/${ thread }` ) ; return ( await response . json ( ) ) . schema_node as Node ; } }