import type { AxiosInstance } from 'contentful-sdk-core' ; import copy from 'fast-copy' ; import { SetOptional } from 'type-fest' ; import { CollectionProp , GetSpaceEnvironmentParams , GetExtensionParams , QueryParams , } from '../../../common-types' ; import { CreateExtensionProps , ExtensionProps } from '../../../entities/extension' ; import { RestEndpoint } from '../types' ; import * as raw from './raw' ; import { normalizeSelect } from './utils' ; const getBaseUrl = ( params ) => `/spaces/${ params . spaceId }/environments/${ params . environmentId }/extensions` ; export const getExtensionUrl = ( params ) => getBaseUrl ( params ) + `/${ params . extensionId }` ; export const get = ( http , params ) => { return raw . get < ExtensionProps > ( http , getExtensionUrl ( params ) , { params : normalizeSelect ( params . query ) , } ) ; } ; export const getMany = ( http , params ) => { return raw . get < CollectionProp < ExtensionProps > > ( http , getBaseUrl ( params ) , { params : normalizeSelect ( params . query ) , } ) ; } ; export const create = ( http , params , rawData , headers ? ) => { return raw . post < ExtensionProps > ( http , getBaseUrl ( params ) , rawData , { headers } ) ; } ; export const createWithId = ( http , params , rawData , headers ? ) => { const data = copy ( rawData ) ; return raw . put < ExtensionProps > ( http , getExtensionUrl ( params ) , data , { headers } ) ; } ; export const update = async ( http , params , rawData , headers ? ) => { const data = copy ( rawData ) ; delete data . sys ; return raw . put < ExtensionProps > ( http , getExtensionUrl ( params ) , data , { headers : { 'X-Contentful-Version' : rawData . sys . version ?? 0 , ... headers , } , } ) ; } ; export const del = ( http , params ) => { return raw . del ( http , getExtensionUrl ( params ) ) ; } ;