import { AxiosInstance } from 'axios' ; import copy from 'fast-copy' ; import { SetOptional } from 'type-fest' ; import { CollectionProp , GetSpaceEnvironmentParams , GetWorkflowDefinitionParams , } from '../../../common-types' ; import { CreateWorkflowDefinitionParams , CreateWorkflowDefinitionProps , DeleteWorkflowDefinitionParams , UpdateWorkflowDefinitionProps , WorkflowDefinitionProps , WorkflowDefinitionQueryOptions , } from '../../../entities/workflow-definition' ; import { RestEndpoint } from '../types' ; import * as raw from './raw' ; const getBaseUrl = ( params ) => `/spaces/${ params . spaceId }/environments/${ params . environmentId }/workflow_definitions` ; const getWorkflowDefinitionUrl = ( params ) => `${ getBaseUrl ( params ) }/${ params . workflowDefinitionId }` ; export const ALPHA_FEATURE_WORKFLOWS = 'workflows' ; export const get = ( http , params , headers ? ) => raw . get < WorkflowDefinitionProps > ( http , getWorkflowDefinitionUrl ( params ) , { headers , } ) ; export const getMany = ( http , params , headers ? ) => raw . get < CollectionProp < WorkflowDefinitionProps > > ( http , getBaseUrl ( params ) , { headers , params : params . query , } ) ; export const create = ( http , params , rawData , headers ? ) => { const data = copy ( rawData ) ; return raw . post < WorkflowDefinitionProps > ( http , getBaseUrl ( params ) , data , { headers , } ) ; } ; export const update = ( http , params , rawData , headers ? ) => { const data = copy ( rawData ) ; delete data . sys ; return raw . put < WorkflowDefinitionProps > ( http , getWorkflowDefinitionUrl ( params ) , data , { headers : { 'X-Contentful-Version' : rawData . sys . version ?? 0 , ... headers , } , } ) ; } ; export const del = ( http , { version , ... params } , headers ? ) => { return raw . del ( http , getWorkflowDefinitionUrl ( params ) , { headers : { 'X-Contentful-Version' : version , ... headers } , } ) ; } ;