import type { AxiosInstance } from 'contentful-sdk-core' ; import copy from 'fast-copy' ; import { SetOptional } from 'type-fest' ; import { CollectionProp , GetSpaceEnvironmentParams , GetTagParams , QueryParams , } from '../../../common-types' ; import { CreateTagProps , DeleteTagParams , TagProps , UpdateTagProps } from '../../../entities/tag' ; import { RestEndpoint } from '../types' ; import * as raw from './raw' ; const getBaseUrl = ( params ) => `/spaces/${ params . spaceId }/environments/${ params . environmentId }/tags` ; const getTagUrl = ( params ) => getBaseUrl ( params ) + `/${ params . tagId }` ; export const get = ( http , params ) => raw . get < TagProps > ( http , getTagUrl ( params ) ) ; export const getMany = ( http , params ) => raw . get < CollectionProp < TagProps > > ( http , getBaseUrl ( params ) , { params : params . query , } ) ; export const createWithId = ( http , params , rawData ) => { const data = copy ( rawData ) ; return raw . put < TagProps > ( http , getTagUrl ( params ) , data , { headers : { 'X-Contentful-Tag-Visibility' : rawData . sys . visibility ?? 'private' } , } ) ; } ; export const update = ( http , params , rawData , headers ? ) => { const data = copy ( rawData ) ; delete data . sys ; return raw . put < TagProps > ( http , getTagUrl ( params ) , data , { headers : { 'X-Contentful-Version' : rawData . sys . version ?? 0 , ... headers , } , } ) ; } ; export const del = ( http , { version , ... params } ) => { return raw . del ( http , getTagUrl ( params ) , { headers : { 'X-Contentful-Version' : version } } ) ; } ;