import { AxiosInstance } from 'axios' ; import copy from 'fast-copy' ; import { SetOptional } from 'type-fest' ; import { CollectionProp , GetEntryParams , GetTaskParams } from '../../../common-types' ; import { CreateTaskParams , CreateTaskProps , DeleteTaskParams , TaskProps , UpdateTaskProps , } from '../../../entities/task' ; import { RestEndpoint } from '../types' ; import * as raw from './raw' ; const getBaseUrl = ( params ) => `/spaces/${ params . spaceId }/environments/${ params . environmentId }/entries/${ params . entryId }/tasks` ; const getTaskUrl = ( params ) => `${ getBaseUrl ( params ) }/${ params . taskId }` ; export const get = ( http , params ) => raw . get < TaskProps > ( http , getTaskUrl ( params ) ) ; export const getAll = ( http , params ) => raw . get < CollectionProp < TaskProps > > ( http , getBaseUrl ( params ) ) ; export const create = ( http , params , rawData ) => { const data = copy ( rawData ) ; return raw . post < TaskProps > ( http , getBaseUrl ( params ) , data ) ; } ; export const update = ( http , params , rawData , headers ? ) => { const data = copy ( rawData ) ; delete data . sys ; return raw . put < TaskProps > ( http , getTaskUrl ( params ) , data , { headers : { 'X-Contentful-Version' : rawData . sys . version ?? 0 , ... headers , } , } ) ; } ; export const del = ( http , { version , ... params } ) => { return raw . del ( http , getTaskUrl ( params ) , { headers : { 'X-Contentful-Version' : version } } ) ; } ;